LibreOffice Module lotuswordpro (master) 1
lwptblformula.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 *
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
38 *
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
61#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
62#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
63
64#include <rtl/ustring.hxx>
65#include <memory>
66#include <vector>
67#include "lwptblcell.hxx"
68
69/* These token types are written to the file. Don't change their
70values unless you filter them.
71*/
73{
74 TK_BAD = 0,
76 TK_END = 2,
81 TK_ADD = 7,
86 TK_LESS = 12,
91 TK_NOT = 17,
92 TK_AND = 18,
93 TK_OR = 19,
96 TK_TEXT = 22,
97 TK_SUM = 23,
98 TK_IF = 24,
108class LwpTableLayout;
110{
111public:
112 virtual ~LwpFormulaArg() = 0;
113 virtual OUString ToString(LwpTableLayout* pCellsMap)=0;
114 virtual OUString ToArgString(LwpTableLayout* pCellsMap){ return ToString(pCellsMap);}
115};
116
118{
119public:
120 static OUString GetName(sal_uInt16 nTokenType);
121 static OUString GetCellAddr(sal_Int16 nRow, sal_Int16 nCol, LwpTableLayout* pCellsMap);
122};
123
125{
126public:
127 explicit LwpFormulaConst( double dVal);
128 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
129private:
130 double m_dVal;
131};
132
134{
135public:
136 explicit LwpFormulaText( OUString aText);
137 virtual OUString ToString(LwpTableLayout* /*pCellsMap*/) override {return m_aText;}
138private:
139 OUString m_aText;
140};
141
143{
144public:
145 LwpFormulaCellAddr(sal_Int16 aCol, sal_Int16 aRow);
146
147 sal_Int16 GetCol() const {return m_aCol;}
148 sal_Int16 GetRow() const {return m_aRow;}
149
150 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
151private:
152 sal_Int16 m_aCol;
153 sal_Int16 m_aRow;
154};
155
157{
158public:
159 LwpFormulaCellRangeAddr(sal_Int16 aStartCol, sal_Int16 aStartRow, sal_Int16 aEndCol, sal_Int16 aEndRow);
160
161 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
162private:
163 sal_Int16 m_aStartCol;
164 sal_Int16 m_aStartRow;
165 sal_Int16 m_aEndCol;
166 sal_Int16 m_aEndRow;
167};
168
170{
171public:
172 explicit LwpFormulaFunc(sal_uInt16 nTokenType);
173 virtual ~LwpFormulaFunc() override;
174
175 void AddArg(std::unique_ptr<LwpFormulaArg> pArg);
176
177 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
178 OUString ToArgString(LwpTableLayout* pCellsMap) override;
179
180protected:
181 std::vector<std::unique_ptr<LwpFormulaArg>> m_aArgs;
182 sal_uInt16 m_nTokenType;
183};
184
186{
187public:
188 explicit LwpFormulaOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){}
189 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
190};
191
193{
194public:
195 explicit LwpFormulaUnaryOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){}
196 virtual OUString ToString(LwpTableLayout* pCellsMap) override;
197};
198
199class LwpFormulaInfo final : public LwpCellList
200{
201public:
202 LwpFormulaInfo(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
203 OUString Convert(LwpTableLayout* pCellsMap);
204 void Convert(XFCell * pCell, LwpTableLayout* pCellsMap=nullptr) override;
205private:
206 void Read() override;
207 void ReadCellID();
208 void ReadText();
209 void ReadCellRange();
210 void ReadExpression();
211 void ReadArguments(LwpFormulaFunc& aFunc);
213 virtual ~LwpFormulaInfo() override;
214 void ReadConst();
215 void MarkUnsupported(sal_uInt16 TokenType);
216
217 std::vector<std::unique_ptr<LwpFormulaArg>> m_aStack;
218 sal_uInt16 m_nFormulaRow;
219};
220
221#endif
222
223/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VO_CELLLIST object.
Definition: lwptblcell.hxx:79
virtual ~LwpFormulaArg()=0
virtual OUString ToArgString(LwpTableLayout *pCellsMap)
virtual OUString ToString(LwpTableLayout *pCellsMap)=0
LwpFormulaCellAddr(sal_Int16 aCol, sal_Int16 aRow)
sal_Int16 GetRow() const
sal_Int16 GetCol() const
virtual OUString ToString(LwpTableLayout *pCellsMap) override
LwpFormulaCellRangeAddr(sal_Int16 aStartCol, sal_Int16 aStartRow, sal_Int16 aEndCol, sal_Int16 aEndRow)
virtual OUString ToString(LwpTableLayout *pCellsMap) override
Convert the cell range into a string.
virtual OUString ToString(LwpTableLayout *pCellsMap) override
LwpFormulaConst(double dVal)
virtual ~LwpFormulaFunc() override
OUString ToArgString(LwpTableLayout *pCellsMap) override
Convert the functions to a string, which is an argument of other formula.
void AddArg(std::unique_ptr< LwpFormulaArg > pArg)
std::vector< std::unique_ptr< LwpFormulaArg > > m_aArgs
virtual OUString ToString(LwpTableLayout *pCellsMap) override
Convert the function to a formula string.
LwpFormulaFunc(sal_uInt16 nTokenType)
sal_uInt16 m_nTokenType
void ReadArguments(LwpFormulaFunc &aFunc)
Read arguments of functions from wordpro file.
std::vector< std::unique_ptr< LwpFormulaArg > > m_aStack
OUString Convert(LwpTableLayout *pCellsMap)
Make the formula string.
void ReadExpression()
Read expression from wordpro file.
void MarkUnsupported(sal_uInt16 TokenType)
sal_uInt16 m_nFormulaRow
void ReadText()
Need more effort for unicode.
void Read() override
@descr Read LwpDLVList data from object stream
LwpFormulaInfo(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
virtual ~LwpFormulaInfo() override
virtual OUString ToString(LwpTableLayout *pCellsMap) override
Convert the formula in operators to a string : e.g.
LwpFormulaOp(sal_uInt16 nTokenType)
LwpFormulaText(OUString aText)
virtual OUString ToString(LwpTableLayout *) override
static OUString GetName(sal_uInt16 nTokenType)
Get token name.
static OUString GetCellAddr(sal_Int16 nRow, sal_Int16 nCol, LwpTableLayout *pCellsMap)
Get cell address in String.
virtual OUString ToString(LwpTableLayout *pCellsMap) override
convert the formula in unary operators into string : e.g.
LwpFormulaUnaryOp(sal_uInt16 nTokenType)
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
VO_TABLELAYOUT object and functions for registering styles and converting tables.
@descr Table cell object.
Definition: xfcell.hxx:76
For LWP filter architecture prototype - table object.
lTokenType
@ TK_CELLRANGE
@ TK_MINIMUM
@ TK_SUBTRACT
@ TK_END
@ TK_MAXIMUM
@ TK_OPEN_FUNCTION
@ TK_GREATER
@ TK_IF
@ TK_UNARY_MINUS
@ TK_COUNT
@ TK_LESS
@ TK_AVERAGE
@ TK_OPERAND
@ TK_MULTIPLY
@ TK_NOT
@ TK_DIVIDE
@ TK_SUM
@ TK_NOT_EQUAL
@ TK_CELLID
@ TK_FUNCTION
@ TK_ADD
@ TK_CONSTANT
@ TK_OR
@ TK_LIST_SEPARATOR
@ TK_RIGHTPAREN
@ TK_LEFTPAREN
@ TK_GREATER_OR_EQUAL
@ TK_EXPRESSION
@ TK_BAD
@ TK_AND
@ TK_TEXT
@ TK_EQUAL
@ TK_LESS_OR_EQUAL
TokenType