merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / inc / xlpivot.hxx
blob8b5bd4e1c9d9b95f39e796d97919765b8a123589
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xlpivot.hxx,v $
10 * $Revision: 1.12.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XLPIVOT_HXX
32 #define SC_XLPIVOT_HXX
34 #include <com/sun/star/sheet/GeneralFunction.hpp>
35 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
36 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
37 #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
38 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
39 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
40 #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
41 #include <tools/datetime.hxx>
42 #include "ftools.hxx"
43 #include "xladdress.hxx"
44 #include "dpobject.hxx"
46 #include <memory>
48 class XclImpStream;
49 class XclExpStream;
51 // Constants and Enumerations =================================================
53 // misc -----------------------------------------------------------------------
55 #define EXC_STORAGE_PTCACHE CREATE_STRING( "_SX_DB_CUR" )
57 // strings
58 const sal_uInt16 EXC_PT_NOSTRING = 0xFFFF;
59 const sal_uInt16 EXC_PT_MAXSTRLEN = 0xFFFE;
61 // pivot cache fields
62 const size_t EXC_PC_MAXFIELDCOUNT = 0xFFFE;
63 const sal_uInt16 EXC_PC_NOFIELD = 0xFFFF;
64 const xub_StrLen EXC_PC_MAXSTRLEN = 255;
66 // pivot cache items
67 const size_t EXC_PC_MAXITEMCOUNT = 32500;
68 const sal_uInt16 EXC_PC_NOITEM = 0xFFFF;
70 // pivot table fields
71 const sal_uInt16 EXC_PT_MAXFIELDCOUNT = 0xFFFE;
72 const sal_uInt16 EXC_PT_MAXROWCOLCOUNT = EXC_PT_MAXFIELDCOUNT;
73 const sal_uInt16 EXC_PT_MAXPAGECOUNT = 256;
74 const sal_uInt16 EXC_PT_MAXDATACOUNT = 256;
76 // pivot table items
77 const sal_uInt16 EXC_PT_MAXITEMCOUNT = 32500;
79 const sal_uInt16 EXC_PT_AUTOFMT_HEADER = 0x810;
80 const sal_uInt16 EXC_PT_AUTOFMT_ZERO = 0;
81 const sal_uInt32 EXC_PT_AUTOFMT_FLAGS = 0x20;
83 /** Data type of a pivot cache item. */
84 enum XclPCItemType
86 EXC_PCITEM_INVALID, /// Special state, not used in Excel files.
87 EXC_PCITEM_EMPTY, /// Empty cell.
88 EXC_PCITEM_TEXT, /// String data.
89 EXC_PCITEM_DOUBLE, /// Floating-point value.
90 EXC_PCITEM_DATETIME, /// Date/time.
91 EXC_PCITEM_INTEGER, /// 16-bit integer value.
92 EXC_PCITEM_BOOL, /// Boolean value.
93 EXC_PCITEM_ERROR /// Error code.
96 /** Specifies the type of a pivot cache field. */
97 enum XclPCFieldType
99 EXC_PCFIELD_STANDARD, /// Standard field without grouping.
100 EXC_PCFIELD_STDGROUP, /// Standard grouping field.
101 EXC_PCFIELD_NUMGROUP, /// Numeric grouping field.
102 EXC_PCFIELD_DATEGROUP, /// First date grouping field (opt. with child grouping field).
103 EXC_PCFIELD_DATECHILD, /// Additional date grouping field.
104 EXC_PCFIELD_CALCED, /// Calculated field.
105 EXC_PCFIELD_UNKNOWN /// Unknown field state, handled like standard field.
108 // (0x0051,0x0052) DCONREF, DCONNAME ------------------------------------------
110 const sal_uInt16 EXC_ID_DCONREF = 0x0051;
111 const sal_uInt16 EXC_ID_DCONNAME = 0x0052;
113 // (0x00B0) SXVIEW ------------------------------------------------------------
115 const sal_uInt16 EXC_ID_SXVIEW = 0x00B0;
117 const sal_uInt16 EXC_SXVIEW_ROWGRAND = 0x0001;
118 const sal_uInt16 EXC_SXVIEW_COLGRAND = 0x0002;
119 const sal_uInt16 EXC_SXVIEW_DEFAULTFLAGS = 0x0208;
121 const sal_uInt16 EXC_SXVIEW_DATALAST = 0xFFFF;
122 const sal_uInt16 EXC_SXVIEW_AUTOFMT = 0x0001;
124 // (0x00B1) SXVD --------------------------------------------------------------
126 const sal_uInt16 EXC_ID_SXVD = 0x00B1;
128 const sal_uInt16 EXC_SXVD_AXIS_NONE = 0x0000;
129 const sal_uInt16 EXC_SXVD_AXIS_ROW = 0x0001;
130 const sal_uInt16 EXC_SXVD_AXIS_COL = 0x0002;
131 const sal_uInt16 EXC_SXVD_AXIS_PAGE = 0x0004;
132 const sal_uInt16 EXC_SXVD_AXIS_DATA = 0x0008;
133 const sal_uInt16 EXC_SXVD_AXIS_ROWCOL = EXC_SXVD_AXIS_ROW | EXC_SXVD_AXIS_COL;
134 const sal_uInt16 EXC_SXVD_AXIS_ROWCOLPAGE = EXC_SXVD_AXIS_ROWCOL | EXC_SXVD_AXIS_PAGE;
136 const sal_uInt16 EXC_SXVD_SUBT_NONE = 0x0000;
137 const sal_uInt16 EXC_SXVD_SUBT_DEFAULT = 0x0001;
138 const sal_uInt16 EXC_SXVD_SUBT_SUM = 0x0002;
139 const sal_uInt16 EXC_SXVD_SUBT_COUNT = 0x0004;
140 const sal_uInt16 EXC_SXVD_SUBT_AVERAGE = 0x0008;
141 const sal_uInt16 EXC_SXVD_SUBT_MAX = 0x0010;
142 const sal_uInt16 EXC_SXVD_SUBT_MIN = 0x0020;
143 const sal_uInt16 EXC_SXVD_SUBT_PROD = 0x0040;
144 const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM = 0x0080;
145 const sal_uInt16 EXC_SXVD_SUBT_STDDEV = 0x0100;
146 const sal_uInt16 EXC_SXVD_SUBT_STDDEVP = 0x0200;
147 const sal_uInt16 EXC_SXVD_SUBT_VAR = 0x0400;
148 const sal_uInt16 EXC_SXVD_SUBT_VARP = 0x0800;
150 const sal_uInt16 EXC_SXVD_DEFAULT_CACHE = EXC_PC_NOFIELD;
152 // (0x00B2) SXVI --------------------------------------------------------------
154 const sal_uInt16 EXC_ID_SXVI = 0x00B2;
156 const sal_uInt16 EXC_SXVI_TYPE_PAGE = 0x00FE;
157 const sal_uInt16 EXC_SXVI_TYPE_NULL = 0x00FF;
158 const sal_uInt16 EXC_SXVI_TYPE_DATA = 0x0000;
159 const sal_uInt16 EXC_SXVI_TYPE_DEFAULT = 0x0001;
160 const sal_uInt16 EXC_SXVI_TYPE_SUM = 0x0002;
161 const sal_uInt16 EXC_SXVI_TYPE_COUNT = 0x0003;
162 const sal_uInt16 EXC_SXVI_TYPE_AVERAGE = 0x0004;
163 const sal_uInt16 EXC_SXVI_TYPE_MAX = 0x0005;
164 const sal_uInt16 EXC_SXVI_TYPE_MIN = 0x0006;
165 const sal_uInt16 EXC_SXVI_TYPE_PROD = 0x0007;
166 const sal_uInt16 EXC_SXVI_TYPE_COUNTNUM = 0x0008;
167 const sal_uInt16 EXC_SXVI_TYPE_STDDEV = 0x0009;
168 const sal_uInt16 EXC_SXVI_TYPE_STDDEVP = 0x000A;
169 const sal_uInt16 EXC_SXVI_TYPE_VAR = 0x000B;
170 const sal_uInt16 EXC_SXVI_TYPE_VARP = 0x000C;
171 const sal_uInt16 EXC_SXVI_TYPE_GRAND = 0x000D;
173 const sal_uInt16 EXC_SXVI_DEFAULTFLAGS = 0x0000;
174 const sal_uInt16 EXC_SXVI_HIDDEN = 0x0001;
175 const sal_uInt16 EXC_SXVI_HIDEDETAIL = 0x0002;
176 const sal_uInt16 EXC_SXVI_FORMULA = 0x0004;
177 const sal_uInt16 EXC_SXVI_MISSING = 0x0008;
179 const sal_uInt16 EXC_SXVI_DEFAULT_CACHE = EXC_PC_NOFIELD;
181 // (0x00B4) SXIVD -------------------------------------------------------------
183 const sal_uInt16 EXC_ID_SXIVD = 0x00B4;
184 const sal_uInt16 EXC_SXIVD_DATA = 0xFFFE;
186 // (0x00B5) SXLI --------------------------------------------------------------
188 const sal_uInt16 EXC_ID_SXLI = 0x00B5;
189 const sal_uInt16 EXC_SXLI_DEFAULTFLAGS = 0x0000;
191 // (0x00B6) SXPI --------------------------------------------------------------
193 const sal_uInt16 EXC_ID_SXPI = 0x00B6;
194 const sal_uInt16 EXC_SXPI_ALLITEMS = 0x7FFD;
196 // (0x00C5) SXDI --------------------------------------------------------------
198 const sal_uInt16 EXC_ID_SXDI = 0x00C5;
200 const sal_uInt16 EXC_SXDI_FUNC_SUM = 0x0000;
201 const sal_uInt16 EXC_SXDI_FUNC_COUNT = 0x0001;
202 const sal_uInt16 EXC_SXDI_FUNC_AVERAGE = 0x0002;
203 const sal_uInt16 EXC_SXDI_FUNC_MAX = 0x0003;
204 const sal_uInt16 EXC_SXDI_FUNC_MIN = 0x0004;
205 const sal_uInt16 EXC_SXDI_FUNC_PRODUCT = 0x0005;
206 const sal_uInt16 EXC_SXDI_FUNC_COUNTNUM = 0x0006;
207 const sal_uInt16 EXC_SXDI_FUNC_STDDEV = 0x0007;
208 const sal_uInt16 EXC_SXDI_FUNC_STDDEVP = 0x0008;
209 const sal_uInt16 EXC_SXDI_FUNC_VAR = 0x0009;
210 const sal_uInt16 EXC_SXDI_FUNC_VARP = 0x000A;
212 const sal_uInt16 EXC_SXDI_REF_NORMAL = 0x0000;
213 const sal_uInt16 EXC_SXDI_REF_DIFF = 0x0001;
214 const sal_uInt16 EXC_SXDI_REF_PERC = 0x0002;
215 const sal_uInt16 EXC_SXDI_REF_PERC_DIFF = 0x0003;
216 const sal_uInt16 EXC_SXDI_REF_RUN_TOTAL = 0x0004;
217 const sal_uInt16 EXC_SXDI_REF_PERC_ROW = 0x0005;
218 const sal_uInt16 EXC_SXDI_REF_PERC_COL = 0x0006;
219 const sal_uInt16 EXC_SXDI_REF_PERC_TOTAL = 0x0007;
220 const sal_uInt16 EXC_SXDI_REF_INDEX = 0x0008;
222 const sal_uInt16 EXC_SXDI_PREVITEM = 0x7FFB;
223 const sal_uInt16 EXC_SXDI_NEXTITEM = 0x7FFC;
225 // (0x00C6) SXDB --------------------------------------------------------------
227 const sal_uInt16 EXC_ID_SXDB = 0x00C6;
229 const sal_uInt16 EXC_SXDB_SAVEDATA = 0x0001;
230 const sal_uInt16 EXC_SXDB_INVALID = 0x0002;
231 const sal_uInt16 EXC_SXDB_REFRESH_LOAD = 0x0004;
232 const sal_uInt16 EXC_SXDB_OPT_CACHE = 0x0008;
233 const sal_uInt16 EXC_SXDB_BG_QUERY = 0x0010;
234 const sal_uInt16 EXC_SXDB_ENABLE_REFRESH = 0x0020;
235 const sal_uInt16 EXC_SXDB_DEFAULTFLAGS = EXC_SXDB_SAVEDATA | EXC_SXDB_ENABLE_REFRESH;
237 const sal_uInt16 EXC_SXDB_BLOCKRECS = 0x1FFF;
239 const sal_uInt16 EXC_SXDB_SRC_SHEET = 0x0001;
240 const sal_uInt16 EXC_SXDB_SRC_EXTERN = 0x0002;
241 const sal_uInt16 EXC_SXDB_SRC_CONSOLID = 0x0004;
242 const sal_uInt16 EXC_SXDB_SRC_SCENARIO = 0x0008;
244 // (0x00C7) SXFIELD -----------------------------------------------------------
246 const sal_uInt16 EXC_ID_SXFIELD = 0x00C7;
248 const sal_uInt16 EXC_SXFIELD_HASITEMS = 0x0001;
249 const sal_uInt16 EXC_SXFIELD_POSTPONE = 0x0002;
250 const sal_uInt16 EXC_SXFIELD_CALCED = 0x0004;
251 const sal_uInt16 EXC_SXFIELD_HASCHILD = 0x0008;
252 const sal_uInt16 EXC_SXFIELD_NUMGROUP = 0x0010;
253 const sal_uInt16 EXC_SXFIELD_16BIT = 0x0200;
255 const sal_uInt16 EXC_SXFIELD_DATA_MASK = 0x0DE0;
256 // known data types
257 const sal_uInt16 EXC_SXFIELD_DATA_NONE = 0x0000; /// Special state for groupings.
258 const sal_uInt16 EXC_SXFIELD_DATA_STR = 0x0480; /// Only strings, nothing else.
259 const sal_uInt16 EXC_SXFIELD_DATA_INT = 0x0520; /// Only integers, opt. with doubles.
260 const sal_uInt16 EXC_SXFIELD_DATA_DBL = 0x0560; /// Only doubles, nothing else.
261 const sal_uInt16 EXC_SXFIELD_DATA_STR_INT = 0x05A0; /// Only strings and integers, opt. with doubles.
262 const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL = 0x05E0; /// Only strings and doubles, nothing else.
263 const sal_uInt16 EXC_SXFIELD_DATA_DATE = 0x0900; /// Only dates, nothing else.
264 const sal_uInt16 EXC_SXFIELD_DATA_DATE_EMP = 0x0980; /// Dates and empty strings, nothing else (?).
265 const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM = 0x0D00; /// Dates with integers or doubles without strings.
266 const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR = 0x0D80; /// Dates and strings, opt. with integers or doubles.
268 const sal_uInt16 EXC_SXFIELD_INDEX_MIN = 0; /// List index for minimum item in groupings.
269 const sal_uInt16 EXC_SXFIELD_INDEX_MAX = 1; /// List index for maximum item in groupings.
270 const sal_uInt16 EXC_SXFIELD_INDEX_STEP = 2; /// List index for step item in groupings.
272 // (0x00C8) SXINDEXLIST -------------------------------------------------------
274 const sal_uInt16 EXC_ID_SXINDEXLIST = 0x00C8;
276 // (0x00C9) SXDOUBLE ----------------------------------------------------------
278 const sal_uInt16 EXC_ID_SXDOUBLE = 0x00C9;
280 // (0x00CA) SXBOOLEAN ---------------------------------------------------------
282 const sal_uInt16 EXC_ID_SXBOOLEAN = 0x00CA;
284 // (0x00CB) SXERROR -----------------------------------------------------------
286 const sal_uInt16 EXC_ID_SXERROR = 0x00CB;
288 // (0x00CC) SXINTEGER ---------------------------------------------------------
290 const sal_uInt16 EXC_ID_SXINTEGER = 0x00CC;
292 // (0x00CD) SXSTRING ----------------------------------------------------------
294 const sal_uInt16 EXC_ID_SXSTRING = 0x00CD;
296 // (0x00CE) SXDATETIME --------------------------------------------------------
298 const sal_uInt16 EXC_ID_SXDATETIME = 0x00CE;
300 // (0x00CF) SXEMPTY -----------------------------------------------------------
302 const sal_uInt16 EXC_ID_SXEMPTY = 0x00CF;
304 // (0x00D5) SXIDSTM -----------------------------------------------------------
306 const sal_uInt16 EXC_ID_SXIDSTM = 0x00D5;
308 // (0x00D8) SXNUMGROUP --------------------------------------------------------
310 const sal_uInt16 EXC_ID_SXNUMGROUP = 0x00D8;
312 const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN = 0x0001;
313 const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX = 0x0002;
315 const sal_uInt16 EXC_SXNUMGROUP_TYPE_SEC = 1;
316 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MIN = 2;
317 const sal_uInt16 EXC_SXNUMGROUP_TYPE_HOUR = 3;
318 const sal_uInt16 EXC_SXNUMGROUP_TYPE_DAY = 4;
319 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MONTH = 5;
320 const sal_uInt16 EXC_SXNUMGROUP_TYPE_QUART = 6;
321 const sal_uInt16 EXC_SXNUMGROUP_TYPE_YEAR = 7;
322 const sal_uInt16 EXC_SXNUMGROUP_TYPE_NUM = 8;
324 // (0x00D9) SXGROUPINFO -------------------------------------------------------
326 const sal_uInt16 EXC_ID_SXGROUPINFO = 0x00D9;
328 // (0x00DC) SXEXT -------------------------------------------------------------
330 const sal_uInt16 EXC_ID_SXEXT = 0x00DC;
332 // (0x00E3) SXVS --------------------------------------------------------------
334 const sal_uInt16 EXC_ID_SXVS = 0x00E3;
336 const sal_uInt16 EXC_SXVS_UNKNOWN = 0x0000;
337 const sal_uInt16 EXC_SXVS_SHEET = 0x0001;
338 const sal_uInt16 EXC_SXVS_EXTERN = 0x0002;
339 const sal_uInt16 EXC_SXVS_CONSOLID = 0x0004;
340 const sal_uInt16 EXC_SXVS_PIVOTTAB = 0x0008;
341 const sal_uInt16 EXC_SXVS_SCENARIO = 0x0010;
343 // (0x00F0) SXRULE ------------------------------------------------------------
345 const sal_uInt16 EXC_ID_SXRULE = 0x00F0;
347 // (0x00F1) SXEX --------------------------------------------------------------
349 const sal_uInt16 EXC_ID_SXEX = 0x00F1;
351 const sal_uInt32 EXC_SXEX_DRILLDOWN = 0x00020000;
352 const sal_uInt32 EXC_SXEX_DEFAULTFLAGS = 0x004F0200;
354 // (0x00F2) SXFILT ------------------------------------------------------------
356 const sal_uInt16 EXC_ID_SXFILT = 0x00F2;
358 // (0x00F5) -------------------------------------------------------------------
360 const sal_uInt16 EXC_ID_00F5 = 0x00F5; /// Unknown record
362 // (0x00F6) SXNAME ------------------------------------------------------------
364 const sal_uInt16 EXC_ID_SXNAME = 0x00F6;
366 // (0x00F8) SXPAIR ------------------------------------------------------------
368 const sal_uInt16 EXC_ID_SXPAIR = 0x00F8;
370 // (0x00F9) SXFMLA ------------------------------------------------------------
372 const sal_uInt16 EXC_ID_SXFMLA = 0x00F9;
374 // (0x0100) SXVDEX ------------------------------------------------------------
376 const sal_uInt16 EXC_ID_SXVDEX = 0x0100;
378 const sal_uInt32 EXC_SXVDEX_SHOWALL = 0x00000001;
379 const sal_uInt32 EXC_SXVDEX_SORT = 0x00000200;
380 const sal_uInt32 EXC_SXVDEX_SORT_ASC = 0x00000400;
381 const sal_uInt32 EXC_SXVDEX_AUTOSHOW = 0x00000800;
382 const sal_uInt32 EXC_SXVDEX_AUTOSHOW_ASC = 0x00001000;
383 const sal_uInt32 EXC_SXVDEX_LAYOUT_REPORT = 0x00200000;
384 const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK = 0x00400000;
385 const sal_uInt32 EXC_SXVDEX_LAYOUT_TOP = 0x00800000;
386 const sal_uInt32 EXC_SXVDEX_DEFAULTFLAGS = 0x0A00001E | EXC_SXVDEX_SORT_ASC | EXC_SXVDEX_AUTOSHOW_ASC;
388 const sal_uInt16 EXC_SXVDEX_SORT_OWN = 0xFFFF;
389 const sal_uInt16 EXC_SXVDEX_SHOW_NONE = 0xFFFF;
390 const sal_uInt16 EXC_SXVDEX_FORMAT_NONE = 0x0000;
392 // (0x0103) SXFORMULA ---------------------------------------------------------
394 const sal_uInt16 EXC_ID_SXFORMULA = 0x0103;
396 // (0x0122) SXDBEX ------------------------------------------------------------
398 const sal_uInt16 EXC_ID_SXDBEX = 0x0122;
399 const double EXC_SXDBEX_CREATION_DATE = 51901.029652778;
401 // (0x01BB) SXFDBTYPE ---------------------------------------------------------
403 const sal_uInt16 EXC_ID_SXFDBTYPE = 0x01BB;
404 const sal_uInt16 EXC_SXFDBTYPE_DEFAULT = 0x0000;
406 // (0x0810) SXVIEWEX9 ---------------------------------------------------------
407 const sal_uInt16 EXC_ID_SXVIEWEX9 = 0x0810;
409 // ============================================================================
410 // Pivot cache
411 // ============================================================================
413 /** Represents a data item of any type in a pivot cache. Supposed as base class for import and export. */
414 class XclPCItem
416 public:
417 explicit XclPCItem();
418 virtual ~XclPCItem();
420 /** Sets the item to 'empty' type. */
421 void SetEmpty();
422 /** Sets the item to 'text' type and adds the passed text. */
423 void SetText( const String& rText );
424 /** Sets the item to 'double' type and adds the passed value. */
425 void SetDouble( double fValue );
426 /** Sets the item to 'date/time' type and adds the passed date. */
427 void SetDateTime( const DateTime& rDateTime );
428 /** Sets the item to 'integer' type and adds the passed value. */
429 void SetInteger( sal_Int16 nValue );
430 /** Sets the item to 'error' type and adds the passed Excel error code. */
431 void SetError( sal_uInt16 nError );
432 /** Sets the item to 'boolean' type and adds the passed Boolean value. */
433 void SetBool( bool bValue );
435 /** Returns the current item type. */
436 inline XclPCItemType GetType() const { return meType; }
437 /** Returns the text representation of the item. */
438 inline const String& ConvertToText() const { return maText; }
440 /** Returns true, if the passed iterm equals this item. */
441 bool IsEqual( const XclPCItem& rItem ) const;
443 /** Returns true, if the item type is 'empty'. */
444 bool IsEmpty() const;
445 /** Returns pointer to text, if the item type is 'text', otherwise 0. */
446 const String* GetText() const;
447 /** Returns pointer to value, if the item type is 'double', otherwise 0. */
448 const double* GetDouble() const;
449 /** Returns pointer to date, if the item type is 'date/time', otherwise 0. */
450 const DateTime* GetDateTime() const;
451 /** Returns pointer to integer, if the item type is 'integer', otherwise 0. */
452 const sal_Int16* GetInteger() const;
453 /** Returns pointer to error code, if the item type is 'error', otherwise 0. */
454 const sal_uInt16* GetError() const;
455 /** Returns pointer to Boolean value, if the item type is 'boolean', otherwise 0. */
456 const bool* GetBool() const;
458 private:
459 XclPCItemType meType; /// Type of the item.
460 String maText; /// Text representation of the item.
461 DateTime maDateTime; /// Value of a date/time item.
462 union
464 double mfValue; /// Value of a floating-point item.
465 sal_Int16 mnValue; /// Value of an integer item.
466 sal_uInt16 mnError; /// Error code of an error item.
467 bool mbValue; /// Value of a boolean item.
471 inline bool operator==( const XclPCItem& rLeft, const XclPCItem& rRight ) { return rLeft.IsEqual( rRight ); }
472 inline bool operator!=( const XclPCItem& rLeft, const XclPCItem& rRight ) { return !(rLeft == rRight); }
474 // Field settings =============================================================
476 /** Contains data for a pivot cache field (SXFIELD record). */
477 struct XclPCFieldInfo
479 String maName; /// Name of the pivot cache field.
480 sal_uInt16 mnFlags; /// Various flags.
481 sal_uInt16 mnGroupChild; /// Field containing grouping info for this field.
482 sal_uInt16 mnGroupBase; /// Base field if this field contains grouping info.
483 sal_uInt16 mnVisItems; /// Number of visible items for this field.
484 sal_uInt16 mnGroupItems; /// Number of special items in a grouping field.
485 sal_uInt16 mnBaseItems; /// Number of items in the base field.
486 sal_uInt16 mnOrigItems; /// Number of original source data items.
488 explicit XclPCFieldInfo();
491 XclImpStream& operator>>( XclImpStream& rStrm, XclPCFieldInfo& rInfo );
492 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCFieldInfo& rInfo );
494 // Numeric grouping field settings ============================================
496 /** Contains data for a numeric grouping field (SXNUMGROUP record). */
497 struct XclPCNumGroupInfo
499 sal_uInt16 mnFlags; /// Various flags.
501 explicit XclPCNumGroupInfo();
503 void SetNumType();
505 sal_Int32 GetScDateType() const;
506 void SetScDateType( sal_Int32 nScType );
508 sal_uInt16 GetXclDataType() const;
509 void SetXclDataType( sal_uInt16 nXclType );
512 XclImpStream& operator>>( XclImpStream& rStrm, XclPCNumGroupInfo& rInfo );
513 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCNumGroupInfo& rInfo );
515 // Base class for pivot cache fields ==========================================
517 /** Represents a field in a pivot cache. Supposed as base class for import and export. */
518 class XclPCField
520 public:
521 explicit XclPCField( XclPCFieldType eFieldType, sal_uInt16 nFieldIdx );
522 virtual ~XclPCField();
524 /** Returns the index of this field in the containing pivot cache. */
525 inline sal_uInt16 GetFieldIndex() const { return mnFieldIdx; }
527 /** Returns true, if the type of the field is supported by Calc. */
528 bool IsSupportedField() const;
530 /** Returns true, if this is a standard field build directly from source data. */
531 bool IsStandardField() const;
533 //UNUSED2008-05 /** Returns true, if the items of the field are calculated from a formula. */
534 //UNUSED2008-05 bool IsCalculatedField() const;
536 /** Returns true, if this field is a grouping field. */
537 bool IsStdGroupField() const;
538 /** Returns true, if this field is a numeric grouping field. */
539 bool IsNumGroupField() const;
540 /** Returns true, if this field is a date/time grouping field. */
541 bool IsDateGroupField() const;
542 /** Returns true, if this field is a grouping field of any type. */
543 bool IsGroupField() const;
545 /** Returns true, if this field has a child field in a grouping. */
546 bool IsGroupBaseField() const;
547 /** Returns true, if this field is a child field in a grouping (it has a base field). */
548 bool IsGroupChildField() const;
549 /** Returns the index of the base field, if exists, otherwise the own index. */
550 sal_uInt16 GetBaseFieldIndex() const;
552 /** Returns true, if the field is based on a column in the source data area. */
553 bool HasOrigItems() const;
554 /** Returns true, if any items are stored after the SXFIELD record. */
555 bool HasInlineItems() const;
556 /** Returns true, if the items are stored separately after the last field. */
557 bool HasPostponedItems() const;
558 /** Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values. */
559 bool Has16BitIndexes() const;
561 protected:
562 XclPCFieldInfo maFieldInfo; /// Pivot cache field info (SXFIELD record).
563 XclPCFieldType meFieldType; /// Type of this pivot cache field.
564 sal_uInt16 mnFieldIdx; /// Own field index in pivot cache.
565 ScfUInt16Vec maGroupOrder; /// Order of items in a grouping field (SXGROUPINFO record).
566 XclPCNumGroupInfo maNumGroupInfo; /// Info for numeric grouping (SXNUMGROUP record).
569 // Pivot cache settings =======================================================
571 /** Contains data for a pivot cache (SXDB record). */
572 struct XclPCInfo
574 sal_uInt32 mnSrcRecs; /// Records in source database.
575 sal_uInt16 mnStrmId; /// Stream identifier.
576 sal_uInt16 mnFlags; /// Flags for the cache.
577 sal_uInt16 mnBlockRecs; /// Records in a source database block.
578 sal_uInt16 mnStdFields; /// Number of standard pivot cache fields.
579 sal_uInt16 mnTotalFields; /// Number of all fields (standard, grouped, calculated).
580 sal_uInt16 mnSrcType; /// Database type.
581 String maUserName; /// Name of user who last modified the cache.
583 explicit XclPCInfo();
586 XclImpStream& operator>>( XclImpStream& rStrm, XclPCInfo& rInfo );
587 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCInfo& rInfo );
589 // ============================================================================
590 // Pivot table
591 // ============================================================================
593 // cached name ================================================================
595 /** A name for various pivot table info structs. Includes 'use cache' state. */
596 struct XclPTCachedName
598 String maName; /// The visible name, if used.
599 bool mbUseCache; /// true = Use name in cache instead of maName.
601 inline explicit XclPTCachedName() : mbUseCache( true ) {}
604 XclImpStream& operator>>( XclImpStream& rStrm, XclPTCachedName& rCachedName );
605 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTCachedName& rCachedName );
607 // ----------------------------------------------------------------------------
609 /** Base struct for named info structs. Supports explicit naming and using the cache. */
610 struct XclPTVisNameInfo
612 XclPTCachedName maVisName; /// The displayed name of the item.
614 /** Returns true, if the name is set explicitly (maVisName.mbUseCache is false). */
615 inline bool HasVisName() const { return !maVisName.mbUseCache; }
616 /** Returns the name, if set explicitly (maVisName.mbUseCache is false). */
617 const String* GetVisName() const;
618 /** Sets the visible name and enables usage of cache if name is empty. */
619 void SetVisName( const String& rName );
622 // Field item settings ========================================================
624 /** Contains data for a pivot table data item (SXVI record). */
625 struct XclPTItemInfo : public XclPTVisNameInfo
627 sal_uInt16 mnType; /// Type of the item (e.g. data, function, grand total).
628 sal_uInt16 mnFlags; /// Several flags.
629 sal_uInt16 mnCacheIdx; /// Index into cache for item name.
631 explicit XclPTItemInfo();
634 XclImpStream& operator>>( XclImpStream& rStrm, XclPTItemInfo& rInfo );
635 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTItemInfo& rInfo );
637 // General field settings =====================================================
639 typedef ::std::vector< USHORT > XclPTSubtotalVec;
641 /** Contains data for a pivot table field (SXVD record). */
642 struct XclPTFieldInfo : public XclPTVisNameInfo
644 sal_uInt16 mnAxes; /// Flags for axes this field is part of.
645 sal_uInt16 mnSubtCount; /// Number of subtotal functions.
646 sal_uInt16 mnSubtotals; /// Bitfield for subtotal functions.
647 sal_uInt16 mnItemCount; /// Number of items of this field.
648 sal_uInt16 mnCacheIdx; /// Index into cache for field name (not part of record).
650 explicit XclPTFieldInfo();
652 /** Returns the API enum representing the orientation (first of row/col/page/data).
653 @param nMask Restricts the axes taken into account.
654 @return The first found axis orientation, that is allowed in nMask parameter. */
655 ::com::sun::star::sheet::DataPilotFieldOrientation GetApiOrient( sal_uInt16 nMask ) const;
656 /** Adds the axis orientation represented by the passed API enum. */
657 void AddApiOrient( ::com::sun::star::sheet::DataPilotFieldOrientation eOrient );
659 /** Returns a vector of all set subtotal functions. */
660 void GetSubtotals( XclPTSubtotalVec& rSubtotals ) const;
661 /** Sets the subtotal functions contained in the passed sequence. */
662 void SetSubtotals( const XclPTSubtotalVec& rSubtotals );
665 XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldInfo& rInfo );
666 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldInfo& rInfo );
668 // Extended field settings ====================================================
670 /** Contains extended data for a pivot table field (SXVDEX record). */
671 struct XclPTFieldExtInfo
673 sal_uInt32 mnFlags; /// Several flags and number of items for AutoShow.
674 sal_uInt16 mnSortField; /// Index to data field sorting bases on.
675 sal_uInt16 mnShowField; /// Index to data field AutoShow bases on.
676 sal_uInt16 mnNumFmt;
677 ::std::auto_ptr<rtl::OUString> mpFieldTotalName;
679 explicit XclPTFieldExtInfo();
681 /** Returns the API constant representing the sorting mode. */
682 sal_Int32 GetApiSortMode() const;
683 /** Sets the sorting mode represented by the passed API constant. */
684 void SetApiSortMode( sal_Int32 nSortMode );
686 /** Returns the API constant representing the AutoShow mode. */
687 sal_Int32 GetApiAutoShowMode() const;
688 /** Sets the AutoShow mode represented by the passed API constant. */
689 void SetApiAutoShowMode( sal_Int32 nShowMode );
691 /** Returns the number of items to be shown in AutoShow mode. */
692 sal_Int32 GetApiAutoShowCount() const;
693 /** Sets the number of items to be shown in AutoShow mode. */
694 void SetApiAutoShowCount( sal_Int32 nShowCount );
696 /** Returns the API constant representing the layout mode. */
697 sal_Int32 GetApiLayoutMode() const;
698 /** Sets the layout mode represented by the passed API constant. */
699 void SetApiLayoutMode( sal_Int32 nLayoutMode );
702 XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldExtInfo& rInfo );
703 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo );
705 // Page field settings ========================================================
707 /** Contains data for a pivot table page field (part of SXPI record). */
708 struct XclPTPageFieldInfo
710 sal_uInt16 mnField; /// Base field for this page info.
711 sal_uInt16 mnSelItem; /// Index to selected item.
712 sal_uInt16 mnObjId; /// Escher object ID of dropdown listbox.
714 explicit XclPTPageFieldInfo();
717 XclImpStream& operator>>( XclImpStream& rStrm, XclPTPageFieldInfo& rInfo );
718 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTPageFieldInfo& rInfo );
720 // Data field settings ========================================================
722 /** Contains data for a pivot table data field (SXDI record). */
723 struct XclPTDataFieldInfo : public XclPTVisNameInfo
725 sal_uInt16 mnField; /// Base field for this data info.
726 sal_uInt16 mnAggFunc; /// Data aggregation function.
727 sal_uInt16 mnRefType; /// Result reference type.
728 sal_uInt16 mnRefField; /// Index to SXVD of referred field used for the results.
729 sal_uInt16 mnRefItem; /// Index to SXVI of referred item of the used field.
730 sal_uInt16 mnNumFmt; /// Number format of the results.
732 explicit XclPTDataFieldInfo();
734 /** Returns the API enum representing the aggregation function. */
735 ::com::sun::star::sheet::GeneralFunction GetApiAggFunc() const;
736 /** Sets the aggregation function represented by the passed API enum. */
737 void SetApiAggFunc( ::com::sun::star::sheet::GeneralFunction eAggFunc );
739 /** Returns the API constant representing the result reference type. */
740 sal_Int32 GetApiRefType() const;
741 /** Sets the result reference type represented by the passed API constant. */
742 void SetApiRefType( sal_Int32 nRefType );
744 /** Returns the API constant representing the result reference item type. */
745 sal_Int32 GetApiRefItemType() const;
746 /** Sets the result reference item type represented by the passed API constant. */
747 void SetApiRefItemType( sal_Int32 nRefItemType );
750 XclImpStream& operator>>( XclImpStream& rStrm, XclPTDataFieldInfo& rInfo );
751 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTDataFieldInfo& rInfo );
753 // Pivot table settings =======================================================
755 /** Contains data for a pivot table (SXVIEW record). */
756 struct XclPTInfo
758 String maTableName; /// The name of the pivot table.
759 String maDataName; /// The visible name of the data field.
760 XclRange maOutXclRange; /// Output range.
761 XclAddress maDataXclPos; /// First cell containing data.
762 sal_uInt16 mnFirstHeadRow; /// First heading row.
763 sal_uInt16 mnCacheIdx; /// 0-based index of the pivot cache.
764 sal_uInt16 mnDataAxis; /// Orientation of data fields.
765 sal_uInt16 mnDataPos; /// Position of data fields.
766 sal_uInt16 mnFields; /// Number of all fields.
767 sal_uInt16 mnRowFields; /// Number of row fields.
768 sal_uInt16 mnColFields; /// Number of column fields.
769 sal_uInt16 mnPageFields; /// Number of page fields.
770 sal_uInt16 mnDataFields; /// Number of data fields.
771 sal_uInt16 mnDataRows; /// Number of rows containing data.
772 sal_uInt16 mnDataCols; /// Number of columns containing data.
773 sal_uInt16 mnFlags; /// Flags for the entire pivot table.
774 sal_uInt16 mnAutoFmtIdx; /// Index to pivot table autoformat.
776 explicit XclPTInfo();
779 XclImpStream& operator>>( XclImpStream& rStrm, XclPTInfo& rInfo );
780 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTInfo& rInfo );
782 // Extended pivot table settings ==============================================
784 /** Extended information about a pivot table (SXEX record). */
785 struct XclPTExtInfo
787 sal_uInt16 mnSxformulaRecs; /// Number of SXFORMULA records.
788 sal_uInt16 mnSxselectRecs; /// Number of SXSELECT records.
789 sal_uInt16 mnPagePerRow; /// Number of page fields per row.
790 sal_uInt16 mnPagePerCol; /// Number of page fields per column.
791 sal_uInt32 mnFlags; /// Flags for the entire pivot table.
793 explicit XclPTExtInfo();
796 XclImpStream& operator>>( XclImpStream& rStrm, XclPTExtInfo& rInfo );
797 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo );
799 // ============================================================================
801 // Pivot table autoformat settings ==============================================
803 /** Pivot table autoformat settings (SXVIEWEX9 record). */
804 struct XclPTViewEx9Info
806 sal_uInt32 mbReport; /// 2 for report* fmts ?
807 sal_uInt8 mnAutoFormat; /// AutoFormat ID
808 sal_uInt8 mnGridLayout; /// 0 == gridlayout, 0x10 == modern
809 String maGrandTotalName;
811 explicit XclPTViewEx9Info();
812 void Init( const ScDPObject& rDPObj );
815 XclImpStream& operator>>( XclImpStream& rStrm, XclPTViewEx9Info& rInfo );
816 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTViewEx9Info& rInfo );
818 // ============================================================================
819 #endif