summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2014-12-08 20:46:05 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-12-09 05:21:50 +0000
commit5f6af01f13460909e7c3819e14edb2eb04788156 (patch)
tree7254a5ded1b705b182893272c21273a472b9dd79 /cui
parent28c251e3cc374314dc19fd772148707b0c711454 (diff)
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@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/customize/cfg.cxx20
-rw-r--r--cui/source/customize/macropg.cxx4
-rw-r--r--cui/source/dialogs/SpellDialog.cxx3
-rw-r--r--cui/source/dialogs/cuigaldlg.cxx6
-rw-r--r--cui/source/dialogs/hangulhanjadlg.cxx3
-rw-r--r--cui/source/dialogs/insdlg.cxx3
-rw-r--r--cui/source/factory/dlgfact.cxx3
-rw-r--r--cui/source/options/optchart.cxx6
-rw-r--r--cui/source/options/optlingu.cxx10
-rw-r--r--cui/source/tabpages/chardlg.cxx3
-rw-r--r--cui/source/tabpages/tpbitmap.cxx3
-rw-r--r--cui/source/tabpages/tpcolor.cxx3
-rw-r--r--cui/source/tabpages/tpgradnt.cxx3
-rw-r--r--cui/source/tabpages/tphatch.cxx3
-rw-r--r--cui/source/tabpages/tpline.cxx3
-rw-r--r--cui/source/tabpages/tplnedef.cxx3
-rw-r--r--cui/source/tabpages/tpshadow.cxx3
17 files changed, 31 insertions, 51 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index b015f0835f45..77d3afcf4726 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 ca978e590b1c..96e4acb1d650 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 5bbf6ddce72a..a589bab71f27 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 e06c973e3cbf..f37b4b564758 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 7e02beed6bee..4ad76f297298 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 bfe8633b1bb1..84c2fd7296dc 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 07c63f315c2b..63d3c7140a8a 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 c8bbffd2f621..55d002d70e51 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 3ba056d17b17..af4e1fc0705d 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 3ca996734a9f..50dd08923571 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 dbef4d939c9c..1e9e466acb89 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 7dbda37f4572..f5935aa66ae1 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 a96b2183bd92..1b04ab7d72d8 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 ba6633ed9b71..a08bcbf8db75 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 7d1fd99e9ef3..4be237f1710a 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 3b45fd902e22..2918f2db641b 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 6aa0fe91962f..dd06af673764 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() )
{