[Libreoffice-commits] core.git: scaddins/source scripting/source sd/source

Michael Weghorn m.weghorn at posteo.de
Sun Dec 21 11:19:11 PST 2014


 scaddins/source/analysis/bessel.cxx                |    8 ++------
 scaddins/source/analysis/financial.cxx             |    7 +++----
 scripting/source/dlgprov/dlgprov.cxx               |    2 +-
 scripting/source/stringresource/stringresource.cxx |    2 +-
 sd/source/core/EffectMigration.cxx                 |    7 +++----
 sd/source/core/drawdoc.cxx                         |    3 +--
 sd/source/core/drawdoc2.cxx                        |   12 +++++-------
 sd/source/core/drawdoc4.cxx                        |    6 ++----
 sd/source/core/sdpage2.cxx                         |    9 +++------
 sd/source/filter/eppt/epptso.cxx                   |    3 ++-
 sd/source/filter/eppt/pptx-text.cxx                |    2 +-
 11 files changed, 24 insertions(+), 37 deletions(-)

New commits:
commit 17fc7aa3b8fcd731fb05b5e17e23ee984d166a8f
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Sat Dec 20 21:09:40 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: I390607e002e93cf7a6babc26d9be084d9f185058

diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx
index 5a4581b..9161655 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 7e79fba..81cf3c4 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 3829429..c6b23ba 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 cde4e73..667a900 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 c434982..855cb9f 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 9e5a422..d80b5fb 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 7d56290..f762e9c 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 6789ad2..2741cf2 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 38c1af1..b5fcdb4 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 939751a..ce9cb4d 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 b2c25b5..86bf44b 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;
 


More information about the Libreoffice-commits mailing list