[Libreoffice-commits] core.git: lotuswordpro/source oox/source package/source registry/source reportdesign/source

Michael Weghorn m.weghorn at posteo.de
Fri Dec 19 03:00:55 PST 2014


 lotuswordpro/source/filter/lwpdoc.cxx              |   10 +++-------
 lotuswordpro/source/filter/lwpfoundry.cxx          |    3 +--
 lotuswordpro/source/filter/lwplayout.cxx           |    4 +---
 lotuswordpro/source/filter/lwppagelayout.cxx       |    2 +-
 lotuswordpro/source/filter/lwppara.cxx             |    5 ++---
 lotuswordpro/source/filter/lwpstory.cxx            |    3 +--
 lotuswordpro/source/filter/lwptablelayout.cxx      |    3 +--
 lotuswordpro/source/filter/lwptblformula.cxx       |    3 +--
 lotuswordpro/source/filter/xfilter/xfliststyle.cxx |    6 ++----
 oox/source/export/chartexport.cxx                  |    2 +-
 package/source/zippackage/ZipPackage.cxx           |    6 ++++--
 registry/source/regimpl.cxx                        |    6 ++----
 registry/source/registry.cxx                       |    8 ++------
 reportdesign/source/core/sdr/RptObject.cxx         |    4 ++--
 reportdesign/source/ui/dlg/Condition.cxx           |    3 +--
 reportdesign/source/ui/dlg/GroupsSorting.cxx       |    2 +-
 reportdesign/source/ui/report/ReportSection.cxx    |    3 ++-
 17 files changed, 28 insertions(+), 45 deletions(-)

New commits:
commit d41bc0f7b328ed6c69b2c2822de00165cdc62c61
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Fri Dec 19 08:47:29 2014 +0100

    fdo#39440 reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Idcedd908c653d5a5700884f233ad134dde8be018
    Reviewed-on: https://gerrit.libreoffice.org/13540
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index e2ab2a7..a2ff123 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -257,10 +257,9 @@ void LwpDocument::RegisterLayoutStyles()
 
     //set initial pagelayout in story for parsing pagelayout
     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO).get());
-    LwpPageLayout* pPageLayout = NULL;
     if(pDivInfo)
     {
-        pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
+        LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
         if(pPageLayout)
         {
             //In Ole division, the content of pagelayout is VO_OLEOBJECT
@@ -540,11 +539,10 @@ LwpDocument* LwpDocument::GetPreviousDivision()
     }
 
     LwpDocument* pDivision = GetLastDivision();
-    LwpDocument* pContentDivision = NULL;
 
     while(pDivision)
     {
-        pContentDivision = pDivision->GetLastDivisionWithContents();
+        LwpDocument* pContentDivision = pDivision->GetLastDivisionWithContents();
         if(pContentDivision)
         {
             return pContentDivision;
@@ -621,11 +619,9 @@ LwpDocument* LwpDocument::GetPreviousDivision()
 
     LwpDocument* pDivision = GetFirstDivision();
 
-    LwpDocument*  pContentDivision = NULL;
-
     while (pDivision)
     {
-        pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
+        LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
         if(pContentDivision)
             return pContentDivision;
         pDivision = pDivision->GetNextDivision();
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index 580f5fd..232afb8 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -488,7 +488,6 @@ LwpOrderedObject* LwpOrderedObjectManager::Enumerate(LwpOrderedObject * pLast)
 LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
 {
     LwpListList* pList = NULL;
-    LwpContent* pContent = NULL;
     if(pLast)
         pList = static_cast<LwpListList*>(pLast->GetNext().obj().get());
     else
@@ -502,7 +501,7 @@ LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
 
     while(pList)
     {
-        pContent = static_cast<LwpContent*>(pList->GetObject().obj().get());
+        LwpContent* pContent = static_cast<LwpContent*>(pList->GetObject().obj().get());
         if(pContent && pContent->HasNonEmbeddedLayouts() &&
             !pContent->IsStyleContent())
             return pList;
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 0c5c78d..594a375 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -447,8 +447,6 @@ void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
 */
 LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout)
 {
-    LwpVirtualLayout* pLayout = NULL;
-
     if (!pStartLayout && !m_OnlyLayout.IsNull())
         /* Looking for the first layout and there's only one layout in  the list.*/
         return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj().get());
@@ -456,7 +454,7 @@ LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout
     LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead().obj().get());
     if(pObjHolder)
     {
-        pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get());
+        LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject().obj().get());
         if(!pStartLayout )
             return pLayout;
 
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index ad75b88..1a3967c 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -719,10 +719,10 @@ LwpPara* LwpPageLayout::GetPagePosition()
     if(pPara)
         return pPara;
     //Get the position from its related section
-    LwpSection* pSection = NULL;
     LwpFoundry* pFoundry = GetFoundry();
     if(pFoundry)
     {
+        LwpSection* pSection = NULL;
         while( (pSection = pFoundry->EnumSections(pSection)) )
         {
             if(pSection->GetPageLayout() == this)
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 02ca8d4..22cf028 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -368,11 +368,11 @@ void LwpPara::RegisterStyle()
 
     XFParaStyle* pOverStyle = NULL;
     bool noSpacing = true;
-    bool noIndent = true;
     LwpParaProperty* pBulletProps = NULL, *pNumberingProps = NULL;
 
     if (m_pProps != NULL)
     {
+        bool noIndent = true;
         pOverStyle = new XFParaStyle;
         *pOverStyle = *pBaseStyle;
         pOverStyle->SetStyleName("");
@@ -582,7 +582,6 @@ void LwpPara::RegisterStyle()
                     bool bHeading;
                     LwpPara* pPara = this;
                     LwpPara* pPrePara = NULL;
-                    LwpSilverBullet* pParaSilverBullet = NULL;
                     sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
 
                     nFoundBound = nLevel = pNumbering->GetLevel();
@@ -602,7 +601,7 @@ void LwpPara::RegisterStyle()
                             break;
                         }*/
 
-                        pParaSilverBullet = pPara->GetSilverBullet();
+                        LwpSilverBullet* pParaSilverBullet = pPara->GetSilverBullet();
                         pNumbering = pPara->GetParaNumbering();
 
                         if (pPara->GetObjectID() != this->GetObjectID())
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index 911e9ae..f4b8eff 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -284,14 +284,13 @@ void LwpStory::SortPageLayout()
 **************************************************************************/
 bool LwpStory::IsNeedSection()
 {
-    bool bColumns = false;
     bool bNewSection = false;
     if(m_pCurrentLayout)
     {
         if(m_pCurrentLayout->HasColumns())
         {
             //get the following pagelayout and its type
-            bColumns = true;
+            bool bColumns = true;
             LwpPageLayout* pNextLayout = GetNextPageLayout();
             if(pNextLayout)
             {
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 6734edb..90897ad 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -848,7 +848,6 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
 
     sal_uInt16 nRowNum = pTmpTable->GetRowCount();
     sal_uInt8* CellMark = new sal_uInt8[nRowNum];
-    bool bFindFlag = false;
 
     if (nRowNum == 1)
     {
@@ -860,7 +859,7 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
     else
     {
         sal_uInt8 nFirstColSpann = 1;
-        bFindFlag = FindSplitColMark(pTmpTable,CellMark,nFirstColSpann);
+        const bool bFindFlag = FindSplitColMark(pTmpTable,CellMark,nFirstColSpann);
 
         if (bFindFlag)//split to 2 cells
         {
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 4f6bca0..eda2b45 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -310,14 +310,13 @@ bool LwpFormulaInfo::ReadArguments(LwpFormulaFunc& aFunc)
     sal_uInt16 NumberOfArguments = m_pObjStrm->QuickReaduInt16();
     sal_uInt16 ArgumentDiskLength, Count;
     sal_uInt8 ArgumentType;
-    bool bArgument = false;
     bool readSucceeded = true;
 
     for (Count = 0; Count < NumberOfArguments; Count++)
     {
         ArgumentType = (sal_uInt8) m_pObjStrm->QuickReaduInt16(); // written as lushort
         ArgumentDiskLength = m_pObjStrm->QuickReaduInt16();
-        bArgument = true;
+        bool bArgument = true;
 
         switch(ArgumentType)
         {
diff --git a/lotuswordpro/source/filter/xfilter/xfliststyle.cxx b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
index 14d28b2..6e75c94 100644
--- a/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
@@ -169,10 +169,9 @@ XFListStyle::XFListStyle()
 
 XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
 {
-    enumXFListLevel type;
     for( int i=0; i<10; i++ )
     {
-        type = other.m_pListLevels[i]->m_eListType;
+        const enumXFListLevel type = other.m_pListLevels[i]->m_eListType;
         if( type == enumXFListLevelNumber )
         {
             XFListlevelNumber *pNum = static_cast<XFListlevelNumber*>(other.m_pListLevels[i]);
@@ -190,10 +189,9 @@ XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
 
 XFListStyle& XFListStyle::operator=(const XFListStyle& other)
 {
-    enumXFListLevel type;
     for( int i=0; i<10; i++ )
     {
-        type = other.m_pListLevels[i]->m_eListType;
+        const enumXFListLevel type = other.m_pListLevels[i]->m_eListType;
         if( type == enumXFListLevelNumber )
         {
             XFListlevelNumber *pNum = static_cast<XFListlevelNumber*>(m_pListLevels[i]);
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 31bb95ee..56d6c1f 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2505,9 +2505,9 @@ void ChartExport::_exportAxis(
             FSEND );
     }
 
-    bool bDisplayUnits = false;
     if( nAxisType == XML_valAx && GetProperty( xAxisProp, "DisplayUnits" ) )
     {
+        bool bDisplayUnits = false;
         mAny >>= bDisplayUnits;
         if(bDisplayUnits)
         {
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index c30ca99..9eee46e 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -194,7 +194,6 @@ void ZipPackage::parseManifest()
     if ( m_nFormat == embed::StorageFormats::PACKAGE )
     {
         bool bManifestParsed = false;
-        bool bDifferentStartKeyAlgorithm = false;
         const OUString sMeta ("META-INF");
         if ( m_xRootFolder->hasByName( sMeta ) )
         {
@@ -410,6 +409,8 @@ void ZipPackage::parseManifest()
         bool bODF12AndNewer = ( m_pRootFolder->GetVersion().compareTo( ODFVER_012_TEXT ) >= 0 );
         if ( !m_bForceRecovery && bODF12AndNewer )
         {
+            bool bDifferentStartKeyAlgorithm = false;
+
             if ( m_bInconsistent )
             {
                 // this is an ODF1.2 document that contains streams not referred in the manifest.xml;
@@ -575,12 +576,13 @@ void ZipPackage::getZipFileContents()
 void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
         throw( Exception, RuntimeException, std::exception )
 {
-    bool bHaveZipFile = true;
     uno::Reference< XProgressHandler > xProgressHandler;
     beans::NamedValue aNamedValue;
 
     if ( aArguments.getLength() )
     {
+        bool bHaveZipFile = true;
+
         for( int ind = 0; ind < aArguments.getLength(); ind++ )
         {
             OUString aParamUrl;
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 3781309..039cde3 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1616,14 +1616,13 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     sal::static_int_cast< unsigned long >(len));
                 fprintf(stdout, "%s       Data = ", indent);
 
-                sal_Char *pValue;
                 for (sal_uInt32 i=0; i < len; i++)
                 {
                     readUINT32(pBuffer+offset, sLen);
 
                     offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes
 
-                    pValue = (sal_Char*)rtl_allocateMemory(sLen);
+                    sal_Char *pValue = (sal_Char*)rtl_allocateMemory(sLen);
                     readUtf8(pBuffer+offset, pValue, sLen);
 
                     if (offset > 8)
@@ -1654,7 +1653,6 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     sal::static_int_cast< unsigned long >(len));
                 fprintf(stdout, "%s       Data = ", indent);
 
-                sal_Unicode *pValue;
                 OString uStr;
                 for (sal_uInt32 i=0; i < len; i++)
                 {
@@ -1662,7 +1660,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
 
                     offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes
 
-                    pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode));
+                    sal_Unicode *pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode));
                     readString(pBuffer+offset, pValue, sLen);
 
                     if (offset > 8)
diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx
index 803372f..3086adb 100644
--- a/registry/source/registry.cxx
+++ b/registry/source/registry.cxx
@@ -74,11 +74,9 @@ static void REGISTRY_CALLTYPE release(RegHandle hReg)
 
 static RegError REGISTRY_CALLTYPE getName(RegHandle hReg, rtl_uString** pName)
 {
-    ORegistry*  pReg;
-
     if (hReg)
     {
-        pReg = (ORegistry*)hReg;
+        ORegistry*  pReg = (ORegistry*)hReg;
         if ( pReg->isOpen() )
         {
             rtl_uString_assign(pName, pReg->getName().pData);
@@ -580,11 +578,9 @@ REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryN
 
 REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry)
 {
-    ORegistry* pReg;
-
     if (hRegistry)
     {
-        pReg = (ORegistry*)hRegistry;
+        ORegistry* pReg = (ORegistry*)hRegistry;
         delete(pReg);
         return REG_NO_ERROR;
     } else
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 0d76ae2..f40b8b8 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -710,9 +710,9 @@ void OUnoObject::NbcMove( const Size& rSize )
 
         bool bPositionFixed = false;
         Size aUndoSize(0,0);
-        bool bUndoMode = false;
         if ( m_xReportComponent.is() )
         {
+            bool bUndoMode = false;
             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
             if (pRptModel->GetUndoEnv().IsUndoMode())
             {
@@ -1006,9 +1006,9 @@ void OOle2Obj::NbcMove( const Size& rSize )
 
         bool bPositionFixed = false;
         Size aUndoSize(0,0);
-        bool bUndoMode = false;
         if ( m_xReportComponent.is() )
         {
+            bool bUndoMode = false;
             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
             if (pRptModel->GetUndoEnv().IsUndoMode())
             {
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 47ea6c0..26e5989 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -122,7 +122,6 @@ OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition)
     short i = 0;
     XColorListRef pColorList( XColorList::CreateStdColorList() );
     long nCount = pColorList->Count();
-    XColorEntry* pEntry = NULL;
     Color aColWhite( COL_WHITE );
     OUString aStrWhite( ModuleRes(STR_COLOR_WHITE) );
 
@@ -132,7 +131,7 @@ OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition)
 
     for ( i = 0; i < nCount; i++ )
     {
-        pEntry = pColorList->GetColor(i);
+        XColorEntry* pEntry = pColorList->GetColor(i);
         m_aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
     }
 
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index dfe9228..171ce37 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -403,9 +403,9 @@ bool OFieldExpressionControl::SaveModified(bool _bAppendRow)
     sal_Int32 nRow = GetCurRow();
     if ( nRow != BROWSER_ENDOFSELECTION )
     {
-        bool bAppend = false;
         try
         {
+            bool bAppend = false;
             uno::Reference< report::XGroup> xGroup;
             if ( m_aGroupPositions[nRow] == NO_GROUP )
             {
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 6b61162..e7e2f53 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -547,7 +547,6 @@ void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_I
         const sal_Int32 nCount = m_xSection->getCount();
         for (sal_Int32 i = 0; i < nCount; ++i)
         {
-            bool bChanged = false;
             uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
             awt::Point aPos = xReportComponent->getPosition();
             awt::Size aSize = xReportComponent->getSize();
@@ -555,6 +554,8 @@ void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_I
             SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
             if ( pObject )
             {
+                bool bChanged = false;
+
                 OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject);
                 rBase.EndListening(false);
                 if ( aPos.X < i_nLeftMargin )


More information about the Libreoffice-commits mailing list