Thread-safe way to check for presence of references in formula tokens.

Change-Id: I995668d1e183dc0dae4f354889bc13053e858723
This commit is contained in:
Kohei Yoshida
2013-11-07 14:16:48 -05:00
parent 6122a6c272
commit 3ac4277ba1
4 changed files with 34 additions and 3 deletions

View File

@@ -130,6 +130,22 @@ bool FormulaToken::IsExternalRef() const
return bRet; return bRet;
} }
bool FormulaToken::IsRef() const
{
switch (eType)
{
case svSingleRef:
case svDoubleRef:
case svExternalSingleRef:
case svExternalDoubleRef:
return true;
default:
;
}
return false;
}
bool FormulaToken::operator==( const FormulaToken& rToken ) const bool FormulaToken::operator==( const FormulaToken& rToken ) const
{ {
// don't compare reference count! // don't compare reference count!
@@ -538,6 +554,17 @@ FormulaToken* FormulaTokenArray::PeekPrevNoSpaces()
return NULL; return NULL;
} }
bool FormulaTokenArray::HasReferences() const
{
for (sal_uInt16 i = 0; i < nLen; ++i)
{
if (pCode[i]->IsRef())
return true;
}
return false;
}
bool FormulaTokenArray::HasExternalRef() const bool FormulaTokenArray::HasExternalRef() const
{ {
for ( sal_uInt16 j=0; j < nLen; j++ ) for ( sal_uInt16 j=0; j < nLen; j++ )

View File

@@ -106,7 +106,10 @@ public:
inline void Delete() { delete this; } inline void Delete() { delete this; }
inline StackVar GetType() const { return eType; } inline StackVar GetType() const { return eType; }
bool IsFunction() const; // pure functions, no operators bool IsFunction() const; // pure functions, no operators
bool IsExternalRef() const;
bool IsExternalRef() const;
bool IsRef() const;
sal_uInt8 GetParamCount() const; sal_uInt8 GetParamCount() const;
inline void IncRef() const inline void IncRef() const

View File

@@ -116,6 +116,8 @@ public:
FormulaToken* LastRPN() { nIndex = nRPN; return PrevRPN(); } FormulaToken* LastRPN() { nIndex = nRPN; return PrevRPN(); }
FormulaToken* PrevRPN(); FormulaToken* PrevRPN();
bool HasReferences() const;
bool HasExternalRef() const; bool HasExternalRef() const;
bool HasOpCode( OpCode ) const; bool HasOpCode( OpCode ) const;
bool HasOpCodeRPN( OpCode ) const; bool HasOpCodeRPN( OpCode ) const;

View File

@@ -518,8 +518,7 @@ sal_uInt16 ScRangeData::GetErrCode() const
bool ScRangeData::HasReferences() const bool ScRangeData::HasReferences() const
{ {
pCode->Reset(); return pCode->HasReferences();
return pCode->GetNextReference() != NULL;
} }
sal_uInt32 ScRangeData::GetUnoType() const sal_uInt32 ScRangeData::GetUnoType() const