xref: /aoo4110/main/sc/source/filter/inc/xeformula.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_XEFORMULA_HXX
25 #define SC_XEFORMULA_HXX
26 
27 #include "xlformula.hxx"
28 #include "xeroot.hxx"
29 
30 // External reference log =====================================================
31 
32 /** Log entry for external references in a formula, used i.e. in change tracking. */
33 struct XclExpRefLogEntry
34 {
35     const XclExpString* mpUrl;              /// URL of the document containing the first sheet.
36     const XclExpString* mpFirstTab;         /// Name of the first sheet.
37     const XclExpString* mpLastTab;          /// Name of the last sheet.
38     sal_uInt16          mnFirstXclTab;      /// Calc index of the first sheet.
39     sal_uInt16          mnLastXclTab;       /// Calc index of the last sheet.
40 
41     explicit            XclExpRefLogEntry();
42 };
43 
44 /** Vector containing a log for all external references in a formula, used i.e. in change tracking. */
45 typedef ::std::vector< XclExpRefLogEntry > XclExpRefLog;
46 
47 // Formula compiler ===========================================================
48 
49 class ScRangeList;
50 class XclExpFmlaCompImpl;
51 
52 /** The formula compiler to create Excel token arrays from Calc token arrays. */
53 class XclExpFormulaCompiler : protected XclExpRoot
54 {
55 public:
56     explicit            XclExpFormulaCompiler( const XclExpRoot& rRoot );
57     virtual             ~XclExpFormulaCompiler();
58 
59     /** Creates and returns the token array of a formula. */
60     XclTokenArrayRef    CreateFormula(
61                             XclFormulaType eType, const ScTokenArray& rScTokArr,
62                             const ScAddress* pScBasePos = 0, XclExpRefLog* pRefLog = 0 );
63 
64     /** Creates and returns a token array containing a single cell address. */
65     XclTokenArrayRef    CreateFormula( XclFormulaType eType, const ScAddress& rScPos );
66 
67     /** Creates and returns a token array containing a single cell range address. */
68     XclTokenArrayRef    CreateFormula( XclFormulaType eType, const ScRange& rScRange );
69 
70     /** Creates and returns the token array for a cell range list. */
71     XclTokenArrayRef    CreateFormula( XclFormulaType eType, const ScRangeList& rScRanges );
72 
73     /** Creates a single error token containing the passed error code. */
74     XclTokenArrayRef    CreateErrorFormula( sal_uInt8 nErrCode );
75 
76     /** Creates a single token for a special cell reference.
77         @descr  This is used for array formulas and shared formulas (token tExp),
78             and multiple operation tables (token tTbl). */
79     XclTokenArrayRef    CreateSpecialRefFormula( sal_uInt8 nTokenId, const XclAddress& rXclPos );
80 
81     /** Creates a single tNameXR token for a reference to an external name.
82         @descr  This is used i.e. for linked macros in push buttons. */
83     XclTokenArrayRef    CreateNameXFormula( sal_uInt16 nExtSheet, sal_uInt16 nExtName );
84 
85 private:
86     typedef ScfRef< XclExpFmlaCompImpl > XclExpFmlaCompImplRef;
87     XclExpFmlaCompImplRef mxImpl;
88 };
89 
90 // ============================================================================
91 
92 #endif
93 
94