diff options
author | Tor Lillqvist <tml@collabora.com> | 2017-06-19 19:56:48 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2017-06-22 12:28:27 +0200 |
commit | 4e27d3cf6bcb278f26878ef7070723dd8a799a03 (patch) | |
tree | 257e00ba9682463d45e462f2fa60e8d2b08af12a /sc | |
parent | e751e24250fda31dde52b3c65ca79f86142dc789 (diff) |
Introduce a range-based iterator for 'references' in a FormulaTokenArray
Take it into use in a couple of places.
Change-Id: I72127f4236220fbe6fbf9ea25cdd56470be89961
Reviewed-on: https://gerrit.libreoffice.org/38997
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 15 |
3 files changed, 6 insertions, 17 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 2a7b213de2a3..d14b0622be54 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -41,9 +41,7 @@ void ScFormulaListener::startListening(ScTokenArray* pArr, const ScRange& rRange if (!pArr || mpDoc->IsClipOrUndo()) return; - formula::FormulaToken* t; - formula::FormulaTokenArrayPlainIterator aIter( *pArr ); - while ( ( t = aIter.GetNextReference() ) != nullptr ) + for ( auto t: pArr->References() ) { switch (t->GetType()) { diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 6ca66da581cb..eab769e70b0d 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1418,9 +1418,7 @@ ScAddress ScConditionEntry::GetValidSrcPos() const ScTokenArray* pFormula = nPass ? pFormula2 : pFormula1; if (pFormula) { - formula::FormulaTokenArrayPlainIterator aIter(*pFormula); - formula::FormulaToken* t; - while ( ( t = aIter.GetNextReference() ) != nullptr ) + for ( auto t: pFormula->References() ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); ScAddress aAbs = rRef1.toAbs(aSrcPos); diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index d373516899fd..e8284bc8fa37 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4808,8 +4808,7 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) void ScCompiler::AdjustSheetLocalNameRelReferences( SCTAB nDelta ) { - maArrIterator.Reset(); - for (formula::FormulaToken* t = maArrIterator.GetNextReference(); t; t = maArrIterator.GetNextReference()) + for ( auto t: pArr->References() ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); if (rRef1.IsTabRel()) @@ -4827,9 +4826,7 @@ void ScCompiler::AdjustSheetLocalNameRelReferences( SCTAB nDelta ) void ScCompiler::SetRelNameReference() { - maArrIterator.Reset(); - for( formula::FormulaToken* t = maArrIterator.GetNextReference(); t; - t = maArrIterator.GetNextReference() ) + for ( auto t: pArr->References() ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) @@ -4847,9 +4844,7 @@ void ScCompiler::SetRelNameReference() // don't call for other token arrays! void ScCompiler::MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow ) { - maArrIterator.Reset(); - for( formula::FormulaToken* t = maArrIterator.GetNextReference(); t; - t = maArrIterator.GetNextReference() ) + for ( auto t: pArr->References() ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, aPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() ); @@ -4863,9 +4858,7 @@ void ScCompiler::MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow ) void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ) { - formula::FormulaTokenArrayPlainIterator aIter(rArr); - for( formula::FormulaToken* t = aIter.GetNextReference(); t; - t = aIter.GetNextReference() ) + for ( auto t: rArr.References() ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, rPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() ); |