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