Line data Source code
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 : ************************************************************************/
56 : /**
57 : * @file
58 : * For LWP filter architecture prototype - table object
59 : */
60 : /*************************************************************************
61 : * Change History
62 : Mar 2005 Created
63 : ************************************************************************/
64 : #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
65 : #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
66 :
67 : /* These token types are written to the file. Don't change their
68 : values unless you filter them.
69 : */
70 : enum lTokenType
71 : {
72 : TK_BAD = 0,
73 : TK_OPERAND = 1,
74 : TK_END = 2,
75 : TK_RIGHTPAREN = 3,
76 : TK_FUNCTION = 4,
77 : TK_LEFTPAREN = 5,
78 : TK_UNARY_MINUS = 6,
79 : TK_ADD = 7,
80 : TK_SUBTRACT = 8,
81 : TK_MULTIPLY = 9,
82 : TK_DIVIDE = 10,
83 : TK_EQUAL = 11,
84 : TK_LESS = 12,
85 : TK_GREATER = 13,
86 : TK_NOT_EQUAL = 14,
87 : TK_GREATER_OR_EQUAL = 15,
88 : TK_LESS_OR_EQUAL = 16,
89 : TK_NOT = 17,
90 : TK_AND = 18,
91 : TK_OR = 19,
92 : TK_CELLID = 20,
93 : TK_CONSTANT = 21,
94 : TK_TEXT = 22,
95 : TK_SUM = 23,
96 : TK_IF = 24,
97 : TK_AVERAGE = 25,
98 : TK_MAXIMUM = 26,
99 : TK_MINIMUM = 27,
100 : TK_COUNT = 28,
101 : TK_CELLRANGE = 29,
102 : TK_EXPRESSION = 30,
103 : TK_OPEN_FUNCTION = 31,
104 : TK_LIST_SEPARATOR = 32
105 : };
106 : class LwpTableLayout;
107 0 : class LwpFormulaArg
108 : {
109 : public:
110 : virtual ~LwpFormulaArg() = 0;
111 : virtual OUString ToString(LwpTableLayout* pCellsMap)=0;
112 0 : virtual OUString ToArgString(LwpTableLayout* pCellsMap){ return ToString(pCellsMap);}
113 : };
114 :
115 : class LwpFormulaTools
116 : {
117 : public:
118 : static OUString GetName(sal_uInt16 nTokenType);
119 : static OUString GetCellAddr(sal_Int16 nRow, sal_Int16 nCol, LwpTableLayout* pCellsMap);
120 : };
121 :
122 0 : class LwpFormulaConst:public LwpFormulaArg
123 : {
124 : public:
125 : LwpFormulaConst( double dVal);
126 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
127 : private:
128 : double m_dVal;
129 : };
130 :
131 0 : class LwpFormulaText:public LwpFormulaArg
132 : {
133 : public:
134 : LwpFormulaText( const OUString& aText);
135 0 : virtual OUString ToString(LwpTableLayout* /*pCellsMap*/) SAL_OVERRIDE {return m_aText;}
136 : private:
137 : OUString m_aText;
138 : };
139 :
140 0 : class LwpFormulaCellAddr:public LwpFormulaArg
141 : {
142 : public:
143 : LwpFormulaCellAddr(sal_Int16 aCol, sal_Int16 aRow);
144 :
145 0 : sal_Int16 GetCol(){return m_aCol;}
146 0 : sal_Int16 GetRow(){return m_aRow;}
147 :
148 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
149 : private:
150 : sal_Int16 m_aCol;
151 : sal_Int16 m_aRow;
152 : };
153 :
154 0 : class LwpFormulaCellRangeAddr:public LwpFormulaArg
155 : {
156 : public:
157 : LwpFormulaCellRangeAddr(sal_Int16 aStartCol, sal_Int16 aStartRow, sal_Int16 aEndCol, sal_Int16 aEndRow);
158 :
159 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
160 : private:
161 : sal_Int16 m_aStartCol;
162 : sal_Int16 m_aStartRow;
163 : sal_Int16 m_aEndCol;
164 : sal_Int16 m_aEndRow;
165 : };
166 :
167 : class LwpFormulaFunc :public LwpFormulaArg
168 : {
169 : public:
170 : LwpFormulaFunc(sal_uInt16 nTokenType);
171 : virtual ~LwpFormulaFunc();
172 :
173 : void AddArg(LwpFormulaArg* pArg);
174 :
175 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
176 : OUString ToArgString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
177 :
178 : protected:
179 : std::vector<LwpFormulaArg*> m_aArgs;
180 : sal_uInt16 m_nTokenType;
181 : };
182 :
183 0 : class LwpFormulaOp : public LwpFormulaFunc
184 : {
185 : public:
186 0 : LwpFormulaOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){;}
187 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
188 : };
189 :
190 0 : class LwpFormulaUnaryOp : public LwpFormulaFunc
191 : {
192 : public:
193 0 : LwpFormulaUnaryOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){;}
194 : virtual OUString ToString(LwpTableLayout* pCellsMap) SAL_OVERRIDE;
195 : };
196 :
197 : class LwpFormulaInfo : public LwpCellList
198 : {
199 : public:
200 : LwpFormulaInfo(LwpObjectHeader &objHdr, LwpSvStream* pStrm);
201 0 : bool IsFormula() SAL_OVERRIDE {return true;}
202 : void SetRow(sal_uInt16 nRow){ m_nFormulaRow = nRow;}
203 : OUString Convert(LwpTableLayout* pCellsMap);
204 : void Convert(XFCell * pCell, LwpTableLayout* pCellsMap) SAL_OVERRIDE;
205 : protected:
206 : void Read() SAL_OVERRIDE;
207 : bool ReadCellID();
208 : bool ReadText();
209 : bool ReadCellRange();
210 : bool ReadExpression();
211 : bool ReadArguments(LwpFormulaFunc& aFunc);
212 : bool m_bSupported;
213 : private:
214 : virtual ~LwpFormulaInfo();
215 :
216 : std::vector<LwpFormulaArg*> m_aStack;
217 : bool ReadConst();
218 : void MarkUnsupported(sal_uInt16 TokenType);
219 :
220 : sal_uInt16 m_nFormulaRow;
221 : };
222 :
223 : #endif
224 :
225 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|