fdo#39440 reduce scope of local variables

This addresses some cppcheck warnings.

Change-Id: I390607e002e93cf7a6babc26d9be084d9f185058
This commit is contained in:
Michael Weghorn 2014-12-20 21:09:40 +01:00 committed by Julien Nabet
parent be34823092
commit 17fc7aa3b8
11 changed files with 24 additions and 37 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 )

View File

@ -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;

View File

@ -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

View File

@ -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())
{

View File

@ -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;

View File

@ -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))
{

View File

@ -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);
}
}

View File

@ -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 );

View File

@ -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;