LibreOffice Module sc (master) 1
formulaparser.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 <memory>
23#include "formulabase.hxx"
24
25namespace oox::xls {
26
27// formula finalizer ==========================================================
28
44{
45public:
46 explicit FormulaFinalizer( const OpCodeProvider& rOpCodeProv );
47
50
51protected:
58 virtual const FunctionInfo* resolveBadFuncName( const OUString& rTokenData ) const;
59
66 virtual OUString resolveDefinedName( sal_Int32 nTokenIndex ) const;
67
68private:
69 typedef ::std::vector< const ApiToken* > ParameterPosVector;
70
71 const FunctionInfo* getFunctionInfo( ApiToken& orFuncToken );
72 const FunctionInfo* getExternCallInfo( ApiToken& orFuncToken, const ApiToken& rECToken );
73
74 void processTokens( const ApiToken* pToken, const ApiToken* pTokenEnd );
75 const ApiToken* processParameters( const FunctionInfo& rFuncInfo, const ApiToken* pToken, const ApiToken* pTokenEnd );
76
77 bool isEmptyParameter( const ApiToken* pToken, const ApiToken* pTokenEnd ) const;
78 const ApiToken* getSingleToken( const ApiToken* pToken, const ApiToken* pTokenEnd ) const;
79 const ApiToken* skipParentheses( const ApiToken* pToken, const ApiToken* pTokenEnd ) const;
80 const ApiToken* findParameters( ParameterPosVector& rParams, const ApiToken* pToken, const ApiToken* pTokenEnd ) const;
81 void appendEmptyParameter( const FunctionInfo& rFuncInfo, size_t nParam );
82 void appendCalcOnlyParameter( const FunctionInfo& rFuncInfo, size_t nParam, size_t nParamCount );
83 void appendRequiredParameters( const FunctionInfo& rFuncInfo, size_t nParamCount );
84
85 bool appendFinalToken( const ApiToken& rToken );
86
87private:
89};
90
92
100{
101public:
102 explicit FormulaParser( const WorkbookHelper& rHelper );
103 virtual ~FormulaParser() override;
104
107 const ScAddress& rBaseAddr,
108 const OUString& rFormulaString ) const;
109
112 const ScAddress& rBaseAddr,
114 SequenceInputStream& rStrm ) const;
115
117 OUString importOleTargetLink( std::u16string_view aFormulaString );
118
121
123 OUString importMacroName( std::u16string_view aFormulaString );
124
125private:
126 ::std::unique_ptr< FormulaParserImpl > mxImpl;
127};
128
129} // namespace oox::xls
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A vector of formula tokens with additional convenience functions.
A generic formula token array finalizer.
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 OPCOD...
const ApiToken * skipParentheses(const ApiToken *pToken, const ApiToken *pTokenEnd) const
ApiTokenSequence finalizeTokenArray(const ApiTokenSequence &rTokens)
Finalizes and returns the passed token array.
FormulaFinalizer(const OpCodeProvider &rOpCodeProv)
const ApiToken * findParameters(ParameterPosVector &rParams, const ApiToken *pToken, const ApiToken *pTokenEnd) const
const FunctionInfo * getFunctionInfo(ApiToken &orFuncToken)
void appendRequiredParameters(const FunctionInfo &rFuncInfo, size_t nParamCount)
::std::vector< const ApiToken * > ParameterPosVector
void processTokens(const ApiToken *pToken, const ApiToken *pTokenEnd)
void appendEmptyParameter(const FunctionInfo &rFuncInfo, size_t nParam)
void appendCalcOnlyParameter(const FunctionInfo &rFuncInfo, size_t nParam, size_t nParamCount)
const ApiToken * getSingleToken(const ApiToken *pToken, const ApiToken *pTokenEnd) const
bool appendFinalToken(const ApiToken &rToken)
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 OP...
const FunctionInfo * getExternCallInfo(ApiToken &orFuncToken, const ApiToken &rECToken)
bool isEmptyParameter(const ApiToken *pToken, const ApiToken *pTokenEnd) const
const ApiToken * processParameters(const FunctionInfo &rFuncInfo, const ApiToken *pToken, const ApiToken *pTokenEnd)
Import formula parser for OOXML and BIFF filters.
virtual ~FormulaParser() override
ApiTokenSequence importFormula(const ScAddress &rBaseAddr, const OUString &rFormulaString) const
Converts an OOXML formula string.
FormulaParser(const WorkbookHelper &rHelper)
OUString importMacroName(std::u16string_view aFormulaString)
Converts the passed formula to a macro name for a drawing shape.
::std::unique_ptr< FormulaParserImpl > mxImpl
OUString importOleTargetLink(std::u16string_view aFormulaString)
Converts the passed XML formula to an OLE link target.
Base class for import formula parsers and export formula compilers.
Provides access to API op-codes for all available formula tokens and to function info structs for all...
Helper class to provide access to global workbook data.
DocumentType eType
void SvStream & rStrm
css::sheet::FormulaToken ApiToken
css::uno::Sequence< ApiToken > ApiTokenSequence
FormulaType
Function identifier of the WEEKNUM function.
Contains all API op-codes needed to build formulas with tokens.
Represents information for a spreadsheet function.