1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tokenarray.hxx,v $
10 * $Revision: 1.12.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_TOKENARRAY_HXX
32 #define SC_TOKENARRAY_HXX
34 #include "formula/token.hxx"
35 #include <tools/solar.h>
37 #include <formula/tokenarray.hxx>
40 struct ScSingleRefData
;
41 struct ScComplexRefData
;
44 class SC_DLLPUBLIC ScTokenArray
: public formula::FormulaTokenArray
46 friend class ScCompiler
;
47 BOOL
ImplGetReference( ScRange
& rRange
, BOOL bValidOnly
) const;
51 /// Assignment with references to ScToken entries (not copied!)
52 ScTokenArray( const ScTokenArray
& );
53 virtual ~ScTokenArray();
54 ScTokenArray
* Clone() const; /// True copy!
56 /// Exactly and only one range (valid or deleted)
57 BOOL
IsReference( ScRange
& rRange
) const;
58 /// Exactly and only one valid range (no #REF!s)
59 BOOL
IsValidReference( ScRange
& rRange
) const;
62 /** Determines the extent of direct adjacent
63 references. Only use with real functions, e.g.
64 GetOuterFuncOpCode() == ocSum ! */
65 BOOL
GetAdjacentExtendOfOuterFuncRefs( SCCOLROW
& nExtend
,
66 const ScAddress
& rPos
, ScDirection
);
68 formula::FormulaToken
* AddRawToken( const ScRawToken
& );
69 virtual bool AddFormulaToken(const com::sun::star::sheet::FormulaToken
& _aToken
,formula::ExternalReferenceHelper
* _pRef
);
70 virtual formula::FormulaToken
* AddOpCode( OpCode eCode
);
71 /** ScSingleRefToken with ocPush. */
72 formula::FormulaToken
* AddSingleReference( const ScSingleRefData
& rRef
);
73 /** ScSingleRefOpToken with ocMatRef. */
74 formula::FormulaToken
* AddMatrixSingleReference( const ScSingleRefData
& rRef
);
75 formula::FormulaToken
* AddDoubleReference( const ScComplexRefData
& rRef
);
76 formula::FormulaToken
* AddExternalName( sal_uInt16 nFileId
, const String
& rName
);
77 formula::FormulaToken
* AddExternalSingleReference( sal_uInt16 nFileId
, const String
& rTabName
, const ScSingleRefData
& rRef
);
78 formula::FormulaToken
* AddExternalDoubleReference( sal_uInt16 nFileId
, const String
& rTabName
, const ScComplexRefData
& rRef
);
79 formula::FormulaToken
* AddMatrix( ScMatrix
* p
);
80 /** ScSingleRefOpToken with ocColRowName. */
81 formula::FormulaToken
* AddColRowName( const ScSingleRefData
& rRef
);
82 virtual formula::FormulaToken
* MergeArray( );
84 /** Merge very last SingleRef+ocRange+SingleRef combination into DoubleRef
85 and adjust pCode array, or do nothing if conditions not met.
86 Unconditionally returns last token from the resulting pCode array, or
87 NULL if there is no pCode (which actually would be caller's fault). */
88 formula::FormulaToken
* MergeRangeReference( const ScAddress
& rPos
);
90 /// Assignment with references to ScToken entries (not copied!)
91 ScTokenArray
& operator=( const ScTokenArray
& );
93 /// Make 3D references point to old referenced position even if relative
94 void ReadjustRelative3DReferences(
95 const ScAddress
& rOldPos
,
96 const ScAddress
& rNewPos
);
99 #endif // SC_TOKENARRAY_HXX