diff options
-rw-r--r-- | formula/inc/formula/FormulaCompiler.hxx | 2 | ||||
-rw-r--r-- | formula/inc/formula/token.hxx | 18 | ||||
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 10 | ||||
-rw-r--r-- | formula/source/core/api/token.cxx | 2 |
4 files changed, 21 insertions, 11 deletions
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx index 00a97cfc7a5a..eca20bcc4120 100644 --- a/formula/inc/formula/FormulaCompiler.hxx +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -331,7 +331,7 @@ private: static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev ) { - if ( rPrev.Is() && rPrev->HasForceArray() && + if ( rPrev && rPrev->HasForceArray() && rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush && !rCurr->HasForceArray() ) rCurr->SetForceArray( true); diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx index dfabc3f2149e..b29bbf9f0c9c 100644 --- a/formula/inc/formula/token.hxx +++ b/formula/inc/formula/token.hxx @@ -33,11 +33,12 @@ #include <string.h> #include <vector> #include "formula/opcode.hxx" -#include "formula/intruref.hxx" #include <tools/mempool.hxx> #include "formula/IFunctionDescription.hxx" #include "formula/formuladllapi.h" +#include <boost/intrusive_ptr.hpp> + namespace formula { @@ -85,9 +86,8 @@ typedef StackVarEnum StackVar; class FormulaToken; -typedef SimpleIntrusiveReference< class FormulaToken > FormulaTokenRef; -typedef SimpleIntrusiveReference< const class FormulaToken > FormulaConstTokenRef; - +typedef ::boost::intrusive_ptr<FormulaToken> FormulaTokenRef; +typedef ::boost::intrusive_ptr<const FormulaToken> FormulaConstTokenRef; class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken { @@ -179,6 +179,16 @@ public: { return GetStrLenBytes( rStr.Len() ); } }; +inline void intrusive_ptr_add_ref(const FormulaToken* p) +{ + p->IncRef(); +} + +inline void intrusive_ptr_release(const FormulaToken* p) +{ + p->DecRef(); +} + class FORMULA_DLLPUBLIC FormulaByteToken : public FormulaToken { private: diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index c359b82c07fc..0dd3389dc231 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -859,11 +859,11 @@ BOOL FormulaCompiler::GetToken() if ( nWasColRowName ) nWasColRowName++; if ( bAutoCorrect && !pStack ) - CreateStringFromToken( aCorrectedFormula, pToken, FALSE ); + CreateStringFromToken( aCorrectedFormula, pToken.get(), FALSE ); pToken = pArr->Next(); } if ( bAutoCorrect && !pStack && pToken ) - CreateStringFromToken( aCorrectedSymbol, pToken, FALSE ); + CreateStringFromToken( aCorrectedSymbol, pToken.get(), FALSE ); if( !pToken ) { if( pStack ) @@ -1401,7 +1401,7 @@ bool FormulaCompiler::MergeRangeReference(FormulaToken * * const pCode1, Formula p->IncRef(); p1->DecRef(); p2->DecRef(); - *pCode1 = p; + *pCode1 = p.get(); --pCode, --pc; pArr->nRefs--; @@ -1840,7 +1840,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p ) { p = new FormulaByteToken( ocStop ); p->IncRef(); - *pCode++ = p; + *pCode++ = p.get(); ++pc; } SetError(errCodeOverflow); @@ -1850,7 +1850,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p ) return; ForceArrayOperator( p, pCurrentFactorToken); p->IncRef(); - *pCode++ = p; + *pCode++ = p.get(); pc++; } diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 9f719de7abc7..58f7dafb2044 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -263,7 +263,7 @@ BOOL FormulaByteToken::operator==( const FormulaToken& r ) const } -FormulaToken* FormulaFAPToken::GetFAPOrigToken() const { return pOrigToken; } +FormulaToken* FormulaFAPToken::GetFAPOrigToken() const { return pOrigToken.get(); } BOOL FormulaFAPToken::operator==( const FormulaToken& r ) const { return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken(); |