Kaydet (Commit) 4ae7b662 authored tarafından Eike Rathke's avatar Eike Rathke

use new'ed FormulaToken and FormulaTokenArray::Add()

... instead of a temporary instance and AddToken() that just clones it
again.

Add function comment describing the difference.

Change-Id: I3f089965d394b33d7bbbb9a1c3f69dc1c4182fd2
üst d7e0d013
...@@ -395,11 +395,11 @@ bool FormulaTokenArray::AddFormulaToken( ...@@ -395,11 +395,11 @@ bool FormulaTokenArray::AddFormulaToken(
// long is svIndex, used for name / database area, or "byte" for spaces // long is svIndex, used for name / database area, or "byte" for spaces
sal_Int32 nValue = rToken.Data.get<sal_Int32>(); sal_Int32 nValue = rToken.Data.get<sal_Int32>();
if ( eOpCode == ocDBArea ) if ( eOpCode == ocDBArea )
AddToken( formula::FormulaIndexToken( eOpCode, static_cast<sal_uInt16>(nValue) ) ); Add( new formula::FormulaIndexToken( eOpCode, static_cast<sal_uInt16>(nValue) ) );
else if ( eOpCode == ocTableRef ) else if ( eOpCode == ocTableRef )
bError = true; /* TODO: implementation */ bError = true; /* TODO: implementation */
else if ( eOpCode == ocSpaces ) else if ( eOpCode == ocSpaces )
AddToken( formula::FormulaByteToken( ocSpaces, static_cast<sal_uInt8>(nValue) ) ); Add( new formula::FormulaByteToken( ocSpaces, static_cast<sal_uInt8>(nValue) ) );
else else
bError = true; bError = true;
} }
...@@ -414,7 +414,7 @@ bool FormulaTokenArray::AddFormulaToken( ...@@ -414,7 +414,7 @@ bool FormulaTokenArray::AddFormulaToken(
else if ( eOpCode == ocStringXML ) else if ( eOpCode == ocStringXML )
AddStringXML( aStrVal ); AddStringXML( aStrVal );
else if ( eOpCode == ocExternal || eOpCode == ocMacro ) else if ( eOpCode == ocExternal || eOpCode == ocMacro )
AddToken( formula::FormulaExternalToken( eOpCode, aStrVal ) ); Add( new formula::FormulaExternalToken( eOpCode, aStrVal ) );
else else
bError = true; // unexpected string: don't know what to do with it bError = true; // unexpected string: don't know what to do with it
} }
...@@ -1600,7 +1600,7 @@ FormulaToken* FormulaTokenArray::AddOpCode( OpCode eOp ) ...@@ -1600,7 +1600,7 @@ FormulaToken* FormulaTokenArray::AddOpCode( OpCode eOp )
pRet = new FormulaByteToken( eOp, 0, false ); pRet = new FormulaByteToken( eOp, 0, false );
break; break;
} }
return AddToken( *pRet ); return Add( pRet );
} }
void FormulaTokenArray::ReinternStrings( svl::SharedStringPool& rPool ) void FormulaTokenArray::ReinternStrings( svl::SharedStringPool& rPool )
......
...@@ -296,7 +296,12 @@ public: ...@@ -296,7 +296,12 @@ public:
*/ */
virtual void CheckToken( const FormulaToken& t ); virtual void CheckToken( const FormulaToken& t );
/** Clones the token and then adds the clone to the pCode array.
For just new'ed tokens use Add() instead of cloning it again.
Use this AddToken() when adding a token from another origin.
*/
FormulaToken* AddToken( const FormulaToken& ); FormulaToken* AddToken( const FormulaToken& );
FormulaToken* AddString( const svl::SharedString& rStr ); FormulaToken* AddString( const svl::SharedString& rStr );
FormulaToken* AddDouble( double fVal ); FormulaToken* AddDouble( double fVal );
FormulaToken* AddExternal( const sal_Unicode* pStr ); FormulaToken* AddExternal( const sal_Unicode* pStr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment