[Libreoffice-commits] core.git: 18 commits - formula/source sc/inc sc/source

Tor Lillqvist tml at collabora.com
Wed Jun 7 18:44:26 UTC 2017


 formula/source/ui/dlg/formula.cxx        |   12 +++++++-----
 sc/inc/formulaiter.hxx                   |    4 +++-
 sc/source/core/data/colorscale.cxx       |    4 ++--
 sc/source/core/data/column.cxx           |    5 +++--
 sc/source/core/data/column3.cxx          |    5 +++--
 sc/source/core/data/conditio.cxx         |    8 ++++----
 sc/source/core/data/documen4.cxx         |    7 ++++---
 sc/source/core/data/document10.cxx       |    9 ++++++---
 sc/source/core/data/formulaiter.cxx      |   12 ++++++------
 sc/source/core/tool/formulagroup.cxx     |    3 ++-
 sc/source/core/tool/interpr4.cxx         |    3 ++-
 sc/source/core/tool/rangenam.cxx         |   27 +++++++++++++--------------
 sc/source/filter/excel/xechart.cxx       |    5 +++--
 sc/source/filter/excel/xeformula.cxx     |    3 ++-
 sc/source/filter/excel/xelink.cxx        |    3 ++-
 sc/source/filter/excel/xichart.cxx       |    9 +++++----
 sc/source/ui/docshell/externalrefmgr.cxx |    9 +++++----
 sc/source/ui/miscdlgs/anyrefdg.cxx       |    6 +++---
 sc/source/ui/unoobj/chart2uno.cxx        |   13 ++++++++-----
 19 files changed, 83 insertions(+), 64 deletions(-)

New commits:
commit 30e27a9936b5ad3550708f7920e749f94abe1828
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:03:57 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more file
    
    Change-Id: Ia2db1835e56d683769d8c3972fb0c73ba2eae2c6

diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 432724da0b68..41ee1ee8a01c 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2104,9 +2104,10 @@ sal_Bool SAL_CALL ScChart2DataProvider::createDataSequenceByFormulaTokensPossibl
     if (!n)
         return false;
 
-    const formula::FormulaToken* pFirst = aCode.First();
+    formula::FormulaTokenArrayPlainIterator aIter(aCode);
+    const formula::FormulaToken* pFirst = aIter.First();
     const formula::FormulaToken* pLast = aCode.GetArray()[n-1];
-    for (const formula::FormulaToken* p = aCode.First(); p; p = aCode.Next())
+    for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         switch (p->GetType())
         {
@@ -2162,9 +2163,10 @@ ScChart2DataProvider::createDataSequenceByFormulaTokens(
         return xResult;
 
     vector<ScTokenRef> aRefTokens;
-    const formula::FormulaToken* pFirst = aCode.First();
+    formula::FormulaTokenArrayPlainIterator aIter(aCode);
+    const formula::FormulaToken* pFirst = aIter.First();
     const formula::FormulaToken* pLast = aCode.GetArray()[n-1];
-    for (const formula::FormulaToken* p = aCode.First(); p; p = aCode.Next())
+    for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         switch (p->GetType())
         {
@@ -2625,7 +2627,8 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke
 
     ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, aTabName, false);
     sal_Int32 nDataCount = 0;
-    for (FormulaToken* p = pArray->First(); p; p = pArray->Next())
+    FormulaTokenArrayPlainIterator aIter(*pArray);
+    for (FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         // Cached external range is always represented as a single
         // matrix token, although that might change in the future when
commit 2a29c792c214633bd8ab4ec229ec8bda91393388
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:03:32 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more file
    
    Change-Id: I70988724367b0ee798ccfee35c94e280b1015b36

diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 2dba375feed6..9cf85abf729f 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -205,8 +205,8 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr)
                 pTabViewShell->DoneRefMode();
                 pTabViewShell->ClearHighlightRanges();
 
-                pScTokA->Reset();
-                const formula::FormulaToken* pToken = pScTokA->GetNextReference();
+                formula::FormulaTokenArrayPlainIterator aIter(*pScTokA);
+                const formula::FormulaToken* pToken = aIter.GetNextReference();
 
                 sal_uInt16 nIndex=0;
 
@@ -232,7 +232,7 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr)
                         pTabViewShell->AddHighlightRange(aRange, aColName);
                     }
 
-                    pToken = pScTokA->GetNextReference();
+                    pToken = aIter.GetNextReference();
                 }
             }
         }
commit 7f2fbc92155f166a3cef61ba4ceb4a7be8e1f8e5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:03:09 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more file
    
    Change-Id: I7134ce5c2d6d8fdc081410dcbc2b36c9db68839e

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c8680615b789..2d27e0034eaa 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -202,9 +202,9 @@ bool hasRefsToSrcDoc(ScRangeData& rData, sal_uInt16 nFileId)
     if (!pArray)
         return false;
 
-    pArray->Reset();
-    formula::FormulaToken* p = pArray->GetNextReference();
-    for (; p; p = pArray->GetNextReference())
+    formula::FormulaTokenArrayPlainIterator aIter(*pArray);
+    formula::FormulaToken* p = aIter.GetNextReference();
+    for (; p; p = aIter.GetNextReference())
     {
         if (!p->IsExternalRef())
             continue;
@@ -2323,7 +2323,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr
     ScExternalRefCache::TokenArrayRef pNew(new ScTokenArray);
 
     ScTokenArray aCode(*pRangeData->GetCode());
-    for (const FormulaToken* pToken = aCode.First(); pToken; pToken = aCode.Next())
+    FormulaTokenArrayPlainIterator aIter(aCode);
+    for (const FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next())
     {
         bool bTokenAdded = false;
         switch (pToken->GetType())
commit 5b142483c14bbf78ba161b2e1bf3302dd4ed6d46
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:02:43 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more file
    
    Change-Id: I2d68513664200349574446e68efcfacda1604f86

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 49c35f7ee6a6..f444ab05d5cf 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -120,6 +120,7 @@ using ::com::sun::star::chart2::data::XLabeledDataSequence;
 using ::com::sun::star::chart2::data::LabeledDataSequence;
 
 using ::formula::FormulaToken;
+using ::formula::FormulaTokenArrayPlainIterator;
 using ::std::unique_ptr;
 
 namespace cssc = ::com::sun::star::chart;
@@ -780,8 +781,8 @@ sal_uInt16 XclImpChSourceLink::GetCellCount() const
     sal_uInt32 nCellCount = 0;
     if( mxTokenArray )
     {
-        mxTokenArray->Reset();
-        for( const FormulaToken* pToken = mxTokenArray->First(); pToken; pToken = mxTokenArray->Next() )
+        FormulaTokenArrayPlainIterator aIter(*mxTokenArray);
+        for( const FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next() )
         {
             switch( pToken->GetType() )
             {
@@ -895,8 +896,8 @@ void XclImpChSourceLink::FillSourceLink( ::std::vector< ScTokenRef >& rTokens )
         // no links to fill.
         return;
 
-    mxTokenArray->Reset();
-    for (FormulaToken* p = mxTokenArray->First(); p; p = mxTokenArray->Next())
+    FormulaTokenArrayPlainIterator aIter(*mxTokenArray);
+    for (FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         ScTokenRef pToken(p->Clone());
         if (ScRefTokenHelper::isRef(pToken))
commit 1d0d7127db27d12a39820023f25a212c05952610
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:02:08 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: Id7f22d2d00e7c3ec79ec2dd886dce72be8692ac5

diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 8b110575f7c0..55b320a50b1e 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1916,7 +1916,8 @@ void XclExpSupbookBuffer::StoreCellRange( sal_uInt16 nFileId, const OUString& rT
     if (!pArray.get())
         return;
 
-    for (FormulaToken* p = pArray->First(); p; p = pArray->Next())
+    FormulaTokenArrayPlainIterator aIter(*pArray);
+    for (FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         if (p->GetType() == svMatrix)
             aMatrixList.push_back(p);
commit 0505d3b22a29d47945f1d08135138610edbdc9bc
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:01:40 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: I8af9204e93608d7f63a502ddcc0b05e6f191343f

diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 7c0134f332be..ccc2ce6218d4 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2126,7 +2126,8 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData )
             // store external cell contents in CRN records
             if( mxData->mpScBasePos )
             {
-                for( FormulaToken* pScToken = xArray->First(); pScToken; pScToken = xArray->Next() )
+                FormulaTokenArrayPlainIterator aIter(*xArray);
+                for( FormulaToken* pScToken = aIter.First(); pScToken; pScToken = aIter.Next() )
                 {
                     if( pScToken->IsExternalRef() )
                     {
commit 468345765e71bcfabfc9148cbed8c4ae6c51910c
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 17:01:15 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: Ieb807769c64d38d8100c6c4bf0e7a0a2913d8e7b

diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index e7d19e5227c4..3cdbd6e5006c 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -113,6 +113,7 @@ using ::com::sun::star::chart2::data::XDataSource;
 using ::com::sun::star::chart2::data::XLabeledDataSequence;
 
 using ::formula::FormulaToken;
+using ::formula::FormulaTokenArrayPlainIterator;
 
 namespace cssc = ::com::sun::star::chart;
 namespace cssc2 = ::com::sun::star::chart2;
@@ -904,8 +905,8 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > c
 
     ScTokenArray aArray;
     sal_uInt32 nValueCount = 0;
-    pArray->Reset();
-    for( const FormulaToken* pToken = pArray->First(); pToken; pToken = pArray->Next() )
+    FormulaTokenArrayPlainIterator aIter(*pArray);
+    for( const FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next() )
     {
         switch( pToken->GetType() )
         {
commit 91a35c6a994a03ef5f0262a781740709a3d8e30a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:47:17 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more file
    
    Change-Id: I5dfae10ec9df7e5b450c9a105ecc76c5d36970c3

diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index f2aff8454dce..cbf3ff621495 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -163,8 +163,8 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError )
     pCode->SetFromRangeName(true);
     if( pCode->GetCodeError() == FormulaError::NONE )
     {
-        pCode->Reset();
-        FormulaToken* p = pCode->GetNextReference();
+        FormulaTokenArrayPlainIterator aIter(*pCode);
+        FormulaToken* p = aIter.GetNextReference();
         if( p )
         {
             // first token is a reference
@@ -222,8 +222,8 @@ void ScRangeData::GuessPosition()
     SCTAB nMinTab = 0;
 
     formula::FormulaToken* t;
-    pCode->Reset();
-    while ( ( t = pCode->GetNextReference() ) != nullptr )
+    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
+    while ( ( t = aIter.GetNextReference() ) != nullptr )
     {
         ScSingleRefData& rRef1 = *t->GetSingleRef();
         if ( rRef1.IsColRel() && rRef1.Col() < nMinCol )
@@ -283,9 +283,9 @@ void ScRangeData::UpdateTranspose( const ScRange& rSource, const ScAddress& rDes
     bool bChanged = false;
 
     formula::FormulaToken* t;
-    pCode->Reset();
+    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
 
-    while ( ( t = pCode->GetNextReference() ) != nullptr )
+    while ( ( t = aIter.GetNextReference() ) != nullptr )
     {
         if( t->GetType() != svIndex )
         {
@@ -315,9 +315,9 @@ void ScRangeData::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
     bool bChanged = false;
 
     formula::FormulaToken* t;
-    pCode->Reset();
+    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
 
-    while ( ( t = pCode->GetNextReference() ) != nullptr )
+    while ( ( t = aIter.GetNextReference() ) != nullptr )
     {
         if( t->GetType() != svIndex )
         {
@@ -544,8 +544,8 @@ void ScRangeData::ValidateTabRefs()
     SCTAB nMinTab = aPos.Tab();
     SCTAB nMaxTab = nMinTab;
     formula::FormulaToken* t;
-    pCode->Reset();
-    while ( ( t = pCode->GetNextReference() ) != nullptr )
+    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
+    while ( ( t = aIter.GetNextReference() ) != nullptr )
     {
         ScSingleRefData& rRef1 = *t->GetSingleRef();
         ScAddress aAbs = rRef1.toAbs(aPos);
@@ -580,8 +580,8 @@ void ScRangeData::ValidateTabRefs()
         ScAddress aOldPos = aPos;
         aPos.SetTab( aPos.Tab() - nMove );
 
-        pCode->Reset();
-        while ( ( t = pCode->GetNextReference() ) != nullptr )
+        aIter.Reset();
+        while ( ( t = aIter.GetNextReference() ) != nullptr )
         {
             switch (t->GetType())
             {
@@ -628,8 +628,7 @@ void ScRangeData::InitCode()
 {
     if( pCode->GetCodeError() == FormulaError::NONE )
     {
-        pCode->Reset();
-        FormulaToken* p = pCode->GetNextReference();
+        FormulaToken* p = FormulaTokenArrayPlainIterator(*pCode).GetNextReference();
         if( p )   // exact one reference at first
         {
             if( p->GetType() == svSingleRef )
commit 74b1a89902980aaacc1c72ba42e3d945ead99bcf
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:46:21 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: I53531cb2e0ecf5972cb6c016b4395ded66622e9a

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 13ff13bf29f1..eb209c4be894 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4453,7 +4453,8 @@ StackVar ScInterpreter::Interpret()
         {
             if ( !nErrorFunctionCount )
             {   // count of errorcode functions in formula
-                for ( FormulaToken* t = rArr.FirstRPN(); t; t = rArr.NextRPN() )
+                FormulaTokenArrayPlainIterator aIter(rArr);
+                for ( FormulaToken* t = aIter.FirstRPN(); t; t = aIter.NextRPN() )
                 {
                     if ( IsErrFunc(t->GetOpCode()) )
                         ++nErrorFunctionCount;
commit 60df53223ba47c41593b94424235ded8a7f9fa49
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:45:08 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: Idcbb0ebdf284568dc552c0edf5ae130ba7aaeafe

diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index e165e0c317fe..cea77f9c90ac 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -168,7 +168,8 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
     for (SCROW i = 0; i < xGroup->mnLength; ++i, aTmpPos.IncRow())
     {
         ScTokenArray aCode2;
-        for (const formula::FormulaToken* p = rCode.First(); p; p = rCode.Next())
+        formula::FormulaTokenArrayPlainIterator aIter(rCode);
+        for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
         {
             CachedTokensType::iterator it = aCachedTokens.find(p);
             if (it != aCachedTokens.end())
commit 8f68e19356bfbc20f52e70a2b88ce77e01304b30
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:43:43 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in a couple more places
    
    Change-Id: Iaccbc7927943948136a56ba17f6bcff3a6971f31

diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 2dc37a90c937..fddc029dc815 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -564,7 +564,8 @@ bool ScDocument::FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes
     bool bRef = !bSameDoc;  // include every name used when copying to other doc
     if (nRecursion < 126)   // whatever.. 42*3
     {
-        for (const formula::FormulaToken* p = pCode->First(); p; p = pCode->Next())
+        formula::FormulaTokenArrayPlainIterator aIter(*pCode);
+        for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
         {
             if (p->GetOpCode() == ocName)
             {
@@ -603,7 +604,8 @@ MightReferenceSheet mightRangeNameReferenceSheet( ScRangeData* pData, SCTAB nRef
     if (!pCode)
         return MightReferenceSheet::NONE;
 
-    for (const formula::FormulaToken* p = pCode->First(); p; p = pCode->Next())
+    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
+    for (const formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
     {
         if (p->GetOpCode() == ocName)
             return MightReferenceSheet::NAME;
@@ -850,7 +852,8 @@ bool ScDocument::CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRange
                 ScTokenArray* pCode = iRD->GetCode();
                 if (pCode)
                 {
-                    for (formula::FormulaToken* p = pCode->First(); p; p = pCode->Next())
+                    formula::FormulaTokenArrayPlainIterator aIter(*pCode);
+                    for (formula::FormulaToken* p = aIter.First(); p; p = aIter.Next())
                     {
                         if (p->GetOpCode() == ocName)
                         {
commit 1bb184b064fbd679152f503c0c997be24c21ce32
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:42:48 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in a couple more places
    
    Change-Id: Ic1725c930bcb376a54acd9ba5d3dfd270d546cd8

diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 97cb5fe7ada7..c157a5f59ac3 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -477,10 +477,10 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress
         return false;
 
     ScExternalRefManager* pRefMgr = nullptr;
-    rArr.Reset();
+    formula::FormulaTokenArrayPlainIterator aIter( rArr );
     formula::FormulaToken* t = nullptr;
     bool bAllMarked = false;
-    while (!bAllMarked && (t = rArr.GetNextReferenceOrName()) != nullptr)
+    while (!bAllMarked && (t = aIter.GetNextReferenceOrName()) != nullptr)
     {
         if (t->IsExternalRef())
         {
@@ -498,7 +498,8 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress
                 continue;
 
             ScTokenArray* pArray = pRangeData->GetCode();
-            for (t = pArray->First(); t; t = pArray->Next())
+            formula::FormulaTokenArrayPlainIterator aArrayIter(*pArray);
+            for (t = aArrayIter.First(); t; t = aArrayIter.Next())
             {
                 if (!t->IsExternalRef())
                     continue;
commit 0eefc9554baf9374f2930b3a3c2cfc1fc2017945
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:41:39 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in a couple more places
    
    Change-Id: I49ddf780c0adee7123d985b1e343b8d248a46446

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 502d0b1e0623..8cbfc706f634 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -83,9 +83,9 @@ static bool lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, sal_uInt16
 {
     if (pFormula)
     {
-        pFormula->Reset();
+        FormulaTokenArrayPlainIterator aIter( *pFormula );
         FormulaToken* t;
-        for( t = pFormula->Next(); t; t = pFormula->Next() )
+        for( t = aIter.Next(); t; t = aIter.Next() )
         {
             switch( t->GetType() )
             {
@@ -1418,9 +1418,9 @@ ScAddress ScConditionEntry::GetValidSrcPos() const
         ScTokenArray* pFormula = nPass ? pFormula2 : pFormula1;
         if (pFormula)
         {
-            pFormula->Reset();
+            formula::FormulaTokenArrayPlainIterator aIter(*pFormula);
             formula::FormulaToken* t;
-            while ( ( t = pFormula->GetNextReference() ) != nullptr )
+            while ( ( t = aIter.GetNextReference() ) != nullptr )
             {
                 ScSingleRefData& rRef1 = *t->GetSingleRef();
                 ScAddress aAbs = rRef1.toAbs(aSrcPos);
commit f01ff6b831a76b3765b41d5bccc815215b1660ae
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:40:27 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: Idd92333d6c07748a2ae25f0124465d56b2302fbf

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index d481a354f4a2..a19675dd7341 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1229,11 +1229,12 @@ void lcl_AddCode( ScTokenArray& rArr, const ScFormulaCell* pCell )
     ScTokenArray* pCode = const_cast<ScFormulaCell*>(pCell)->GetCode();
     if (pCode)
     {
-        const formula::FormulaToken* pToken = pCode->First();
+        FormulaTokenArrayPlainIterator aIter(*pCode);
+        const formula::FormulaToken* pToken = aIter.First();
         while (pToken)
         {
             rArr.AddToken( *pToken );
-            pToken = pCode->Next();
+            pToken = aIter.Next();
         }
     }
 
commit d08f91b9acb52015c55dbfe7d5f4c4683d5a3e54
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:39:23 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: I22b57104cf603883b51bb0f16f2e71ede939f9f4

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3d04070ebab5..314cf453f765 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2684,11 +2684,12 @@ public:
         if (pCode && pCode->IsFormulaVectorDisabled())
         {
             pCode->ResetVectorState();
-            FormulaToken* pFT = pCode->First();
+            FormulaTokenArrayPlainIterator aIter(*pCode);
+            FormulaToken* pFT = aIter.First();
             while (pFT)
             {
                 pCode->CheckToken(*pFT);
-                pFT = pCode->Next();
+                pFT = aIter.Next();
             }
         }
     }
commit f1d4b0a9c831e5170ada49549197953af95d02a4
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 16:14:32 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: I8c1ffdd725cc26f48722e09ba5c4d58551ce38a2

diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 6b9837bb4a68..2a7b213de2a3 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -41,9 +41,9 @@ void ScFormulaListener::startListening(ScTokenArray* pArr, const ScRange& rRange
     if (!pArr || mpDoc->IsClipOrUndo())
         return;
 
-    pArr->Reset();
     formula::FormulaToken* t;
-    while ( ( t = pArr->GetNextReference() ) != nullptr )
+    formula::FormulaTokenArrayPlainIterator aIter( *pArr );
+    while ( ( t = aIter.GetNextReference() ) != nullptr )
     {
         switch (t->GetType())
         {
commit 8b03c9595806fefaf49c844517024b088a007045
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 15:36:44 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one more place
    
    Change-Id: Ia93b7759939bce42a4baf9ff55ec3c2b01840d9d

diff --git a/sc/inc/formulaiter.hxx b/sc/inc/formulaiter.hxx
index 75ec9e7d87c9..bbc0811cc286 100644
--- a/sc/inc/formulaiter.hxx
+++ b/sc/inc/formulaiter.hxx
@@ -20,11 +20,12 @@
 #ifndef INCLUDED_SC_INC_FORMULAITER_HXX
 #define INCLUDED_SC_INC_FORMULAITER_HXX
 
+#include <formula/tokenarray.hxx>
+
 #include "address.hxx"
 
 class ScTokenArray;
 class ScFormulaCell;
-namespace formula { class FormulaToken; }
 
 /**
  * Iterator for references in a formula cell.
@@ -33,6 +34,7 @@ class ScDetectiveRefIter
 {
 private:
     ScTokenArray* pCode;
+    formula::FormulaTokenArrayPlainIterator maIter;
     ScAddress aPos;
 public:
                 ScDetectiveRefIter( ScFormulaCell* pCell );
diff --git a/sc/source/core/data/formulaiter.cxx b/sc/source/core/data/formulaiter.cxx
index e17da0769f54..dce2b20d7042 100644
--- a/sc/source/core/data/formulaiter.cxx
+++ b/sc/source/core/data/formulaiter.cxx
@@ -25,11 +25,11 @@
 
 using namespace formula;
 
-ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell )
+ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell ) :
+    pCode(pCell->GetCode()),
+    maIter(*pCode),
+    aPos(pCell->aPos)
 {
-    pCode = pCell->GetCode();
-    pCode->Reset();
-    aPos = pCell->aPos;
 }
 
 static bool lcl_ScDetectiveRefIter_SkipRef( formula::FormulaToken* p, const ScAddress& rPos )
@@ -65,10 +65,10 @@ bool ScDetectiveRefIter::GetNextRef( ScRange& rRange )
 
 formula::FormulaToken* ScDetectiveRefIter::GetNextRefToken()
 {
-    formula::FormulaToken* p = pCode->GetNextReferenceRPN();
+    formula::FormulaToken* p = maIter.GetNextReferenceRPN();
     while (p && lcl_ScDetectiveRefIter_SkipRef(p, aPos))
     {
-        p = pCode->GetNextReferenceRPN();
+        p = maIter.GetNextReferenceRPN();
     }
     return p;
 }
commit 5abb8cc240238a9224c77108a2a9c207f03cf378
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Jun 7 14:05:35 2017 +0300

    Take new FormulaTokenArrayPlainIterator into use in one simple place
    
    Change-Id: Ib3e0b24ab2857a94ccce3efbac160b2d8dd910c7

diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 304b9430478c..3b137404419e 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -138,6 +138,7 @@ public:
     mutable uno::Reference< sheet::XFormulaOpCodeMapper>    m_xOpCodeMapper;
     uno::Sequence< sheet::FormulaToken >                    m_aTokenList;
     ::std::unique_ptr<FormulaTokenArray>                    m_pTokenArray;
+    ::std::unique_ptr<FormulaTokenArrayPlainIterator>       m_pTokenArrayIterator;
     mutable uno::Sequence< sheet::FormulaOpCodeMapEntry >   m_aSpecialOpCodes;
     mutable const sheet::FormulaOpCodeMapEntry*             m_pSpecialOpCodesEnd;
     mutable uno::Sequence< sheet::FormulaToken >            m_aSeparatorsOpCodes;
@@ -676,7 +677,7 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree,SvTreeListEntry* pParent,Formu
                     }
                 }
 
-                MakeTree(_pTree,pEntry,m_pTokenArray->PrevRPN(),nParas);
+                MakeTree(_pTree,pEntry,m_pTokenArrayIterator->PrevRPN(),nParas);
 
                 if (bCalcSubformula)
                 {
@@ -702,8 +703,8 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree,SvTreeListEntry* pParent,Formu
                 }
 
                 --Count;
-                m_pTokenArray->NextRPN();
-                MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count);
+                m_pTokenArrayIterator->NextRPN();
+                MakeTree(_pTree,pParent,m_pTokenArrayIterator->PrevRPN(),Count);
             }
             else
             {
@@ -732,7 +733,7 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree,SvTreeListEntry* pParent,Formu
                     _pTree->InsertEntry(aResult,pParent,STRUCT_END,0,_pToken);
                 }
                 --Count;
-                MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count);
+                MakeTree(_pTree,pParent,m_pTokenArrayIterator->PrevRPN(),Count);
             }
         }
         catch(const uno::Exception&)
@@ -745,7 +746,7 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree,SvTreeListEntry* pParent,Formu
 void FormulaDlg_Impl::fillTree(StructPage* _pTree)
 {
     InitFormulaOpCodeMapper();
-    FormulaToken* pToken = m_pTokenArray->LastRPN();
+    FormulaToken* pToken = m_pTokenArrayIterator->LastRPN();
 
     if( pToken != nullptr)
     {
@@ -768,6 +769,7 @@ void FormulaDlg_Impl::UpdateTokenArray( const OUString& rStrExp)
     }
     InitFormulaOpCodeMapper();
     m_pTokenArray = m_pHelper->convertToTokenArray(m_aTokenList);
+    m_pTokenArrayIterator.reset(new FormulaTokenArrayPlainIterator(*m_pTokenArray));
     const sal_Int32 nLen = static_cast<sal_Int32>(m_pTokenArray->GetLen());
     FormulaToken** pTokens = m_pTokenArray->GetArray();
     if ( pTokens && nLen == m_aTokenList.getLength() )


More information about the Libreoffice-commits mailing list