LibreOffice Module sc (master) 1
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
oox::xls::FormulaFinalizer Class Reference

A generic formula token array finalizer. More...

#include <formulaparser.hxx>

Inheritance diagram for oox::xls::FormulaFinalizer:
[legend]
Collaboration diagram for oox::xls::FormulaFinalizer:
[legend]

Public Member Functions

 FormulaFinalizer (const OpCodeProvider &rOpCodeProv)
 
ApiTokenSequence finalizeTokenArray (const ApiTokenSequence &rTokens)
 Finalizes and returns the passed token array. More...
 
- Public Member Functions inherited from oox::xls::OpCodeProvider
 OpCodeProvider (const css::uno::Reference< css::lang::XMultiServiceFactory > &rxModelFactory, bool bImportFilter)
 
virtual ~OpCodeProvider () override
 
 OpCodeProvider (OpCodeProvider const &)=default
 
 OpCodeProvider (OpCodeProvider &&)=default
 
OpCodeProvideroperator= (OpCodeProvider const &)=delete
 
OpCodeProvideroperator= (OpCodeProvider &&)=delete
 
const ApiOpCodesgetOpCodes () const
 Returns the structure containing all token op-codes for operators and special tokens used by the Calc document and its formula parser. More...
 
const FunctionInfogetFuncInfoFromApiToken (const ApiToken &rToken) const
 Returns the function info for an API token, or 0 on error. More...
 
css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry > getOoxParserMap () const
 Returns the op-code map that is used by the OOXML formula parser. More...
 
- Public Member Functions inherited from oox::xls::FunctionProvider
 FunctionProvider (bool bImportFilter)
 
virtual ~FunctionProvider ()
 
 FunctionProvider (FunctionProvider const &)=default
 
 FunctionProvider (FunctionProvider &&)=default
 
FunctionProvideroperator= (FunctionProvider const &)=delete
 
FunctionProvideroperator= (FunctionProvider &&)=delete
 
const FunctionInfogetFuncInfoFromOoxFuncName (const OUString &rFuncName) const
 Returns the function info for an OOXML function name, or 0 on error. More...
 
const FunctionInfogetFuncInfoFromBiff12FuncId (sal_uInt16 nFuncId) const
 Returns the function info for a BIFF12 function index, or 0 on error. More...
 
const FunctionInfogetFuncInfoFromMacroName (const OUString &rFuncName) const
 Returns the function info for a macro function referred by the EXTERN.CALL function, or 0 on error. More...
 

Protected Member Functions

virtual const FunctionInforesolveBadFuncName (const OUString &rTokenData) const
 Derived classed may try to find a function info struct from the passed string extracted from an OPCODE_BAD token. More...
 
virtual OUString resolveDefinedName (sal_Int32 nTokenIndex) const
 Derived classed may try to find the name of a defined name with the passed index extracted from an OPCODE_NAME token. More...
 
- Protected Member Functions inherited from oox::xls::FunctionProvider
const FunctionInfoVectorgetFuncs () const
 Returns the list of all function infos. More...
 

Private Types

typedef ::std::vector< const ApiToken * > ParameterPosVector
 

Private Member Functions

const FunctionInfogetFunctionInfo (ApiToken &orFuncToken)
 
const FunctionInfogetExternCallInfo (ApiToken &orFuncToken, const ApiToken &rECToken)
 
void processTokens (const ApiToken *pToken, const ApiToken *pTokenEnd)
 
const ApiTokenprocessParameters (const FunctionInfo &rFuncInfo, const ApiToken *pToken, const ApiToken *pTokenEnd)
 
bool isEmptyParameter (const ApiToken *pToken, const ApiToken *pTokenEnd) const
 
const ApiTokengetSingleToken (const ApiToken *pToken, const ApiToken *pTokenEnd) const
 
const ApiTokenskipParentheses (const ApiToken *pToken, const ApiToken *pTokenEnd) const
 
const ApiTokenfindParameters (ParameterPosVector &rParams, const ApiToken *pToken, const ApiToken *pTokenEnd) const
 
void appendEmptyParameter (const FunctionInfo &rFuncInfo, size_t nParam)
 
void appendCalcOnlyParameter (const FunctionInfo &rFuncInfo, size_t nParam, size_t nParamCount)
 
void appendRequiredParameters (const FunctionInfo &rFuncInfo, size_t nParamCount)
 
bool appendFinalToken (const ApiToken &rToken)
 

Private Attributes

ApiTokenVector maTokens
 

Additional Inherited Members

- Static Public Member Functions inherited from oox::xls::FunctionProvider
static FunctionLibraryType getFuncLibTypeFromLibraryName (std::u16string_view rLibraryName)
 Returns the library type associated with the passed URL of a function library (function add-in). More...
 
- Protected Attributes inherited from oox::xls::ApiOpCodes
sal_Int32 OPCODE_UNKNOWN
 
sal_Int32 OPCODE_EXTERNAL
 Internal: function name unknown to mapper. More...
 
sal_Int32 OPCODE_PUSH
 External function call (e.g. add-ins). More...
 
sal_Int32 OPCODE_MISSING
 Op-code for common value operands. More...
 
sal_Int32 OPCODE_SPACES
 Placeholder for a missing function parameter. More...
 
sal_Int32 OPCODE_NAME
 Spaces between other formula tokens. More...
 
sal_Int32 OPCODE_DBAREA
 Index of a defined name. More...
 
sal_Int32 OPCODE_NLR
 Index of a database area. More...
 
sal_Int32 OPCODE_DDE
 Natural language reference. More...
 
sal_Int32 OPCODE_MACRO
 DDE link function. More...
 
sal_Int32 OPCODE_BAD
 Macro function call. More...
 
sal_Int32 OPCODE_NONAME
 Bad token (unknown name, formula error). More...
 
sal_Int32 OPCODE_OPEN
 Function style #NAME? error. More...
 
sal_Int32 OPCODE_CLOSE
 Opening parenthesis. More...
 
sal_Int32 OPCODE_SEP
 Closing parenthesis. More...
 
sal_Int32 OPCODE_ARRAY_OPEN
 Function parameter separator. More...
 
sal_Int32 OPCODE_ARRAY_CLOSE
 Opening brace for constant arrays. More...
 
sal_Int32 OPCODE_ARRAY_ROWSEP
 Closing brace for constant arrays. More...
 
sal_Int32 OPCODE_ARRAY_COLSEP
 Row separator in constant arrays. More...
 
sal_Int32 OPCODE_PLUS_SIGN
 Column separator in constant arrays. More...
 
sal_Int32 OPCODE_MINUS_SIGN
 Unary plus sign. More...
 
sal_Int32 OPCODE_PERCENT
 Unary minus sign. More...
 
sal_Int32 OPCODE_ADD
 Percent sign. More...
 
sal_Int32 OPCODE_SUB
 Addition operator. More...
 
sal_Int32 OPCODE_MULT
 Subtraction operator. More...
 
sal_Int32 OPCODE_DIV
 Multiplication operator. More...
 
sal_Int32 OPCODE_POWER
 Division operator. More...
 
sal_Int32 OPCODE_CONCAT
 Power operator. More...
 
sal_Int32 OPCODE_EQUAL
 String concatenation operator. More...
 
sal_Int32 OPCODE_NOT_EQUAL
 Compare equal operator. More...
 
sal_Int32 OPCODE_LESS
 Compare not equal operator. More...
 
sal_Int32 OPCODE_LESS_EQUAL
 Compare less operator. More...
 
sal_Int32 OPCODE_GREATER
 Compare less or equal operator. More...
 
sal_Int32 OPCODE_GREATER_EQUAL
 Compare greater operator. More...
 
sal_Int32 OPCODE_INTERSECT
 Compare greater or equal operator. More...
 
sal_Int32 OPCODE_LIST
 Range intersection operator. More...
 
sal_Int32 OPCODE_RANGE
 Range list operator. More...
 

Detailed Description

A generic formula token array finalizer.

After building a formula token array from alien binary file formats, or parsing an XML formula string using the com.sun.star.sheet.FormulaParser service, the token array is still not ready to be put into the spreadsheet document. There may be functions with a wrong number of parameters (missing but required parameters, or unsupported parameters) or intermediate tokens used to encode references to macro functions or add-in functions. This helper processes a passed token array and builds a new compatible token array.

Derived classes may add more functionality by overwriting the virtual functions.

Definition at line 43 of file formulaparser.hxx.

Member Typedef Documentation

◆ ParameterPosVector

typedef ::std::vector< const ApiToken* > oox::xls::FormulaFinalizer::ParameterPosVector
private

Definition at line 69 of file formulaparser.hxx.

Constructor & Destructor Documentation

◆ FormulaFinalizer()

oox::xls::FormulaFinalizer::FormulaFinalizer ( const OpCodeProvider rOpCodeProv)
explicit

Definition at line 48 of file formulaparser.cxx.

References maTokens, and oox::xls::ApiTokenVector::reserve().

Member Function Documentation

◆ appendCalcOnlyParameter()

void oox::xls::FormulaFinalizer::appendCalcOnlyParameter ( const FunctionInfo rFuncInfo,
size_t  nParam,
size_t  nParamCount 
)
private

◆ appendEmptyParameter()

void oox::xls::FormulaFinalizer::appendEmptyParameter ( const FunctionInfo rFuncInfo,
size_t  nParam 
)
private

◆ appendFinalToken()

bool oox::xls::FormulaFinalizer::appendFinalToken ( const ApiToken rToken)
private

◆ appendRequiredParameters()

void oox::xls::FormulaFinalizer::appendRequiredParameters ( const FunctionInfo rFuncInfo,
size_t  nParamCount 
)
private

◆ finalizeTokenArray()

ApiTokenSequence oox::xls::FormulaFinalizer::finalizeTokenArray ( const ApiTokenSequence rTokens)

◆ findParameters()

const ApiToken * oox::xls::FormulaFinalizer::findParameters ( ParameterPosVector rParams,
const ApiToken pToken,
const ApiToken pTokenEnd 
) const
private

◆ getExternCallInfo()

const FunctionInfo * oox::xls::FormulaFinalizer::getExternCallInfo ( ApiToken orFuncToken,
const ApiToken rECToken 
)
private

◆ getFunctionInfo()

const FunctionInfo * oox::xls::FormulaFinalizer::getFunctionInfo ( ApiToken orFuncToken)
private

◆ getSingleToken()

const ApiToken * oox::xls::FormulaFinalizer::getSingleToken ( const ApiToken pToken,
const ApiToken pTokenEnd 
) const
private

Definition at line 297 of file formulaparser.cxx.

References oox::xls::ApiOpCodes::OPCODE_SPACES.

Referenced by processParameters().

◆ isEmptyParameter()

bool oox::xls::FormulaFinalizer::isEmptyParameter ( const ApiToken pToken,
const ApiToken pTokenEnd 
) const
private

◆ processParameters()

const ApiToken * oox::xls::FormulaFinalizer::processParameters ( const FunctionInfo rFuncInfo,
const ApiToken pToken,
const ApiToken pTokenEnd 
)
private

◆ processTokens()

void oox::xls::FormulaFinalizer::processTokens ( const ApiToken pToken,
const ApiToken pTokenEnd 
)
private

◆ resolveBadFuncName()

const FunctionInfo * oox::xls::FormulaFinalizer::resolveBadFuncName ( const OUString &  rTokenData) const
protectedvirtual

Derived classed may try to find a function info struct from the passed string extracted from an OPCODE_BAD token.

Parameters
rTokenDataThe string that has been found in an OPCODE_BAD token preceding the function parentheses.

Reimplemented in oox::xls::FormulaParserImpl, and oox::xls::OOXMLFormulaParserImpl.

Definition at line 66 of file formulaparser.cxx.

Referenced by getFunctionInfo().

◆ resolveDefinedName()

OUString oox::xls::FormulaFinalizer::resolveDefinedName ( sal_Int32  nTokenIndex) const
protectedvirtual

Derived classed may try to find the name of a defined name with the passed index extracted from an OPCODE_NAME token.

Parameters
nTokenIndexThe index of the defined name that has been found in an OPCODE_NAME token preceding the function parentheses.

Reimplemented in oox::xls::FormulaParserImpl.

Definition at line 71 of file formulaparser.cxx.

Referenced by getExternCallInfo().

◆ skipParentheses()

const ApiToken * oox::xls::FormulaFinalizer::skipParentheses ( const ApiToken pToken,
const ApiToken pTokenEnd 
) const
private

Member Data Documentation

◆ maTokens

ApiTokenVector oox::xls::FormulaFinalizer::maTokens
private

The documentation for this class was generated from the following files: