summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2014-12-20 21:09:40 +0100
committerJulien Nabet <serval2412@yahoo.fr>2014-12-21 20:18:17 +0100
commit17fc7aa3b8fcd731fb05b5e17e23ee984d166a8f (patch)
tree247985f50367083dbfd1688e66db12c230d04fc1
parentbe34823092ce05002be61a50d0dbf156bb5095ba (diff)
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: I390607e002e93cf7a6babc26d9be084d9f185058
-rw-r--r--scaddins/source/analysis/bessel.cxx8
-rw-r--r--scaddins/source/analysis/financial.cxx7
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx2
-rw-r--r--scripting/source/stringresource/stringresource.cxx2
-rw-r--r--sd/source/core/EffectMigration.cxx7
-rw-r--r--sd/source/core/drawdoc.cxx3
-rw-r--r--sd/source/core/drawdoc2.cxx12
-rw-r--r--sd/source/core/drawdoc4.cxx6
-rw-r--r--sd/source/core/sdpage2.cxx9
-rw-r--r--sd/source/filter/eppt/epptso.cxx3
-rw-r--r--sd/source/filter/eppt/pptx-text.cxx2
11 files changed, 24 insertions, 37 deletions
diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx
index 5a4581b2ac15..9161655f4c1a 100644
--- a/scaddins/source/analysis/bessel.cxx
+++ b/scaddins/source/analysis/bessel.cxx
@@ -284,15 +284,13 @@ double BesselK( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException,
case 1: return Besselk1( fNum );
default:
{
- double fBkp;
-
double fTox = 2.0 / fNum;
double fBkm = Besselk0( fNum );
double fBk = Besselk1( fNum );
for( sal_Int32 n = 1 ; n < nOrder ; n++ )
{
- fBkp = fBkm + double( n ) * fTox * fBk;
+ const double fBkp = fBkm + double( n ) * fTox * fBk;
fBkm = fBk;
fBk = fBkp;
}
@@ -438,15 +436,13 @@ double BesselY( double fNum, sal_Int32 nOrder ) throw( IllegalArgumentException,
case 1: return Bessely1( fNum );
default:
{
- double fByp;
-
double fTox = 2.0 / fNum;
double fBym = Bessely0( fNum );
double fBy = Bessely1( fNum );
for( sal_Int32 n = 1 ; n < nOrder ; n++ )
{
- fByp = double( n ) * fTox * fBy - fBym;
+ const double fByp = double( n ) * fTox * fBy - fBym;
fBym = fBy;
fBy = fByp;
}
diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx
index 7e79fba7d7d9..81cf3c428808 100644
--- a/scaddins/source/analysis/financial.cxx
+++ b/scaddins/source/analysis/financial.cxx
@@ -539,14 +539,13 @@ double SAL_CALL AnalysisAddIn::getXirr(
static const sal_Int32 nMaxIter = 50;
// Newton's method - try to find a fResultRate, so that lcl_sca_XirrResult() returns 0.
- double fNewRate, fRateEps, fResultValue;
sal_Int32 nIter = 0;
bool bContLoop;
do
{
- fResultValue = lcl_sca_XirrResult( aValues, aDates, fResultRate );
- fNewRate = fResultRate - fResultValue / lcl_sca_XirrResult_Deriv1( aValues, aDates, fResultRate );
- fRateEps = fabs( fNewRate - fResultRate );
+ double fResultValue = lcl_sca_XirrResult( aValues, aDates, fResultRate );
+ double fNewRate = fResultRate - fResultValue / lcl_sca_XirrResult_Deriv1( aValues, aDates, fResultRate );
+ double fRateEps = fabs( fNewRate - fResultRate );
fResultRate = fNewRate;
bContLoop = (fRateEps > fMaxEps) && (fabs( fResultValue ) > fMaxEps);
}
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 38294297cc75..c6b23ba052e0 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -669,9 +669,9 @@ static const char aResourceResolverPropName[] = "ResourceResolver";
uno::Reference< beans::XPropertySet > xDlgModPropSet( xCtrlMod, uno::UNO_QUERY );
if( xDlgModPropSet.is() )
{
- bool bDecoration = true;
try
{
+ bool bDecoration = true;
Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName );
aDecorationAny >>= bDecoration;
if( !bDecoration )
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index cde4e730a24d..667a9008d2b6 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -543,10 +543,10 @@ void StringResourceImpl::removeLocale( const Locale& locale )
sal_Int32 nLocaleCount = m_aLocaleItemVector.size();
if( nLocaleCount > 1 )
{
- LocaleItem* pFallbackItem = NULL;
if( m_pCurrentLocaleItem == pRemoveItem ||
m_pDefaultLocaleItem == pRemoveItem )
{
+ LocaleItem* pFallbackItem = NULL;
for( LocaleItemVectorIt it = m_aLocaleItemVector.begin(); it != m_aLocaleItemVector.end(); ++it )
{
LocaleItem* pLocaleItem = *it;
diff --git a/sd/source/core/EffectMigration.cxx b/sd/source/core/EffectMigration.cxx
index c434982711cf..855cb9fad204 100644
--- a/sd/source/core/EffectMigration.cxx
+++ b/sd/source/core/EffectMigration.cxx
@@ -445,10 +445,10 @@ void EffectMigration::SetAnimationEffect( SvxShape* pShape, AnimationEffect eEff
EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) );
const EffectSequence::iterator aEnd( pMainSequence->getEnd() );
- bool bEffectCreated = false;
-
if( (aIterOnlyBackground == aEnd) && (aIterAsWhole == aEnd) )
{
+ bool bEffectCreated = false;
+
// check if there is already an text effect for this shape
EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) );
if( aIterOnlyText != aEnd )
@@ -1402,14 +1402,13 @@ void EffectMigration::CreateAnimatedGroup(SdrObjGroup& rGroupObj, SdPage& rPage)
Reference< XTimeContainer > xParentContainer(xOuterSeqTimeContainer, UNO_QUERY_THROW);
// prepare loop over objects
- SdrObject* pLast = 0;
SdrObject* pNext = 0;
const double fDurationShow(0.2);
const double fDurationHide(0.001);
for(sal_uInt32 a(0); a < aObjects.size(); a++)
{
- pLast = pNext;
+ SdrObject* pLast = pNext;
pNext = aObjects[a];
// create node
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 9e5a422b08b2..d80b5fbf93c2 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -666,12 +666,11 @@ void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
mbNewOrLoadCompleted = true;
// Update all linked pages
- SdPage* pPage = NULL;
sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD);
for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
{
- pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
+ SdPage* pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
if (pPage && !pPage->GetFileName().isEmpty() && pPage->GetBookmarkName().getLength())
{
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 7d56290d9ba0..f762e9cc5c68 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -224,10 +224,9 @@ void SdDrawDocument::UpdatePageObjectsInNotes(sal_uInt16 nStartPos)
if (pPage && pPage->GetPageKind() == PK_NOTES)
{
const size_t nObjCount = pPage->GetObjCount();
- SdrObject* pObj = NULL;
for (size_t nObj = 0; nObj < nObjCount; ++nObj)
{
- pObj = pPage->GetObj(nObj);
+ SdrObject* pObj = pPage->GetObj(nObj);
if (pObj->GetObjIdentifier() == OBJ_PAGE &&
pObj->GetObjInventor() == SdrInventor)
{
@@ -923,13 +922,12 @@ SdAnimationInfo* SdDrawDocument::GetShapeUserData(SdrObject& rObject, bool bCrea
{
sal_uInt16 nUD = 0;
sal_uInt16 nUDCount = rObject.GetUserDataCount();
- SdrObjUserData* pUD = 0;
SdAnimationInfo* pRet = 0;
// Can we find animation information within the user data?
for (nUD = 0; nUD < nUDCount; nUD++)
{
- pUD = rObject.GetUserData(nUD);
+ SdrObjUserData* pUD = rObject.GetUserData(nUD);
if((pUD->GetInventor() == SdUDInventor) && (pUD->GetId() == SD_ANIMATIONINFO_ID))
{
pRet = dynamic_cast<SdAnimationInfo*>(pUD);
@@ -950,14 +948,13 @@ SdIMapInfo* SdDrawDocument::GetIMapInfo( SdrObject* pObject ) const
{
DBG_ASSERT(pObject, "Without an object there is no IMapInfo");
- SdrObjUserData* pUserData = NULL;
SdIMapInfo* pIMapInfo = NULL;
sal_uInt16 nCount = pObject->GetUserDataCount();
// Can we find IMap information within the user data?
for ( sal_uInt16 i = 0; i < nCount; i++ )
{
- pUserData = pObject->GetUserData( i );
+ SdrObjUserData* pUserData = pObject->GetUserData( i );
if ( ( pUserData->GetInventor() == SdUDInventor ) && ( pUserData->GetId() == SD_IMAPINFO_ID ) )
pIMapInfo = static_cast<SdIMapInfo*>(pUserData);
@@ -1057,7 +1054,6 @@ void SdDrawDocument::CheckMasterPages()
}
SdPage* pPage = NULL;
- SdPage* pNotesPage = NULL;
sal_uInt16 nPage;
@@ -1073,6 +1069,8 @@ void SdDrawDocument::CheckMasterPages()
if( nPage < nMaxPages )
{
+ SdPage* pNotesPage = NULL;
+
// there is a fatal error in the master page order,
// we need to repair the document
bool bChanged = false;
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index 6789ad278c87..2741cf2c56c4 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -783,12 +783,11 @@ void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling)
// Fill OnlineSpelling list
void SdDrawDocument::FillOnlineSpellingList(SdPage* pPage)
{
- SdrObject* pObj = NULL;
SdrObjListIter aIter(*pPage, IM_FLAT);
while (aIter.IsMore())
{
- pObj = aIter.Next();
+ SdrObject* pObj = aIter.Next();
if( !pObj )
continue;
@@ -845,11 +844,10 @@ IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl)
SdrObjListIter aGroupIter(*static_cast<SdrObjGroup*>(pObj)->GetSubList(),
IM_DEEPNOGROUPS);
- SdrObject* pSubObj = NULL;
while (aGroupIter.IsMore())
{
- pSubObj = aGroupIter.Next();
+ SdrObject* pSubObj = aGroupIter.Next();
if (pSubObj->GetOutlinerParaObject() && pSubObj->ISA(SdrTextObj))
{
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 38c1af1d9e9e..b5fcdb47ad10 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -195,16 +195,14 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
bListsFilled = true;
}
- SfxStyleSheet* pSheet = NULL;
- SfxStyleSheet* pOldSheet = NULL;
std::vector<SfxStyleSheetBase*>::iterator iterOut = aOutlineStyles.begin();
std::vector<SfxStyleSheetBase*>::iterator iterOldOut = aOldOutlineStyles.begin();
while (iterOut != aOutlineStyles.end())
{
- pSheet = static_cast<SfxStyleSheet*>(*iterOut);
- pOldSheet = static_cast<SfxStyleSheet*>(*iterOldOut);
+ SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(*iterOut);
+ SfxStyleSheet* pOldSheet = static_cast<SfxStyleSheet*>(*iterOldOut);
if (pSheet != pOldSheet)
{
@@ -270,14 +268,13 @@ void SdPage::EndListenOutlineText()
if( nIndex != -1 )
aTrueLayoutName = aTrueLayoutName.copy(0, nIndex);
- SfxStyleSheet *pSheet = NULL;
std::vector<SfxStyleSheetBase*> aOutlineStyles;
pSPool->CreateOutlineSheetList(aTrueLayoutName,aOutlineStyles);
std::vector<SfxStyleSheetBase*>::iterator iter;
for (iter = aOutlineStyles.begin(); iter != aOutlineStyles.end(); ++iter)
{
- pSheet = static_cast<SfxStyleSheet*>(*iter);
+ SfxStyleSheet *pSheet = static_cast<SfxStyleSheet*>(*iter);
pOutlineTextObj->EndListening(*pSheet);
}
}
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 939751a533b1..ce9cb4d0ef0b 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -2231,11 +2231,12 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
if ( bGroup )
{
- SvMemoryStream* pTmp = NULL;
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
aXIndexAccess( mXShape, ::com::sun::star::uno::UNO_QUERY );
if ( EnterGroup( aXIndexAccess ) )
{
+ SvMemoryStream* pTmp = NULL;
+
if ( bEffect && !mbUseNewAnimations )
{
pTmp = new SvMemoryStream( 0x200, 0x200 );
diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index b2c25b55eb27..86bf44bfe3b9 100644
--- a/sd/source/filter/eppt/pptx-text.cxx
+++ b/sd/source/filter/eppt/pptx-text.cxx
@@ -88,7 +88,6 @@ PortionObj::PortionObj(::com::sun::star::uno::Reference< ::com::sun::star::text:
{
OUString aString( rXTextRange->getString() );
OUString aURL;
- bool bRTL_endingParen = false;
mnTextSize = aString.getLength();
if ( bLast )
@@ -96,6 +95,7 @@ PortionObj::PortionObj(::com::sun::star::uno::Reference< ::com::sun::star::text:
if ( mnTextSize )
{
+ bool bRTL_endingParen = false;
mpFieldEntry = NULL;
sal_uInt32 nFieldType = 0;