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 #pragma once
21 
22 #include <com/sun/star/beans/Pair.hpp>
23 #include <com/sun/star/sheet/FormulaToken.hpp>
24 #include <com/sun/star/table/CellAddress.hpp>
26 #include <oox/helper/refvector.hxx>
27 #include "workbookhelper.hxx"
28 
29 namespace com::sun::star {
30  namespace lang { class XMultiServiceFactory; }
31  namespace sheet { class XFormulaParser; }
32 }
33 
34 namespace oox { template< typename Type > class Matrix; }
35 namespace com::sun::star::sheet { struct FormulaOpCodeMapEntry; }
36 namespace oox { class SequenceInputStream; }
37 namespace oox::xls { struct BinAddress; }
38 class ScRangeList;
39 
40 namespace oox::xls {
41 
42 // Constants ==================================================================
43 
44 const size_t BIFF_TOKARR_MAXLEN = 4096;
45 
46 // token class flags ----------------------------------------------------------
47 
53 
55 
56 // base token identifiers -----------------------------------------------------
57 
59 
60 const sal_uInt8 BIFF_TOKID_NONE = 0x00;
61 const sal_uInt8 BIFF_TOKID_EXP = 0x01;
62 const sal_uInt8 BIFF_TOKID_TBL = 0x02;
63 const sal_uInt8 BIFF_TOKID_ADD = 0x03;
64 const sal_uInt8 BIFF_TOKID_SUB = 0x04;
65 const sal_uInt8 BIFF_TOKID_MUL = 0x05;
66 const sal_uInt8 BIFF_TOKID_DIV = 0x06;
69 const sal_uInt8 BIFF_TOKID_LT = 0x09;
70 const sal_uInt8 BIFF_TOKID_LE = 0x0A;
71 const sal_uInt8 BIFF_TOKID_EQ = 0x0B;
72 const sal_uInt8 BIFF_TOKID_GE = 0x0C;
73 const sal_uInt8 BIFF_TOKID_GT = 0x0D;
74 const sal_uInt8 BIFF_TOKID_NE = 0x0E;
76 const sal_uInt8 BIFF_TOKID_LIST = 0x10;
83 const sal_uInt8 BIFF_TOKID_STR = 0x17;
84 const sal_uInt8 BIFF_TOKID_NLR = 0x18;
85 const sal_uInt8 BIFF_TOKID_ATTR = 0x19;
88 const sal_uInt8 BIFF_TOKID_ERR = 0x1C;
89 const sal_uInt8 BIFF_TOKID_BOOL = 0x1D;
90 const sal_uInt8 BIFF_TOKID_INT = 0x1E;
91 const sal_uInt8 BIFF_TOKID_NUM = 0x1F;
92 
93 // base identifiers of classified tokens --------------------------------------
94 
96 const sal_uInt8 BIFF_TOKID_FUNC = 0x01;
98 const sal_uInt8 BIFF_TOKID_NAME = 0x03;
99 const sal_uInt8 BIFF_TOKID_REF = 0x04;
117 
118 // specific token constants ---------------------------------------------------
119 
124 
127 
137 
145 
146 const sal_uInt16 BIFF_TOK_FUNCVAR_CMD = 0x8000;
147 const sal_uInt16 BIFF_TOK_FUNCVAR_FUNCIDMASK = 0x7FFF;
150 
151 const sal_uInt16 BIFF12_TOK_REF_COLMASK = 0x3FFF;
152 const sal_Int32 BIFF12_TOK_REF_ROWMASK = 0xFFFFF;
153 const sal_uInt16 BIFF12_TOK_REF_COLREL = 0x4000;
154 const sal_uInt16 BIFF12_TOK_REF_ROWREL = 0x8000;
155 
156 const sal_uInt16 BIFF_TOK_REF_COLMASK = 0x00FF;
157 const sal_uInt16 BIFF_TOK_REF_ROWMASK = 0x3FFF;
158 const sal_uInt16 BIFF_TOK_REF_COLREL = 0x4000;
159 const sal_uInt16 BIFF_TOK_REF_ROWREL = 0x8000;
160 
161 const sal_uInt16 BIFF12_TOK_TABLE_COLUMN = 0x0001;
162 const sal_uInt16 BIFF12_TOK_TABLE_COLRANGE = 0x0002;
163 const sal_uInt16 BIFF12_TOK_TABLE_ALL = 0x0004;
164 const sal_uInt16 BIFF12_TOK_TABLE_HEADERS = 0x0008;
165 const sal_uInt16 BIFF12_TOK_TABLE_DATA = 0x0010;
166 const sal_uInt16 BIFF12_TOK_TABLE_TOTALS = 0x0020;
167 const sal_uInt16 BIFF12_TOK_TABLE_THISROW = 0x0040;
168 const sal_uInt16 BIFF12_TOK_TABLE_SP_BRACKETS = 0x0080;
169 const sal_uInt16 BIFF12_TOK_TABLE_SP_SEP = 0x0100;
170 const sal_uInt16 BIFF12_TOK_TABLE_ROW = 0x0200;
171 const sal_uInt16 BIFF12_TOK_TABLE_CELL = 0x0400;
172 
186 const sal_uInt16 BIFF_TOK_NLR_REL = 0x8000;
187 const sal_uInt16 BIFF_TOK_NLR_MASK = 0x3FFF;
188 
189 const sal_uInt32 BIFF_TOK_NLR_ADDREL = 0x80000000;
190 const sal_uInt32 BIFF_TOK_NLR_ADDMASK = 0x3FFFFFFF;
191 
192 // function constants ---------------------------------------------------------
193 
196 
197 const sal_uInt16 BIFF_FUNC_IF = 1;
198 const sal_uInt16 BIFF_FUNC_SUM = 4;
199 const sal_uInt16 BIFF_FUNC_TRUE = 34;
200 const sal_uInt16 BIFF_FUNC_FALSE = 35;
201 const sal_uInt16 BIFF_FUNC_ROWS = 76;
202 const sal_uInt16 BIFF_FUNC_COLUMNS = 77;
203 const sal_uInt16 BIFF_FUNC_OFFSET = 78;
204 const sal_uInt16 BIFF_FUNC_EXTERNCALL = 255;
205 const sal_uInt16 BIFF_FUNC_FLOOR = 285;
206 const sal_uInt16 BIFF_FUNC_CEILING = 288;
207 const sal_uInt16 BIFF_FUNC_HYPERLINK = 359;
208 const sal_uInt16 BIFF_FUNC_WEEKNUM = 465;
209 
210 // Formula type ===============================================================
211 
213 enum class FormulaType
214 {
215  Cell,
216  Array,
217  SharedFormula,
218  CondFormat,
219  Validation
220 };
221 
222 // Reference helpers ==========================================================
223 
226 {
227  sal_Int32 mnCol;
228  sal_Int32 mnRow;
229  bool mbColRel;
230  bool mbRowRel;
231 
232  explicit BinSingleRef2d();
233 
234  void setBiff12Data( sal_uInt16 nCol, sal_Int32 nRow, bool bRelativeAsOffset );
235 
236  void readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
237 };
238 
241 {
244 
245  void readBiff12Data( SequenceInputStream& rStrm, bool bRelativeAsOffset );
246 };
247 
248 // Token vector, token sequence ===============================================
249 
250 typedef css::sheet::FormulaToken ApiToken;
251 typedef css::uno::Sequence< ApiToken > ApiTokenSequence;
252 
255 typedef css::beans::Pair< css::table::CellAddress, sal_Bool > ApiSpecialTokenInfo;
256 
259 {
260 public:
261  explicit ApiTokenVector();
262 
263  ApiToken& operator[]( size_t i ) { return mvTokens[i]; }
264 
265  size_t size() const { return mvTokens.size(); }
266 
267  ApiToken& back() { return mvTokens.back(); }
268  const ApiToken& back() const { return mvTokens.back(); }
269 
270  void clear() { mvTokens.clear(); }
271 
272  void pop_back() { mvTokens.pop_back(); }
273 
274  void push_back( const ApiToken& rToken ) { mvTokens.push_back( rToken ); }
275 
276  void reserve( size_t n ) { mvTokens.reserve( n ); }
277 
278  void resize( size_t n ) { mvTokens.resize( n ); }
279 
281  css::uno::Any& append( sal_Int32 nOpCode );
282 
284  template< typename Type >
285  void append( sal_Int32 nOpCode, const Type& rData ) { append( nOpCode ) <<= rData; }
286 
288  ApiTokenSequence toSequence() const;
289 
290 private:
291  ::std::vector< ApiToken > mvTokens;
292 };
293 
294 // Token sequence iterator ====================================================
295 
298 {
299 public:
300  explicit ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode );
301  bool is() const { return mpToken != mpTokenEnd; }
302  const ApiToken* operator->() const { return mpToken; }
303 
305 
306 private:
307  void skipSpaces();
308 
309 private:
310  const ApiToken* mpToken;
311  const ApiToken* mpTokenEnd;
312  const sal_Int32 mnSpacesOpCode;
313 };
314 
315 // List of API op-codes =======================================================
316 
319 {
320  // special
321  sal_Int32 OPCODE_UNKNOWN;
322  sal_Int32 OPCODE_EXTERNAL;
323  // formula structure
324  sal_Int32 OPCODE_PUSH;
325  sal_Int32 OPCODE_MISSING;
326  sal_Int32 OPCODE_SPACES;
327  sal_Int32 OPCODE_NAME;
328  sal_Int32 OPCODE_DBAREA;
329  sal_Int32 OPCODE_NLR;
330  sal_Int32 OPCODE_DDE;
331  sal_Int32 OPCODE_MACRO;
332  sal_Int32 OPCODE_BAD;
333  sal_Int32 OPCODE_NONAME;
334  // separators
335  sal_Int32 OPCODE_OPEN;
336  sal_Int32 OPCODE_CLOSE;
337  sal_Int32 OPCODE_SEP;
338  // array separators
339  sal_Int32 OPCODE_ARRAY_OPEN;
340  sal_Int32 OPCODE_ARRAY_CLOSE;
343  // unary operators
344  sal_Int32 OPCODE_PLUS_SIGN;
345  sal_Int32 OPCODE_MINUS_SIGN;
346  sal_Int32 OPCODE_PERCENT;
347  // binary operators
348  sal_Int32 OPCODE_ADD;
349  sal_Int32 OPCODE_SUB;
350  sal_Int32 OPCODE_MULT;
351  sal_Int32 OPCODE_DIV;
352  sal_Int32 OPCODE_POWER;
353  sal_Int32 OPCODE_CONCAT;
354  sal_Int32 OPCODE_EQUAL;
355  sal_Int32 OPCODE_NOT_EQUAL;
356  sal_Int32 OPCODE_LESS;
357  sal_Int32 OPCODE_LESS_EQUAL;
358  sal_Int32 OPCODE_GREATER;
360  sal_Int32 OPCODE_INTERSECT;
361  sal_Int32 OPCODE_LIST;
362  sal_Int32 OPCODE_RANGE;
363 };
364 
365 // Function parameter info ====================================================
366 
369 {
370  Regular,
371  CalcOnly,
372  ExcelOnly
373 };
374 
456 {
458 };
459 
460 // Function data ==============================================================
461 
465 {
468 };
469 
479 {
480  OUString maOdfFuncName;
481  OUString maOoxFuncName;
482  OUString maBiffMacroName;
483  OUString maExtProgName;
485  sal_Int32 mnApiOpCode;
486  sal_uInt16 mnBiff12FuncId;
487  sal_uInt16 mnBiffFuncId;
493  bool mbVolatile;
494  bool mbExternal;
495  bool mbInternal;
496  bool mbMacroFunc;
497  bool mbVarParam;
498 };
499 
501 
502 // Function info parameter class iterator =====================================
503 
513 {
514 public:
515  explicit FunctionParamInfoIterator( const FunctionInfo& rFuncInfo );
516 
517  bool isCalcOnlyParam() const;
518  bool isExcelOnlyParam() const;
520 
521 private:
525 };
526 
527 // Base function provider =====================================================
528 
529 struct FunctionProviderImpl;
530 
533 class FunctionProvider // not derived from WorkbookHelper to make it usable in file dumpers
534 {
535 public:
536  explicit FunctionProvider(bool bImportFilter);
537  virtual ~FunctionProvider();
538 
539  FunctionProvider(FunctionProvider const &) = default;
540  FunctionProvider(FunctionProvider &&) = default;
541  FunctionProvider & operator =(FunctionProvider const &) = delete;
543 
545  const FunctionInfo* getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const;
546 
548  const FunctionInfo* getFuncInfoFromBiff12FuncId( sal_uInt16 nFuncId ) const;
549 
552  const FunctionInfo* getFuncInfoFromMacroName( const OUString& rFuncName ) const;
553 
556  static FunctionLibraryType getFuncLibTypeFromLibraryName( const OUString& rLibraryName );
557 
558 protected:
560  const FunctionInfoVector& getFuncs() const;
561 
562 private:
563  typedef std::shared_ptr< FunctionProviderImpl > FunctionProviderImplRef;
564  FunctionProviderImplRef mxFuncImpl;
565 };
566 
567 // Op-code and function provider ==============================================
568 
569 struct OpCodeProviderImpl;
570 
574 class OpCodeProvider : public FunctionProvider // not derived from WorkbookHelper to make it usable as UNO service
575 {
576 public:
577  explicit OpCodeProvider(const css::uno::Reference<css::lang::XMultiServiceFactory>& rxModelFactory,
578  bool bImportFilter);
579  virtual ~OpCodeProvider() override;
580 
581  OpCodeProvider(OpCodeProvider const &) = default;
582  OpCodeProvider(OpCodeProvider &&) = default;
583  OpCodeProvider & operator =(OpCodeProvider const &) = delete;
585 
588  const ApiOpCodes& getOpCodes() const;
589 
591  const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const;
592 
594  css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry >
595  getOoxParserMap() const;
596 
597 private:
598  typedef std::shared_ptr< OpCodeProviderImpl > OpCodeProviderImplRef;
599  OpCodeProviderImplRef mxOpCodeImpl;
600 };
601 
602 // API formula parser wrapper =================================================
603 
606 {
607 public:
608  explicit ApiParserWrapper(
609  const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory,
610  const OpCodeProvider& rOpCodeProv );
611 
614 
616  ApiTokenSequence parseFormula(
617  const OUString& rFormula,
618  const ScAddress& rRefPos );
619 
620 private:
621  css::uno::Reference< css::sheet::XFormulaParser >
624 };
625 
626 // Formula parser/printer base class for filters ==============================
627 
630 {
631 public:
632  explicit FormulaProcessorBase( const WorkbookHelper& rHelper );
633 
640  static OUString generateAddress2dString(
641  const ScAddress& rAddress,
642  bool bAbsolute );
643 
650  static OUString generateAddress2dString(
651  const BinAddress& rAddress,
652  bool bAbsolute );
653 
661  static OUString generateApiString( const OUString& rString );
662 
668  static OUString generateApiArray( const Matrix< css::uno::Any >& rMatrix );
669 
681  css::uno::Any
682  extractReference( const ApiTokenSequence& rTokens ) const;
683 
699  bool extractCellRange(
700  ScRange& orRange,
701  const ApiTokenSequence& rTokens ) const;
702 
722  ScRangeList& orRanges,
723  const ApiTokenSequence& rTokens,
724  sal_Int32 nFilterBySheet ) const;
725 
736  bool extractString(
737  OUString& orString,
738  const ApiTokenSequence& rTokens ) const;
739 
755  ApiSpecialTokenInfo& orTokenInfo,
756  const ApiTokenSequence& rTokens ) const;
757 
773  ApiTokenSequence& orTokens,
774  sal_Unicode cStringSep,
775  bool bTrimLeadingSpaces ) const;
776 };
777 
778 } // namespace oox::xls
779 
780 /* 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:78
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:95
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:54
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:76
bool mbExternal
True = volatile function.
sal_Int32 OPCODE_LIST
Range intersection operator.
const sal_uInt8 BIFF_TOKID_LT
String concatenation operator.
Definition: formulabase.hxx:69
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:74
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:51
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.
Definition: formulabase.hxx:99
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:61
const sal_uInt8 BIFF_TOKID_FUNCVAR
Function, fixed number of arguments.
Definition: formulabase.hxx:97
bool mbVarParam
True = macro sheet function or command.
const sal_uInt8 BIFF_TOKCLASS_REF
00-1F: Base tokens.
Definition: formulabase.hxx:50
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:44
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:80
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:64
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:96
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:60
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:68
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:66
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:88
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:75
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:87
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:72
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:70
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:82
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:98
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:91
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:49
const sal_uInt16 BIFF12_TOK_TABLE_COLRANGE
Table reference: Single column.
const sal_uInt8 BIFF_TOKID_UMINUS
Unary plus.
Definition: formulabase.hxx:79
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:90
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:83
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:58
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:81
OUString maOoxFuncName
ODF function name.
const sal_uInt8 BIFF_TOKID_TBL
Array or shared formula reference.
Definition: formulabase.hxx:62
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:85
const sal_uInt16 BIFF_FUNC_CEILING
Function identifier of the FLOOR function.
const sal_uInt8 BIFF_TOKID_SHEET
Special attribute.
Definition: formulabase.hxx:86
sal_uInt8 mnRetClass
Maximum number of parameters.
const sal_uInt8 BIFF_TOKID_RANGE
List operator.
Definition: formulabase.hxx:77
const sal_uInt8 BIFF_TOKID_MUL
Subtraction operator.
Definition: formulabase.hxx:65
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:52
const sal_uInt8 BIFF_TOKID_BOOL
Error constant.
Definition: formulabase.hxx:89
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:67
const sal_uInt8 BIFF_TOKCLASS_MASK
Maximum size of a token array.
Definition: formulabase.hxx:48
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:84
const sal_uInt8 BIFF_TOKID_EQ
Less than or equal operator.
Definition: formulabase.hxx:71
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:73
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:63