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