[Libreoffice-commits] core.git: basegfx/source chart2/source cui/source dbaccess/source desktop/source editeng/source filter/source framework/source helpcompiler/source

Łukasz Hryniuk lukasz.hryniuk at wp.pl
Tue Jan 6 22:47:37 PST 2015


 basegfx/source/workbench/gauss.hxx                        |   20 +++++++-------
 chart2/source/controller/main/DrawCommandDispatch.cxx     |    2 -
 chart2/source/tools/AxisHelper.cxx                        |    2 -
 chart2/source/tools/DiagramHelper.cxx                     |    5 +--
 cui/source/options/treeopt.cxx                            |   12 ++++----
 dbaccess/source/filter/xml/xmlfilter.cxx                  |    2 -
 dbaccess/source/ui/control/FieldDescControl.cxx           |    3 --
 dbaccess/source/ui/querydesign/TableWindowListBox.cxx     |    2 -
 dbaccess/source/ui/uno/copytablewizard.cxx                |    2 -
 desktop/source/app/app.cxx                                |    3 --
 desktop/source/deployment/manager/dp_extensionmanager.cxx |    2 -
 editeng/source/rtf/svxrtf.cxx                             |   10 +++----
 filter/source/graphicfilter/epict/epict.cxx               |   12 ++------
 framework/source/uielement/toolbarsmenucontroller.cxx     |    5 +--
 helpcompiler/source/HelpLinker.cxx                        |    2 -
 15 files changed, 38 insertions(+), 46 deletions(-)

New commits:
commit 9fd89a5952a48b473cee03a2681eb5d4cd6d1742
Author: Łukasz Hryniuk <lukasz.hryniuk at wp.pl>
Date:   Sun Jan 4 22:50:05 2015 +0100

    fdo#39440 reduce scope of local variables
    
    Beside scope changes, it fixes lack of initialization in a few places.
    
    Change-Id: Ia09fdb9845d8ac17256330a5ec5168401c84f0f2
    Reviewed-on: https://gerrit.libreoffice.org/13755
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basegfx/source/workbench/gauss.hxx b/basegfx/source/workbench/gauss.hxx
index b6a784c..fc352fe 100644
--- a/basegfx/source/workbench/gauss.hxx
+++ b/basegfx/source/workbench/gauss.hxx
@@ -49,14 +49,14 @@ bool eliminate(     Matrix&         matrix,
                     const BaseType& minPivot    )
 {
     BaseType    temp;
-    int         max, i, j, k;   /* *must* be signed, when looping like: j>=0 ! */
 
+    /* i, j, k *must* be signed, when looping like: j>=0 ! */
     /* eliminate below main diagonal */
-    for(i=0; i<cols-1; ++i)
+    for(int i=0; i<cols-1; ++i)
     {
         /* find best pivot */
-        max = i;
-        for(j=i+1; j<rows; ++j)
+        int max = i;
+        for(int j=i+1; j<rows; ++j)
             if( fabs(matrix[ j*cols + i ]) > fabs(matrix[ max*cols + i ]) )
                 max = j;
 
@@ -65,7 +65,7 @@ bool eliminate(     Matrix&         matrix,
             return false;   /* pivot too small! */
 
         /* interchange rows 'max' and 'i' */
-        for(k=0; k<cols; ++k)
+        for(int k=0; k<cols; ++k)
         {
             temp = matrix[ i*cols + k ];
             matrix[ i*cols + k ] = matrix[ max*cols + k ];
@@ -73,8 +73,8 @@ bool eliminate(     Matrix&         matrix,
         }
 
         /* eliminate column */
-        for(j=i+1; j<rows; ++j)
-            for(k=cols-1; k>=i; --k)
+        for(int j=i+1; j<rows; ++j)
+            for(int k=cols-1; k>=i; --k)
                 matrix[ j*cols + k ] -= matrix[ i*cols + k ] *
                     matrix[ j*cols + i ] / matrix[ i*cols + i ];
     }
@@ -110,13 +110,13 @@ bool substitute(    const Matrix&   matrix,
                     Vector&         result  )
 {
     BaseType    temp;
-    int         j,k;    /* *must* be signed, when looping like: j>=0 ! */
 
+    /* j, k *must* be signed, when looping like: j>=0 ! */
     /* substitute backwards */
-    for(j=rows-1; j>=0; --j)
+    for(int j=rows-1; j>=0; --j)
     {
         temp = 0.0;
-        for(k=j+1; k<cols-1; ++k)
+        for(int k=j+1; k<cols-1; ++k)
             temp += matrix[ j*cols + k ] * result[k];
 
         if( matrix[ j*cols + j ] == 0.0 )
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx
index af43e75..8804bb9 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -287,13 +287,13 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea
 
     ChartDrawMode eDrawMode = CHARTDRAW_SELECT;
     SdrObjKind eKind = OBJ_NONE;
-    bool bCreate = false;
 
     sal_uInt16 nFeatureId = 0;
     OUString aBaseCommand;
     OUString aCustomShapeType;
     if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
     {
+        bool bCreate = false;
         m_nFeatureId = nFeatureId;
         m_aCustomShapeType = aCustomShapeType;
 
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index fc475d6..70b4a80 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -136,7 +136,6 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
                 , bool bSearchForParallelAxisIfNothingIsFound )
 {
     sal_Int32 nNumberFormatKey(0);
-    bool bNumberFormatKeyFoundViaAttachedData = false;
     sal_Int32 nAxisIndex = 0;
     sal_Int32 nDimensionIndex = 1;
     AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex );
@@ -235,6 +234,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
         {
             typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency;
             tNumberformatFrequency aKeyMap;
+            bool bNumberFormatKeyFoundViaAttachedData = false;
 
             try
             {
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 7705851..82dca03 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1297,11 +1297,10 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
     {
         uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
 
-        //find position of series.
-        bool bFound = false;
-
         if( xGivenDataSeries.is() && xCooSysContainer.is() )
         {
+            //find position of series.
+            bool bFound = false;
             uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
 
             for( sal_Int32 nCS = 0; !bFound && nCS < aCooSysList.getLength(); ++nCS )
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 05bb302..99b7b76 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1179,10 +1179,10 @@ SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
             pRet->Put(aOptSet);
 
             utl::MiscCfg    aMisc;
-            const SfxPoolItem* pItem;
             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
             if ( pViewFrame )
             {
+                const SfxPoolItem* pItem = NULL;
                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
 
                 // miscellaneous - Year2000
@@ -1229,11 +1229,11 @@ SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
             aHyphen.GetMinLead()  = (sal_uInt8)nMinLead;
             aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
 
-            const SfxPoolItem* pItem;
-            SfxPoolItem* pClone;
             SfxViewFrame* pViewFrame = SfxViewFrame::Current();
             if ( pViewFrame )
             {
+                const SfxPoolItem* pItem = NULL;
+                SfxPoolItem* pClone = NULL;
                 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
                 if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
                     pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, static_cast<const SvxLanguageItem*>(pItem)->GetLanguage()));
@@ -1312,7 +1312,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet
         case SID_GENERAL_OPTIONS:
         {
             utl::MiscCfg    aMisc;
-            const SfxPoolItem* pItem;
+            const SfxPoolItem* pItem = NULL;
             SfxItemSet aOptSet(SfxGetpApp()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
             aOptSet.Put(rSet);
             if(aOptSet.Count())
@@ -1386,7 +1386,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet
 void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
 {
     bool bSaveSpellCheck = false;
-    const SfxPoolItem* pItem;
+    const SfxPoolItem* pItem = NULL;
 
     if ( SfxItemState::SET == rSet.GetItemState( SID_SPELL_MODIFIED, false, &pItem ) )
     {
@@ -1407,7 +1407,7 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
     if ( pViewFrame )
     {
         SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
-        pItem = 0;
+        pItem = NULL;
         if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_LANGUAGE, false, &pItem ))
         {
             pDispatch->Execute(pItem->Which(),    SfxCallMode::ASYNCHRON, pItem, 0L);
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 76f8e84..a47b6c8 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -306,10 +306,10 @@ sal_Int32 ReadThroughComponent(
     if ( xStorage.is() )
     {
         uno::Reference< io::XStream > xDocStream;
-        bool bEncrypted = false;
 
         try
         {
+            bool bEncrypted = false;
             // open stream (and set parser input)
         OUString sStreamName = OUString::createFromAscii(pStreamName);
             if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
index ab59911..5221734 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -1669,12 +1669,11 @@ OUString OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldD
     if ( bCheck )
     {
         sal_uInt32 nFormatKey;
-        bool bTextFormat = false;
 
         try
         {
             double nValue = 0.0;
-            bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
+            bool bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
             if ( _pFieldDescr->GetControlDefault() >>= sDefault )
             {
                 if ( !bTextFormat )
diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
index 6d8f855..f11a7b8 100644
--- a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
@@ -85,9 +85,9 @@ SvTreeListEntry* OTableWindowListBox::GetEntryFromText( const OUString& rEntryTe
     OJoinDesignView* pView = m_pTabWin->getDesignView();
     OJoinController& rController = pView->getController();
 
-    bool bCase = false;
     try
     {
+        bool bCase = false;
         Reference<XConnection> xConnection = rController.getConnection();
         if(xConnection.is())
         {
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 70e5a6e..e7ad4f9 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -1167,13 +1167,13 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
         }
 
         ++nRowCount;
-        bool bInsertAutoIncrement = true;
         ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin();
         ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end();
 
         aCopyEvent.Error.clear();
         try
         {
+            bool bInsertAutoIncrement = true;
             // notify listeners
             m_aCopyTableListeners.notifyEach( &XCopyTableListener::copyingRow, aCopyEvent );
 
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index e5f0a84..af0cf51 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2690,7 +2690,6 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
 void Desktop::OpenSplashScreen()
 {
     const CommandLineArgs &rCmdLine = GetCommandLineArgs();
-    bool bVisible = false;
     // Show intro only if this is normal start (e.g. no server, no quickstart, no printing )
     if ( !rCmdLine.IsInvisible() &&
          !rCmdLine.IsHeadless() &&
@@ -2726,7 +2725,7 @@ void Desktop::OpenSplashScreen()
         if ( rCmdLine.HasSplashPipe() )
             aSplashService = "com.sun.star.office.PipeSplashScreen";
 
-        bVisible = true;
+        bool bVisible = true;
         Sequence< Any > aSeq( 2 );
         aSeq[0] <<= bVisible;
         aSeq[1] <<= aAppName;
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index 4643794..345a3e0 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -680,7 +680,6 @@ Reference<css::deployment::XPackage> ExtensionManager::addExtension(
     Reference<css::deployment::XPackage> xExtensionBackup;
 
     uno::Any excOccurred2;
-    bool bUserDisabled = false;
     bool bCanInstall = doChecksForAddExtension(
         xPackageManager,
         properties,
@@ -690,6 +689,7 @@ Reference<css::deployment::XPackage> ExtensionManager::addExtension(
         xOldExtension );
 
     {
+        bool bUserDisabled = false;
         // In this garded section (getMutex) we must not use the argument xCmdEnv
         // because it may bring up dialogs (XInteractionHandler::handle) this
         //may potententially deadlock. See issue
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 6e76371..3cf9996 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -454,12 +454,12 @@ void SvxRTFParser::ReadColorTable()
 
 void SvxRTFParser::ReadFontTable()
 {
-    int nToken;
+    int nToken = 0;
     int _nOpenBrakets = 1;      // the first was already detected earlier!!
     vcl::Font* pFont = new vcl::Font();
     short nFontNo(0), nInsFontNo (0);
     OUString sAltNm, sFntNm;
-    bool bIsAltFntNm = false, bCheckNewFont;
+    bool bIsAltFntNm = false;
 
     rtl_TextEncoding nSystemChar = lcl_GetDefaultTextEncodingForRTF();
     pFont->SetCharSet( nSystemChar );
@@ -467,7 +467,7 @@ void SvxRTFParser::ReadFontTable()
 
     while( _nOpenBrakets && IsParserWorking() )
     {
-        bCheckNewFont = false;
+        bool bCheckNewFont = false;
         switch( ( nToken = GetNextToken() ))
         {
             case '}':
@@ -601,7 +601,7 @@ void SvxRTFParser::ReadOLEData()
 OUString& SvxRTFParser::GetTextToEndGroup( OUString& rStr )
 {
     rStr.clear();
-    int _nOpenBrakets = 1, nToken;  // the first was already detected earlier!!
+    int _nOpenBrakets = 1, nToken = 0;  // the first was already detected earlier!!
 
     while( _nOpenBrakets && IsParserWorking() )
     {
@@ -661,7 +661,7 @@ util::DateTime SvxRTFParser::GetDateTimeStamp( )
 
 void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
 {
-    int _nOpenBrakets = 1, nToken;  // the first was already detected earlier!!
+    int _nOpenBrakets = 1, nToken = 0;  // the first was already detected earlier!!
     DBG_ASSERT(m_xDocProps.is(),
         "SvxRTFParser::ReadInfo: no DocumentProperties");
     OUString sStr, sComment;
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 4d33b4e..aa8d045 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -335,7 +335,6 @@ void PictWriter::WritePolygon(const Polygon & rPoly)
 {
     sal_uInt16 nDataSize,i,nSize;
     short nMinX = 0, nMinY = 0, nMaxX = 0, nMaxY = 0;
-    short nx,ny;
     Polygon aPoly(rPoly);
 
     nSize=aPoly.GetSize();
@@ -354,8 +353,8 @@ void PictWriter::WritePolygon(const Polygon & rPoly)
                                                    aSrcMapMode,
                                                    aTargetMapMode );
 
-        nx = (short) aPoint.X();
-        ny = (short) aPoint.Y();
+        short nx = (short) aPoint.X();
+        short ny = (short) aPoint.Y();
 
         if ( i==0 || nMinX>nx )
             nMinX=nx;
@@ -1308,21 +1307,18 @@ void PictWriter::SetAttrForText()
 
 void PictWriter::WriteTextArray(Point & rPoint, const OUString& rString, const long* pDXAry)
 {
-    bool bDelta;
-    Point aPt;
-
     if ( pDXAry == NULL )
         WriteOpcode_Text( rPoint, rString, false );
     else
     {
-        bDelta = false;
+        bool bDelta = false;
         sal_Int32 nLen = rString.getLength();
         for ( sal_Int32 i = 0; i < nLen; i++ )
         {
             sal_Unicode c = rString[ i ];
             if ( c && ( c != 0x20 ) )
             {
-                aPt = rPoint;
+                Point aPt = rPoint;
                 if ( i > 0 )
                     aPt.X() += pDXAry[ i - 1 ];
 
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index 1972713..3cbfc91 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -543,9 +543,6 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev
     OUString aFeatureURL( Event.FeatureURL.Complete );
 
     // All other status events will be processed here
-    bool bSetCheckmark      = false;
-    bool bCheckmark         = false;
-
     osl::ClearableMutexGuard aLock( m_aMutex );
     Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu );
     aLock.clear();
@@ -560,6 +557,8 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev
         if (!pVCLPopupMenu)
             return;
 
+        bool bSetCheckmark      = false;
+        bool bCheckmark         = false;
         for ( sal_uInt16 i = 0; i < pVCLPopupMenu->GetItemCount(); i++ )
         {
             sal_uInt16 nId = pVCLPopupMenu->GetItemId( i );
diff --git a/helpcompiler/source/HelpLinker.cxx b/helpcompiler/source/HelpLinker.cxx
index 9449469..b85911a 100644
--- a/helpcompiler/source/HelpLinker.cxx
+++ b/helpcompiler/source/HelpLinker.cxx
@@ -283,7 +283,6 @@ void HelpLinker::initIndexerPreProcessor()
 */
 void HelpLinker::link() throw(HelpProcessingException, BasicCodeTagger::TaggerException)
 {
-    bool bIndexForExtension = true;
 
     if( bExtensionMode )
     {
@@ -337,6 +336,7 @@ void HelpLinker::link() throw(HelpProcessingException, BasicCodeTagger::TaggerEx
     // catch HelpProcessingException to avoid locking data bases
     try
     {
+        bool bIndexForExtension = true;
         // lastly, initialize the indexBuilder
         if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty())
             initIndexerPreProcessor();


More information about the Libreoffice-commits mailing list