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