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