xref: /aoo42x/main/sc/inc/tokenarray.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_TOKENARRAY_HXX
25cdf0e10cSrcweir #define SC_TOKENARRAY_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "formula/token.hxx"
28cdf0e10cSrcweir #include <tools/solar.h>
29cdf0e10cSrcweir #include "scdllapi.h"
30cdf0e10cSrcweir #include <formula/tokenarray.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir struct ScRawToken;
33cdf0e10cSrcweir struct ScSingleRefData;
34cdf0e10cSrcweir struct ScComplexRefData;
35cdf0e10cSrcweir class ScMatrix;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     friend class ScCompiler;
40cdf0e10cSrcweir     sal_Bool                    ImplGetReference( ScRange& rRange, sal_Bool bValidOnly ) const;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir     ScTokenArray();
44cdf0e10cSrcweir     /// Assignment with references to ScToken entries (not copied!)
45cdf0e10cSrcweir     ScTokenArray( const ScTokenArray& );
46cdf0e10cSrcweir    virtual ~ScTokenArray();
47cdf0e10cSrcweir     ScTokenArray* Clone() const;    /// True copy!
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     /// Exactly and only one range (valid or deleted)
50cdf0e10cSrcweir     sal_Bool    IsReference( ScRange& rRange ) const;
51cdf0e10cSrcweir     /// Exactly and only one valid range (no #REF!s)
52cdf0e10cSrcweir     sal_Bool    IsValidReference( ScRange& rRange ) const;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir                             /** Determines the extent of direct adjacent
56cdf0e10cSrcweir                                 references. Only use with real functions, e.g.
57cdf0e10cSrcweir                                 GetOuterFuncOpCode() == ocSum ! */
58cdf0e10cSrcweir     sal_Bool                    GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
59cdf0e10cSrcweir                                 const ScAddress& rPos, ScDirection );
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     formula::FormulaToken* AddRawToken( const ScRawToken& );
62cdf0e10cSrcweir     virtual bool AddFormulaToken(const com::sun::star::sheet::FormulaToken& _aToken,formula::ExternalReferenceHelper* _pRef);
63cdf0e10cSrcweir     virtual formula::FormulaToken* AddOpCode( OpCode eCode );
64cdf0e10cSrcweir     /** ScSingleRefToken with ocPush. */
65cdf0e10cSrcweir     formula::FormulaToken* AddSingleReference( const ScSingleRefData& rRef );
66cdf0e10cSrcweir     /** ScSingleRefOpToken with ocMatRef. */
67cdf0e10cSrcweir     formula::FormulaToken* AddMatrixSingleReference( const ScSingleRefData& rRef );
68cdf0e10cSrcweir     formula::FormulaToken* AddDoubleReference( const ScComplexRefData& rRef );
69cdf0e10cSrcweir     formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const String& rName );
70cdf0e10cSrcweir     formula::FormulaToken* AddExternalSingleReference( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef );
71cdf0e10cSrcweir     formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef );
72cdf0e10cSrcweir     formula::FormulaToken* AddMatrix( ScMatrix* p );
73cdf0e10cSrcweir     /** ScSingleRefOpToken with ocColRowName. */
74cdf0e10cSrcweir     formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef );
75cdf0e10cSrcweir     virtual formula::FormulaToken* MergeArray( );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /** Merge very last SingleRef+ocRange+SingleRef combination into DoubleRef
78cdf0e10cSrcweir         and adjust pCode array, or do nothing if conditions not met.
79cdf0e10cSrcweir         Unconditionally returns last token from the resulting pCode array, or
80cdf0e10cSrcweir         NULL if there is no pCode (which actually would be caller's fault). */
81cdf0e10cSrcweir     formula::FormulaToken* MergeRangeReference( const ScAddress & rPos );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /// Assignment with references to ScToken entries (not copied!)
84cdf0e10cSrcweir     ScTokenArray& operator=( const ScTokenArray& );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     /// Make 3D references point to old referenced position even if relative
87cdf0e10cSrcweir     void            ReadjustRelative3DReferences(
88cdf0e10cSrcweir                                 const ScAddress& rOldPos,
89cdf0e10cSrcweir                                 const ScAddress& rNewPos );
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #endif // SC_TOKENARRAY_HXX
93cdf0e10cSrcweir 
94