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