LibreOffice Module sc (master) 1
|
A generic formula token array finalizer. More...
#include <formulaparser.hxx>
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 | |
OpCodeProvider & | operator= (OpCodeProvider const &)=delete |
OpCodeProvider & | operator= (OpCodeProvider &&)=delete |
const ApiOpCodes & | getOpCodes () 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 FunctionInfo * | getFuncInfoFromApiToken (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 | |
FunctionProvider & | operator= (FunctionProvider const &)=delete |
FunctionProvider & | operator= (FunctionProvider &&)=delete |
const FunctionInfo * | getFuncInfoFromOoxFuncName (const OUString &rFuncName) const |
Returns the function info for an OOXML function name, or 0 on error. More... | |
const FunctionInfo * | getFuncInfoFromBiff12FuncId (sal_uInt16 nFuncId) const |
Returns the function info for a BIFF12 function index, or 0 on error. More... | |
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. More... | |
Protected Member Functions | |
virtual const FunctionInfo * | resolveBadFuncName (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 FunctionInfoVector & | getFuncs () const |
Returns the list of all function infos. More... | |
Private Types | |
typedef ::std::vector< const ApiToken * > | ParameterPosVector |
Private Member Functions | |
const FunctionInfo * | getFunctionInfo (ApiToken &orFuncToken) |
const FunctionInfo * | getExternCallInfo (ApiToken &orFuncToken, const ApiToken &rECToken) |
void | processTokens (const ApiToken *pToken, const ApiToken *pTokenEnd) |
const ApiToken * | processParameters (const FunctionInfo &rFuncInfo, const ApiToken *pToken, const ApiToken *pTokenEnd) |
bool | isEmptyParameter (const ApiToken *pToken, const ApiToken *pTokenEnd) const |
const ApiToken * | getSingleToken (const ApiToken *pToken, const ApiToken *pTokenEnd) const |
const ApiToken * | skipParentheses (const ApiToken *pToken, const ApiToken *pTokenEnd) const |
const ApiToken * | findParameters (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... | |
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.
|
private |
Definition at line 69 of file formulaparser.hxx.
|
explicit |
Definition at line 48 of file formulaparser.cxx.
References maTokens, and oox::xls::ApiTokenVector::reserve().
|
private |
Definition at line 370 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::append(), oox::xls::BIFF_FUNC_CEILING, oox::xls::BIFF_FUNC_FLOOR, maTokens, oox::xls::FunctionInfo::mnBiff12FuncId, oox::xls::ApiOpCodes::OPCODE_PUSH, and oox::xls::ApiOpCodes::OPCODE_SEP.
Referenced by processParameters().
|
private |
Definition at line 351 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::append(), oox::xls::BIFF_FUNC_IF, maTokens, oox::xls::FunctionInfo::mnBiff12FuncId, oox::xls::ApiOpCodes::OPCODE_MISSING, oox::xls::ApiOpCodes::OPCODE_PUSH, and oox::xls::ApiTokenVector::size().
Referenced by processParameters().
|
private |
Definition at line 399 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::append(), oox::xls::BIFF_ERR_NAME, oox::xls::BiffHelper::calcDoubleFromError(), maTokens, oox::xls::ApiOpCodes::OPCODE_ARRAY_CLOSE, oox::xls::ApiOpCodes::OPCODE_ARRAY_OPEN, oox::xls::ApiOpCodes::OPCODE_MACRO, oox::xls::ApiOpCodes::OPCODE_PUSH, and oox::xls::ApiTokenVector::push_back().
Referenced by processTokens().
|
private |
Definition at line 385 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::append(), oox::xls::BIFF_FUNC_WEEKNUM, maTokens, oox::xls::FunctionInfo::mnBiff12FuncId, oox::xls::ApiOpCodes::OPCODE_PUSH, and oox::xls::ApiOpCodes::OPCODE_SEP.
Referenced by processParameters().
ApiTokenSequence oox::xls::FormulaFinalizer::finalizeTokenArray | ( | const ApiTokenSequence & | rTokens | ) |
Finalizes and returns the passed token array.
Definition at line 55 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::clear(), maTokens, processTokens(), and oox::xls::ApiTokenVector::toSequence().
Referenced by oox::xls::FormulaParserImpl::finalizeImport(), and oox::xls::OOXMLFormulaParserImpl::parseFormula().
|
private |
Definition at line 327 of file formulaparser.cxx.
References oox::xls::ApiOpCodes::OPCODE_BAD, oox::xls::ApiOpCodes::OPCODE_CLOSE, oox::xls::ApiOpCodes::OPCODE_OPEN, oox::xls::ApiOpCodes::OPCODE_SEP, and skipParentheses().
Referenced by processParameters().
|
private |
Definition at line 103 of file formulaparser.cxx.
References oox::xls::OpCodeProvider::getFuncInfoFromApiToken(), oox::xls::FunctionInfo::mnApiOpCode, oox::xls::ApiOpCodes::OPCODE_BAD, oox::xls::ApiOpCodes::OPCODE_EXTERNAL, oox::xls::ApiOpCodes::OPCODE_MACRO, oox::xls::ApiOpCodes::OPCODE_NAME, and resolveDefinedName().
Referenced by processParameters().
|
private |
Definition at line 76 of file formulaparser.cxx.
References oox::xls::OpCodeProvider::getFuncInfoFromApiToken(), oox::xls::FunctionInfo::mnApiOpCode, oox::xls::ApiOpCodes::OPCODE_BAD, oox::xls::ApiOpCodes::OPCODE_EXTERNAL, and resolveBadFuncName().
Referenced by processTokens().
|
private |
Definition at line 297 of file formulaparser.cxx.
References oox::xls::ApiOpCodes::OPCODE_SPACES.
Referenced by processParameters().
|
private |
Definition at line 289 of file formulaparser.cxx.
References oox::xls::ApiOpCodes::OPCODE_MISSING, and oox::xls::ApiOpCodes::OPCODE_SPACES.
Referenced by processParameters().
|
private |
Definition at line 151 of file formulaparser.cxx.
References oox::xls::ApiTokenVector::append(), appendCalcOnlyParameter(), appendEmptyParameter(), appendRequiredParameters(), oox::xls::ApiTokenVector::back(), oox::xls::BIFF_FUNC_EXTERNCALL, findParameters(), getExternCallInfo(), getSingleToken(), oox::xls::FunctionParamInfoIterator::isCalcOnlyParam(), isEmptyParameter(), oox::xls::FunctionParamInfoIterator::isExcelOnlyParam(), maTokens, oox::xls::FunctionInfo::mnBiffFuncId, mnMinParamCount, oox::xls::ApiOpCodes::OPCODE_BAD, oox::xls::ApiOpCodes::OPCODE_CLOSE, oox::xls::ApiOpCodes::OPCODE_EXTERNAL, oox::xls::ApiOpCodes::OPCODE_MISSING, oox::xls::ApiOpCodes::OPCODE_NONAME, oox::xls::ApiOpCodes::OPCODE_OPEN, oox::xls::ApiOpCodes::OPCODE_SEP, oox::xls::ApiOpCodes::OPCODE_SPACES, oox::xls::ApiTokenVector::pop_back(), processTokens(), oox::xls::ApiTokenVector::push_back(), oox::xls::ApiTokenVector::resize(), and oox::xls::ApiTokenVector::size().
Referenced by processTokens().
|
private |
Definition at line 136 of file formulaparser.cxx.
References appendFinalToken(), oox::xls::ApiTokenVector::back(), getFunctionInfo(), maTokens, and processParameters().
Referenced by finalizeTokenArray(), and processParameters().
|
protectedvirtual |
Derived classed may try to find a function info struct from the passed string extracted from an OPCODE_BAD token.
rTokenData | The 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().
|
protectedvirtual |
Derived classed may try to find the name of a defined name with the passed index extracted from an OPCODE_NAME token.
nTokenIndex | The 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().
|
private |
Definition at line 310 of file formulaparser.cxx.
References oox::xls::ApiOpCodes::OPCODE_BAD, oox::xls::ApiOpCodes::OPCODE_CLOSE, oox::xls::ApiOpCodes::OPCODE_OPEN, and skipParentheses().
Referenced by findParameters(), and skipParentheses().
|
private |
Definition at line 88 of file formulaparser.hxx.
Referenced by appendCalcOnlyParameter(), appendEmptyParameter(), appendFinalToken(), appendRequiredParameters(), finalizeTokenArray(), FormulaFinalizer(), processParameters(), and processTokens().