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 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLCELL_HXX
62 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLCELL_HXX
63
64 #include <lwpobj.hxx>
65 #include "lwpdlvlist.hxx"
66
67 #include <xfilter/xfcell.hxx>
68
69 // temporarily added for compile
70 class LwpObject;
71
72 class LwpContent;
73 class LwpTableLayout;
74 /**
75 * @brief
76 * VO_CELLLIST object
77 */
78 class LwpCellList : public LwpDLVList
79 {
80 public:
81 LwpCellList(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
82
83 virtual void Parse(IXFStream* pOutputStream) override;
GetNextID()84 LwpObjectID const & GetNextID(){return GetNext();}
GetColumnID() const85 sal_uInt8 GetColumnID() const {return cColumn;}
86
87 virtual void Convert(XFCell * pCell, LwpTableLayout* pCellsMap=nullptr);
88 protected:
89 virtual ~LwpCellList() override;
90
91 sal_uInt8 cColumn;
92 LwpObjectID cParent;
93
94 void Read() override;
95 LwpObjectID cValue;
96 };
97 /**
98 * @brief
99 * VO_ROWLIST object
100 */
101 class LwpRowList final : public LwpDLVList
102 {
103 public:
104 LwpRowList(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
105
106 void Parse(IXFStream* pOutputStream) override;
GetChildHeadID()107 LwpObjectID const & GetChildHeadID(){return cChild.GetHead();}
GetNextID()108 LwpObjectID const & GetNextID(){return GetNext();}
GetRowID() const109 sal_uInt16 GetRowID() const {return cRowID;}
110 private:
111 void Read() override;
112 virtual ~LwpRowList() override;
113
114 LwpDLVListHeadTail cChild;
115 LwpObjectID cParent;
116 sal_uInt16 cRowID;
117 };
118 /**
119 * @brief
120 * VO_NUMERICVALUE object
121 */
122 class LwpNumericValue final : public LwpObject
123 {
124 public:
125 LwpNumericValue(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
126
GetValue() const127 double GetValue() const {return cNumber;}
128 void Parse(IXFStream* pOutputStream) override;
129 private:
130 void Read() override;
131 virtual ~LwpNumericValue() override;
132
133 double cNumber;
134 };
135
136 /**
137 * @brief
138 * VO_TABLERANGE object
139 */
140 class LwpTableRange final : public LwpDLVList
141 {
142 public:
143 LwpTableRange(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
144
145 void Parse(IXFStream* pOutputStream) override;
GetCellRangeID() const146 const LwpObjectID& GetCellRangeID() const {return cpCellRange;}
GetTableID() const147 const LwpObjectID& GetTableID() const { return cqTable;}
GetNext()148 LwpTableRange* GetNext() { return dynamic_cast<LwpTableRange*>(LwpDLVList::GetNext().obj().get());}
149 private:
150 void Read() override;
151 virtual ~LwpTableRange() override;
152
153 LwpObjectID cqTable;
154 LwpObjectID cpCellRange;
155 };
156 /**
157 * @brief
158 * VO_CELLRANGE object
159 */
160 class LwpCellRange final : public LwpObject
161 {
162 public:
163 LwpCellRange(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
164
165 void Parse(IXFStream* pOutputStream) override;
GetFolderID() const166 const LwpObjectID& GetFolderID() const {return cpFolder;}
167 private:
168 void Read() override;
169 virtual ~LwpCellRange() override;
170
171 LwpObjectID cpFolder;
172 };
173 /**
174 * @brief
175 * VO_FOLDER object
176 */
177 class LwpFolder final : public LwpDLVList
178 {
179 public:
180 LwpFolder(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
181
182 void Parse(IXFStream* pOutputStream) override;
GetChildHeadID()183 LwpObjectID const & GetChildHeadID(){ return cChild.GetHead();}
184 private:
185 void Read() override;
186 virtual ~LwpFolder() override;
187
188 LwpDLVListHeadTail cChild;
189 LwpObjectID cParent;
190 LwpObjectID cqTable;
191 };
192 /**
193 * @brief
194 * VO_DEPENDENT object
195 */
196 class LwpDependent final : public LwpDLVList
197 {
198 public:
199 LwpDependent(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
200
201 void Parse(IXFStream* pOutputStream) override;
202 private:
203 void Read() override;
204 virtual ~LwpDependent() override;
205
206 LwpObjectID cFormulaInfo;
207 sal_uInt16 cReferenceOffset; // Used to fix dependent formula when we're
208 // dropped, sorted.
209 // Flags:
210 enum
211 {
212 START_CELL = 0x01,
213 END_CELL = 0x02,
214 REGISTERED = 0x04
215 };
216 sal_uInt8 cFlags; // Used to fix dependent formula when we're
217 // dropped, sorted.
218 };
219
220 /**
221 * @brief
222 * row or column id
223 */
224 class LwpRowColumnQualifier
225 {
226 public:
227 LwpRowColumnQualifier();
228
229 bool IsAbsolute() const;
230
231 bool IsAfter() const;
232
233 bool IsBad() const;
234
235 void QuickRead(LwpObjectStream *pStrm);
236
237 private:
238 enum // cFlags bit definitions
239 {
240 REF_ABSOLUTE = 0x01,
241 REF_AFTER = 0x02,
242 REF_BAD = 0x04
243 };
244 sal_uInt8 cFlags;
245 };
246
247 inline
LwpRowColumnQualifier()248 LwpRowColumnQualifier::LwpRowColumnQualifier() : cFlags(0)
249 {
250 }
251
252 inline bool
IsAfter() const253 LwpRowColumnQualifier::IsAfter() const
254 {
255 return (cFlags & REF_AFTER) != 0;
256 }
257
258 inline bool
IsBad() const259 LwpRowColumnQualifier::IsBad() const
260 {
261 return (cFlags & REF_BAD) != 0;
262 }
263
264 inline bool
IsAbsolute() const265 LwpRowColumnQualifier::IsAbsolute() const
266 {
267 return (cFlags & REF_ABSOLUTE) != 0;
268 }
269 /**
270 * @brief
271 * row id
272 */
273 class LwpRowSpecifier
274 {
275 public:
LwpRowSpecifier()276 LwpRowSpecifier()
277 : cRow(0)
278 {}
279
280 void QuickRead(LwpObjectStream *pStrm);
281
282 sal_uInt16 RowID(sal_uInt16 FormulaRow);
283
284 private:
285 sal_uInt16 cRow;
286 LwpRowColumnQualifier cQualifier;
287 };
288
289 inline sal_uInt16
RowID(sal_uInt16 FormulaRow)290 LwpRowSpecifier::RowID(sal_uInt16 FormulaRow)
291 {
292 if (cQualifier.IsBad())
293 {
294 return 0xffff;
295 }
296 if (cQualifier.IsAbsolute())
297 return cRow;
298
299 if (cQualifier.IsAfter())
300 return FormulaRow + cRow;
301 return FormulaRow - cRow;
302 }
303
304 /**
305 * @brief
306 * column id
307 */
308 class LwpColumnSpecifier
309 {
310 public:
LwpColumnSpecifier()311 LwpColumnSpecifier()
312 : cColumn(0)
313 {}
314
315 void QuickRead(LwpObjectStream *pStrm);
316
317 sal_uInt8 ColumnID(sal_uInt8 FormulaColumn);
318
319 private:
320 sal_uInt8 cColumn;
321 LwpRowColumnQualifier cQualifier;
322 };
323
324 inline sal_uInt8
ColumnID(sal_uInt8 FormulaColumn)325 LwpColumnSpecifier::ColumnID(sal_uInt8 FormulaColumn)
326 {
327 if (cQualifier.IsBad())
328 {
329 return 0xff;
330 }
331 if (cQualifier.IsAbsolute())
332 return cColumn;
333 if (cQualifier.IsAfter())
334 return FormulaColumn + cColumn;
335 return FormulaColumn - cColumn;
336 }
337
338 #endif
339
340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
341