summaryrefslogtreecommitdiff
path: root/sc/inc/token.hxx
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-03-06 14:20:53 +0000
committerKurt Zenker <kz@openoffice.org>2008-03-06 14:20:53 +0000
commite636afc92e1c16528d712c0dcfe50307f3899b3a (patch)
tree1640d0f59c0e7723b3e2bac9d12549f58264459c /sc/inc/token.hxx
parent47f32a10143ed6ca15372c7c6136dd5e8bf6fb2c (diff)
INTEGRATION: CWS odff (1.13.60); FILE MERGED
2008/02/20 16:41:50 er 1.13.60.18: #i32340# ISBLANK needs to distinguish between inherited / non-inherited emptiness; corrected ISNUMBER and ISTEXT/ISNONTEXT handling of svEmptyCell 2008/02/15 14:23:03 er 1.13.60.17: #i81063# grammar here, grammar there, grammar everywhere 2008/02/07 13:10:01 er 1.13.60.16: Always wanted to do this, now I'm taking the opportunity: :retab on selected files and all tabs are gone, producing hopefully easier to read diffs in future. 2008/02/06 16:15:17 er 1.13.60.15: warning-free 2008/02/05 17:59:04 er 1.13.60.14: #i77280# treat undefined name as usual ocBad ScStringOpToken, so ISERROR(undefinedname) yields TRUE; => ocBad doesn't terminate compilation anymore. 2008/01/31 15:34:21 er 1.13.60.13: #i32340# ScFormulaResult, third wave 2008/01/24 20:42:16 er 1.13.60.12: #i32340# ScFormulaResult, handle error code and matrix clone 2008/01/24 16:41:00 er 1.13.60.11: #i32340# variable cell result ScFormulaResult, second wave 2008/01/21 20:07:30 er 1.13.60.10: satisfy compilers 2008/01/21 19:58:40 er 1.13.60.9: make 'enum is int' conditional return happy 2008/01/18 20:45:33 er 1.13.60.8: ScToken base class without OpCode member but implicit ocPush, derived ScOpToken class to inherit from if explicit OpCode needed; this saves 2 bytes on each (!) allocation of ScDoubleToken, ScStringToken, ScSingleRefToken, ScDoubleRefToken. And there are zillions.. 2008/01/17 17:31:33 er 1.13.60.7: #i32340# variable cell result ScFormulaResult, first wave 2008/01/10 16:54:26 er 1.13.60.6: introduce ScErrorToken, get rid of secondary error stack 2008/01/08 21:09:26 er 1.13.60.5: rename StackVar svErr to svUnknown 2008/01/08 20:44:14 er 1.13.60.4: get rid of distracting binfilter legacy 2008/01/08 19:30:26 er 1.13.60.3: get rid of distracting binfilter legacy 2007/12/17 15:59:33 er 1.13.60.2: #i32341# union / range list operator ocUnion; first wave 2007/11/29 19:06:45 er 1.13.60.1: #i4904# range operator ocRange
Diffstat (limited to 'sc/inc/token.hxx')
-rw-r--r--sc/inc/token.hxx418
1 files changed, 337 insertions, 81 deletions
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index a995b9ba7fa1..761de3845835 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: token.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: rt $ $Date: 2007-07-06 12:31:14 $
+ * last change: $Author: kz $ $Date: 2008-03-06 15:20:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -37,6 +37,7 @@
#define SC_TOKEN_HXX
#include <memory>
+#include <vector>
#ifndef SC_OPCODE_HXX
#include "opcode.hxx"
@@ -59,7 +60,6 @@
#endif
-//! Fixed values!
enum StackVarEnum
{
svByte,
@@ -71,13 +71,23 @@ enum StackVarEnum
svIndex,
svJump,
svExternal, // Byte + String
-
svFAP, // FormulaAutoPilot only, ever exported
-
svJumpMatrix, // 2003-07-02
+ svRefList, // ocUnion result
+ svEmptyCell, // Result is an empty cell, e.g. in LOOKUP()
+
+ svMatrixCell, // Result is a matrix with bells and
+ // whistles as needed for _the_ matrix
+ // formula result.
+
+ svHybridCell, // A temporary condition of a formula
+ // cell during import, having a double
+ // and/or string result and a formula
+ // string to be compiled.
+ svError, // error token
svMissing = 0x70, // 0 or ""
- svErr // unknown StackType
+ svUnknown // unknown StackType
};
#ifdef PRODUCT
@@ -91,11 +101,17 @@ typedef StackVarEnum StackVar;
class ScJumpMatrix;
+class ScToken;
+typedef ScSimpleIntrusiveReference< class ScToken > ScTokenRef;
+typedef ScSimpleIntrusiveReference< const class ScToken > ScConstTokenRef;
+
+typedef ::std::vector< ComplRefData > ScRefList;
+
+
class ScToken
{
private:
- OpCode eOp; // OpCode
const StackVar eType; // type of data
mutable USHORT nRefCnt; // reference count
@@ -105,14 +121,12 @@ private:
protected:
- static SingleRefData aDummySingleRef;
- static ComplRefData aDummyDoubleRef;
static String aDummyString;
- ScToken( OpCode eOpP, StackVar eTypeP ) :
- eOp( eOpP ), eType( eTypeP ), nRefCnt(0) {}
+ ScToken( StackVar eTypeP ) :
+ eType( eTypeP ), nRefCnt(0) {}
ScToken( const ScToken& r ) :
- eOp( r.eOp ), eType( r.eType ), nRefCnt(0) {}
+ eType( r.eType ), nRefCnt(0) {}
public:
@@ -120,11 +134,9 @@ public:
inline void Delete() { delete this; }
inline const StackVar GetType() const { return eType; }
- inline OpCode GetOpCode() const { return eOp; }
BOOL IsFunction() const; // pure functions, no operators
BOOL IsMatrixFunction() const; // if a function _always_ returns a Matrix
BYTE GetParamCount() const;
- inline void NewOpCode( OpCode e ) { eOp = e; }
inline void IncRef() const { nRefCnt++; }
inline void DecRef() const
{
@@ -138,6 +150,9 @@ public:
the real token classes have to overload the appropriate method[s].
The only methods valid anytime if not overloaded are:
+ - GetOpCode() since for a token type not needing an explicit OpCode set
+ the implicit OpCode is ocPush.
+
- GetByte() since this represents the count of parameters to a function
which of course is 0 on non-functions. ScByteToken and ScExternal do
overload it.
@@ -148,11 +163,13 @@ public:
Any other non-overloaded method pops up an assertion.
*/
+ virtual OpCode GetOpCode() const;
virtual BYTE GetByte() const;
virtual void SetByte( BYTE n );
virtual bool HasForceArray() const;
virtual void SetForceArray( bool b );
virtual double GetDouble() const;
+ virtual double& GetDoubleAsReference();
virtual const String& GetString() const;
virtual const SingleRefData& GetSingleRef() const;
virtual SingleRefData& GetSingleRef();
@@ -162,19 +179,21 @@ public:
virtual SingleRefData& GetSingleRef2();
virtual void CalcAbsIfRel( const ScAddress& );
virtual void CalcRelFromAbs( const ScAddress& );
- virtual ScMatrix* GetMatrix() const;
+ virtual const ScMatrix* GetMatrix() const;
+ virtual ScMatrix* GetMatrix();
virtual USHORT GetIndex() const;
virtual void SetIndex( USHORT n );
virtual short* GetJump() const;
virtual const String& GetExternal() const;
- virtual BYTE* GetUnknown() const;
virtual ScToken* GetFAPOrigToken() const;
virtual ScJumpMatrix* GetJumpMatrix() const;
+ virtual const ScRefList* GetRefList() const;
+ virtual ScRefList* GetRefList();
+ virtual USHORT GetError() const;
+ virtual void SetError( USHORT );
ScToken* Clone() const;
- void Store( SvStream& ) const;
-
virtual BOOL operator==( const ScToken& rToken ) const;
BOOL TextEqual( const ScToken& rToken ) const;
BOOL Is3DRef() const; // reference with 3D flag set
@@ -184,6 +203,20 @@ public:
// or similar.
BOOL IsRPNReferenceAbsName() const;
+ /** If rTok1 and rTok2 both are SingleRef or DoubleRef tokens, extend/merge
+ ranges as needed for ocRange.
+ @param rPos
+ The formula's position, used to calculate absolute positions from
+ relative references.
+ @param bReuseDoubleRef
+ If TRUE, a DoubleRef token is reused if passed as rTok1 or rTok2,
+ else a new DoubleRef token is created and returned.
+ @return
+ A reused or new'ed ScDoubleRefToken, or a NULL TokenRef if rTok1 or
+ rTok2 are not of sv(Single|Double)Ref
+ */
+ static ScTokenRef ExtendRangeReference( ScToken & rTok1, ScToken & rTok2, const ScAddress & rPos, bool bReuseDoubleRef );
+
static size_t GetStrLenBytes( xub_StrLen nLen )
{ return nLen * sizeof(sal_Unicode); }
static size_t GetStrLenBytes( const String& rStr )
@@ -191,31 +224,46 @@ public:
};
-typedef ScSimpleIntrusiveReference< class ScToken > ScTokenRef;
-typedef ScSimpleIntrusiveReference< const class ScToken > ScConstTokenRef;
+/** Tokens that need a different OpCode than ocPush are derived from this. */
+class ScOpToken : public ScToken
+{
+private:
+ OpCode eOp;
+public:
+ ScOpToken( OpCode e, StackVar v ) :
+ ScToken( v ), eOp( e ) {}
+ ScOpToken( const ScOpToken & r ) :
+ ScToken( r ), eOp( r.eOp ) {}
+ /** This is dirty and only the compiler should use it! */
+ inline void NewOpCode( OpCode e ) { eOp = e; }
+ virtual OpCode GetOpCode() const;
+
+ // No operator== to be overloaded, ScToken::operator== already checks the
+ // OpCode as well via GetOpCode().
+};
-class ScByteToken : public ScToken
+class ScByteToken : public ScOpToken
{
private:
BYTE nByte;
bool bHasForceArray;
protected:
ScByteToken( OpCode e, BYTE n, StackVar v, bool b ) :
- ScToken( e, v ), nByte( n ),
+ ScOpToken( e, v ), nByte( n ),
bHasForceArray( b ) {}
public:
ScByteToken( OpCode e, BYTE n, bool b ) :
- ScToken( e, svByte ), nByte( n ),
+ ScOpToken( e, svByte ), nByte( n ),
bHasForceArray( b ) {}
ScByteToken( OpCode e, BYTE n ) :
- ScToken( e, svByte ), nByte( n ),
+ ScOpToken( e, svByte ), nByte( n ),
bHasForceArray( false ) {}
ScByteToken( OpCode e ) :
- ScToken( e, svByte ), nByte( 0 ),
+ ScOpToken( e, svByte ), nByte( 0 ),
bHasForceArray( false ) {}
ScByteToken( const ScByteToken& r ) :
- ScToken( r ), nByte( r.nByte ),
+ ScOpToken( r ), nByte( r.nByte ),
bHasForceArray( r.bHasForceArray ) {}
virtual BYTE GetByte() const;
virtual void SetByte( BYTE n );
@@ -250,12 +298,11 @@ private:
double fDouble;
public:
ScDoubleToken( double f ) :
- ScToken( ocPush, svDouble ), fDouble( f ) {}
- ScDoubleToken( OpCode e, double f ) :
- ScToken( e, svDouble ), fDouble( f ) {}
+ ScToken( svDouble ), fDouble( f ) {}
ScDoubleToken( const ScDoubleToken& r ) :
ScToken( r ), fDouble( r.fDouble ) {}
virtual double GetDouble() const;
+ virtual double& GetDoubleAsReference();
virtual BOOL operator==( const ScToken& rToken ) const;
DECL_FIXEDMEMPOOL_NEWDEL( ScDoubleToken );
@@ -268,9 +315,7 @@ private:
String aString;
public:
ScStringToken( const String& r ) :
- ScToken( ocPush, svString ), aString( r ) {}
- ScStringToken( OpCode e, const String& r ) :
- ScToken( e, svString ), aString( r ) {}
+ ScToken( svString ), aString( r ) {}
ScStringToken( const ScStringToken& r ) :
ScToken( r ), aString( r.aString ) {}
virtual const String& GetString() const;
@@ -280,15 +325,29 @@ public:
};
+/** Identical to ScStringToken, but with explicit OpCode instead of implicit
+ ocPush, and an optional BYTE for ocBad tokens. */
+class ScStringOpToken : public ScByteToken
+{
+private:
+ String aString;
+public:
+ ScStringOpToken( OpCode e, const String& r ) :
+ ScByteToken( e, 0, svString, false ), aString( r ) {}
+ ScStringOpToken( const ScStringOpToken& r ) :
+ ScByteToken( r ), aString( r.aString ) {}
+ virtual const String& GetString() const;
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
class ScSingleRefToken : public ScToken
{
private:
SingleRefData aSingleRef;
public:
ScSingleRefToken( const SingleRefData& r ) :
- ScToken( ocPush, svSingleRef ), aSingleRef( r ) {}
- ScSingleRefToken( OpCode e, const SingleRefData& r ) :
- ScToken( e, svSingleRef ), aSingleRef( r ) {}
+ ScToken( svSingleRef ), aSingleRef( r ) {}
ScSingleRefToken( const ScSingleRefToken& r ) :
ScToken( r ), aSingleRef( r.aSingleRef ) {}
virtual const SingleRefData& GetSingleRef() const;
@@ -301,17 +360,34 @@ public:
};
+/** Identical to ScSingleRefToken, but with explicit OpCode instead of implicit
+ ocPush. */
+class ScSingleRefOpToken : public ScOpToken
+{
+private:
+ SingleRefData aSingleRef;
+public:
+ ScSingleRefOpToken( OpCode e, const SingleRefData& r ) :
+ ScOpToken( e, svSingleRef ), aSingleRef( r ) {}
+ ScSingleRefOpToken( const ScSingleRefOpToken& r ) :
+ ScOpToken( r ), aSingleRef( r.aSingleRef ) {}
+ virtual const SingleRefData& GetSingleRef() const;
+ virtual SingleRefData& GetSingleRef();
+ virtual void CalcAbsIfRel( const ScAddress& );
+ virtual void CalcRelFromAbs( const ScAddress& );
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
class ScDoubleRefToken : public ScToken
{
private:
ComplRefData aDoubleRef;
public:
ScDoubleRefToken( const ComplRefData& r ) :
- ScToken( ocPush, svDoubleRef ), aDoubleRef( r ) {}
- ScDoubleRefToken( OpCode e, const ComplRefData& r ) :
- ScToken( e, svDoubleRef ), aDoubleRef( r ) {}
- ScDoubleRefToken( OpCode e, const SingleRefData& r ) :
- ScToken( e, svDoubleRef )
+ ScToken( svDoubleRef ), aDoubleRef( r ) {}
+ ScDoubleRefToken( const SingleRefData& r ) :
+ ScToken( svDoubleRef )
{
aDoubleRef.Ref1 = r;
aDoubleRef.Ref2 = r;
@@ -332,50 +408,78 @@ public:
};
+/** Identical to ScDoubleRefToken, but with explicit OpCode instead of implicit
+ ocPush. */
+class ScDoubleRefOpToken : public ScOpToken
+{
+private:
+ ComplRefData aDoubleRef;
+public:
+ ScDoubleRefOpToken( OpCode e, const ComplRefData& r ) :
+ ScOpToken( e, svDoubleRef ), aDoubleRef( r ) {}
+ ScDoubleRefOpToken( OpCode e, const SingleRefData& r ) :
+ ScOpToken( e, svDoubleRef )
+ {
+ aDoubleRef.Ref1 = r;
+ aDoubleRef.Ref2 = r;
+ }
+ ScDoubleRefOpToken( const ScDoubleRefOpToken& r ) :
+ ScOpToken( r ), aDoubleRef( r.aDoubleRef ) {}
+ virtual const SingleRefData& GetSingleRef() const;
+ virtual SingleRefData& GetSingleRef();
+ virtual const ComplRefData& GetDoubleRef() const;
+ virtual ComplRefData& GetDoubleRef();
+ virtual const SingleRefData& GetSingleRef2() const;
+ virtual SingleRefData& GetSingleRef2();
+ virtual void CalcAbsIfRel( const ScAddress& );
+ virtual void CalcRelFromAbs( const ScAddress& );
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
class ScMatrixToken : public ScToken
{
private:
ScMatrixRef pMatrix;
public:
ScMatrixToken( ScMatrix* p ) :
- ScToken( ocPush, svMatrix ), pMatrix( p ) {}
- ScMatrixToken( OpCode e, ScMatrix* p ) :
- ScToken( e, svMatrix ), pMatrix( p ) {}
+ ScToken( svMatrix ), pMatrix( p ) {}
ScMatrixToken( const ScMatrixToken& r ) :
ScToken( r ), pMatrix( r.pMatrix ) {}
- virtual ScMatrix* GetMatrix() const;
+ virtual const ScMatrix* GetMatrix() const;
+ virtual ScMatrix* GetMatrix();
virtual BOOL operator==( const ScToken& rToken ) const;
};
-class ScIndexToken : public ScToken
+class ScIndexToken : public ScOpToken
{
private:
USHORT nIndex;
public:
ScIndexToken( OpCode e, USHORT n ) :
- ScToken( e, svIndex ), nIndex( n ) {}
+ ScOpToken( e, svIndex ), nIndex( n ) {}
ScIndexToken( const ScIndexToken& r ) :
- ScToken( r ), nIndex( r.nIndex ) {}
+ ScOpToken( r ), nIndex( r.nIndex ) {}
virtual USHORT GetIndex() const;
virtual void SetIndex( USHORT n );
virtual BOOL operator==( const ScToken& rToken ) const;
};
-class ScJumpToken : public ScToken
+class ScJumpToken : public ScOpToken
{
private:
short* pJump;
public:
ScJumpToken( OpCode e, short* p ) :
- ScToken( e, svJump )
+ ScOpToken( e, svJump )
{
pJump = new short[ p[0] + 1 ];
memcpy( pJump, p, (p[0] + 1) * sizeof(short) );
}
ScJumpToken( const ScJumpToken& r ) :
- ScToken( r )
+ ScOpToken( r )
{
pJump = new short[ r.pJump[0] + 1 ];
memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) );
@@ -394,7 +498,7 @@ private:
ScJumpMatrix* pJumpMatrix;
public:
ScJumpMatrixToken( ScJumpMatrix* p ) :
- ScToken( ocPush, svJumpMatrix ), pJumpMatrix( p ) {}
+ ScToken( svJumpMatrix ), pJumpMatrix( p ) {}
ScJumpMatrixToken( const ScJumpMatrixToken& r ) :
ScToken( r ), pJumpMatrix( r.pJumpMatrix ) {}
virtual ~ScJumpMatrixToken();
@@ -403,20 +507,39 @@ public:
};
-class ScExternalToken : public ScToken
+// Only created from within the interpreter, no conversion from ScRawToken,
+// never added to ScTokenArray!
+class ScRefListToken : public ScToken
+{
+private:
+ ScRefList aRefList;
+public:
+ ScRefListToken() :
+ ScToken( svRefList ) {}
+ ScRefListToken( const ScRefListToken & r ) :
+ ScToken( r ), aRefList( r.aRefList ) {}
+ virtual void CalcAbsIfRel( const ScAddress& );
+ virtual void CalcRelFromAbs( const ScAddress& );
+ virtual const ScRefList* GetRefList() const;
+ virtual ScRefList* GetRefList();
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
+class ScExternalToken : public ScOpToken
{
private:
String aExternal;
BYTE nByte;
public:
ScExternalToken( OpCode e, BYTE n, const String& r ) :
- ScToken( e, svExternal ), aExternal( r ),
+ ScOpToken( e, svExternal ), aExternal( r ),
nByte( n ) {}
ScExternalToken( OpCode e, const String& r ) :
- ScToken( e, svExternal ), aExternal( r ),
+ ScOpToken( e, svExternal ), aExternal( r ),
nByte( 0 ) {}
ScExternalToken( const ScExternalToken& r ) :
- ScToken( r ), aExternal( r.aExternal ),
+ ScOpToken( r ), aExternal( r.aExternal ),
nByte( r.nByte ) {}
virtual const String& GetExternal() const;
virtual BYTE GetByte() const;
@@ -425,51 +548,184 @@ public:
};
-class ScMissingToken : public ScToken
+class ScMissingToken : public ScOpToken
{
public:
ScMissingToken() :
- ScToken( ocPush, svMissing ) {}
- ScMissingToken( OpCode e ) :
- ScToken( e, svMissing ) {}
+ ScOpToken( ocMissing, svMissing ) {}
ScMissingToken( const ScMissingToken& r ) :
- ScToken( r ) {}
+ ScOpToken( r ) {}
virtual double GetDouble() const;
virtual const String& GetString() const;
virtual BOOL operator==( const ScToken& rToken ) const;
};
-class ScErrToken : public ScToken
+class ScUnknownToken : public ScOpToken
+{
+public:
+ ScUnknownToken( OpCode e ) :
+ ScOpToken( e, svUnknown ) {}
+ ScUnknownToken( const ScUnknownToken& r ) :
+ ScOpToken( r ) {}
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
+class ScErrorToken : public ScToken
+{
+ USHORT nError;
+public:
+ ScErrorToken( USHORT nErr ) :
+ ScToken( svError ), nError( nErr) {}
+ ScErrorToken( const ScErrorToken& r ) :
+ ScToken( r ), nError( r.nError) {}
+ virtual USHORT GetError() const;
+ virtual void SetError( USHORT nErr );
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
+class ScEmptyCellToken : public ScToken
+{
+ bool bInherited :1;
+ bool bDisplayedAsString :1;
+public:
+ explicit ScEmptyCellToken( bool bInheritedP, bool bDisplayAsString ) :
+ ScToken( svEmptyCell ),
+ bInherited( bInheritedP ),
+ bDisplayedAsString( bDisplayAsString ) {}
+ ScEmptyCellToken( const ScEmptyCellToken& r ) :
+ ScToken( r ),
+ bInherited( r.bInherited ),
+ bDisplayedAsString( r.bDisplayedAsString ) {}
+ bool IsInherited() const { return bInherited; }
+ bool IsDisplayedAsString() const { return bDisplayedAsString; }
+ virtual double GetDouble() const;
+ virtual const String & GetString() const;
+ virtual BOOL operator==( const ScToken& rToken ) const;
+};
+
+
+/** Transports the result from the interpreter to the formula cell. */
+class ScMatrixCellResultToken : public ScToken
+{
+ // No non-const access implemented, silence down unxsols4 complaining about
+ // the public GetMatrix() hiding the one from ScToken.
+ virtual ScMatrix* GetMatrix();
+
+protected:
+ ScConstMatrixRef xMatrix;
+ ScConstTokenRef xUpperLeft;
+public:
+ ScMatrixCellResultToken( ScMatrix* pMat, ScToken* pUL ) :
+ ScToken( svMatrixCell ),
+ xMatrix( pMat), xUpperLeft( pUL) {}
+ ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
+ ScToken( r ), xMatrix( r.xMatrix ),
+ xUpperLeft( r.xUpperLeft ) {}
+ virtual double GetDouble() const;
+ virtual const String & GetString() const;
+ virtual const ScMatrix* GetMatrix() const;
+ virtual BOOL operator==( const ScToken& rToken ) const;
+ StackVar GetUpperLeftType() const
+ {
+ return xUpperLeft ?
+ xUpperLeft->GetType() :
+ static_cast<StackVar>(svUnknown);
+ }
+ ScConstTokenRef GetUpperLeftToken() const { return xUpperLeft; }
+ void Assign( const ScMatrixCellResultToken & r )
+ {
+ xMatrix = r.xMatrix;
+ xUpperLeft = r.xUpperLeft;
+ }
+};
+
+
+/** Stores the matrix result at the formula cell, additionally the range the
+ matrix formula occupies. */
+class ScMatrixFormulaCellToken : public ScMatrixCellResultToken
{
+private:
+ SCROW nRows;
+ SCCOL nCols;
public:
- ScErrToken( OpCode e ) :
- ScToken( e, svErr ) {}
- ScErrToken( const ScErrToken& r ) :
- ScToken( r ) {}
+ ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
+ ScMatrixCellResultToken( NULL, NULL ),
+ nRows( nR ), nCols( nC ) {}
+ ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
+ ScMatrixCellResultToken( r ),
+ nRows( r.nRows ), nCols( r.nCols )
+ {
+ // xUpperLeft is modifiable through
+ // SetUpperLeftDouble(), so clone it.
+ if (xUpperLeft)
+ xUpperLeft = xUpperLeft->Clone();
+ }
virtual BOOL operator==( const ScToken& rToken ) const;
+ void SetMatColsRows( SCCOL nC, SCROW nR )
+ {
+ nRows = nR;
+ nCols = nC;
+ }
+ void GetMatColsRows( SCCOL & nC, SCROW & nR ) const
+ {
+ nR = nRows;
+ nC = nCols;
+ }
+ SCCOL GetMatCols() const { return nCols; }
+ SCROW GetMatRows() const { return nRows; }
+
+ /** Assign matrix result, keep matrix formula
+ dimension. */
+ void Assign( const ScMatrixCellResultToken & r )
+ {
+ ScMatrixCellResultToken::Assign( r);
+ }
+
+ /** Assign any result, keep matrix formula
+ dimension. If token is of type
+ ScMatrixCellResultToken uses the
+ appropriate Assign() call, other tokens
+ are assigned to xUpperLeft and xMatrix will
+ be assigned NULL. */
+ void Assign( const ScToken & r );
+
+ /** Modify xUpperLeft if svDouble, or create
+ new ScDoubleToken if not set yet. Does
+ nothing if xUpperLeft is of different type! */
+ void SetUpperLeftDouble( double f);
+
+ /** Reset matrix and upper left, keep matrix
+ formula dimension. */
+ void ResetResult()
+ {
+ xMatrix = NULL;
+ xUpperLeft = NULL;
+ }
};
-class ScUnknownToken : public ScToken
+class ScHybridCellToken : public ScToken
{
private:
- BYTE* pUnknown;
+ double fDouble;
+ String aString;
+ String aFormula;
public:
- ScUnknownToken( OpCode e, StackVar v, BYTE* p ) :
- ScToken( e, v )
- {
- pUnknown = new BYTE[ int(p[0]) + 1 ];
- memcpy( pUnknown, p, int(p[0]) + 1 );
- }
- ScUnknownToken( const ScUnknownToken& r ) :
- ScToken( r )
- {
- pUnknown = new BYTE[ int(r.pUnknown[0]) + 1 ];
- memcpy( pUnknown, r.pUnknown, int(r.pUnknown[0]) + 1 );
- }
- virtual ~ScUnknownToken();
- virtual BYTE* GetUnknown() const;
+ ScHybridCellToken( double f,
+ const String & rStr,
+ const String & rFormula ) :
+ ScToken( svHybridCell ),
+ fDouble( f ), aString( rStr ),
+ aFormula( rFormula ) {}
+ ScHybridCellToken( const ScHybridCellToken& r ) :
+ ScToken( r ), fDouble( r.fDouble),
+ aString( r.aString), aFormula( r.aFormula) {}
+ const String & GetFormula() const { return aFormula; }
+ virtual double GetDouble() const;
+ virtual const String & GetString() const;
virtual BOOL operator==( const ScToken& rToken ) const;
};