xref: /aoo41x/main/oox/inc/oox/xls/formulabase.hxx (revision e3508121)
1*e3508121SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e3508121SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e3508121SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e3508121SAndrew Rist  * distributed with this work for additional information
6*e3508121SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e3508121SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e3508121SAndrew Rist  * "License"); you may not use this file except in compliance
9*e3508121SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e3508121SAndrew Rist  *
11*e3508121SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e3508121SAndrew Rist  *
13*e3508121SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e3508121SAndrew Rist  * software distributed under the License is distributed on an
15*e3508121SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e3508121SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e3508121SAndrew Rist  * specific language governing permissions and limitations
18*e3508121SAndrew Rist  * under the License.
19*e3508121SAndrew Rist  *
20*e3508121SAndrew Rist  *************************************************************/
21*e3508121SAndrew Rist 
22*e3508121SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef OOX_XLS_FORMULABASE_HXX
25cdf0e10cSrcweir #define OOX_XLS_FORMULABASE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/beans/Pair.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaToken.hpp>
30cdf0e10cSrcweir #include <com/sun/star/table/CellAddress.hpp>
31cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp>
32cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
33cdf0e10cSrcweir #include "oox/helper/propertyset.hxx"
34cdf0e10cSrcweir #include "oox/helper/refvector.hxx"
35cdf0e10cSrcweir #include "oox/xls/addressconverter.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace com { namespace sun { namespace star {
38cdf0e10cSrcweir     namespace sheet { class XFormulaOpCodeMapper; }
39cdf0e10cSrcweir     namespace sheet { class XFormulaParser; }
40cdf0e10cSrcweir } } }
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace oox { template< typename Type > class Matrix; }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace oox {
45cdf0e10cSrcweir namespace xls {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // Constants ==================================================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir const size_t BIFF_TOKARR_MAXLEN                 = 4096;     /// Maximum size of a token array.
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // token class flags ----------------------------------------------------------
52cdf0e10cSrcweir 
53cdf0e10cSrcweir const sal_uInt8 BIFF_TOKCLASS_MASK              = 0x60;
54cdf0e10cSrcweir const sal_uInt8 BIFF_TOKCLASS_NONE              = 0x00;     /// 00-1F: Base tokens.
55cdf0e10cSrcweir const sal_uInt8 BIFF_TOKCLASS_REF               = 0x20;     /// 20-3F: Reference class tokens.
56cdf0e10cSrcweir const sal_uInt8 BIFF_TOKCLASS_VAL               = 0x40;     /// 40-5F: Value class tokens.
57cdf0e10cSrcweir const sal_uInt8 BIFF_TOKCLASS_ARR               = 0x60;     /// 60-7F: Array class tokens.
58cdf0e10cSrcweir 
59cdf0e10cSrcweir const sal_uInt8 BIFF_TOKFLAG_INVALID            = 0x80;     /// This bit must be null for a valid token identifier.
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // base token identifiers -----------------------------------------------------
62cdf0e10cSrcweir 
63cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MASK                 = 0x1F;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NONE                 = 0x00;     /// Placeholder for invalid token id.
66cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_EXP                  = 0x01;     /// Array or shared formula reference.
67cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_TBL                  = 0x02;     /// Multiple operation reference.
68cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ADD                  = 0x03;     /// Addition operator.
69cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_SUB                  = 0x04;     /// Subtraction operator.
70cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MUL                  = 0x05;     /// Multiplication operator.
71cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_DIV                  = 0x06;     /// Division operator.
72cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_POWER                = 0x07;     /// Power operator.
73cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_CONCAT               = 0x08;     /// String concatenation operator.
74cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_LT                   = 0x09;     /// Less than operator.
75cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_LE                   = 0x0A;     /// Less than or equal operator.
76cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_EQ                   = 0x0B;     /// Equal operator.
77cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_GE                   = 0x0C;     /// Greater than or equal operator.
78cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_GT                   = 0x0D;     /// Greater than operator.
79cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NE                   = 0x0E;     /// Not equal operator.
80cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ISECT                = 0x0F;     /// Intersection operator.
81cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_LIST                 = 0x10;     /// List operator.
82cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_RANGE                = 0x11;     /// Range operator.
83cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_UPLUS                = 0x12;     /// Unary plus.
84cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_UMINUS               = 0x13;     /// Unary minus.
85cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_PERCENT              = 0x14;     /// Percent sign.
86cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_PAREN                = 0x15;     /// Parentheses.
87cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MISSARG              = 0x16;     /// Missing argument.
88cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_STR                  = 0x17;     /// String constant.
89cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NLR                  = 0x18;     /// Natural language reference (NLR).
90cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ATTR                 = 0x19;     /// Special attribute.
91cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_SHEET                = 0x1A;     /// Start of a sheet reference (BIFF2-BIFF4).
92cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ENDSHEET             = 0x1B;     /// End of a sheet reference (BIFF2-BIFF4).
93cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ERR                  = 0x1C;     /// Error constant.
94cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_BOOL                 = 0x1D;     /// Boolean constant.
95cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_INT                  = 0x1E;     /// Integer constant.
96cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NUM                  = 0x1F;     /// Floating-point constant.
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // base identifiers of classified tokens --------------------------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_ARRAY                = 0x00;     /// Array constant.
101cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_FUNC                 = 0x01;     /// Function, fixed number of arguments.
102cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_FUNCVAR              = 0x02;     /// Function, variable number of arguments.
103cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NAME                 = 0x03;     /// Defined name.
104cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_REF                  = 0x04;     /// 2D cell reference.
105cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_AREA                 = 0x05;     /// 2D area reference.
106cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMAREA              = 0x06;     /// Constant reference subexpression.
107cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMERR               = 0x07;     /// Deleted reference subexpression.
108cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMNOMEM             = 0x08;     /// Constant reference subexpression without result.
109cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMFUNC              = 0x09;     /// Variable reference subexpression.
110cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_REFERR               = 0x0A;     /// Deleted 2D cell reference.
111cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_AREAERR              = 0x0B;     /// Deleted 2D area reference.
112cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_REFN                 = 0x0C;     /// Relative 2D cell reference (in names).
113cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_AREAN                = 0x0D;     /// Relative 2D area reference (in names).
114cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMAREAN             = 0x0E;     /// Reference subexpression (in names).
115cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_MEMNOMEMN            = 0x0F;     /// Reference subexpression (in names) without result.
116cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_FUNCCE               = 0x18;
117cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_NAMEX                = 0x19;     /// External reference.
118cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_REF3D                = 0x1A;     /// 3D cell reference.
119cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_AREA3D               = 0x1B;     /// 3D area reference.
120cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_REFERR3D             = 0x1C;     /// Deleted 3D cell reference.
121cdf0e10cSrcweir const sal_uInt8 BIFF_TOKID_AREAERR3D            = 0x1D;     /// Deleted 3D area reference
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // specific token constants ---------------------------------------------------
124cdf0e10cSrcweir 
125cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ARRAY_DOUBLE           = 0;        /// Double value in an array.
126cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ARRAY_STRING           = 1;        /// String value in an array.
127cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ARRAY_BOOL             = 2;        /// Boolean value in an array.
128cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ARRAY_ERROR            = 4;        /// Error code in an array.
129cdf0e10cSrcweir 
130cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_BOOL_FALSE             = 0;        /// FALSE value of a tBool token.
131cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_BOOL_TRUE              = 1;        /// TRUE value of a tBool token.
132cdf0e10cSrcweir 
133cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_VOLATILE          = 0x01;     /// Volatile function.
134cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_IF                = 0x02;     /// Start of true condition in IF function.
135cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_CHOOSE            = 0x04;     /// Jump array of CHOOSE function.
136cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SKIP              = 0x08;     /// Skip tokens.
137cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SUM               = 0x10;     /// SUM function with one parameter.
138cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_ASSIGN            = 0x20;     /// BASIC style assignment.
139cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE             = 0x40;     /// Spaces in formula representation.
140cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_VOLATILE    = 0x41;     /// Leading spaces and volatile formula.
141cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_IFERROR           = 0x80;     /// Start of condition in IFERROR function (BIFF12 only).
142cdf0e10cSrcweir 
143cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP          = 0x00;     /// Spaces before next token.
144cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR          = 0x01;     /// Line breaks before next token.
145cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_OPEN     = 0x02;     /// Spaces before opening parenthesis.
146cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR_OPEN     = 0x03;     /// Line breaks before opening parenthesis.
147cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_CLOSE    = 0x04;     /// Spaces before closing parenthesis.
148cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR_CLOSE    = 0x05;     /// Line breaks before closing parenthesis.
149cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_PRE      = 0x06;     /// Spaces before formula (BIFF3).
150cdf0e10cSrcweir 
151cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_FUNCVAR_CMD           = 0x8000;   /// Macro command.
152cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_FUNCVAR_FUNCIDMASK    = 0x7FFF;   /// Mask for function/command index.
153cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_FUNCVAR_CMDPROMPT      = 0x80;     /// User prompt for macro commands.
154cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_FUNCVAR_COUNTMASK      = 0x7F;     /// Mask for parameter count.
155cdf0e10cSrcweir 
156cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_REF_COLMASK         = 0x3FFF;   /// Mask to extract column from reference (BIFF12).
157cdf0e10cSrcweir const sal_Int32 BIFF12_TOK_REF_ROWMASK          = 0xFFFFF;  /// Mask to extract row from reference (BIFF12).
158cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_REF_COLREL          = 0x4000;   /// True = column is relative (BIFF12).
159cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_REF_ROWREL          = 0x8000;   /// True = row is relative (BIFF12).
160cdf0e10cSrcweir 
161cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_REF_COLMASK           = 0x00FF;   /// Mask to extract BIFF8 column from reference.
162cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_REF_ROWMASK           = 0x3FFF;   /// Mask to extract BIFF2-BIFF5 row from reference.
163cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_REF_COLREL            = 0x4000;   /// True = column is relative.
164cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_REF_ROWREL            = 0x8000;   /// True = row is relative.
165cdf0e10cSrcweir 
166cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_COLUMN         = 0x0001;   /// Table reference: Single column.
167cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_COLRANGE       = 0x0002;   /// Table reference: Range of columns.
168cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_ALL            = 0x0004;   /// Table reference: Special [#All] range.
169cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_HEADERS        = 0x0008;   /// Table reference: Special [#Headers] range.
170cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_DATA           = 0x0010;   /// Table reference: Special [#Data] range.
171cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_TOTALS         = 0x0020;   /// Table reference: Special [#Totals] range.
172cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_THISROW        = 0x0040;   /// Table reference: Special [#This Row] range.
173cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_SP_BRACKETS    = 0x0080;   /// Table reference: Spaces in outer brackets.
174cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_SP_SEP         = 0x0100;   /// Table reference: Spaces after separators.
175cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_ROW            = 0x0200;   /// Table reference: Single row.
176cdf0e10cSrcweir const sal_uInt16 BIFF12_TOK_TABLE_CELL           = 0x0400;   /// Table reference: Single cell.
177cdf0e10cSrcweir 
178cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_ERR                = 0x01;     /// NLR: Invalid/deleted.
179cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_ROWR               = 0x02;     /// NLR: Row index.
180cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_COLR               = 0x03;     /// NLR: Column index.
181cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_ROWV               = 0x06;     /// NLR: Value in row.
182cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_COLV               = 0x07;     /// NLR: Value in column.
183cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_RANGE              = 0x0A;     /// NLR: Range.
184cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SRANGE             = 0x0B;     /// Stacked NLR: Range.
185cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SROWR              = 0x0C;     /// Stacked NLR: Row index.
186cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SCOLR              = 0x0D;     /// Stacked NLR: Column index.
187cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SROWV              = 0x0E;     /// Stacked NLR: Value in row.
188cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SCOLV              = 0x0F;     /// Stacked NLR: Value in column.
189cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_RANGEERR           = 0x10;     /// NLR: Invalid/deleted range.
190cdf0e10cSrcweir const sal_uInt8 BIFF_TOK_NLR_SXNAME             = 0x1D;     /// NLR: Pivot table name.
191cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_NLR_REL               = 0x8000;   /// True = NLR is relative.
192cdf0e10cSrcweir const sal_uInt16 BIFF_TOK_NLR_MASK              = 0x3FFF;   /// Mask to extract BIFF8 column from NLR.
193cdf0e10cSrcweir 
194cdf0e10cSrcweir const sal_uInt32 BIFF_TOK_NLR_ADDREL            = 0x80000000;   /// NLR relative (in appended data).
195cdf0e10cSrcweir const sal_uInt32 BIFF_TOK_NLR_ADDMASK           = 0x3FFFFFFF;   /// Mask for number of appended ranges.
196cdf0e10cSrcweir 
197cdf0e10cSrcweir // function constants ---------------------------------------------------------
198cdf0e10cSrcweir 
199cdf0e10cSrcweir const sal_uInt8 OOX_MAX_PARAMCOUNT              = 255;      /// Maximum parameter count for OOXML/BIFF12 files.
200cdf0e10cSrcweir const sal_uInt8 BIFF_MAX_PARAMCOUNT             = 30;       /// Maximum parameter count for BIFF2-BIFF8 files.
201cdf0e10cSrcweir 
202cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_IF                   = 1;        /// Function identifier of the IF function.
203cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_SUM                  = 4;        /// Function identifier of the SUM function.
204cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_TRUE                 = 34;       /// Function identifier of the TRUE function.
205cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_FALSE                = 35;       /// Function identifier of the FALSE function.
206cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_ROWS                 = 76;       /// Function identifier of the ROWS function.
207cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_COLUMNS              = 77;       /// Function identifier of the COLUMNS function.
208cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_OFFSET               = 78;       /// Function identifier of the OFFSET function.
209cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_EXTERNCALL           = 255;      /// BIFF function id of the EXTERN.CALL function.
210cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_FLOOR                = 285;      /// Function identifier of the FLOOR function.
211cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_CEILING              = 288;      /// Function identifier of the CEILING function.
212cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_HYPERLINK            = 359;      /// Function identifier of the HYPERLINK function.
213cdf0e10cSrcweir const sal_uInt16 BIFF_FUNC_WEEKNUM              = 465;      /// Function identifier of the WEEKNUM function.
214cdf0e10cSrcweir 
215cdf0e10cSrcweir // Formula type ===============================================================
216cdf0e10cSrcweir 
217cdf0e10cSrcweir /** Enumerates all possible types of a formula. */
218cdf0e10cSrcweir enum FormulaType
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     FORMULATYPE_CELL,           /// Simple cell formula, or reference to a shared formula name.
221cdf0e10cSrcweir     FORMULATYPE_ARRAY,          /// Array (matrix) formula.
222cdf0e10cSrcweir     FORMULATYPE_SHAREDFORMULA,  /// Shared formula definition.
223cdf0e10cSrcweir     FORMULATYPE_CONDFORMAT,     /// Condition of a conditional format rule.
224cdf0e10cSrcweir     FORMULATYPE_VALIDATION,     /// Condition of a data validation.
225cdf0e10cSrcweir     FORMULATYPE_DEFINEDNAME     /// Definition of a defined name.
226cdf0e10cSrcweir };
227cdf0e10cSrcweir 
228cdf0e10cSrcweir // Reference helpers ==========================================================
229cdf0e10cSrcweir 
230cdf0e10cSrcweir /** A 2D formula cell reference struct with relative flags. */
231cdf0e10cSrcweir struct BinSingleRef2d
232cdf0e10cSrcweir {
233cdf0e10cSrcweir     sal_Int32           mnCol;              /// Column index.
234cdf0e10cSrcweir     sal_Int32           mnRow;              /// Row index.
235cdf0e10cSrcweir     bool                mbColRel;           /// True = relative column reference.
236cdf0e10cSrcweir     bool                mbRowRel;           /// True = relative row reference.
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     explicit            BinSingleRef2d();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     void                setBiff12Data( sal_uInt16 nCol, sal_Int32 nRow, bool bRelativeAsOffset );
241cdf0e10cSrcweir     void                setBiff2Data( sal_uInt8 nCol, sal_uInt16 nRow, bool bRelativeAsOffset );
242cdf0e10cSrcweir     void                setBiff8Data( sal_uInt16 nCol, sal_uInt16 nRow, bool bRelativeAsOffset );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     void                readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
245cdf0e10cSrcweir     void                readBiff2Data( BiffInputStream& rStrm, bool bRelativeAsOffset );
246cdf0e10cSrcweir     void                readBiff8Data( BiffInputStream& rStrm, bool bRelativeAsOffset );
247cdf0e10cSrcweir };
248cdf0e10cSrcweir 
249cdf0e10cSrcweir // ----------------------------------------------------------------------------
250cdf0e10cSrcweir 
251cdf0e10cSrcweir /** A 2D formula cell range reference struct with relative flags. */
252cdf0e10cSrcweir struct BinComplexRef2d
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     BinSingleRef2d      maRef1;             /// Start (top-left) cell address.
255cdf0e10cSrcweir     BinSingleRef2d      maRef2;             /// End (bottom-right) cell address.
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     void                readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
258cdf0e10cSrcweir     void                readBiff2Data( BiffInputStream& rStrm, bool bRelativeAsOffset );
259cdf0e10cSrcweir     void                readBiff8Data( BiffInputStream& rStrm, bool bRelativeAsOffset );
260cdf0e10cSrcweir };
261cdf0e10cSrcweir 
262cdf0e10cSrcweir // Token vector, token sequence ===============================================
263cdf0e10cSrcweir 
264cdf0e10cSrcweir typedef ::com::sun::star::sheet::FormulaToken       ApiToken;
265cdf0e10cSrcweir typedef ::com::sun::star::uno::Sequence< ApiToken > ApiTokenSequence;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir /** Contains the base address and type of a special token representing an array
268cdf0e10cSrcweir     formula or a shared formula (sal_False), or a table operation (sal_True). */
269cdf0e10cSrcweir typedef ::com::sun::star::beans::Pair< ::com::sun::star::table::CellAddress, sal_Bool > ApiSpecialTokenInfo;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir /** A vector of formula tokens with additional convenience functions. */
272cdf0e10cSrcweir class ApiTokenVector : public ::std::vector< ApiToken >
273cdf0e10cSrcweir {
274cdf0e10cSrcweir public:
275cdf0e10cSrcweir     explicit            ApiTokenVector();
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     /** Appends a new token with the passed op-code, returns its data field. */
278cdf0e10cSrcweir     ::com::sun::star::uno::Any&
279cdf0e10cSrcweir                         append( sal_Int32 nOpCode );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     /** Appends a new token with the passed op-code and data. */
282cdf0e10cSrcweir     template< typename Type >
append(sal_Int32 nOpCode,const Type & rData)283cdf0e10cSrcweir     inline void         append( sal_Int32 nOpCode, const Type& rData ) { append( nOpCode ) <<= rData; }
284cdf0e10cSrcweir };
285cdf0e10cSrcweir 
286cdf0e10cSrcweir // Token sequence iterator ====================================================
287cdf0e10cSrcweir 
288cdf0e10cSrcweir /** Token sequence iterator that is able to skip space tokens. */
289cdf0e10cSrcweir class ApiTokenIterator
290cdf0e10cSrcweir {
291cdf0e10cSrcweir public:
292cdf0e10cSrcweir     explicit            ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode, bool bSkipSpaces );
293cdf0e10cSrcweir     /** Copy constructor that allows to change the skip spaces mode. */
294cdf0e10cSrcweir     explicit            ApiTokenIterator( const ApiTokenIterator& rIter, bool bSkipSpaces );
295cdf0e10cSrcweir 
is() const296cdf0e10cSrcweir     inline bool         is() const { return mpToken != mpTokenEnd; }
get() const297cdf0e10cSrcweir     inline const ApiToken* get() const { return mpToken; }
operator ->() const298cdf0e10cSrcweir     inline const ApiToken* operator->() const { return mpToken; }
operator *() const299cdf0e10cSrcweir     inline const ApiToken& operator*() const { return *mpToken; }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     ApiTokenIterator&   operator++();
302cdf0e10cSrcweir 
303cdf0e10cSrcweir private:
304cdf0e10cSrcweir     void                skipSpaces();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir private:
307cdf0e10cSrcweir     const ApiToken*     mpToken;            /// Pointer to current token of the token sequence.
308cdf0e10cSrcweir     const ApiToken*     mpTokenEnd;         /// Pointer behind last token of the token sequence.
309cdf0e10cSrcweir     const sal_Int32     mnSpacesOpCode;     /// Op-code for whitespace tokens.
310cdf0e10cSrcweir     const bool          mbSkipSpaces;       /// true = Skip whitespace tokens.
311cdf0e10cSrcweir };
312cdf0e10cSrcweir 
313cdf0e10cSrcweir // List of API op-codes =======================================================
314cdf0e10cSrcweir 
315cdf0e10cSrcweir /** Contains all API op-codes needed to build formulas with tokens. */
316cdf0e10cSrcweir struct ApiOpCodes
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     // special
319cdf0e10cSrcweir     sal_Int32           OPCODE_UNKNOWN;         /// Internal: function name unknown to mapper.
320cdf0e10cSrcweir     sal_Int32           OPCODE_EXTERNAL;        /// External function call (e.g. add-ins).
321cdf0e10cSrcweir     // formula structure
322cdf0e10cSrcweir     sal_Int32           OPCODE_PUSH;            /// Op-code for common value operands.
323cdf0e10cSrcweir     sal_Int32           OPCODE_MISSING;         /// Placeholder for a missing function parameter.
324cdf0e10cSrcweir     sal_Int32           OPCODE_SPACES;          /// Spaces between other formula tokens.
325cdf0e10cSrcweir     sal_Int32           OPCODE_NAME;            /// Index of a defined name.
326cdf0e10cSrcweir     sal_Int32           OPCODE_DBAREA;          /// Index of a database area.
327cdf0e10cSrcweir     sal_Int32           OPCODE_NLR;             /// Natural language reference.
328cdf0e10cSrcweir     sal_Int32           OPCODE_DDE;             /// DDE link function.
329cdf0e10cSrcweir     sal_Int32           OPCODE_MACRO;           /// Macro function call.
330cdf0e10cSrcweir     sal_Int32           OPCODE_BAD;             /// Bad token (unknown name, formula error).
331cdf0e10cSrcweir     sal_Int32           OPCODE_NONAME;          /// Function style #NAME? error.
332cdf0e10cSrcweir     // separators
333cdf0e10cSrcweir     sal_Int32           OPCODE_OPEN;            /// Opening parenthesis.
334cdf0e10cSrcweir     sal_Int32           OPCODE_CLOSE;           /// Closing parenthesis.
335cdf0e10cSrcweir     sal_Int32           OPCODE_SEP;             /// Function parameter separator.
336cdf0e10cSrcweir     // array separators
337cdf0e10cSrcweir     sal_Int32           OPCODE_ARRAY_OPEN;      /// Opening brace for constant arrays.
338cdf0e10cSrcweir     sal_Int32           OPCODE_ARRAY_CLOSE;     /// Closing brace for constant arrays.
339cdf0e10cSrcweir     sal_Int32           OPCODE_ARRAY_ROWSEP;    /// Row separator in constant arrays.
340cdf0e10cSrcweir     sal_Int32           OPCODE_ARRAY_COLSEP;    /// Column separator in constant arrays.
341cdf0e10cSrcweir     // unary operators
342cdf0e10cSrcweir     sal_Int32           OPCODE_PLUS_SIGN;       /// Unary plus sign.
343cdf0e10cSrcweir     sal_Int32           OPCODE_MINUS_SIGN;      /// Unary minus sign.
344cdf0e10cSrcweir     sal_Int32           OPCODE_PERCENT;         /// Percent sign.
345cdf0e10cSrcweir     // binary operators
346cdf0e10cSrcweir     sal_Int32           OPCODE_ADD;             /// Addition operator.
347cdf0e10cSrcweir     sal_Int32           OPCODE_SUB;             /// Subtraction operator.
348cdf0e10cSrcweir     sal_Int32           OPCODE_MULT;            /// Multiplication operator.
349cdf0e10cSrcweir     sal_Int32           OPCODE_DIV;             /// Division operator.
350cdf0e10cSrcweir     sal_Int32           OPCODE_POWER;           /// Power operator.
351cdf0e10cSrcweir     sal_Int32           OPCODE_CONCAT;          /// String concatenation operator.
352cdf0e10cSrcweir     sal_Int32           OPCODE_EQUAL;           /// Compare equal operator.
353cdf0e10cSrcweir     sal_Int32           OPCODE_NOT_EQUAL;       /// Compare not equal operator.
354cdf0e10cSrcweir     sal_Int32           OPCODE_LESS;            /// Compare less operator.
355cdf0e10cSrcweir     sal_Int32           OPCODE_LESS_EQUAL;      /// Compare less or equal operator.
356cdf0e10cSrcweir     sal_Int32           OPCODE_GREATER;         /// Compare greater operator.
357cdf0e10cSrcweir     sal_Int32           OPCODE_GREATER_EQUAL;   /// Compare greater or equal operator.
358cdf0e10cSrcweir     sal_Int32           OPCODE_INTERSECT;       /// Range intersection operator.
359cdf0e10cSrcweir     sal_Int32           OPCODE_LIST;            /// Range list operator.
360cdf0e10cSrcweir     sal_Int32           OPCODE_RANGE;           /// Range operator.
361cdf0e10cSrcweir };
362cdf0e10cSrcweir 
363cdf0e10cSrcweir // Function parameter info ====================================================
364cdf0e10cSrcweir 
365cdf0e10cSrcweir /** Enumerates validity modes for a function parameter. */
366cdf0e10cSrcweir enum FuncParamValidity
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     FUNC_PARAM_NONE = 0,        /// Default for an unspecified entry in a C-array.
369cdf0e10cSrcweir     FUNC_PARAM_REGULAR,         /// Parameter supported by Calc and Excel.
370cdf0e10cSrcweir     FUNC_PARAM_CALCONLY,        /// Parameter supported by Calc only.
371cdf0e10cSrcweir     FUNC_PARAM_EXCELONLY        /// Parameter supported by Excel only.
372cdf0e10cSrcweir };
373cdf0e10cSrcweir 
374cdf0e10cSrcweir /** Enumerates different types of token class conversion in function parameters. */
375cdf0e10cSrcweir enum FuncParamConversion
376cdf0e10cSrcweir {
377cdf0e10cSrcweir     FUNC_PARAMCONV_ORG,         /// Use original class of current token.
378cdf0e10cSrcweir     FUNC_PARAMCONV_VAL,         /// Convert tokens to VAL class.
379cdf0e10cSrcweir     FUNC_PARAMCONV_ARR,         /// Convert tokens to ARR class.
380cdf0e10cSrcweir     FUNC_PARAMCONV_RPT,         /// Repeat parent conversion in VALTYPE parameters.
381cdf0e10cSrcweir     FUNC_PARAMCONV_RPX,         /// Repeat parent conversion in REFTYPE parameters.
382cdf0e10cSrcweir     FUNC_PARAMCONV_RPO          /// Repeat parent conversion in operands of operators.
383cdf0e10cSrcweir };
384cdf0e10cSrcweir 
385cdf0e10cSrcweir /** Structure that contains all needed information for a parameter in a
386cdf0e10cSrcweir     function.
387cdf0e10cSrcweir 
388cdf0e10cSrcweir     The member meValid specifies which application supports the parameter. If
389cdf0e10cSrcweir     set to CALCONLY, import filters have to insert a default value for this
390cdf0e10cSrcweir     parameter, and export filters have to skip the parameter. If set to
391cdf0e10cSrcweir     EXCELONLY, import filters have to skip the parameter, and export filters
392cdf0e10cSrcweir     have to insert a default value for this parameter.
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     The member mbValType specifies whether the parameter requires tokens to be
395cdf0e10cSrcweir     of value type (VAL or ARR class).
396cdf0e10cSrcweir 
397cdf0e10cSrcweir         If set to false, the parameter is called to be REFTYPE. Tokens with REF
398cdf0e10cSrcweir         default class can be inserted for the parameter (e.g. tAreaR tokens).
399cdf0e10cSrcweir 
400cdf0e10cSrcweir         If set to true, the parameter is called to be VALTYPE. Tokens with REF
401cdf0e10cSrcweir         class need to be converted to VAL tokens first (e.g. tAreaR will be
402cdf0e10cSrcweir         converted to tAreaV), and further conversion is done according to this
403cdf0e10cSrcweir         new token class.
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     The member meConv specifies how to convert the current token class of the
406cdf0e10cSrcweir     token inserted for the parameter. If the token class is still REF this
407cdf0e10cSrcweir     means that the token has default REF class and the parameter is REFTYPE
408cdf0e10cSrcweir     (see member mbValType), the token will not be converted at all and remains
409cdf0e10cSrcweir     in REF class. Otherwise, token class conversion is depending on the actual
410cdf0e10cSrcweir     token class of the return value of the function containing this parameter.
411cdf0e10cSrcweir     The function may return REF class (tFuncR, tFuncVarR, tFuncCER), or it may
412cdf0e10cSrcweir     return VAL or ARR class (tFuncV, tFuncA, tFuncVarV, tFuncVarA, tFuncCEV,
413cdf0e10cSrcweir     tFuncCEA). Even if the function is able to return REF class, it may return
414cdf0e10cSrcweir     VAL or ARR class instead due to the VALTYPE data type of the parent
415cdf0e10cSrcweir     function parameter that calls the own function. Example: The INDIRECT
416cdf0e10cSrcweir     function returns REF class by default. But if called from a VALTYPE
417cdf0e10cSrcweir     function parameter, e.g. in the formula =ABS(INDIRECT("A1")), it returns
418cdf0e10cSrcweir     VAL or ARR class instead. Additionally, the repeating conversion types RPT
419cdf0e10cSrcweir     and RPX rely on the conversion executed for the function token class.
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         1) ORG:
422cdf0e10cSrcweir         Use the original class of the token (VAL or ARR), regardless of any
423cdf0e10cSrcweir         conversion done for the function return class.
424cdf0e10cSrcweir 
425cdf0e10cSrcweir         2) VAL:
426cdf0e10cSrcweir         Convert ARR tokens to VAL class, regardless of any conversion done for
427cdf0e10cSrcweir         the function return class.
428cdf0e10cSrcweir 
429cdf0e10cSrcweir         3) ARR:
430cdf0e10cSrcweir         Convert VAL tokens to ARR class, regardless of any conversion done for
431cdf0e10cSrcweir         the function return class.
432cdf0e10cSrcweir 
433cdf0e10cSrcweir         4) RPT:
434cdf0e10cSrcweir         If the own function returns REF class (thus it is called from a REFTYPE
435cdf0e10cSrcweir         parameter, see above), and the parent conversion type (for the function
436cdf0e10cSrcweir         return class) was ORG, VAL, or ARR, ignore that conversion and always
437cdf0e10cSrcweir         use VAL conversion for the own token instead. If the parent conversion
438cdf0e10cSrcweir         type was RPT or RPX, repeat the conversion that would have been used if
439cdf0e10cSrcweir         the function would return value type.
440cdf0e10cSrcweir         If the own function returns value type (VAL or ARR class, see above),
441cdf0e10cSrcweir         and the parent conversion type (for the function return class) was ORG,
442cdf0e10cSrcweir         VAL, ARR, or RPT, repeat this conversion for the own token. If the
443cdf0e10cSrcweir         parent conversion type was RPX, always use ORG conversion type for the
444cdf0e10cSrcweir         own token instead.
445cdf0e10cSrcweir 
446cdf0e10cSrcweir         5) RPX:
447cdf0e10cSrcweir         This type of conversion only occurs in functions returning VAL class by
448cdf0e10cSrcweir         default. If the own token is value type, and the VAL return class of
449cdf0e10cSrcweir         the own function has been changed to ARR class (due to direct ARR
450cdf0e10cSrcweir         conversion, or due to ARR conversion repeated by RPT or RPX), set the
451cdf0e10cSrcweir         own token to ARR type. Otherwise use the original token type (VAL
452cdf0e10cSrcweir         conversion from parent parameter will not be repeated at all). If
453cdf0e10cSrcweir         nested functions have RPT or value-type RPX parameters, they will not
454cdf0e10cSrcweir         repeat this conversion type, but will use ORG conversion instead (see
455cdf0e10cSrcweir         description of RPT above).
456cdf0e10cSrcweir 
457cdf0e10cSrcweir         6) RPO:
458cdf0e10cSrcweir         This type of conversion is only used for the operands of all operators
459cdf0e10cSrcweir         (unary and binary arithmetic operators, comparison operators, and range
460cdf0e10cSrcweir         operators). It is not used for function parameters. On conversion, it
461cdf0e10cSrcweir         will be replaced by the last conversion type that was not the RPO
462cdf0e10cSrcweir         conversion. This leads to a slightly different behaviour than the RPT
463cdf0e10cSrcweir         conversion for operands in conjunction with a parent RPX conversion.
464cdf0e10cSrcweir  */
465cdf0e10cSrcweir struct FunctionParamInfo
466cdf0e10cSrcweir {
467cdf0e10cSrcweir     FuncParamValidity   meValid;        /// Parameter validity.
468cdf0e10cSrcweir     FuncParamConversion meConv;         /// Token class conversion type.
469cdf0e10cSrcweir     bool                mbValType;      /// Data type (false = REFTYPE, true = VALTYPE).
470cdf0e10cSrcweir };
471cdf0e10cSrcweir 
472cdf0e10cSrcweir // Function data ==============================================================
473cdf0e10cSrcweir 
474cdf0e10cSrcweir /** This enumeration contains constants for all known external libraries
475cdf0e10cSrcweir     containing supported sheet functions. */
476cdf0e10cSrcweir enum FunctionLibraryType
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     FUNCLIB_UNKNOWN = 0,        /// Unknown library (must be zero).
479cdf0e10cSrcweir     FUNCLIB_EUROTOOL            /// EuroTool add-in with EUROCONVERT function.
480cdf0e10cSrcweir };
481cdf0e10cSrcweir 
482cdf0e10cSrcweir // ----------------------------------------------------------------------------
483cdf0e10cSrcweir 
484cdf0e10cSrcweir /** Represents information for a spreadsheet function.
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     The member mpParamInfos points to a C-array of type information structures
487cdf0e10cSrcweir     for all parameters of the function. The last initialized structure
488cdf0e10cSrcweir     describing a regular parameter (member meValid == FUNC_PARAM_REGULAR) in
489cdf0e10cSrcweir     this array is used repeatedly for all following parameters supported by a
490cdf0e10cSrcweir     function.
491cdf0e10cSrcweir  */
492cdf0e10cSrcweir struct FunctionInfo
493cdf0e10cSrcweir {
494cdf0e10cSrcweir     ::rtl::OUString     maOdfFuncName;      /// ODF function name.
495cdf0e10cSrcweir     ::rtl::OUString     maOoxFuncName;      /// OOXML function name.
496cdf0e10cSrcweir     ::rtl::OUString     maBiffMacroName;    /// Expected macro name in EXTERN.CALL function.
497cdf0e10cSrcweir     ::rtl::OUString     maExtProgName;      /// Programmatic function name for external functions.
498cdf0e10cSrcweir     FunctionLibraryType meFuncLibType;      /// The external library this function is part of.
499cdf0e10cSrcweir     sal_Int32           mnApiOpCode;        /// API function opcode.
500cdf0e10cSrcweir     sal_uInt16          mnBiff12FuncId;     /// BIFF12 function identifier.
501cdf0e10cSrcweir     sal_uInt16          mnBiffFuncId;       /// BIFF2-BIFF8 function identifier.
502cdf0e10cSrcweir     sal_uInt8           mnMinParamCount;    /// Minimum number of parameters.
503cdf0e10cSrcweir     sal_uInt8           mnMaxParamCount;    /// Maximum number of parameters.
504cdf0e10cSrcweir     sal_uInt8           mnRetClass;         /// BIFF token class of the return value.
505cdf0e10cSrcweir     const FunctionParamInfo* mpParamInfos;  /// Information about all parameters.
506cdf0e10cSrcweir     bool                mbParamPairs;       /// True = optional parameters are expected to appear in pairs.
507cdf0e10cSrcweir     bool                mbVolatile;         /// True = volatile function.
508cdf0e10cSrcweir     bool                mbExternal;         /// True = external function in Calc.
509cdf0e10cSrcweir     bool                mbMacroFunc;        /// True = macro sheet function or command.
510cdf0e10cSrcweir     bool                mbVarParam;         /// True = use a tFuncVar token, also if min/max are equal.
511cdf0e10cSrcweir };
512cdf0e10cSrcweir 
513cdf0e10cSrcweir typedef RefVector< FunctionInfo > FunctionInfoVector;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir // Function info parameter class iterator =====================================
516cdf0e10cSrcweir 
517cdf0e10cSrcweir /** Iterator working on the mpParamInfos member of the FunctionInfo struct.
518cdf0e10cSrcweir 
519cdf0e10cSrcweir     This iterator can be used to iterate through the array containing the
520cdf0e10cSrcweir     token class conversion information of function parameters. This iterator
521cdf0e10cSrcweir     repeats the last valid structure in the array - it stops automatically
522cdf0e10cSrcweir     before the first empty array entry or before the end of the array, even for
523cdf0e10cSrcweir     repeated calls to the increment operator.
524cdf0e10cSrcweir  */
525cdf0e10cSrcweir class FunctionParamInfoIterator
526cdf0e10cSrcweir {
527cdf0e10cSrcweir public:
528cdf0e10cSrcweir     explicit            FunctionParamInfoIterator( const FunctionInfo& rFuncInfo );
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     const FunctionParamInfo& getParamInfo() const;
531cdf0e10cSrcweir     bool                isCalcOnlyParam() const;
532cdf0e10cSrcweir     bool                isExcelOnlyParam() const;
533cdf0e10cSrcweir     FunctionParamInfoIterator& operator++();
534cdf0e10cSrcweir 
535cdf0e10cSrcweir private:
536cdf0e10cSrcweir     const FunctionParamInfo* mpParamInfo;
537cdf0e10cSrcweir     const FunctionParamInfo* mpParamInfoEnd;
538cdf0e10cSrcweir     bool                mbParamPairs;
539cdf0e10cSrcweir };
540cdf0e10cSrcweir 
541cdf0e10cSrcweir // Base function provider =====================================================
542cdf0e10cSrcweir 
543cdf0e10cSrcweir struct FunctionProviderImpl;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir /** Provides access to function info structs for all available sheet functions.
546cdf0e10cSrcweir  */
547cdf0e10cSrcweir class FunctionProvider  // not derived from WorkbookHelper to make it usable in file dumpers
548cdf0e10cSrcweir {
549cdf0e10cSrcweir public:
550cdf0e10cSrcweir     explicit            FunctionProvider( FilterType eFilter, BiffType eBiff, bool bImportFilter );
551cdf0e10cSrcweir     virtual             ~FunctionProvider();
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     /** Returns the function info for an ODF function name, or 0 on error. */
554cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromOdfFuncName( const ::rtl::OUString& rFuncName ) const;
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     /** Returns the function info for an OOXML function name, or 0 on error. */
557cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromOoxFuncName( const ::rtl::OUString& rFuncName ) const;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir     /** Returns the function info for a BIFF12 function index, or 0 on error. */
560cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromBiff12FuncId( sal_uInt16 nFuncId ) const;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir     /** Returns the function info for a BIFF2-BIFF8 function index, or 0 on error. */
563cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     /** Returns the function info for a macro function referred by the
566cdf0e10cSrcweir         EXTERN.CALL function, or 0 on error. */
567cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromMacroName( const ::rtl::OUString& rFuncName ) const;
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     /** Returns the library type associated with the passed URL of a function
570cdf0e10cSrcweir         library (function add-in). */
571cdf0e10cSrcweir     FunctionLibraryType getFuncLibTypeFromLibraryName( const ::rtl::OUString& rLibraryName ) const;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir protected:
574cdf0e10cSrcweir     /** Returns the list of all function infos. */
575cdf0e10cSrcweir     const FunctionInfoVector& getFuncs() const;
576cdf0e10cSrcweir 
577cdf0e10cSrcweir private:
578cdf0e10cSrcweir     typedef ::boost::shared_ptr< FunctionProviderImpl > FunctionProviderImplRef;
579cdf0e10cSrcweir     FunctionProviderImplRef mxFuncImpl;     /// Shared implementation between all copies of the provider.
580cdf0e10cSrcweir };
581cdf0e10cSrcweir 
582cdf0e10cSrcweir // Op-code and function provider ==============================================
583cdf0e10cSrcweir 
584cdf0e10cSrcweir struct OpCodeProviderImpl;
585cdf0e10cSrcweir 
586cdf0e10cSrcweir /** Provides access to API op-codes for all available formula tokens and to
587cdf0e10cSrcweir     function info structs for all available sheet functions.
588cdf0e10cSrcweir  */
589cdf0e10cSrcweir class OpCodeProvider : public FunctionProvider // not derived from WorkbookHelper to make it usable as UNO service
590cdf0e10cSrcweir {
591cdf0e10cSrcweir public:
592cdf0e10cSrcweir     explicit            OpCodeProvider(
593cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory,
594cdf0e10cSrcweir                             FilterType eFilter, BiffType eBiff, bool bImportFilter );
595cdf0e10cSrcweir     virtual             ~OpCodeProvider();
596cdf0e10cSrcweir 
597cdf0e10cSrcweir     /** Returns the structure containing all token op-codes for operators and
598cdf0e10cSrcweir         special tokens used by the Calc document and its formula parser. */
599cdf0e10cSrcweir     const ApiOpCodes&   getOpCodes() const;
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     /** Returns the function info for an API token, or 0 on error. */
602cdf0e10cSrcweir     const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const;
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     /** Returns the op-code map that is used by the OOXML formula parser. */
605cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry >
606cdf0e10cSrcweir                         getOoxParserMap() const;
607cdf0e10cSrcweir 
608cdf0e10cSrcweir private:
609cdf0e10cSrcweir     typedef ::boost::shared_ptr< OpCodeProviderImpl > OpCodeProviderImplRef;
610cdf0e10cSrcweir     OpCodeProviderImplRef mxOpCodeImpl;     /// Shared implementation between all copies of the provider.
611cdf0e10cSrcweir };
612cdf0e10cSrcweir 
613cdf0e10cSrcweir // API formula parser wrapper =================================================
614cdf0e10cSrcweir 
615cdf0e10cSrcweir /** A wrapper around the FormulaParser service provided by the Calc document. */
616cdf0e10cSrcweir class ApiParserWrapper : public OpCodeProvider
617cdf0e10cSrcweir {
618cdf0e10cSrcweir public:
619cdf0e10cSrcweir     explicit            ApiParserWrapper(
620cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory,
621cdf0e10cSrcweir                             const OpCodeProvider& rOpCodeProv );
622cdf0e10cSrcweir 
623cdf0e10cSrcweir     /** Returns read/write access to the formula parser property set. */
getParserProperties()624cdf0e10cSrcweir     inline PropertySet& getParserProperties() { return maParserProps; }
625cdf0e10cSrcweir 
626cdf0e10cSrcweir     /** Calls the XFormulaParser::parseFormula() function of the API parser. */
627cdf0e10cSrcweir     ApiTokenSequence    parseFormula(
628cdf0e10cSrcweir                             const ::rtl::OUString& rFormula,
629cdf0e10cSrcweir                             const ::com::sun::star::table::CellAddress& rRefPos );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir private:
632cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser >
633cdf0e10cSrcweir                         mxParser;
634cdf0e10cSrcweir     PropertySet         maParserProps;
635cdf0e10cSrcweir };
636cdf0e10cSrcweir 
637cdf0e10cSrcweir // Formula parser/printer base class for filters ==============================
638cdf0e10cSrcweir 
639cdf0e10cSrcweir /** Base class for import formula parsers and export formula compilers. */
640cdf0e10cSrcweir class FormulaProcessorBase : public OpCodeProvider, protected ApiOpCodes, public WorkbookHelper
641cdf0e10cSrcweir {
642cdf0e10cSrcweir public:
643cdf0e10cSrcweir     explicit            FormulaProcessorBase( const WorkbookHelper& rHelper );
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     // ------------------------------------------------------------------------
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     /** Generates a cell address string in A1 notation from the passed cell
648cdf0e10cSrcweir         address.
649cdf0e10cSrcweir 
650cdf0e10cSrcweir         @param rAddress  The cell address containing column and row index.
651cdf0e10cSrcweir         @param bAbsolute  True = adds dollar signs before column and row.
652cdf0e10cSrcweir      */
653cdf0e10cSrcweir     static ::rtl::OUString generateAddress2dString(
654cdf0e10cSrcweir                             const ::com::sun::star::table::CellAddress& rAddress,
655cdf0e10cSrcweir                             bool bAbsolute );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir     /** Generates a cell address string in A1 notation from the passed binary
658cdf0e10cSrcweir         cell address.
659cdf0e10cSrcweir 
660cdf0e10cSrcweir         @param rAddress  The cell address containing column and row index.
661cdf0e10cSrcweir         @param bAbsolute  True = adds dollar signs before column and row.
662cdf0e10cSrcweir      */
663cdf0e10cSrcweir     static ::rtl::OUString generateAddress2dString(
664cdf0e10cSrcweir                             const BinAddress& rAddress,
665cdf0e10cSrcweir                             bool bAbsolute );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     /** Generates a cell range string in A1:A1 notation from the passed cell
668cdf0e10cSrcweir         range address.
669cdf0e10cSrcweir 
670cdf0e10cSrcweir         @param rRange  The cell range address containing column and row indexes.
671cdf0e10cSrcweir         @param bAbsolute  True = adds dollar signs before columns and rows.
672cdf0e10cSrcweir      */
673cdf0e10cSrcweir     static ::rtl::OUString generateRange2dString(
674cdf0e10cSrcweir                             const ::com::sun::star::table::CellRangeAddress& rRange,
675cdf0e10cSrcweir                             bool bAbsolute );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     /** Generates a cell range string in A1:A1 notation from the passed binary
678cdf0e10cSrcweir         cell range address.
679cdf0e10cSrcweir 
680cdf0e10cSrcweir         @param rRange  The cell range address containing column and row indexes.
681cdf0e10cSrcweir         @param bAbsolute  True = adds dollar signs before columns and rows.
682cdf0e10cSrcweir      */
683cdf0e10cSrcweir     static ::rtl::OUString generateRange2dString(
684cdf0e10cSrcweir                             const BinRange& rRange,
685cdf0e10cSrcweir                             bool bAbsolute );
686cdf0e10cSrcweir 
687cdf0e10cSrcweir     /** Generates a cell range list string in A1:A1 notation from the passed
688cdf0e10cSrcweir         cell range addresses. May enclose multiple ranges into parentheses.
689cdf0e10cSrcweir 
690cdf0e10cSrcweir         @param rRanges  The list of cell range addresses.
691cdf0e10cSrcweir         @param bAbsolute  True = adds dollar signs before columns and rows.
692cdf0e10cSrcweir         @param cSeparator  Separator character between ranges.
693cdf0e10cSrcweir         @param bEncloseMultiple  True = enclose multiple ranges in parentheses.
694cdf0e10cSrcweir      */
695cdf0e10cSrcweir     static ::rtl::OUString generateRangeList2dString(
696cdf0e10cSrcweir                             const ApiCellRangeList& rRanges,
697cdf0e10cSrcweir                             bool bAbsolute,
698cdf0e10cSrcweir                             sal_Unicode cSeparator,
699cdf0e10cSrcweir                             bool bEncloseMultiple );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     // ------------------------------------------------------------------------
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     /** Generates a cell address string in Calc's absolute $Sheet.$A$1 notation
704cdf0e10cSrcweir         from the passed cell address.
705cdf0e10cSrcweir 
706cdf0e10cSrcweir         @param rAddress  The cell address to be converted to a string.
707cdf0e10cSrcweir      */
708cdf0e10cSrcweir     ::rtl::OUString     generateApiAddressString(
709cdf0e10cSrcweir                             const ::com::sun::star::table::CellAddress& rAddress ) const;
710cdf0e10cSrcweir 
711cdf0e10cSrcweir     /** Generates a cell range string in Calc's absolute $Sheet.$A$1:$A$
712cdf0e10cSrcweir         notation from the passed cell range address.
713cdf0e10cSrcweir 
714cdf0e10cSrcweir         @param rRange  The cell range address to be converted to a string.
715cdf0e10cSrcweir      */
716cdf0e10cSrcweir     ::rtl::OUString     generateApiRangeString(
717cdf0e10cSrcweir                             const ::com::sun::star::table::CellRangeAddress& rRange ) const;
718cdf0e10cSrcweir 
719cdf0e10cSrcweir     /** Generates a cell range list string in Calc's absolute $Sheet.$A$1:$A$1
720cdf0e10cSrcweir         notation from the passed cell range addresses.
721cdf0e10cSrcweir 
722cdf0e10cSrcweir         @param rRanges  The list of cell ranges to be converted to a string.
723cdf0e10cSrcweir      */
724cdf0e10cSrcweir     ::rtl::OUString     generateApiRangeListString( const ApiCellRangeList& rRanges ) const;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir     /** Generates a string in Calc formula notation from the passed string.
727cdf0e10cSrcweir 
728cdf0e10cSrcweir         @param rString  The string value.
729cdf0e10cSrcweir 
730cdf0e10cSrcweir         @return  The string enclosed in double quotes, where all contained
731cdf0e10cSrcweir             quote characters are doubled.
732cdf0e10cSrcweir      */
733cdf0e10cSrcweir     static ::rtl::OUString generateApiString( const ::rtl::OUString& rString );
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     /** Generates an array string in Calc formula notation from the passed
736cdf0e10cSrcweir         matrix with Any's containing double values or strings.
737cdf0e10cSrcweir 
738cdf0e10cSrcweir         @param rMatrix  The matrix containing double values or strings.
739cdf0e10cSrcweir      */
740cdf0e10cSrcweir     static ::rtl::OUString generateApiArray( const Matrix< ::com::sun::star::uno::Any >& rMatrix );
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     // ------------------------------------------------------------------------
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     /** Tries to extract a single cell reference from a formula token sequence.
745cdf0e10cSrcweir 
746cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. Should contain exactly
747cdf0e10cSrcweir             one address token or cell range address token. The token sequence
748cdf0e10cSrcweir             may contain whitespace tokens.
749cdf0e10cSrcweir 
750cdf0e10cSrcweir         @return  If the token sequence is valid, this function returns an Any
751cdf0e10cSrcweir             containing a com.sun.star.sheet.SingleReference object, or a
752cdf0e10cSrcweir             com.sun.star.sheet.ComplexReference object. If the token sequence
753cdf0e10cSrcweir             contains too many, or unexpected tokens, an empty Any is returned.
754cdf0e10cSrcweir      */
755cdf0e10cSrcweir     ::com::sun::star::uno::Any
756cdf0e10cSrcweir                         extractReference( const ApiTokenSequence& rTokens ) const;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir     /** Tries to extract a single cell address from a formula token sequence.
759cdf0e10cSrcweir 
760cdf0e10cSrcweir         @param orAddress  (output parameter) If the token sequence is valid,
761cdf0e10cSrcweir             this parameter will contain the extracted cell address. If the
762cdf0e10cSrcweir             token sequence contains unexpected tokens, nothing meaningful is
763cdf0e10cSrcweir             inserted, and the function returns false.
764cdf0e10cSrcweir 
765cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. Should contain exactly
766cdf0e10cSrcweir             one cell address token. The token sequence may contain whitespace
767cdf0e10cSrcweir             tokens.
768cdf0e10cSrcweir 
769cdf0e10cSrcweir         @param bAllowRelative  True = it is allowed that rTokens contains
770cdf0e10cSrcweir             relative references (based on cell A1 of the current sheet).
771cdf0e10cSrcweir             False = only real absolute references will be accepted.
772cdf0e10cSrcweir 
773cdf0e10cSrcweir         @return  True, if the token sequence contains a valid cell address
774cdf0e10cSrcweir             which has been extracted to orAddress, false otherwise.
775cdf0e10cSrcweir      */
776cdf0e10cSrcweir     bool                extractCellAddress(
777cdf0e10cSrcweir                             ::com::sun::star::table::CellAddress& orAddress,
778cdf0e10cSrcweir                             const ApiTokenSequence& rTokens,
779cdf0e10cSrcweir                             bool bAllowRelative ) const;
780cdf0e10cSrcweir 
781cdf0e10cSrcweir     /** Tries to extract a cell range address from a formula token sequence.
782cdf0e10cSrcweir 
783cdf0e10cSrcweir         @param orAddress  (output parameter) If the token sequence is valid,
784cdf0e10cSrcweir             this parameter will contain the extracted cell range address. If
785cdf0e10cSrcweir             the token sequence contains unexpected tokens, nothing meaningful
786cdf0e10cSrcweir             is inserted, and the function returns false.
787cdf0e10cSrcweir 
788cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. Should contain exactly
789cdf0e10cSrcweir             one cell range address token. The token sequence may contain
790cdf0e10cSrcweir             whitespace tokens.
791cdf0e10cSrcweir 
792cdf0e10cSrcweir         @param bAllowRelative  True = it is allowed that rTokens contains
793cdf0e10cSrcweir             relative references (based on cell A1 of the current sheet).
794cdf0e10cSrcweir             False = only real absolute references will be accepted.
795cdf0e10cSrcweir 
796cdf0e10cSrcweir         @return  True, if the token sequence contains a valid cell range
797cdf0e10cSrcweir             address which has been extracted to orRange, false otherwise.
798cdf0e10cSrcweir      */
799cdf0e10cSrcweir     bool                extractCellRange(
800cdf0e10cSrcweir                             ::com::sun::star::table::CellRangeAddress& orRange,
801cdf0e10cSrcweir                             const ApiTokenSequence& rTokens,
802cdf0e10cSrcweir                             bool bAllowRelative ) const;
803cdf0e10cSrcweir 
804cdf0e10cSrcweir     /** Tries to extract a cell range list from a formula token sequence.
805cdf0e10cSrcweir 
806cdf0e10cSrcweir         @param orRanges  (output parameter) If the token sequence is valid,
807cdf0e10cSrcweir             this parameter will contain the extracted cell range list. Deleted
808cdf0e10cSrcweir             cells or cell ranges (shown as #REF! error in a formula) will be
809cdf0e10cSrcweir             skipped. If the token sequence contains unexpected tokens, an empty
810cdf0e10cSrcweir             list is returned here.
811cdf0e10cSrcweir 
812cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. Should contain cell
813cdf0e10cSrcweir             address tokens or cell range address tokens, separated by the
814cdf0e10cSrcweir             standard function parameter separator token. The token sequence may
815cdf0e10cSrcweir             contain parentheses and whitespace tokens.
816cdf0e10cSrcweir 
817cdf0e10cSrcweir         @param bAllowRelative  True = it is allowed that rTokens contains
818cdf0e10cSrcweir             relative references (based on cell A1 of the current sheet).
819cdf0e10cSrcweir             False = only real absolute references will be accepted.
820cdf0e10cSrcweir 
821cdf0e10cSrcweir         @param nFilterBySheet  If non-negative, this function returns only cell
822cdf0e10cSrcweir             ranges located in the specified sheet, otherwise returns all cell
823cdf0e10cSrcweir             ranges contained in the token sequence.
824cdf0e10cSrcweir      */
825cdf0e10cSrcweir     void                extractCellRangeList(
826cdf0e10cSrcweir                             ApiCellRangeList& orRanges,
827cdf0e10cSrcweir                             const ApiTokenSequence& rTokens,
828cdf0e10cSrcweir                             bool bAllowRelative,
829cdf0e10cSrcweir                             sal_Int32 nFilterBySheet = -1 ) const;
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     /** Tries to extract a string from a formula token sequence.
832cdf0e10cSrcweir 
833cdf0e10cSrcweir         @param orString  (output parameter) The extracted string.
834cdf0e10cSrcweir 
835cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. Should contain exactly
836cdf0e10cSrcweir             one string token, may contain whitespace tokens.
837cdf0e10cSrcweir 
838cdf0e10cSrcweir         @return  True = token sequence is valid, output parameter orString
839cdf0e10cSrcweir             contains the string extracted from the token sequence.
840cdf0e10cSrcweir      */
841cdf0e10cSrcweir     bool                extractString(
842cdf0e10cSrcweir                             ::rtl::OUString& orString,
843cdf0e10cSrcweir                             const ApiTokenSequence& rTokens ) const;
844cdf0e10cSrcweir 
845cdf0e10cSrcweir     /** Tries to extract information about a special token used for array
846cdf0e10cSrcweir         formulas, shared formulas, or table operations.
847cdf0e10cSrcweir 
848cdf0e10cSrcweir         @param orTokenInfo  (output parameter) The extracted information about
849cdf0e10cSrcweir             the token. Contains the base address and the token type (sal_False
850cdf0e10cSrcweir             for array or shared formulas, sal_True for table operations).
851cdf0e10cSrcweir 
852cdf0e10cSrcweir         @param rTokens  The token sequence to be parsed. If it contains exactly
853cdf0e10cSrcweir             one OPCODE_BAD token with special token information, this
854cdf0e10cSrcweir             information will be extracted.
855cdf0e10cSrcweir 
856cdf0e10cSrcweir         @return  True = token sequence is valid, output parameter orTokenInfo
857cdf0e10cSrcweir             contains the token information extracted from the token sequence.
858cdf0e10cSrcweir      */
859cdf0e10cSrcweir     bool                extractSpecialTokenInfo(
860cdf0e10cSrcweir                             ApiSpecialTokenInfo& orTokenInfo,
861cdf0e10cSrcweir                             const ApiTokenSequence& rTokens ) const;
862cdf0e10cSrcweir 
863cdf0e10cSrcweir     /** Converts a single string with separators in the passed formula token
864cdf0e10cSrcweir         sequence to a list of string tokens.
865cdf0e10cSrcweir 
866cdf0e10cSrcweir         @param orTokens  (input/output parameter) Expects a single string token
867cdf0e10cSrcweir             in this token sequence (whitespace tokens are allowed). The string
868cdf0e10cSrcweir             is split into substrings. A list of string tokens separated with
869cdf0e10cSrcweir             parameter separator tokens is returned in this psrameter.
870cdf0e10cSrcweir 
871cdf0e10cSrcweir         @param cStringSep  The separator character used to split the input
872cdf0e10cSrcweir             string.
873cdf0e10cSrcweir 
874cdf0e10cSrcweir         @param bTrimLeadingSpaces  True = removes leading whitespace from all
875cdf0e10cSrcweir             substrings inserted into the formula token sequence.
876cdf0e10cSrcweir      */
877cdf0e10cSrcweir     void                convertStringToStringList(
878cdf0e10cSrcweir                             ApiTokenSequence& orTokens,
879cdf0e10cSrcweir                             sal_Unicode cStringSep,
880cdf0e10cSrcweir                             bool bTrimLeadingSpaces ) const;
881cdf0e10cSrcweir };
882cdf0e10cSrcweir 
883cdf0e10cSrcweir // ============================================================================
884cdf0e10cSrcweir 
885cdf0e10cSrcweir } // namespace xls
886cdf0e10cSrcweir } // namespace oox
887cdf0e10cSrcweir 
888cdf0e10cSrcweir #endif
889