LibreOffice Module sc (master)  1
formulabase.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FORMULABASE_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_FORMULABASE_HXX
22 
23 #include <com/sun/star/beans/Pair.hpp>
24 #include <com/sun/star/sheet/FormulaToken.hpp>
25 #include <com/sun/star/table/CellAddress.hpp>
27 #include <oox/helper/refvector.hxx>
28 #include "workbookhelper.hxx"
29 
30 namespace com::sun::star {
31  namespace lang { class XMultiServiceFactory; }
32  namespace sheet { class XFormulaParser; }
33 }
34 
35 namespace oox { template< typename Type > class Matrix; }
36 namespace com::sun::star::sheet { struct FormulaOpCodeMapEntry; }
37 namespace oox { class SequenceInputStream; }
38 namespace oox::xls { struct BinAddress; }
39 class ScRangeList;
40 
41 namespace oox::xls {
42 
43 // Constants ==================================================================
44 
45 const size_t BIFF_TOKARR_MAXLEN = 4096;
46 
47 // token class flags ----------------------------------------------------------
48 
54 
56 
57 // base token identifiers -----------------------------------------------------
58 
60 
61 const sal_uInt8 BIFF_TOKID_NONE = 0x00;
62 const sal_uInt8 BIFF_TOKID_EXP = 0x01;
63 const sal_uInt8 BIFF_TOKID_TBL = 0x02;
64 const sal_uInt8 BIFF_TOKID_ADD = 0x03;
65 const sal_uInt8 BIFF_TOKID_SUB = 0x04;
66 const sal_uInt8 BIFF_TOKID_MUL = 0x05;
67 const sal_uInt8 BIFF_TOKID_DIV = 0x06;
70 const sal_uInt8 BIFF_TOKID_LT = 0x09;
71 const sal_uInt8 BIFF_TOKID_LE = 0x0A;
72 const sal_uInt8 BIFF_TOKID_EQ = 0x0B;
73 const sal_uInt8 BIFF_TOKID_GE = 0x0C;
74 const sal_uInt8 BIFF_TOKID_GT = 0x0D;
75 const sal_uInt8 BIFF_TOKID_NE = 0x0E;
77 const sal_uInt8 BIFF_TOKID_LIST = 0x10;
84 const sal_uInt8 BIFF_TOKID_STR = 0x17;
85 const sal_uInt8 BIFF_TOKID_NLR = 0x18;
86 const sal_uInt8 BIFF_TOKID_ATTR = 0x19;
89 const sal_uInt8 BIFF_TOKID_ERR = 0x1C;
90 const sal_uInt8 BIFF_TOKID_BOOL = 0x1D;
91 const sal_uInt8 BIFF_TOKID_INT = 0x1E;
92 const sal_uInt8 BIFF_TOKID_NUM = 0x1F;
93 
94 // base identifiers of classified tokens --------------------------------------
95 
97 const sal_uInt8 BIFF_TOKID_FUNC = 0x01;
99 const sal_uInt8 BIFF_TOKID_NAME = 0x03;
100 const sal_uInt8 BIFF_TOKID_REF = 0x04;
118 
119 // specific token constants ---------------------------------------------------
120 
125 
128 
138 
146 
147 const sal_uInt16 BIFF_TOK_FUNCVAR_CMD = 0x8000;
148 const sal_uInt16 BIFF_TOK_FUNCVAR_FUNCIDMASK = 0x7FFF;
151 
152 const sal_uInt16 BIFF12_TOK_REF_COLMASK = 0x3FFF;
153 const sal_Int32 BIFF12_TOK_REF_ROWMASK = 0xFFFFF;
154 const sal_uInt16 BIFF12_TOK_REF_COLREL = 0x4000;
155 const sal_uInt16 BIFF12_TOK_REF_ROWREL = 0x8000;
156 
157 const sal_uInt16 BIFF_TOK_REF_COLMASK = 0x00FF;
158 const sal_uInt16 BIFF_TOK_REF_ROWMASK = 0x3FFF;
159 const sal_uInt16 BIFF_TOK_REF_COLREL = 0x4000;
160 const sal_uInt16 BIFF_TOK_REF_ROWREL = 0x8000;
161 
162 const sal_uInt16 BIFF12_TOK_TABLE_COLUMN = 0x0001;
163 const sal_uInt16 BIFF12_TOK_TABLE_COLRANGE = 0x0002;
164 const sal_uInt16 BIFF12_TOK_TABLE_ALL = 0x0004;
165 const sal_uInt16 BIFF12_TOK_TABLE_HEADERS = 0x0008;
166 const sal_uInt16 BIFF12_TOK_TABLE_DATA = 0x0010;
167 const sal_uInt16 BIFF12_TOK_TABLE_TOTALS = 0x0020;
168 const sal_uInt16 BIFF12_TOK_TABLE_THISROW = 0x0040;
169 const sal_uInt16 BIFF12_TOK_TABLE_SP_BRACKETS = 0x0080;
170 const sal_uInt16 BIFF12_TOK_TABLE_SP_SEP = 0x0100;
171 const sal_uInt16 BIFF12_TOK_TABLE_ROW = 0x0200;
172 const sal_uInt16 BIFF12_TOK_TABLE_CELL = 0x0400;
173 
187 const sal_uInt16 BIFF_TOK_NLR_REL = 0x8000;
188 const sal_uInt16 BIFF_TOK_NLR_MASK = 0x3FFF;
189 
190 const sal_uInt32 BIFF_TOK_NLR_ADDREL = 0x80000000;
191 const sal_uInt32 BIFF_TOK_NLR_ADDMASK = 0x3FFFFFFF;
192 
193 // function constants ---------------------------------------------------------
194 
197 
198 const sal_uInt16 BIFF_FUNC_IF = 1;
199 const sal_uInt16 BIFF_FUNC_SUM = 4;
200 const sal_uInt16 BIFF_FUNC_TRUE = 34;
201 const sal_uInt16 BIFF_FUNC_FALSE = 35;
202 const sal_uInt16 BIFF_FUNC_ROWS = 76;
203 const sal_uInt16 BIFF_FUNC_COLUMNS = 77;
204 const sal_uInt16 BIFF_FUNC_OFFSET = 78;
205 const sal_uInt16 BIFF_FUNC_EXTERNCALL = 255;
206 const sal_uInt16 BIFF_FUNC_FLOOR = 285;
207 const sal_uInt16 BIFF_FUNC_CEILING = 288;
208 const sal_uInt16 BIFF_FUNC_HYPERLINK = 359;
209 const sal_uInt16 BIFF_FUNC_WEEKNUM = 465;
210 
211 // Formula type ===============================================================
212 
214 enum class FormulaType
215 {
216  Cell,
217  Array,
218  SharedFormula,
219  CondFormat,
220  Validation
221 };
222 
223 // Reference helpers ==========================================================
224 
227 {
228  sal_Int32 mnCol;
229  sal_Int32 mnRow;
230  bool mbColRel;
231  bool mbRowRel;
232 
233  explicit BinSingleRef2d();
234 
235  void setBiff12Data( sal_uInt16 nCol, sal_Int32 nRow, bool bRelativeAsOffset );
236 
237  void readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
238 };
239 
242 {
245 
246  void readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
247 };
248 
249 // Token vector, token sequence ===============================================
250 
251 typedef css::sheet::FormulaToken ApiToken;
252 typedef css::uno::Sequence< ApiToken > ApiTokenSequence;
253 
256 typedef css::beans::Pair< css::table::CellAddress, sal_Bool > ApiSpecialTokenInfo;
257 
260 {
261 public:
262  explicit ApiTokenVector();
263 
264  ApiToken& operator[]( size_t i ) { return mvTokens[i]; }
265 
266  size_t size() const { return mvTokens.size(); }
267 
268  ApiToken& back() { return mvTokens.back(); }
269  const ApiToken& back() const { return mvTokens.back(); }
270 
271  void clear() { mvTokens.clear(); }
272 
273  void pop_back() { mvTokens.pop_back(); }
274 
275  void push_back( const ApiToken& rToken ) { mvTokens.push_back( rToken ); }
276 
277  void reserve( size_t n ) { mvTokens.reserve( n ); }
278 
279  void resize( size_t n ) { mvTokens.resize( n ); }
280 
282  css::uno::Any& append( sal_Int32 nOpCode );
283 
285  template< typename Type >
286  void append( sal_Int32 nOpCode, const Type& rData ) { append( nOpCode ) <<= rData; }
287 
289  ApiTokenSequence toSequence() const;
290 
291 private:
292  ::std::vector< ApiToken > mvTokens;
293 };
294 
295 // Token sequence iterator ====================================================
296 
299 {
300 public:
301  explicit ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode );
302  bool is() const { return mpToken != mpTokenEnd; }
303  const ApiToken* operator->() const { return mpToken; }
304 
306 
307 private:
308  void skipSpaces();
309 
310 private:
311  const ApiToken* mpToken;
312  const ApiToken* mpTokenEnd;
313  const sal_Int32 mnSpacesOpCode;
314 };
315 
316 // List of API op-codes =======================================================
317 
320 {
321  // special
322  sal_Int32 OPCODE_UNKNOWN;
323  sal_Int32 OPCODE_EXTERNAL;
324  // formula structure
325  sal_Int32 OPCODE_PUSH;
326  sal_Int32 OPCODE_MISSING;
327  sal_Int32 OPCODE_SPACES;
328  sal_Int32 OPCODE_NAME;
329  sal_Int32 OPCODE_DBAREA;
330  sal_Int32 OPCODE_NLR;
331  sal_Int32 OPCODE_DDE;
332  sal_Int32 OPCODE_MACRO;
333  sal_Int32 OPCODE_BAD;
334  sal_Int32 OPCODE_NONAME;
335  // separators
336  sal_Int32 OPCODE_OPEN;
337  sal_Int32 OPCODE_CLOSE;
338  sal_Int32 OPCODE_SEP;
339  // array separators
340  sal_Int32 OPCODE_ARRAY_OPEN;
341  sal_Int32 OPCODE_ARRAY_CLOSE;
344  // unary operators
345  sal_Int32 OPCODE_PLUS_SIGN;
346  sal_Int32 OPCODE_MINUS_SIGN;
347  sal_Int32 OPCODE_PERCENT;
348  // binary operators
349  sal_Int32 OPCODE_ADD;
350  sal_Int32 OPCODE_SUB;
351  sal_Int32 OPCODE_MULT;
352  sal_Int32 OPCODE_DIV;
353  sal_Int32 OPCODE_POWER;
354  sal_Int32 OPCODE_CONCAT;
355  sal_Int32 OPCODE_EQUAL;
356  sal_Int32 OPCODE_NOT_EQUAL;
357  sal_Int32 OPCODE_LESS;
358  sal_Int32 OPCODE_LESS_EQUAL;
359  sal_Int32 OPCODE_GREATER;
361  sal_Int32 OPCODE_INTERSECT;
362  sal_Int32 OPCODE_LIST;
363  sal_Int32 OPCODE_RANGE;
364 };
365 
366 // Function parameter info ====================================================
367 
370 {
371  Regular,
372  CalcOnly,
373  ExcelOnly
374 };
375 
457 {
459 };
460 
461 // Function data ==============================================================
462 
466 {
469 };
470 
480 {
481  OUString maOdfFuncName;
482  OUString maOoxFuncName;
483  OUString maBiffMacroName;
484  OUString maExtProgName;
486  sal_Int32 mnApiOpCode;
487  sal_uInt16 mnBiff12FuncId;
488  sal_uInt16 mnBiffFuncId;
494  bool mbVolatile;
495  bool mbExternal;
496  bool mbInternal;
497  bool mbMacroFunc;
498  bool mbVarParam;
499 };
500 
502 
503 // Function info parameter class iterator =====================================
504 
514 {
515 public:
516  explicit FunctionParamInfoIterator( const FunctionInfo& rFuncInfo );
517 
518  bool isCalcOnlyParam() const;
519  bool isExcelOnlyParam() const;
521 
522 private:
526 };
527 
528 // Base function provider =====================================================
529 
530 struct FunctionProviderImpl;
531 
534 class FunctionProvider // not derived from WorkbookHelper to make it usable in file dumpers
535 {
536 public:
537  explicit FunctionProvider(bool bImportFilter);
538  virtual ~FunctionProvider();
539 
540  FunctionProvider(FunctionProvider const &) = default;
541  FunctionProvider(FunctionProvider &&) = default;
542  FunctionProvider & operator =(FunctionProvider const &) = delete;
544 
546  const FunctionInfo* getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const;
547 
549  const FunctionInfo* getFuncInfoFromBiff12FuncId( sal_uInt16 nFuncId ) const;
550 
553  const FunctionInfo* getFuncInfoFromMacroName( const OUString& rFuncName ) const;
554 
557  static FunctionLibraryType getFuncLibTypeFromLibraryName( const OUString& rLibraryName );
558 
559 protected:
561  const FunctionInfoVector& getFuncs() const;
562 
563 private:
564  typedef std::shared_ptr< FunctionProviderImpl > FunctionProviderImplRef;
565  FunctionProviderImplRef mxFuncImpl;
566 };
567 
568 // Op-code and function provider ==============================================
569 
570 struct OpCodeProviderImpl;
571 
575 class OpCodeProvider : public FunctionProvider // not derived from WorkbookHelper to make it usable as UNO service
576 {
577 public:
578  explicit OpCodeProvider(const css::uno::Reference<css::lang::XMultiServiceFactory>& rxModelFactory,
579  bool bImportFilter);
580  virtual ~OpCodeProvider() override;
581 
582  OpCodeProvider(OpCodeProvider const &) = default;
583  OpCodeProvider(OpCodeProvider &&) = default;
584  OpCodeProvider & operator =(OpCodeProvider const &) = delete;
586 
589  const ApiOpCodes& getOpCodes() const;
590 
592  const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const;
593 
595  css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry >
596  getOoxParserMap() const;
597 
598 private:
599  typedef std::shared_ptr< OpCodeProviderImpl > OpCodeProviderImplRef;
600  OpCodeProviderImplRef mxOpCodeImpl;
601 };
602 
603 // API formula parser wrapper =================================================
604 
607 {
608 public:
609  explicit ApiParserWrapper(
610  const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory,
611  const OpCodeProvider& rOpCodeProv );
612 
615 
617  ApiTokenSequence parseFormula(
618  const OUString& rFormula,
619  const ScAddress& rRefPos );
620 
621 private:
622  css::uno::Reference< css::sheet::XFormulaParser >
625 };
626 
627 // Formula parser/printer base class for filters ==============================
628 
631 {
632 public:
633  explicit FormulaProcessorBase( const WorkbookHelper& rHelper );
634 
641  static OUString generateAddress2dString(
642  const ScAddress& rAddress,
643  bool bAbsolute );
644 
651  static OUString generateAddress2dString(
652  const BinAddress& rAddress,
653  bool bAbsolute );
654 
662  static OUString generateApiString( const OUString& rString );
663 
669  static OUString generateApiArray( const Matrix< css::uno::Any >& rMatrix );
670 
682  css::uno::Any
683  extractReference( const ApiTokenSequence& rTokens ) const;
684 
700  bool extractCellRange(
701  ScRange& orRange,
702  const ApiTokenSequence& rTokens ) const;
703 
723  ScRangeList& orRanges,
724  const ApiTokenSequence& rTokens,
725  sal_Int32 nFilterBySheet ) const;
726 
737  bool extractString(
738  OUString& orString,
739  const ApiTokenSequence& rTokens ) const;
740 
756  ApiSpecialTokenInfo& orTokenInfo,
757  const ApiTokenSequence& rTokens ) const;
758 
774  ApiTokenSequence& orTokens,
775  sal_Unicode cStringSep,
776  bool bTrimLeadingSpaces ) const;
777 };
778 
779 } // namespace oox::xls
780 
781 #endif
782 
783 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
sal_Int32 OPCODE_EXTERNAL
Internal: function name unknown to mapper.
sal_Int32 OPCODE_PERCENT
Unary minus sign.
Type
const sal_uInt8 BIFF_TOKID_MEMNOMEM
Deleted reference subexpression.
const sal_uInt8 BIFF_TOKID_AREA
2D cell reference.
sal_Int32 OPCODE_OPEN
Function style #NAME? error.
bool mbMacroFunc
True = internal function in Calc. (Both can be true!)
Iterator working on the mpParamInfos member of the FunctionInfo struct.
const sal_uInt8 BIFF_TOKID_UPLUS
Range operator.
Definition: formulabase.hxx:79
BinSingleRef2d maRef2
Start (top-left) cell address.
const sal_uInt8 BIFF_TOKID_AREAN
Relative 2D cell reference (in names).
bool mbColRel
Row index.
const FunctionParamInfo * mpParamInfoEnd
sal_Int32 OPCODE_CLOSE
Opening parenthesis.
Condition of a conditional format rule.
const sal_uInt8 BIFF_TOKID_ARRAY
Floating-point constant.
Definition: formulabase.hxx:96
const sal_uInt8 BIFF_TOK_ATTR_SKIP
Jump array of CHOOSE function.
OUString maBiffMacroName
OOXML function name.
void push_back(const ApiToken &rToken)
sal_Int32 OPCODE_EQUAL
String concatenation operator.
A 2D cell address struct for binary filters.
const sal_uInt16 BIFF_TOK_NLR_REL
NLR: Pivot table name.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_CLOSE
Line breaks before opening parenthesis.
const sal_uInt8 BIFF_TOKFLAG_INVALID
60-7F: Array class tokens.
Definition: formulabase.hxx:55
const FunctionParamInfo * mpParamInfos
BIFF token class of the return value.
const sal_uInt8 BIFF_TOKID_REF3D
External reference.
const sal_Int32 BIFF12_TOK_REF_ROWMASK
Mask to extract column from reference (BIFF12).
sal_Int32 OPCODE_MACRO
DDE link function.
const sal_uInt16 BIFF12_TOK_REF_ROWREL
True = column is relative (BIFF12).
FunctionProvider & operator=(FunctionProvider const &)=delete
Simple cell formula, or reference to a shared formula name.
const sal_uInt8 BIFF_TOKID_LIST
Intersection operator.
Definition: formulabase.hxx:77
bool mbExternal
True = volatile function.
sal_Int32 OPCODE_LIST
Range intersection operator.
const sal_uInt8 BIFF_TOKID_LT
String concatenation operator.
Definition: formulabase.hxx:70
const sal_uInt16 BIFF_TOK_FUNCVAR_FUNCIDMASK
Macro command.
Contains all API op-codes needed to build formulas with tokens.
FunctionProvider(bool bImportFilter)
sal_Int32 OPCODE_RANGE
Range list operator.
const FunctionInfo * getFuncInfoFromApiToken(const ApiToken &rToken) const
Returns the function info for an API token, or 0 on error.
const sal_uInt8 BIFF_TOKID_MEMFUNC
Constant reference subexpression without result.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR
Spaces before next token.
sal_Int32 OPCODE_NOT_EQUAL
Compare equal operator.
const sal_uInt8 BIFF_TOK_FUNCVAR_CMDPROMPT
Mask for function/command index.
sal_Int32 OPCODE_POWER
Division operator.
OUString maExtProgName
Expected macro name in EXTERN.CALL function.
const sal_uInt8 BIFF_TOKID_NE
Greater than operator.
Definition: formulabase.hxx:75
const sal_uInt16 BIFF_FUNC_ROWS
Function identifier of the FALSE function.
const sal_uInt8 BIFF_TOKCLASS_VAL
20-3F: Reference class tokens.
Definition: formulabase.hxx:52
const sal_uInt8 BIFF_TOK_NLR_SCOLR
Stacked NLR: Row index.
sal_Int32 OPCODE_ARRAY_COLSEP
Row separator in constant arrays.
Structure that contains all needed information for a parameter in a function.
css::sheet::FormulaToken ApiToken
const sal_uInt8 BIFF_TOKID_REF
Defined name.
const FunctionInfoVector & getFuncs() const
Returns the list of all function infos.
const sal_uInt8 BIFF_TOKID_EXP
Placeholder for invalid token id.
Definition: formulabase.hxx:62
const sal_uInt8 BIFF_TOKID_FUNCVAR
Function, fixed number of arguments.
Definition: formulabase.hxx:98
bool mbVarParam
True = macro sheet function or command.
const sal_uInt8 BIFF_TOKCLASS_REF
00-1F: Base tokens.
Definition: formulabase.hxx:51
const sal_uInt8 BIFF_TOKID_REFERR3D
3D area reference.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR_CLOSE
Spaces before closing parenthesis.
sal_Int32 OPCODE_PUSH
External function call (e.g. add-ins).
RefVector< FunctionInfo > FunctionInfoVector
const sal_uInt8 BIFF_TOK_NLR_ROWR
NLR: Invalid/deleted.
sal_Int32 OPCODE_MISSING
Op-code for common value operands.
const sal_uInt16 BIFF_FUNC_HYPERLINK
Function identifier of the CEILING function.
css::uno::Any & append(sal_Int32 nOpCode)
Appends a new token with the passed op-code, returns its data field.
const sal_uInt16 BIFF12_TOK_TABLE_DATA
Table reference: Special [#Headers] range.
const sal_uInt16 BIFF_FUNC_EXTERNCALL
Function identifier of the OFFSET function.
exports com.sun.star. sheet
const sal_uInt8 BIFF_TOKID_FUNCCE
Reference subexpression (in names) without result.
const size_t BIFF_TOKARR_MAXLEN
Definition: formulabase.hxx:45
sal_Int32 OPCODE_PLUS_SIGN
Column separator in constant arrays.
const sal_Int32 mnSpacesOpCode
Pointer behind last token of the token sequence.
OpCodeProvider & operator=(OpCodeProvider const &)=delete
sal_uInt16 sal_Unicode
const sal_uInt8 BIFF_TOKID_MEMERR
Constant reference subexpression.
Represents information for a spreadsheet function.
const sal_uInt8 OOX_MAX_PARAMCOUNT
Mask for number of appended ranges.
const sal_uInt8 BIFF_TOKID_PERCENT
Unary minus.
Definition: formulabase.hxx:81
const FunctionInfo * getFuncInfoFromOoxFuncName(const OUString &rFuncName) const
Returns the function info for an OOXML function name, or 0 on error.
const sal_uInt16 BIFF_FUNC_TRUE
Function identifier of the SUM function.
sal_Int32 OPCODE_SUB
Addition operator.
css::uno::Reference< css::sheet::XFormulaParser > mxParser
const sal_uInt8 BIFF_TOK_ARRAY_BOOL
String value in an array.
const sal_uInt8 BIFF_TOKID_NAMEX
const sal_uInt16 BIFF_FUNC_WEEKNUM
Function identifier of the HYPERLINK function.
bool mbParamPairs
Information about all parameters.
const sal_uInt16 BIFF_TOK_NLR_MASK
True = NLR is relative.
bool mbVolatile
True = optional parameters are expected to appear in pairs.
const sal_uInt8 BIFF_TOKID_SUB
Addition operator.
Definition: formulabase.hxx:65
sal_uInt16 mnBiff12FuncId
API function opcode.
const sal_uInt16 BIFF12_TOK_TABLE_COLUMN
True = row is relative.
const sal_uInt8 BIFF_TOKID_FUNC
Array constant.
Definition: formulabase.hxx:97
void append(sal_Int32 nOpCode, const Type &rData)
Appends a new token with the passed op-code and data.
sal_Int32 OPCODE_SEP
Closing parenthesis.
std::shared_ptr< FunctionProviderImpl > FunctionProviderImplRef
const sal_uInt8 BIFF_TOK_ATTR_CHOOSE
Start of true condition in IF function.
Provides access to API op-codes for all available formula tokens and to function info structs for all...
void setBiff12Data(sal_uInt16 nCol, sal_Int32 nRow, bool bRelativeAsOffset)
Definition: formulabase.cxx:93
FunctionProviderImplRef mxFuncImpl
sal_Int32 OPCODE_ARRAY_OPEN
Function parameter separator.
const sal_uInt8 BIFF_TOKID_NONE
Definition: formulabase.hxx:61
css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry > getOoxParserMap() const
Returns the op-code map that is used by the OOXML formula parser.
const sal_uInt32 BIFF_TOK_NLR_ADDREL
Mask to extract BIFF8 column from NLR.
Array (matrix) formula.
bool extractCellRange(ScRange &orRange, const ApiTokenSequence &rTokens) const
Tries to extract a cell range address from a formula token sequence.
const sal_uInt8 BIFF_TOKID_REFN
Deleted 2D area reference.
sal_Int32 OPCODE_NAME
Spaces between other formula tokens.
const sal_uInt8 BIFF_TOK_NLR_SRANGE
NLR: Range.
FormulaProcessorBase(const WorkbookHelper &rHelper)
const sal_uInt16 BIFF12_TOK_TABLE_SP_SEP
Table reference: Spaces in outer brackets.
A 2D formula cell range reference struct with relative flags.
static OUString generateApiString(const OUString &rString)
Generates a string in Calc formula notation from the passed string.
sal_Int32 OPCODE_LESS_EQUAL
Compare less operator.
const sal_uInt8 BIFF_TOKID_CONCAT
Power operator.
Definition: formulabase.hxx:69
const sal_uInt32 BIFF_TOK_NLR_ADDMASK
NLR relative (in appended data).
css::beans::Pair< css::table::CellAddress, sal_Bool > ApiSpecialTokenInfo
Contains the base address and type of a special token representing an array formula or a shared formu...
const sal_uInt8 BIFF_TOK_NLR_SCOLV
Stacked NLR: Value in row.
const sal_uInt8 BIFF_TOKID_DIV
Multiplication operator.
Definition: formulabase.hxx:67
sal_uInt8 mnMinParamCount
BIFF2-BIFF8 function identifier.
const sal_uInt16 BIFF12_TOK_TABLE_ROW
Table reference: Spaces after separators.
FuncParamValidity
Enumerates validity modes for a function parameter.
const sal_uInt16 BIFF12_TOK_TABLE_CELL
Table reference: Single row.
Parameter supported by Calc only.
bool extractSpecialTokenInfo(ApiSpecialTokenInfo &orTokenInfo, const ApiTokenSequence &rTokens) const
Tries to extract information about a special token used for array formulas, shared formulas...
const sal_uInt8 BIFF_TOKID_AREAERR3D
Deleted 3D cell reference.
const sal_uInt16 BIFF_FUNC_FLOOR
BIFF function id of the EXTERN.CALL function.
const sal_uInt8 BIFF_TOKID_ERR
End of a sheet reference (BIFF2-BIFF4).
Definition: formulabase.hxx:89
Shared formula definition.
sal_Int32 OPCODE_ARRAY_CLOSE
Opening brace for constant arrays.
const sal_uInt16 BIFF12_TOK_REF_COLMASK
Mask for parameter count.
const sal_uInt8 BIFF_TOKID_ISECT
Not equal operator.
Definition: formulabase.hxx:76
const sal_uInt8 BIFF_TOKID_MEMAREA
2D area reference.
ApiToken & operator[](size_t i)
sal_Int32 OPCODE_CONCAT
Power operator.
std::shared_ptr< OpCodeProviderImpl > OpCodeProviderImplRef
Base class for import formula parsers and export formula compilers.
sal_Int32 OPCODE_SPACES
Placeholder for a missing function parameter.
sal_Int32 OPCODE_NONAME
Bad token (unknown name, formula error).
const sal_uInt8 BIFF_TOKID_ENDSHEET
Start of a sheet reference (BIFF2-BIFF4).
Definition: formulabase.hxx:88
const sal_uInt8 BIFF_TOK_BOOL_FALSE
Error code in an array.
sal_Int32 OPCODE_DIV
Multiplication operator.
const sal_uInt8 BIFF_TOKID_GE
Equal operator.
Definition: formulabase.hxx:73
const sal_uInt8 BIFF_TOK_ARRAY_STRING
Double value in an array.
const sal_uInt8 BIFF_TOK_NLR_COLR
NLR: Row index.
const sal_uInt8 BIFF_TOK_NLR_ERR
Table reference: Single cell.
FunctionLibraryType meFuncLibType
Programmatic function name for external functions.
const sal_uInt8 BIFF_TOKID_MEMAREAN
Relative 2D area reference (in names).
sal_Int32 OPCODE_GREATER
Compare less or equal operator.
PropertySet & getParserProperties()
Returns read/write access to the formula parser property set.
ApiParserWrapper(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxModelFactory, const OpCodeProvider &rOpCodeProv)
const sal_uInt8 BIFF_TOKID_LE
Less than operator.
Definition: formulabase.hxx:71
static FunctionLibraryType getFuncLibTypeFromLibraryName(const OUString &rLibraryName)
Returns the library type associated with the passed URL of a function library (function add-in)...
const sal_uInt16 BIFF12_TOK_TABLE_SP_BRACKETS
Table reference: Special [#This Row] range.
::std::vector< ApiToken > mvTokens
sal_Int32 OPCODE_GREATER_EQUAL
Compare greater operator.
void convertStringToStringList(ApiTokenSequence &orTokens, sal_Unicode cStringSep, bool bTrimLeadingSpaces) const
Converts a single string with separators in the passed formula token sequence to a list of string tok...
const ApiToken & back() const
const ApiToken * operator->() const
const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_PRE
Line breaks before closing parenthesis.
const sal_uInt8 BIFF_TOKID_AREA3D
3D cell reference.
const sal_uInt8 BIFF_TOK_NLR_ROWV
NLR: Column index.
const sal_uInt8 BIFF_MAX_PARAMCOUNT
Maximum parameter count for OOXML/BIFF12 files.
const sal_uInt8 BIFF_TOK_ATTR_IFERROR
Leading spaces and volatile formula.
sal_Int32 OPCODE_DBAREA
Index of a defined name.
const sal_uInt8 BIFF_TOKID_MISSARG
Parentheses.
Definition: formulabase.hxx:83
sal_Int32 OPCODE_DDE
Natural language reference.
const ApiToken * mpTokenEnd
Pointer to current token of the token sequence.
OpCodeProviderImplRef mxOpCodeImpl
Parameter supported by Calc and Excel.
css::uno::Any extractReference(const ApiTokenSequence &rTokens) const
Tries to extract a single cell reference from a formula token sequence.
const FunctionInfo * getFuncInfoFromMacroName(const OUString &rFuncName) const
Returns the function info for a macro function referred by the EXTERN.CALL function, or 0 on error.
const sal_uInt8 BIFF_TOKID_NAME
Function, variable number of arguments.
Definition: formulabase.hxx:99
const sal_uInt8 BIFF_TOK_NLR_SROWR
Stacked NLR: Range.
BinSingleRef2d()
True = relative row reference.
Definition: formulabase.cxx:85
sal_Int32 mnApiOpCode
The external library this function is part of.
const sal_uInt8 BIFF_TOKID_NUM
Integer constant.
Definition: formulabase.hxx:92
sal_Int32 mnRow
Column index.
ApiTokenSequence toSequence() const
Converts to a sequence.
const sal_uInt8 BIFF_TOK_FUNCVAR_COUNTMASK
User prompt for macro commands.
css::uno::Sequence< ApiToken > ApiTokenSequence
const sal_uInt16 BIFF12_TOK_TABLE_HEADERS
Table reference: Special [#All] range.
const sal_uInt16 BIFF_TOK_REF_ROWREL
True = column is relative.
const sal_uInt8 BIFF_TOKID_MEMNOMEMN
Reference subexpression (in names).
FunctionLibraryType
This enumeration contains constants for all known external libraries containing supported sheet funct...
ApiTokenIterator & operator++()
const sal_uInt8 BIFF_TOK_NLR_SROWV
Stacked NLR: Column index.
const sal_uInt8 BIFF_TOKCLASS_NONE
Definition: formulabase.hxx:50
const sal_uInt16 BIFF12_TOK_TABLE_COLRANGE
Table reference: Single column.
const sal_uInt8 BIFF_TOKID_UMINUS
Unary plus.
Definition: formulabase.hxx:80
virtual ~OpCodeProvider() override
bool extractString(OUString &orString, const ApiTokenSequence &rTokens) const
Tries to extract a string from a formula token sequence.
void extractCellRangeList(ScRangeList &orRanges, const ApiTokenSequence &rTokens, sal_Int32 nFilterBySheet) const
Tries to extract a cell range list from a formula token sequence.
const sal_uInt16 BIFF_TOK_FUNCVAR_CMD
Spaces before formula (BIFF3).
FuncParamValidity meValid
const sal_uInt8 BIFF_TOKID_INT
Boolean constant.
Definition: formulabase.hxx:91
const sal_uInt16 BIFF12_TOK_TABLE_TOTALS
Table reference: Special [#Data] range.
sal_uInt16 mnBiffFuncId
BIFF12 function identifier.
const sal_uInt8 BIFF_TOK_ARRAY_DOUBLE
Deleted 3D area reference.
const sal_uInt16 BIFF_FUNC_FALSE
Function identifier of the TRUE function.
const sal_uInt8 BIFF_TOKID_STR
Missing argument.
Definition: formulabase.hxx:84
unsigned char sal_uInt8
ApiTokenSequence parseFormula(const OUString &rFormula, const ScAddress &rRefPos)
Calls the XFormulaParser::parseFormula() function of the API parser.
sal_Int32 OPCODE_BAD
Macro function call.
const sal_uInt8 BIFF_TOK_NLR_RANGE
NLR: Value in column.
const sal_uInt16 BIFF_TOK_REF_ROWMASK
Mask to extract BIFF8 column from reference.
const sal_uInt8 BIFF_TOK_ATTR_SPACE
BASIC style assignment.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP_OPEN
Line breaks before next token.
const sal_uInt16 BIFF_FUNC_SUM
Function identifier of the IF function.
const sal_uInt8 BIFF_TOKID_MASK
This bit must be null for a valid token identifier.
Definition: formulabase.hxx:59
const sal_uInt8 BIFF_TOK_BOOL_TRUE
FALSE value of a tBool token.
const sal_uInt8 BIFF_TOK_NLR_COLV
NLR: Value in row.
const sal_uInt16 BIFF_TOK_REF_COLMASK
True = row is relative (BIFF12).
static OUString generateAddress2dString(const ScAddress &rAddress, bool bAbsolute)
Generates a cell address string in A1 notation from the passed cell address.
const sal_uInt8 BIFF_TOK_ATTR_VOLATILE
TRUE value of a tBool token.
const FunctionInfo * getFuncInfoFromBiff12FuncId(sal_uInt16 nFuncId) const
Returns the function info for a BIFF12 function index, or 0 on error.
sal_Int32 OPCODE_LESS
Compare not equal operator.
sal_Int32 OPCODE_ADD
Percent sign.
FunctionParamInfoIterator(const FunctionInfo &rFuncInfo)
const sal_uInt8 BIFF_TOK_ARRAY_ERROR
Boolean value in an array.
const sal_uInt8 BIFF_TOKID_PAREN
Percent sign.
Definition: formulabase.hxx:82
OUString maOoxFuncName
ODF function name.
const sal_uInt8 BIFF_TOKID_TBL
Array or shared formula reference.
Definition: formulabase.hxx:63
const sal_uInt16 BIFF_FUNC_IF
Maximum parameter count for BIFF2-BIFF8 files.
bool mbRowRel
True = relative column reference.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_BR_OPEN
Spaces before opening parenthesis.
const sal_uInt16 BIFF12_TOK_REF_COLREL
Mask to extract row from reference (BIFF12).
const sal_uInt8 BIFF_TOK_ATTR_IF
Volatile function.
const sal_uInt8 BIFF_TOKID_ATTR
Natural language reference (NLR).
Definition: formulabase.hxx:86
const sal_uInt16 BIFF_FUNC_CEILING
Function identifier of the FLOOR function.
const sal_uInt8 BIFF_TOKID_SHEET
Special attribute.
Definition: formulabase.hxx:87
sal_uInt8 mnRetClass
Maximum number of parameters.
const sal_uInt8 BIFF_TOKID_RANGE
List operator.
Definition: formulabase.hxx:78
const sal_uInt8 BIFF_TOKID_MUL
Subtraction operator.
Definition: formulabase.hxx:66
const sal_uInt8 BIFF_TOK_NLR_RANGEERR
Stacked NLR: Value in column.
const sal_uInt16 BIFF_FUNC_OFFSET
Function identifier of the COLUMNS function.
Unknown library (must be zero).
sal_Int32 OPCODE_MULT
Subtraction operator.
bool mbInternal
True = external function in Calc.
ApiTokenIterator(const ApiTokenSequence &rTokens, sal_Int32 nSpacesOpCode)
const sal_uInt16 BIFF_FUNC_COLUMNS
Function identifier of the ROWS function.
sal_Int32 OPCODE_NLR
Index of a database area.
const sal_uInt16 BIFF12_TOK_TABLE_THISROW
Table reference: Special [#Totals] range.
const sal_uInt8 BIFF_TOKID_REFERR
Variable reference subexpression.
Provides access to function info structs for all available sheet functions.
const sal_uInt8 BIFF_TOK_ATTR_SUM
Skip tokens.
const sal_uInt8 BIFF_TOKID_AREAERR
Deleted 2D cell reference.
A wrapper around the FormulaParser service provided by the Calc document.
static OUString generateApiArray(const Matrix< css::uno::Any > &rMatrix)
Generates an array string in Calc formula notation from the passed matrix with Any's containing doubl...
const sal_uInt8 BIFF_TOK_ATTR_SPACE_VOLATILE
Spaces in formula representation.
const sal_uInt8 BIFF_TOKCLASS_ARR
40-5F: Value class tokens.
Definition: formulabase.hxx:53
const sal_uInt8 BIFF_TOKID_BOOL
Error constant.
Definition: formulabase.hxx:90
sal_Int32 OPCODE_MINUS_SIGN
Unary plus sign.
const sal_uInt8 BIFF_TOK_NLR_SXNAME
NLR: Invalid/deleted range.
const sal_uInt8 BIFF_TOK_ATTR_SPACE_SP
Start of condition in IFERROR function (BIFF12 only).
const sal_uInt8 BIFF_TOKID_POWER
Division operator.
Definition: formulabase.hxx:68
const sal_uInt8 BIFF_TOKCLASS_MASK
Maximum size of a token array.
Definition: formulabase.hxx:49
const sal_uInt16 BIFF_TOK_REF_COLREL
Mask to extract BIFF2-BIFF5 row from reference.
FunctionParamInfoIterator & operator++()
const sal_uInt16 BIFF12_TOK_TABLE_ALL
Table reference: Range of columns.
const ApiToken * mpToken
const sal_uInt8 BIFF_TOKID_NLR
String constant.
Definition: formulabase.hxx:85
const sal_uInt8 BIFF_TOKID_EQ
Less than or equal operator.
Definition: formulabase.hxx:72
FormulaType
Function identifier of the WEEKNUM function.
const FunctionParamInfo * mpParamInfo
const ApiOpCodes & getOpCodes() const
Returns the structure containing all token op-codes for operators and special tokens used by the Calc...
Token sequence iterator that is able to skip space tokens.
A vector of formula tokens with additional convenience functions.
const sal_uInt8 BIFF_TOK_ATTR_ASSIGN
SUM function with one parameter.
void readBiff12Data(SequenceInputStream &rStrm, bool bRelativeAsOffset)
End (bottom-right) cell address.
sal_Int32 OPCODE_ARRAY_ROWSEP
Closing brace for constant arrays.
const sal_uInt8 BIFF_TOKID_GT
Greater than or equal operator.
Definition: formulabase.hxx:74
OpCodeProvider(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxModelFactory, bool bImportFilter)
sal_Int32 OPCODE_INTERSECT
Compare greater or equal operator.
sal_uInt8 mnMaxParamCount
Minimum number of parameters.
A 2D formula cell reference struct with relative flags.
void readBiff12Data(SequenceInputStream &rStrm, bool bRelativeAsOffset)
const sal_uInt8 BIFF_TOKID_ADD
Multiple operation reference.
Definition: formulabase.hxx:64