[Libreoffice-commits] core.git: crashrep/source cui/source

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


 crashrep/source/win32/soreport.cxx    |    2 +-
 cui/source/customize/cfg.cxx          |   20 ++++++++------------
 cui/source/customize/macropg.cxx      |    4 ++--
 cui/source/dialogs/SpellDialog.cxx    |    3 +--
 cui/source/dialogs/cuigaldlg.cxx      |    6 ++----
 cui/source/dialogs/hangulhanjadlg.cxx |    3 +--
 cui/source/dialogs/insdlg.cxx         |    3 +--
 cui/source/factory/dlgfact.cxx        |    3 +--
 cui/source/options/optchart.cxx       |    6 ++----
 cui/source/options/optlingu.cxx       |   10 ++++------
 cui/source/tabpages/chardlg.cxx       |    3 +--
 cui/source/tabpages/tpbitmap.cxx      |    3 +--
 cui/source/tabpages/tpcolor.cxx       |    3 +--
 cui/source/tabpages/tpgradnt.cxx      |    3 +--
 cui/source/tabpages/tphatch.cxx       |    3 +--
 cui/source/tabpages/tpline.cxx        |    3 +--
 cui/source/tabpages/tplnedef.cxx      |    3 +--
 cui/source/tabpages/tpshadow.cxx      |    3 ++-
 18 files changed, 32 insertions(+), 52 deletions(-)

New commits:
commit 5f6af01f13460909e7c3819e14edb2eb04788156
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Mon Dec 8 20:46:05 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: I19d0070c5dc54c605a7924b750eee1538bed16b3
    Reviewed-on: https://gerrit.libreoffice.org/13384
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/crashrep/source/win32/soreport.cxx b/crashrep/source/win32/soreport.cxx
index 4a4d2bf..ee8b7d0 100644
--- a/crashrep/source/win32/soreport.cxx
+++ b/crashrep/source/win32/soreport.cxx
@@ -564,11 +564,11 @@ static string xml_encode( const string &rString )
 
 static size_t fcopy( FILE *fpin, FILE *fpout )
 {
-    char buffer[1024];
     size_t nBytesWritten = 0;
 
     if ( fpin && fpout )
     {
+        char buffer[1024];
         size_t nBytes;
         while ( 0 != (nBytes = fread( buffer, 1, sizeof(buffer), fpin )) )
         {
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index b015f08..77d3afc 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -275,10 +275,9 @@ generateCustomName(
     // now check is there is an already existing entry with this name
     SvxEntries::const_iterator iter = entries->begin();
 
-    SvxConfigEntry* pEntry;
     while ( iter != entries->end() )
     {
-        pEntry = *iter;
+        SvxConfigEntry* pEntry = *iter;
 
         if ( name.equals( pEntry->GetName() ) )
         {
@@ -314,10 +313,9 @@ generateCustomURL(
     // now check is there is an already existing entry with this url
     SvxEntries::const_iterator iter = entries->begin();
 
-    SvxConfigEntry* pEntry;
     while ( iter != entries->end() )
     {
-        pEntry = *iter;
+        SvxConfigEntry* pEntry = *iter;
 
         if ( url.equals( pEntry->GetCommand() ) )
         {
@@ -1082,7 +1080,6 @@ bool MenuSaveInData::LoadSubMenus(
         uno::Reference< container::XIndexAccess >   xSubMenu;
         OUString                aCommandURL;
         OUString                aLabel;
-        bool                    bIsUserDefined = true;
 
         sal_uInt16 nType( css::ui::ItemType::DEFAULT );
 
@@ -1091,6 +1088,7 @@ bool MenuSaveInData::LoadSubMenus(
 
         if ( bItem )
         {
+            bool bIsUserDefined = true;
             if ( nType == css::ui::ItemType::DEFAULT )
             {
                 uno::Any a;
@@ -2594,16 +2592,13 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
     // Copy the entries list passed in
     if ( entries != NULL )
     {
-        SvxConfigEntry* pEntry;
-        SvTreeListEntry* pLBEntry;
-
         mpEntries = new SvxEntries();
         SvxEntries::const_iterator iter = entries->begin();
 
         while ( iter != entries->end() )
         {
-            pEntry = *iter;
-            pLBEntry =
+            SvxConfigEntry* pEntry = *iter;
+            SvTreeListEntry* pLBEntry =
                 m_pMenuListBox->InsertEntry( stripHotKey( pEntry->GetName() ) );
             pLBEntry->SetUserData( pEntry );
             mpEntries->push_back( pEntry );
@@ -4176,7 +4171,6 @@ bool ToolbarSaveInData::LoadToolbar(
         uno::Reference< container::XIndexAccess >   xSubMenu;
         OUString                aCommandURL;
         OUString                aLabel;
-        bool                    bIsUserDefined = true;
         bool                bIsVisible;
         sal_Int32               nStyle;
 
@@ -4187,6 +4181,7 @@ bool ToolbarSaveInData::LoadToolbar(
 
         if ( bItem )
         {
+            bool bIsUserDefined = true;
             if ( nType == css::ui::ItemType::DEFAULT )
             {
                 uno::Any a;
@@ -5238,7 +5233,6 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
 
     uno::Reference< graphic::XGraphic > xGraphic;
     com::sun::star::awt::Size aSize;
-    bool bOK = true;
     aMediaProps[0].Value <<= aURL;
     try
     {
@@ -5251,6 +5245,8 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
             xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
             if ( xGraphic.is() )
             {
+                bool bOK = true;
+
                 a >>= aSize;
                 if ( 0 == aSize.Width || 0 == aSize.Height )
                     bOK = false;
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index ca978e5..96e4acb 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -103,10 +103,10 @@ IMPL_LINK( MacroEventListBox, HeaderEndDrag_Impl, HeaderBar*, pBar )
             maHeaderBar.SetItemSize( ITEMID_EVENT, nBarWidth - TAB_WIDTH_MIN );
 
         {
-            long _nWidth, nTmpSz = 0;
+            long nTmpSz = 0;
             for( sal_uInt16 i = 1 ; i < _nTabs ; ++i )
             {
-                _nWidth = maHeaderBar.GetItemSize( i );
+                long _nWidth = maHeaderBar.GetItemSize( i );
                 aSz.Width() =  _nWidth + nTmpSz;
                 nTmpSz += _nWidth;
                 maListBox.SetTab( i, PixelToLogic( aSz, MapMode( MAP_APPFONT ) ).Width(), MAP_APPFONT );
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 5bbf6dd..a589bab 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -1273,7 +1273,6 @@ SentenceEditWindow_Impl::~SentenceEditWindow_Impl()
 bool SentenceEditWindow_Impl::PreNotify( NotifyEvent& rNEvt )
 {
     bool bChange = false;
-    const TextCharAttrib*  pErrorAttrib = 0;
     if(rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
     {
         const KeyEvent& rKeyEvt = *rNEvt.GetKeyEvent();
@@ -1511,7 +1510,7 @@ bool SentenceEditWindow_Impl::PreNotify( NotifyEvent& rNEvt )
             if(!IsUndoEditMode() && bIsErrorActive)
             {
                 const TextCharAttrib* pFontColor = pTextEngine->FindCharAttrib( aCursor, TEXTATTR_FONTCOLOR );
-                pErrorAttrib = pTextEngine->FindCharAttrib( TextPaM(0, m_nErrorStart), TEXTATTR_SPELL_ERROR );
+                const TextCharAttrib*  pErrorAttrib = pTextEngine->FindCharAttrib( TextPaM(0, m_nErrorStart), TEXTATTR_SPELL_ERROR );
                 if(pFontColor && pErrorAttrib )
                 {
                     m_nErrorStart = pFontColor->GetStart();
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index e06c973..f37b4b5 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -802,9 +802,7 @@ void TPGalleryThemeProperties::FillFilterList()
     OUString            aExt;
     OUString            aName;
     FilterEntry*        pFilterEntry;
-    FilterEntry*        pTestEntry;
     sal_uInt16          i, nKeyCount;
-    bool                bInList;
 
     // graphic filters
     for( i = 0, nKeyCount = rFilter.GetImportFormatCount(); i < nKeyCount; i++ )
@@ -812,8 +810,8 @@ void TPGalleryThemeProperties::FillFilterList()
         aExt = rFilter.GetImportFormatShortName( i );
         aName = rFilter.GetImportFormatName( i );
         size_t entryIndex = 0;
-        pTestEntry = aFilterEntryList.empty() ? NULL : aFilterEntryList[ entryIndex ];
-        bInList = false;
+        FilterEntry* pTestEntry = aFilterEntryList.empty() ? NULL : aFilterEntryList[ entryIndex ];
+        bool bInList = false;
 
         OUString aExtensions;
         int j = 0;
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index 7e02bee..4ad76f2 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -1126,10 +1126,9 @@ namespace svx
     HangulHanjaOptionsDialog::~HangulHanjaOptionsDialog()
     {
         SvTreeListEntry*    pEntry = m_pDictsLB->First();
-        OUString*         pDel;
         while( pEntry )
         {
-            pDel = ( OUString* ) pEntry->GetUserData();
+            OUString* pDel = ( OUString* ) pEntry->GetUserData();
             if( pDel )
                 delete pDel;
             pEntry = m_pDictsLB->Next( pEntry );
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index bfe8633..84c2fd7 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -215,7 +215,6 @@ short SvInsertOleDlg::Execute()
     if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
     {
         OUString aFileName;
-        bool bLink = false;
         bool bCreateNew = IsCreateNew();
         if ( bCreateNew )
         {
@@ -299,7 +298,7 @@ short SvInsertOleDlg::Execute()
             aURL.SetSmartProtocol( INET_PROT_FILE );
             aURL.SetSmartURL( aFileName );
             aFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
-            bLink = IsLinked();
+            bool bLink = IsLinked();
 
             if ( !aFileName.isEmpty() )
             {
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 07c63f3..63d3c71 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1800,10 +1800,9 @@ SfxAbstractInsertObjectDialog* AbstractDialogFactory_Impl::CreateInsertObjectDia
 VclAbstractDialog* AbstractDialogFactory_Impl::CreateEditObjectDialog( vcl::Window* pParent,  const OUString& rCommand,
             const Reference < com::sun::star::embed::XEmbeddedObject >& xObj )
 {
-    InsertObjectDialog_Impl* pDlg=0;
     if ( rCommand == ".uno:InsertObjectFloatingFrame" )
     {
-        pDlg = new SfxInsertFloatingFrameDialog( pParent, xObj );
+        InsertObjectDialog_Impl* pDlg = new SfxInsertFloatingFrameDialog( pParent, xObj );
         pDlg->SetHelpId( OUStringToOString( rCommand, RTL_TEXTENCODING_UTF8 ) );
         return new CuiVclAbstractDialog_Impl( pDlg );
     }
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
index c8bbffd..55d002d 100644
--- a/cui/source/options/optchart.cxx
+++ b/cui/source/options/optchart.cxx
@@ -127,14 +127,13 @@ void SvxDefaultColorOptPage::FillColorBox()
     if( !pColorList.is() ) return;
 
     long nCount = pColorList->Count();
-    XColorEntry* pColorEntry;
 
     if( nCount > 104 )
         m_pValSetColorBox->SetStyle( m_pValSetColorBox->GetStyle() | WB_VSCROLL );
 
     for( long i = 0; i < nCount; i++ )
     {
-        pColorEntry = pColorList->GetColor( i );
+        XColorEntry* pColorEntry = pColorList->GetColor( i );
         m_pValSetColorBox->InsertItem( i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
     }
 }
@@ -145,11 +144,10 @@ long SvxDefaultColorOptPage::GetColorIndex( const Color& rCol )
     if( pColorList.is() )
     {
         long nCount = pColorList->Count();
-        XColorEntry* pColorEntry;
 
         for( long i = nCount - 1; i >= 0; i-- )         // default chart colors are at the end of the table
         {
-            pColorEntry = pColorList->GetColor( i );
+            XColorEntry* pColorEntry = pColorList->GetColor( i );
             if( pColorEntry && pColorEntry->GetColor() == rCol )
                 return pColorList->GetIndex( pColorEntry->GetName() );
         }
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 3ba056d..af4e1fc 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -671,10 +671,9 @@ static void lcl_MergeDisplayArray(
     ServiceInfoArr &rSvcInfoArr = rData.GetDisplayServiceArray();
     sal_uLong nEntries = rData.GetDisplayServiceCount();
 
-    ServiceInfo_Impl* pEntry;
     for (sal_uLong i = 0;  i < nEntries;  ++i)
     {
-        pEntry = &rSvcInfoArr[i];
+        ServiceInfo_Impl* pEntry = &rSvcInfoArr[i];
         if (pEntry  &&  pEntry->sDisplayName == rToAdd.sDisplayName)
         {
             if(rToAdd.xSpell.is())
@@ -887,10 +886,9 @@ void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices
     const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
     for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
     {
-        ServiceInfo_Impl* pEntry;
         for (sal_uLong i = 0;  i < nDisplayServices;  ++i)
         {
-            pEntry = &aDisplayServiceArr[i];
+            ServiceInfo_Impl* pEntry = &aDisplayServiceArr[i];
             if (pEntry  &&  !pEntry->bConfigured)
             {
                 const OUString &rSrvcImplName = pConfiguredServices[n];
@@ -1940,11 +1938,11 @@ IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, SvxCheckListBox *, pBox )
 {
     if (m_pModulesCLB == pBox)
     {
-        bool bDisableUp = true;
-        bool bDisableDown = true;
         SvTreeListEntry *pEntry = pBox->GetCurEntry();
         if (pEntry)
         {
+            bool bDisableUp = true;
+            bool bDisableDown = true;
             ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
             if(!pData->IsParent() && pData->GetType() != TYPE_HYPH)
             {
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 3ca9967..50dd089 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -408,12 +408,11 @@ const FontList* SvxCharNamePage::GetFontList() const
     if ( !m_pImpl->m_pFontList )
     {
         SfxObjectShell* pDocSh = SfxObjectShell::Current();
-        const SfxPoolItem* pItem;
 
         /* #110771# SvxFontListItem::GetFontList can return NULL */
         if ( pDocSh )
         {
-            pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+            const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
             if ( pItem != NULL )
             {
                 DBG_ASSERT(NULL != static_cast<const SvxFontListItem*>(pItem)->GetFontList(),
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index dbef4d9..1e9e466 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -676,14 +676,13 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickModifyHdl_Impl)
         DBG_ASSERT(pDlg, "Dialog creation failed!");
 
         long nCount = pBitmapList->Count();
-        bool bDifferent = false;
         bool bLoop = true;
         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
 
         while( bLoop && pDlg->Execute() == RET_OK )
         {
             pDlg->GetName( aName );
-            bDifferent = true;
+            bool bDifferent = true;
 
             for( long i = 0; i < nCount && bDifferent; i++ )
             {
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 7dbda37..f5935aa 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -665,7 +665,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
     ResMgr& rMgr = CUI_MGR();
     OUString aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
     OUString aName( m_pEdtName->GetText() );
-    XColorEntry* pEntry;
     long nCount = pColorList->Count();
     bool bDifferent = true;
 
@@ -707,7 +706,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
     // if not existing the entry is entered
     if( bDifferent )
     {
-        pEntry = new XColorEntry( aCurrentColor, aName );
+        XColorEntry* pEntry = new XColorEntry( aCurrentColor, aName );
 
         pColorList->Insert( pEntry, pColorList->Count() );
 
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index a96b218..1b04ab7 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -522,13 +522,12 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl)
         DBG_ASSERT(pDlg, "Dialog creation failed!");
 
         long nCount = pGradientList->Count();
-        bool bDifferent = false;
         bool bLoop = true;
 
         while( bLoop && pDlg->Execute() == RET_OK )
         {
             pDlg->GetName( aName );
-            bDifferent = true;
+            bool bDifferent = true;
 
             for( long i = 0; i < nCount && bDifferent; i++ )
             {
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index ba6633ed..a08bcbf 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -566,12 +566,11 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl)
         DBG_ASSERT(pDlg, "Dialog creation failed!");
 
         long nCount = pHatchingList->Count();
-        bool bDifferent = false;
         bool bLoop = true;
         while( bLoop && pDlg->Execute() == RET_OK )
         {
             pDlg->GetName( aName );
-            bDifferent = true;
+            bool bDifferent = true;
 
             for( long i = 0; i < nCount && bDifferent; i++ )
             {
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 7d1fd99..4be237f 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -261,12 +261,11 @@ void SvxLineTabPage::InitSymbols(MenuButton* pButton)
 
         PopupMenu* pPopup = new PopupMenu;
         OUString aEmptyStr;
-        const OUString *pUIName = NULL;
         sal_uInt32 i = 0;
         nNumMenuGalleryItems = aGrfNames.size();
         for(std::vector<OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i)
         {
-            pUIName = &(*it);
+            const OUString *pUIName = &(*it);
 
             // Convert URL encodings to UI characters (e.g. %20 for spaces)
             OUString aPhysicalName;
diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx
index 3b45fd90..2918f2d 100644
--- a/cui/source/tabpages/tplnedef.cxx
+++ b/cui/source/tabpages/tplnedef.cxx
@@ -631,13 +631,12 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl)
         DBG_ASSERT(pDlg, "Dialog creation failed!");
 
         long nCount = pDashList->Count();
-        bool bDifferent = false;
         bool bLoop = true;
 
         while ( bLoop && pDlg->Execute() == RET_OK )
         {
             pDlg->GetName( aName );
-            bDifferent = true;
+            bool bDifferent = true;
 
             for( long i = 0; i < nCount && bDifferent; i++ )
             {
diff --git a/cui/source/tabpages/tpshadow.cxx b/cui/source/tabpages/tpshadow.cxx
index 6aa0fe9..dd06af6 100644
--- a/cui/source/tabpages/tpshadow.cxx
+++ b/cui/source/tabpages/tpshadow.cxx
@@ -244,11 +244,12 @@ int SvxShadowTabPage::DeactivatePage( SfxItemSet* _pSet )
 
 bool SvxShadowTabPage::FillItemSet( SfxItemSet* rAttrs )
 {
-    const SfxPoolItem*  pOld = NULL;
     bool                bModified = false;
 
     if( !bDisable )
     {
+        const SfxPoolItem*  pOld = NULL;
+
         TriState eState = m_pTsbShowShadow->GetState();
         if( m_pTsbShowShadow->IsValueChangedFromSaved() )
         {


More information about the Libreoffice-commits mailing list