summaryrefslogtreecommitdiff
path: root/formula/source/core/api/token.cxx
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2017-06-16 00:18:57 +0300
committerTor Lillqvist <tml@collabora.com>2017-06-16 12:17:40 +0200
commit5c81adc51a05a016e754de7961d3a7bdb4494e01 (patch)
treefbfdca0ef841a545ed10d612df83631c50c24bfc /formula/source/core/api/token.cxx
parent468fc3847cfd65217949630e2ffd9fb0a89e9cbb (diff)
Get rid of the index inside FormulaTokenArray
Instead, use FormulaTokenArrrayPlainIterator everywhere, especially in the FormulaCompiler. This is the final step of a long chain of commits. (Split up into many "uncontroversial" bits, and then this, to make potential bisecting easier.) Also added a logging operator<< for FormulaTokenArray, for SAL_DEBUG, SAL_INFO etc goodness. Change-Id: I02fe29f3f1e0dc33e5cba69e594223b4178a12bc Reviewed-on: https://gerrit.libreoffice.org/38851 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'formula/source/core/api/token.cxx')
-rw-r--r--formula/source/core/api/token.cxx181
1 files changed, 2 insertions, 179 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 1e966f1a40f1..78c69ea7360a 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -456,134 +456,6 @@ bool FormulaTokenArray::Fill(
}
return bError;
}
-FormulaToken* FormulaTokenArray::GetNextReference()
-{
- while( nIndex < nLen )
- {
- FormulaToken* t = pCode[ nIndex++ ];
- switch( t->GetType() )
- {
- case svSingleRef:
- case svDoubleRef:
- case svExternalSingleRef:
- case svExternalDoubleRef:
- return t;
- default:
- {
- // added to avoid warnings
- }
- }
- }
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::GetNextColRowName()
-{
- while( nIndex < nLen )
- {
- FormulaToken* t = pCode[ nIndex++ ];
- if ( t->GetOpCode() == ocColRowName )
- return t;
- }
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::GetNextReferenceRPN()
-{
- while( nIndex < nRPN )
- {
- FormulaToken* t = pRPN[ nIndex++ ];
- switch( t->GetType() )
- {
- case svSingleRef:
- case svDoubleRef:
- case svExternalSingleRef:
- case svExternalDoubleRef:
- return t;
- default:
- {
- // added to avoid warnings
- }
- }
- }
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::GetNextReferenceOrName()
-{
- if( pCode )
- {
- while ( nIndex < nLen )
- {
- FormulaToken* t = pCode[ nIndex++ ];
- switch( t->GetType() )
- {
- case svSingleRef:
- case svDoubleRef:
- case svIndex:
- case svExternalSingleRef:
- case svExternalDoubleRef:
- case svExternalName:
- return t;
- default:
- {
- // added to avoid warnings
- }
- }
- }
- }
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::GetNextName()
-{
- if( pCode )
- {
- while ( nIndex < nLen )
- {
- FormulaToken* t = pCode[ nIndex++ ];
- if( t->GetType() == svIndex )
- return t;
- }
- } // if( pCode )
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::Next()
-{
- if( pCode && nIndex < nLen )
- return pCode[ nIndex++ ];
- else
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::NextNoSpaces()
-{
- if( pCode )
- {
- while( (nIndex < nLen) && (pCode[ nIndex ]->GetOpCode() == ocSpaces) )
- ++nIndex;
- if( nIndex < nLen )
- return pCode[ nIndex++ ];
- }
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::NextRPN()
-{
- if( pRPN && nIndex < nRPN )
- return pRPN[ nIndex++ ];
- else
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::PrevRPN()
-{
- if( pRPN && nIndex )
- return pRPN[ --nIndex ];
- else
- return nullptr;
-}
void FormulaTokenArray::DelRPN()
{
@@ -597,7 +469,7 @@ void FormulaTokenArray::DelRPN()
delete [] pRPN;
}
pRPN = nullptr;
- nRPN = nIndex = 0;
+ nRPN = 0;
}
FormulaToken* FormulaTokenArray::FirstToken() const
@@ -614,46 +486,6 @@ FormulaToken* FormulaTokenArray::PeekPrev( sal_uInt16 & nIdx )
return nullptr;
}
-FormulaToken* FormulaTokenArray::PeekNext()
-{
- if( pCode && nIndex < nLen )
- return pCode[ nIndex ];
- else
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::PeekNextNoSpaces()
-{
- if( pCode && nIndex < nLen )
- {
- sal_uInt16 j = nIndex;
- while ( j < nLen && pCode[j]->GetOpCode() == ocSpaces )
- j++;
- if ( j < nLen )
- return pCode[ j ];
- else
- return nullptr;
- }
- else
- return nullptr;
-}
-
-FormulaToken* FormulaTokenArray::PeekPrevNoSpaces()
-{
- if( pCode && nIndex > 1 )
- {
- sal_uInt16 j = nIndex - 2;
- while ( pCode[j]->GetOpCode() == ocSpaces && j > 0 )
- j--;
- if ( j > 0 || pCode[j]->GetOpCode() != ocSpaces )
- return pCode[ j ];
- else
- return nullptr;
- }
- else
- return nullptr;
-}
-
FormulaToken* FormulaTokenArray::FirstRPNToken() const
{
if (!pRPN || nRPN == 0)
@@ -737,7 +569,6 @@ FormulaTokenArray::FormulaTokenArray() :
pRPN(nullptr),
nLen(0),
nRPN(0),
- nIndex(0),
nError(FormulaError::NONE),
nMode(ScRecalcMode::NORMAL),
bHyperLink(false),
@@ -761,7 +592,6 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r )
{
nLen = r.nLen;
nRPN = r.nRPN;
- nIndex = r.nIndex;
nError = r.nError;
nMode = r.nMode;
bHyperLink = r.bHyperLink;
@@ -828,7 +658,7 @@ void FormulaTokenArray::Clear()
}
pCode = nullptr; pRPN = nullptr;
nError = FormulaError::NONE;
- nLen = nIndex = nRPN = 0;
+ nLen = nRPN = 0;
bHyperLink = false;
mbFromRangeName = false;
mbShareable = true;
@@ -924,13 +754,6 @@ sal_uInt16 FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount
}
nLen -= nCount;
- if (nIndex >= nOffset)
- {
- if (nIndex < nStop)
- nIndex = nOffset + 1;
- else
- nIndex -= nStop - nOffset;
- }
return nCount;
}
else