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