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

2019-07-30 Thread Arkadiy Illarionov (via logerrit)
 scaddins/source/analysis/analysis.cxx   |   14 
 scaddins/source/analysis/analysishelper.cxx |   62 +---
 sccomp/source/solver/CoinMPSolver.cxx   |   17 ++---
 sccomp/source/solver/LpsolveSolver.cxx  |   25 +++-
 scripting/source/basprov/basmethnode.cxx|   16 +
 scripting/source/basprov/basprov.cxx|7 --
 scripting/source/dlgprov/dlgevtatt.cxx  |   13 +---
 scripting/source/protocolhandler/scripthandler.cxx  |   19 ++
 scripting/source/provider/BrowseNodeFactoryImpl.cxx |   25 +++-
 scripting/source/provider/ProviderCache.cxx |   27 +---
 scripting/source/provider/ProviderCache.hxx |   14 
 scripting/source/provider/URIHelper.cxx |   26 +++-
 scripting/source/stringresource/stringresource.cxx  |5 -
 scripting/source/vbaevents/eventhelper.cxx  |   22 +--
 14 files changed, 107 insertions(+), 185 deletions(-)

New commits:
commit 5ba84c3c7080d55d86b8b39db077b6da36cb700a
Author: Arkadiy Illarionov 
AuthorDate: Sat Jul 27 23:20:29 2019 +0300
Commit: Arkadiy Illarionov 
CommitDate: Tue Jul 30 11:16:00 2019 +0200

Simplify Sequence iterations in scaddins, sccomp, scripting

Use range-based loops, STL and comphelper functions

Change-Id: I836422a1c81a3dc9585687ed2e506eb59bb4ec91
Reviewed-on: https://gerrit.libreoffice.org/76484
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov 

diff --git a/scaddins/source/analysis/analysis.cxx 
b/scaddins/source/analysis/analysis.cxx
index 3587d859c2d6..ce3c866aba2b 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -571,19 +571,11 @@ double SAL_CALL AnalysisAddIn::getSeriessum( double fX, 
double fN, double fM, co
 
 if( fX != 0.0 )
 {
-sal_Int32   n1, n2;
-sal_Int32   nE1 = aCoeffList.getLength();
-sal_Int32   nE2;
-
-for( n1 = 0 ; n1 < nE1 ; n1++ )
+for( const uno::Sequence< double >& rList : aCoeffList )
 {
-const uno::Sequence< double >&rList = aCoeffList[ n1 ];
-nE2 = rList.getLength();
-const double*   pList = rList.getConstArray();
-
-for( n2 = 0 ; n2 < nE2 ; n2++ )
+for( const double fCoef : rList )
 {
-fRet += pList[ n2 ] * pow( fX, fN );
+fRet += fCoef * pow( fX, fN );
 
 fN += fM;
 }
diff --git a/scaddins/source/analysis/analysishelper.cxx 
b/scaddins/source/analysis/analysishelper.cxx
index c44c55f763db..c608732b14d6 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -1481,14 +1481,10 @@ void SortedIndividualInt32List::InsertHolidayList(
 if( !(rHolAny >>= aAnySeq) )
 throw lang::IllegalArgumentException();
 
-const uno::Sequence< uno::Any >* pSeqArray = aAnySeq.getConstArray();
-for( sal_Int32 nIndex1 = 0; nIndex1 < aAnySeq.getLength(); nIndex1++ )
+for( const uno::Sequence< uno::Any >& rSubSeq : aAnySeq )
 {
-const uno::Sequence< uno::Any >& rSubSeq = pSeqArray[ nIndex1 ];
-const uno::Any* pAnyArray = rSubSeq.getConstArray();
-
-for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); 
nIndex2++ )
-InsertHolidayList( rAnyConv, pAnyArray[ nIndex2 ], nNullDate, 
false/*bInsertOnWeekend*/ );
+for( const uno::Any& rAny : rSubSeq )
+InsertHolidayList( rAnyConv, rAny, nNullDate, 
false/*bInsertOnWeekend*/ );
 }
 }
 else
@@ -1499,13 +1495,10 @@ void SortedIndividualInt32List::InsertHolidayList(
 void ScaDoubleList::Append(
 const uno::Sequence< uno::Sequence< double > >& rValueSeq )
 {
-const uno::Sequence< double >* pSeqArray = rValueSeq.getConstArray();
-for( sal_Int32 nIndex1 = 0; nIndex1 < rValueSeq.getLength(); nIndex1++ )
+for( const uno::Sequence< double >& rSubSeq : rValueSeq )
 {
-const uno::Sequence< double >& rSubSeq = pSeqArray[ nIndex1 ];
-const double* pArray = rSubSeq.getConstArray();
-for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); nIndex2++ )
-Append( pArray[ nIndex2 ] );
+for( const double fValue : rSubSeq )
+Append( fValue );
 }
 }
 
@@ -1513,13 +1506,10 @@ void ScaDoubleList::Append(
 void ScaDoubleList::Append(
 const uno::Sequence< uno::Sequence< sal_Int32 > >& rValueSeq )
 {
-const uno::Sequence< sal_Int32 >* pSeqArray = rValueSeq.getConstArray();
-for( sal_Int32 nIndex1 = 0; nIndex1 < rValueSeq.getLength(); nIndex1++ )
+for( const uno::Sequence< sal_Int32 >& rSubSeq : rValueSeq )
 {
-const uno::Sequence< sal_Int32 >& rSubSeq = pSeqArray[ nIndex1 ];
-const sal_Int32* pArray = rSubSeq.getConstArray();
-for( sal_Int32 nIndex2 = 0; 

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

2018-12-19 Thread Libreoffice Gerrit user
 scaddins/source/analysis/analysishelper.cxx |8 +-
 sccomp/source/solver/CoinMPSolver.cxx   |   36 -
 sccomp/source/solver/LpsolveSolver.cxx  |   36 -
 scripting/source/basprov/basscript.cxx  |8 +-
 scripting/source/provider/BrowseNodeFactoryImpl.cxx |   24 +++---
 scripting/source/stringresource/stringresource.cxx  |   76 
 scripting/source/vbaevents/eventhelper.cxx  |   14 +--
 7 files changed, 93 insertions(+), 109 deletions(-)

New commits:
commit b38e690296e48657ec8c66427a6511f42f4b0115
Author: Arkadiy Illarionov 
AuthorDate: Wed Dec 19 21:53:06 2018 +0300
Commit: Noel Grandin 
CommitDate: Thu Dec 20 08:15:54 2018 +0100

Simplify containers iterations in scaddins, sccomp, scripting

Use range-based loop or replace with STL functions

Change-Id: I21ec2eea8f322e2792097d352fc352dc6099c7b7
Reviewed-on: https://gerrit.libreoffice.org/65461
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/scaddins/source/analysis/analysishelper.cxx 
b/scaddins/source/analysis/analysishelper.cxx
index 1a21ecbb0b31..787c99bd3dd8 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -2457,10 +2457,9 @@ double ConvertDataList::Convert( double fVal, const 
OUString& rFrom, const OUStr
 sal_Int16   nLevelFrom = 0;
 sal_Int16   nLevelTo = 0;
 
-auto it = maVector.begin();
-while( it != maVector.end() && ( bSearchFrom || bSearchTo ) )
+for( const auto& rItem : maVector )
 {
-ConvertData*p = it->get();
+ConvertData*p = rItem.get();
 if( bSearchFrom )
 {
 sal_Int16   n = p->GetMatchingLevel( rFrom );
@@ -2499,7 +2498,8 @@ double ConvertDataList::Convert( double fVal, const 
OUString& rFrom, const OUStr
 }
 }
 
-++it;
+if( !bSearchFrom && !bSearchTo )
+break;
 }
 
 if( !pFrom || !pTo )
diff --git a/sccomp/source/solver/CoinMPSolver.cxx 
b/sccomp/source/solver/CoinMPSolver.cxx
index dbd19a4d9f43..d227e48d5f0f 100644
--- a/sccomp/source/solver/CoinMPSolver.cxx
+++ b/sccomp/source/solver/CoinMPSolver.cxx
@@ -86,40 +86,38 @@ void SAL_CALL CoinMPSolver::solve()
 // set all variables to zero
 //! store old values?
 //! use old values as initial values?
-std::vector::const_iterator aVarIter;
-for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); 
++aVarIter )
+for ( const auto& rVarCell : aVariableCells )
 {
-SolverComponent::SetValue( mxDoc, *aVarIter, 0.0 );
+SolverComponent::SetValue( mxDoc, rVarCell, 0.0 );
 }
 
 // read initial values from all dependent cells
-ScSolverCellHashMap::iterator aCellsIter;
-for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); 
++aCellsIter )
+for ( auto& rEntry : aCellsHash )
 {
-double fValue = SolverComponent::GetValue( mxDoc, aCellsIter->first );
-aCellsIter->second.push_back( fValue ); // 
store as first element, as-is
+double fValue = SolverComponent::GetValue( mxDoc, rEntry.first );
+rEntry.second.push_back( fValue ); // store as 
first element, as-is
 }
 
 // loop through variables
-for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); 
++aVarIter )
+for ( const auto& rVarCell : aVariableCells )
 {
-SolverComponent::SetValue( mxDoc, *aVarIter, 1.0 );  // set to 1 
to examine influence
+SolverComponent::SetValue( mxDoc, rVarCell, 1.0 );  // set to 1 to 
examine influence
 
 // read value change from all dependent cells
-for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); 
++aCellsIter )
+for ( auto& rEntry : aCellsHash )
 {
-double fChanged = SolverComponent::GetValue( mxDoc, 
aCellsIter->first );
-double fInitial = aCellsIter->second.front();
-aCellsIter->second.push_back( fChanged - fInitial );
+double fChanged = SolverComponent::GetValue( mxDoc, rEntry.first );
+double fInitial = rEntry.second.front();
+rEntry.second.push_back( fChanged - fInitial );
 }
 
-SolverComponent::SetValue( mxDoc, *aVarIter, 2.0 );  // minimal 
test for linearity
+SolverComponent::SetValue( mxDoc, rVarCell, 2.0 );  // minimal 
test for linearity
 
-for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); 
++aCellsIter )
+for ( const auto& rEntry : aCellsHash )
 {
-double fInitial = aCellsIter->second.front();
-double fCoeff   = aCellsIter->second.back();   // last 
appended: coefficient for this variable
-double fTwo = SolverComponent::GetValue( mxDoc, 
aCellsIter->first );
+double fInitial =