1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/DataPilotFieldOrientation.hpp>
24 #include <tools/datetime.hxx>
26 #include "xladdress.hxx"
27 #include <dpobject.hxx>
29 #include <boost/optional.hpp>
33 enum class ScGeneralFunction
;
35 // Constants and Enumerations =================================================
37 // misc -----------------------------------------------------------------------
39 #define EXC_STORAGE_PTCACHE "_SX_DB_CUR"
42 const sal_uInt16 EXC_PT_NOSTRING
= 0xFFFF;
43 const sal_uInt16 EXC_PT_MAXSTRLEN
= 0xFFFE;
46 const size_t EXC_PC_MAXFIELDCOUNT
= 0xFFFE;
47 const sal_uInt16 EXC_PC_NOFIELD
= 0xFFFF;
48 const sal_Int32 EXC_PC_MAXSTRLEN
= 255;
51 const size_t EXC_PC_MAXITEMCOUNT
= 32500;
52 const sal_uInt16 EXC_PC_NOITEM
= 0xFFFF;
55 const sal_uInt16 EXC_PT_MAXFIELDCOUNT
= 0xFFFE;
56 const sal_uInt16 EXC_PT_MAXROWCOLCOUNT
= EXC_PT_MAXFIELDCOUNT
;
57 const sal_uInt16 EXC_PT_MAXPAGECOUNT
= 256;
58 const sal_uInt16 EXC_PT_MAXDATACOUNT
= 256;
61 const sal_uInt16 EXC_PT_MAXITEMCOUNT
= 32500;
63 const sal_uInt16 EXC_PT_AUTOFMT_HEADER
= 0x810;
64 const sal_uInt16 EXC_PT_AUTOFMT_ZERO
= 0;
65 const sal_uInt32 EXC_PT_AUTOFMT_FLAGS
= 0x20;
67 /** Data type of a pivot cache item. */
70 EXC_PCITEM_INVALID
, /// Special state, not used in Excel files.
71 EXC_PCITEM_EMPTY
, /// Empty cell.
72 EXC_PCITEM_TEXT
, /// String data.
73 EXC_PCITEM_DOUBLE
, /// Floating-point value.
74 EXC_PCITEM_DATETIME
, /// Date/time.
75 EXC_PCITEM_INTEGER
, /// 16-bit integer value.
76 EXC_PCITEM_BOOL
, /// Boolean value.
77 EXC_PCITEM_ERROR
/// Error code.
80 /** Specifies the type of a pivot cache field. */
83 EXC_PCFIELD_STANDARD
, /// Standard field without grouping.
84 EXC_PCFIELD_STDGROUP
, /// Standard grouping field.
85 EXC_PCFIELD_NUMGROUP
, /// Numeric grouping field.
86 EXC_PCFIELD_DATEGROUP
, /// First date grouping field (opt. with child grouping field).
87 EXC_PCFIELD_DATECHILD
, /// Additional date grouping field.
88 EXC_PCFIELD_CALCED
, /// Calculated field.
89 EXC_PCFIELD_UNKNOWN
/// Unknown field state, handled like standard field.
92 // (0x0051,0x0052) DCONREF, DCONNAME ------------------------------------------
94 const sal_uInt16 EXC_ID_DCONREF
= 0x0051;
95 const sal_uInt16 EXC_ID_DCONNAME
= 0x0052;
97 // (0x00B0) SXVIEW ------------------------------------------------------------
99 const sal_uInt16 EXC_ID_SXVIEW
= 0x00B0;
101 const sal_uInt16 EXC_SXVIEW_ROWGRAND
= 0x0001;
102 const sal_uInt16 EXC_SXVIEW_COLGRAND
= 0x0002;
103 const sal_uInt16 EXC_SXVIEW_DEFAULTFLAGS
= 0x0208;
105 const sal_uInt16 EXC_SXVIEW_DATALAST
= 0xFFFF;
106 const sal_uInt16 EXC_SXVIEW_AUTOFMT
= 0x0001;
108 // (0x00B1) SXVD --------------------------------------------------------------
109 const sal_uInt16 EXC_ID_SXVD
= 0x00B1;
111 const sal_uInt16 EXC_SXVD_AXIS_NONE
= 0x0000;
112 const sal_uInt16 EXC_SXVD_AXIS_ROW
= 0x0001;
113 const sal_uInt16 EXC_SXVD_AXIS_COL
= 0x0002;
114 const sal_uInt16 EXC_SXVD_AXIS_PAGE
= 0x0004;
115 const sal_uInt16 EXC_SXVD_AXIS_DATA
= 0x0008;
116 const sal_uInt16 EXC_SXVD_AXIS_ROWCOL
= EXC_SXVD_AXIS_ROW
| EXC_SXVD_AXIS_COL
;
117 const sal_uInt16 EXC_SXVD_AXIS_ROWCOLPAGE
= EXC_SXVD_AXIS_ROWCOL
| EXC_SXVD_AXIS_PAGE
;
119 const sal_uInt16 EXC_SXVD_SUBT_NONE
= 0x0000;
120 const sal_uInt16 EXC_SXVD_SUBT_DEFAULT
= 0x0001;
121 const sal_uInt16 EXC_SXVD_SUBT_SUM
= 0x0002;
122 const sal_uInt16 EXC_SXVD_SUBT_COUNT
= 0x0004;
123 const sal_uInt16 EXC_SXVD_SUBT_AVERAGE
= 0x0008;
124 const sal_uInt16 EXC_SXVD_SUBT_MAX
= 0x0010;
125 const sal_uInt16 EXC_SXVD_SUBT_MIN
= 0x0020;
126 const sal_uInt16 EXC_SXVD_SUBT_PROD
= 0x0040;
127 const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM
= 0x0080;
128 const sal_uInt16 EXC_SXVD_SUBT_STDDEV
= 0x0100;
129 const sal_uInt16 EXC_SXVD_SUBT_STDDEVP
= 0x0200;
130 const sal_uInt16 EXC_SXVD_SUBT_VAR
= 0x0400;
131 const sal_uInt16 EXC_SXVD_SUBT_VARP
= 0x0800;
133 const sal_uInt16 EXC_SXVD_DEFAULT_CACHE
= EXC_PC_NOFIELD
;
135 // (0x00B2) SXVI --------------------------------------------------------------
136 const sal_uInt16 EXC_ID_SXVI
= 0x00B2;
138 const sal_uInt16 EXC_SXVI_TYPE_PAGE
= 0x00FE;
139 const sal_uInt16 EXC_SXVI_TYPE_NULL
= 0x00FF;
140 const sal_uInt16 EXC_SXVI_TYPE_DATA
= 0x0000;
141 const sal_uInt16 EXC_SXVI_TYPE_DEFAULT
= 0x0001;
142 const sal_uInt16 EXC_SXVI_TYPE_SUM
= 0x0002;
143 const sal_uInt16 EXC_SXVI_TYPE_COUNT
= 0x0003;
144 const sal_uInt16 EXC_SXVI_TYPE_AVERAGE
= 0x0004;
145 const sal_uInt16 EXC_SXVI_TYPE_MAX
= 0x0005;
146 const sal_uInt16 EXC_SXVI_TYPE_MIN
= 0x0006;
147 const sal_uInt16 EXC_SXVI_TYPE_PROD
= 0x0007;
148 const sal_uInt16 EXC_SXVI_TYPE_COUNTNUM
= 0x0008;
149 const sal_uInt16 EXC_SXVI_TYPE_STDDEV
= 0x0009;
150 const sal_uInt16 EXC_SXVI_TYPE_STDDEVP
= 0x000A;
151 const sal_uInt16 EXC_SXVI_TYPE_VAR
= 0x000B;
152 const sal_uInt16 EXC_SXVI_TYPE_VARP
= 0x000C;
153 const sal_uInt16 EXC_SXVI_TYPE_GRAND
= 0x000D;
155 const sal_uInt16 EXC_SXVI_DEFAULTFLAGS
= 0x0000;
156 const sal_uInt16 EXC_SXVI_HIDDEN
= 0x0001;
157 const sal_uInt16 EXC_SXVI_HIDEDETAIL
= 0x0002;
158 const sal_uInt16 EXC_SXVI_FORMULA
= 0x0004;
159 const sal_uInt16 EXC_SXVI_MISSING
= 0x0008;
161 const sal_uInt16 EXC_SXVI_DEFAULT_CACHE
= EXC_PC_NOFIELD
;
163 // (0x00B4) SXIVD -------------------------------------------------------------
164 const sal_uInt16 EXC_ID_SXIVD
= 0x00B4;
165 const sal_uInt16 EXC_SXIVD_DATA
= 0xFFFE;
167 // (0x00B5) SXLI --------------------------------------------------------------
168 const sal_uInt16 EXC_ID_SXLI
= 0x00B5;
169 const sal_uInt16 EXC_SXLI_DEFAULTFLAGS
= 0x0000;
171 // (0x00B6) SXPI --------------------------------------------------------------
172 const sal_uInt16 EXC_ID_SXPI
= 0x00B6;
173 const sal_uInt16 EXC_SXPI_ALLITEMS
= 0x7FFD;
175 // (0x00C5) SXDI --------------------------------------------------------------
176 const sal_uInt16 EXC_ID_SXDI
= 0x00C5;
178 const sal_uInt16 EXC_SXDI_FUNC_SUM
= 0x0000;
179 const sal_uInt16 EXC_SXDI_FUNC_COUNT
= 0x0001;
180 const sal_uInt16 EXC_SXDI_FUNC_AVERAGE
= 0x0002;
181 const sal_uInt16 EXC_SXDI_FUNC_MAX
= 0x0003;
182 const sal_uInt16 EXC_SXDI_FUNC_MIN
= 0x0004;
183 const sal_uInt16 EXC_SXDI_FUNC_PRODUCT
= 0x0005;
184 const sal_uInt16 EXC_SXDI_FUNC_COUNTNUM
= 0x0006;
185 const sal_uInt16 EXC_SXDI_FUNC_STDDEV
= 0x0007;
186 const sal_uInt16 EXC_SXDI_FUNC_STDDEVP
= 0x0008;
187 const sal_uInt16 EXC_SXDI_FUNC_VAR
= 0x0009;
188 const sal_uInt16 EXC_SXDI_FUNC_VARP
= 0x000A;
190 const sal_uInt16 EXC_SXDI_REF_NORMAL
= 0x0000;
191 const sal_uInt16 EXC_SXDI_REF_DIFF
= 0x0001;
192 const sal_uInt16 EXC_SXDI_REF_PERC
= 0x0002;
193 const sal_uInt16 EXC_SXDI_REF_PERC_DIFF
= 0x0003;
194 const sal_uInt16 EXC_SXDI_REF_RUN_TOTAL
= 0x0004;
195 const sal_uInt16 EXC_SXDI_REF_PERC_ROW
= 0x0005;
196 const sal_uInt16 EXC_SXDI_REF_PERC_COL
= 0x0006;
197 const sal_uInt16 EXC_SXDI_REF_PERC_TOTAL
= 0x0007;
198 const sal_uInt16 EXC_SXDI_REF_INDEX
= 0x0008;
200 const sal_uInt16 EXC_SXDI_PREVITEM
= 0x7FFB;
201 const sal_uInt16 EXC_SXDI_NEXTITEM
= 0x7FFC;
203 // (0x00C6) SXDB --------------------------------------------------------------
204 const sal_uInt16 EXC_ID_SXDB
= 0x00C6;
206 const sal_uInt16 EXC_SXDB_SAVEDATA
= 0x0001;
207 const sal_uInt16 EXC_SXDB_INVALID
= 0x0002;
208 const sal_uInt16 EXC_SXDB_REFRESH_LOAD
= 0x0004;
209 const sal_uInt16 EXC_SXDB_OPT_CACHE
= 0x0008;
210 const sal_uInt16 EXC_SXDB_BG_QUERY
= 0x0010;
211 const sal_uInt16 EXC_SXDB_ENABLE_REFRESH
= 0x0020;
212 const sal_uInt16 EXC_SXDB_DEFAULTFLAGS
= EXC_SXDB_SAVEDATA
| EXC_SXDB_ENABLE_REFRESH
;
214 const sal_uInt16 EXC_SXDB_BLOCKRECS
= 0x1FFF;
216 const sal_uInt16 EXC_SXDB_SRC_SHEET
= 0x0001;
217 const sal_uInt16 EXC_SXDB_SRC_EXTERN
= 0x0002;
218 const sal_uInt16 EXC_SXDB_SRC_CONSOLID
= 0x0004;
219 const sal_uInt16 EXC_SXDB_SRC_SCENARIO
= 0x0008;
221 // (0x00C7) SXFIELD -----------------------------------------------------------
222 const sal_uInt16 EXC_ID_SXFIELD
= 0x00C7;
224 const sal_uInt16 EXC_SXFIELD_HASITEMS
= 0x0001;
225 const sal_uInt16 EXC_SXFIELD_POSTPONE
= 0x0002;
226 const sal_uInt16 EXC_SXFIELD_CALCED
= 0x0004;
227 const sal_uInt16 EXC_SXFIELD_HASCHILD
= 0x0008;
228 const sal_uInt16 EXC_SXFIELD_NUMGROUP
= 0x0010;
229 const sal_uInt16 EXC_SXFIELD_16BIT
= 0x0200;
231 const sal_uInt16 EXC_SXFIELD_DATA_MASK
= 0x0DE0;
233 const sal_uInt16 EXC_SXFIELD_DATA_NONE
= 0x0000; /// Special state for groupings.
234 const sal_uInt16 EXC_SXFIELD_DATA_STR
= 0x0480; /// Only strings, nothing else.
235 const sal_uInt16 EXC_SXFIELD_DATA_INT
= 0x0520; /// Only integers, opt. with doubles.
236 const sal_uInt16 EXC_SXFIELD_DATA_DBL
= 0x0560; /// Only doubles, nothing else.
237 const sal_uInt16 EXC_SXFIELD_DATA_STR_INT
= 0x05A0; /// Only strings and integers, opt. with doubles.
238 const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL
= 0x05E0; /// Only strings and doubles, nothing else.
239 const sal_uInt16 EXC_SXFIELD_DATA_DATE
= 0x0900; /// Only dates, nothing else.
240 const sal_uInt16 EXC_SXFIELD_DATA_DATE_EMP
= 0x0980; /// Dates and empty strings, nothing else (?).
241 const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM
= 0x0D00; /// Dates with integers or doubles without strings.
242 const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR
= 0x0D80; /// Dates and strings, opt. with integers or doubles.
244 const sal_uInt16 EXC_SXFIELD_INDEX_MIN
= 0; /// List index for minimum item in groupings.
245 const sal_uInt16 EXC_SXFIELD_INDEX_MAX
= 1; /// List index for maximum item in groupings.
246 const sal_uInt16 EXC_SXFIELD_INDEX_STEP
= 2; /// List index for step item in groupings.
248 // (0x00C8) SXINDEXLIST -------------------------------------------------------
249 const sal_uInt16 EXC_ID_SXINDEXLIST
= 0x00C8;
251 // (0x00C9) SXDOUBLE ----------------------------------------------------------
252 const sal_uInt16 EXC_ID_SXDOUBLE
= 0x00C9;
254 // (0x00CA) SXBOOLEAN ---------------------------------------------------------
255 const sal_uInt16 EXC_ID_SXBOOLEAN
= 0x00CA;
257 // (0x00CB) SXERROR -----------------------------------------------------------
258 const sal_uInt16 EXC_ID_SXERROR
= 0x00CB;
260 // (0x00CC) SXINTEGER ---------------------------------------------------------
261 const sal_uInt16 EXC_ID_SXINTEGER
= 0x00CC;
263 // (0x00CD) SXSTRING ----------------------------------------------------------
264 const sal_uInt16 EXC_ID_SXSTRING
= 0x00CD;
266 // (0x00CE) SXDATETIME --------------------------------------------------------
267 const sal_uInt16 EXC_ID_SXDATETIME
= 0x00CE;
269 // (0x00CF) SXEMPTY -----------------------------------------------------------
270 const sal_uInt16 EXC_ID_SXEMPTY
= 0x00CF;
272 // (0x00D5) SXIDSTM -----------------------------------------------------------
273 const sal_uInt16 EXC_ID_SXIDSTM
= 0x00D5;
275 // (0x00D8) SXNUMGROUP --------------------------------------------------------
276 const sal_uInt16 EXC_ID_SXNUMGROUP
= 0x00D8;
278 const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN
= 0x0001;
279 const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX
= 0x0002;
281 const sal_uInt16 EXC_SXNUMGROUP_TYPE_SEC
= 1;
282 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MIN
= 2;
283 const sal_uInt16 EXC_SXNUMGROUP_TYPE_HOUR
= 3;
284 const sal_uInt16 EXC_SXNUMGROUP_TYPE_DAY
= 4;
285 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MONTH
= 5;
286 const sal_uInt16 EXC_SXNUMGROUP_TYPE_QUART
= 6;
287 const sal_uInt16 EXC_SXNUMGROUP_TYPE_YEAR
= 7;
288 const sal_uInt16 EXC_SXNUMGROUP_TYPE_NUM
= 8;
290 // (0x00D9) SXGROUPINFO -------------------------------------------------------
291 const sal_uInt16 EXC_ID_SXGROUPINFO
= 0x00D9;
293 // (0x00DC) SXEXT -------------------------------------------------------------
294 const sal_uInt16 EXC_ID_SXEXT
= 0x00DC;
296 // (0x00E3) SXVS --------------------------------------------------------------
297 const sal_uInt16 EXC_ID_SXVS
= 0x00E3;
299 const sal_uInt16 EXC_SXVS_UNKNOWN
= 0x0000;
300 const sal_uInt16 EXC_SXVS_SHEET
= 0x0001;
301 const sal_uInt16 EXC_SXVS_EXTERN
= 0x0002;
302 const sal_uInt16 EXC_SXVS_CONSOLID
= 0x0004;
303 const sal_uInt16 EXC_SXVS_PIVOTTAB
= 0x0008;
304 const sal_uInt16 EXC_SXVS_SCENARIO
= 0x0010;
306 // (0x00F0) SXRULE ------------------------------------------------------------
307 const sal_uInt16 EXC_ID_SXRULE
= 0x00F0;
309 // (0x00F1) SXEX --------------------------------------------------------------
310 const sal_uInt16 EXC_ID_SXEX
= 0x00F1;
312 const sal_uInt32 EXC_SXEX_DRILLDOWN
= 0x00020000;
313 const sal_uInt32 EXC_SXEX_DEFAULTFLAGS
= 0x004F0200;
315 // (0x00F2) SXFILT ------------------------------------------------------------
316 const sal_uInt16 EXC_ID_SXFILT
= 0x00F2;
318 // (0x00F5) -------------------------------------------------------------------
319 const sal_uInt16 EXC_ID_00F5
= 0x00F5; /// Unknown record
321 // (0x00F6) SXNAME ------------------------------------------------------------
322 const sal_uInt16 EXC_ID_SXNAME
= 0x00F6;
324 // (0x00F8) SXPAIR ------------------------------------------------------------
325 const sal_uInt16 EXC_ID_SXPAIR
= 0x00F8;
327 // (0x00F9) SXFMLA ------------------------------------------------------------
328 const sal_uInt16 EXC_ID_SXFMLA
= 0x00F9;
330 // (0x0100) SXVDEX ------------------------------------------------------------
331 const sal_uInt16 EXC_ID_SXVDEX
= 0x0100;
333 const sal_uInt32 EXC_SXVDEX_SHOWALL
= 0x00000001;
334 const sal_uInt32 EXC_SXVDEX_SORT
= 0x00000200;
335 const sal_uInt32 EXC_SXVDEX_SORT_ASC
= 0x00000400;
336 const sal_uInt32 EXC_SXVDEX_AUTOSHOW
= 0x00000800;
337 const sal_uInt32 EXC_SXVDEX_AUTOSHOW_ASC
= 0x00001000;
338 const sal_uInt32 EXC_SXVDEX_LAYOUT_REPORT
= 0x00200000;
339 const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK
= 0x00400000;
340 const sal_uInt32 EXC_SXVDEX_LAYOUT_TOP
= 0x00800000;
341 const sal_uInt32 EXC_SXVDEX_DEFAULTFLAGS
= 0x0A00001E | EXC_SXVDEX_SORT_ASC
| EXC_SXVDEX_AUTOSHOW_ASC
;
343 const sal_uInt16 EXC_SXVDEX_SORT_OWN
= 0xFFFF;
344 const sal_uInt16 EXC_SXVDEX_SHOW_NONE
= 0xFFFF;
345 const sal_uInt16 EXC_SXVDEX_FORMAT_NONE
= 0x0000;
347 // (0x0103) SXFORMULA ---------------------------------------------------------
348 const sal_uInt16 EXC_ID_SXFORMULA
= 0x0103;
350 // (0x0122) SXDBEX ------------------------------------------------------------
351 const sal_uInt16 EXC_ID_SXDBEX
= 0x0122;
352 const double EXC_SXDBEX_CREATION_DATE
= 51901.029652778;
354 // (0x01BB) SXFDBTYPE ---------------------------------------------------------
355 const sal_uInt16 EXC_ID_SXFDBTYPE
= 0x01BB;
356 const sal_uInt16 EXC_SXFDBTYPE_DEFAULT
= 0x0000;
358 // (0x0810) SXVIEWEX9 ---------------------------------------------------------
359 const sal_uInt16 EXC_ID_SXVIEWEX9
= 0x0810;
361 // (0x0864) SXADDL ("Pivot Table Additional Info") ----------------------------
362 const sal_uInt16 EXC_ID_SXADDL
= 0x0864;
366 /** Represents a data item of any type in a pivot cache. Supposed as base class for import and export. */
370 explicit XclPCItem();
371 virtual ~XclPCItem();
373 XclPCItem(XclPCItem
const &) = default;
374 XclPCItem(XclPCItem
&&) = default;
375 XclPCItem
& operator =(XclPCItem
const &) = default;
376 XclPCItem
& operator =(XclPCItem
&&) = default;
378 /** Sets the item to 'empty' type. */
380 /** Sets the item to 'text' type and adds the passed text. */
381 void SetText( const OUString
& rText
);
382 /** Sets the item to 'double' type and adds the passed value. */
383 void SetDouble( double fValue
, const OUString
& rText
= OUString() );
384 /** Sets the item to 'date/time' type and adds the passed date. */
385 void SetDateTime( const DateTime
& rDateTime
, const OUString
& rText
= OUString() );
386 /** Sets the item to 'integer' type and adds the passed value. */
387 void SetInteger( sal_Int16 nValue
);
388 /** Sets the item to 'error' type and adds the passed Excel error code. */
389 void SetError( sal_uInt16 nError
);
390 /** Sets the item to 'boolean' type and adds the passed Boolean value. */
391 void SetBool( bool bValue
, const OUString
& rText
= OUString() );
393 /** Returns the text representation of the item. */
394 const OUString
& ConvertToText() const { return maText
; }
396 /** Returns true, if the passed term equals this item. */
397 bool IsEqual( const XclPCItem
& rItem
) const;
399 /** Returns true, if the item type is 'empty'. */
400 bool IsEmpty() const;
401 /** Returns pointer to text, if the item type is 'text', otherwise 0. */
402 const OUString
* GetText() const;
403 /** Returns pointer to value, if the item type is 'double', otherwise 0. */
404 const double* GetDouble() const;
405 /** Returns pointer to date, if the item type is 'date/time', otherwise 0. */
406 const DateTime
* GetDateTime() const;
407 /** Returns pointer to integer, if the item type is 'integer', otherwise 0. */
408 const sal_Int16
* GetInteger() const;
409 /** Returns pointer to error code, if the item type is 'error', otherwise 0. */
410 const sal_uInt16
* GetError() const;
411 /** Returns pointer to Boolean value, if the item type is 'boolean', otherwise 0. */
412 const bool* GetBool() const;
414 /** Returns the type of the item */
415 XclPCItemType
GetType() const;
418 XclPCItemType meType
; /// Type of the item.
419 OUString maText
; /// Text representation of the item.
420 DateTime maDateTime
; /// Value of a date/time item.
423 double mfValue
; /// Value of a floating-point item.
424 sal_Int16 mnValue
; /// Value of an integer item.
425 sal_uInt16 mnError
; /// Error code of an error item.
426 bool mbValue
; /// Value of a boolean item.
430 inline bool operator==( const XclPCItem
& rLeft
, const XclPCItem
& rRight
) { return rLeft
.IsEqual( rRight
); }
431 inline bool operator!=( const XclPCItem
& rLeft
, const XclPCItem
& rRight
) { return !(rLeft
== rRight
); }
433 // Field settings =============================================================
435 /** Contains data for a pivot cache field (SXFIELD record). */
436 struct XclPCFieldInfo
438 OUString maName
; /// Name of the pivot cache field.
439 sal_uInt16 mnFlags
; /// Various flags.
440 sal_uInt16 mnGroupChild
; /// Field containing grouping info for this field.
441 sal_uInt16 mnGroupBase
; /// Base field if this field contains grouping info.
442 sal_uInt16 mnVisItems
; /// Number of visible items for this field.
443 sal_uInt16 mnGroupItems
; /// Number of special items in a grouping field.
444 sal_uInt16 mnBaseItems
; /// Number of items in the base field.
445 sal_uInt16 mnOrigItems
; /// Number of original source data items.
447 explicit XclPCFieldInfo();
450 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPCFieldInfo
& rInfo
);
451 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPCFieldInfo
& rInfo
);
453 // Numeric grouping field settings ============================================
455 /** Contains data for a numeric grouping field (SXNUMGROUP record). */
456 struct XclPCNumGroupInfo
458 sal_uInt16 mnFlags
; /// Various flags.
460 explicit XclPCNumGroupInfo();
464 sal_Int32
GetScDateType() const;
465 void SetScDateType( sal_Int32 nScType
);
467 sal_uInt16
GetXclDataType() const;
468 void SetXclDataType( sal_uInt16 nXclType
);
471 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPCNumGroupInfo
& rInfo
);
472 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPCNumGroupInfo
& rInfo
);
474 // Base class for pivot cache fields ==========================================
476 /** Represents a field in a pivot cache. Supposed as base class for import and export. */
480 explicit XclPCField( XclPCFieldType eFieldType
, sal_uInt16 nFieldIdx
);
481 virtual ~XclPCField();
483 /** Returns the index of this field in the containing pivot cache. */
484 sal_uInt16
GetFieldIndex() const { return mnFieldIdx
; }
486 /** Returns true, if the type of the field is supported by Calc. */
487 bool IsSupportedField() const;
489 /** Returns true, if this is a standard field build directly from source data. */
490 bool IsStandardField() const;
492 /** Returns true, if this field is a grouping field. */
493 bool IsStdGroupField() const;
494 /** Returns true, if this field is a numeric grouping field. */
495 bool IsNumGroupField() const;
496 /** Returns true, if this field is a date/time grouping field. */
497 bool IsDateGroupField() const;
498 /** Returns true, if this field is a grouping field of any type. */
499 bool IsGroupField() const;
501 /** Returns true, if this field has a child field in a grouping. */
502 bool IsGroupBaseField() const;
503 /** Returns true, if this field is a child field in a grouping (it has a base field). */
504 bool IsGroupChildField() const;
506 /** Returns true, if the field is based on a column in the source data area. */
507 bool HasOrigItems() const;
508 /** Returns true, if any items are stored after the SXFIELD record. */
509 bool HasInlineItems() const;
510 /** Returns true, if the items are stored separately after the last field. */
511 bool HasPostponedItems() const;
512 /** Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values. */
513 bool Has16BitIndexes() const;
516 XclPCFieldInfo maFieldInfo
; /// Pivot cache field info (SXFIELD record).
517 XclPCFieldType meFieldType
; /// Type of this pivot cache field.
518 sal_uInt16
const mnFieldIdx
; /// Own field index in pivot cache.
519 ScfUInt16Vec maGroupOrder
; /// Order of items in a grouping field (SXGROUPINFO record).
520 XclPCNumGroupInfo maNumGroupInfo
; /// Info for numeric grouping (SXNUMGROUP record).
523 // Pivot cache settings =======================================================
525 /** Contains data for a pivot cache (SXDB record). */
528 sal_uInt32 mnSrcRecs
; /// Records in source database.
529 sal_uInt16 mnStrmId
; /// Stream identifier.
530 sal_uInt16 mnFlags
; /// Flags for the cache.
531 sal_uInt16 mnBlockRecs
; /// Records in a source database block.
532 sal_uInt16 mnStdFields
; /// Number of standard pivot cache fields.
533 sal_uInt16 mnTotalFields
; /// Number of all fields (standard, grouped, calculated).
534 sal_uInt16 mnSrcType
; /// Database type.
535 OUString maUserName
; /// Name of user who last modified the cache.
537 explicit XclPCInfo();
540 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPCInfo
& rInfo
);
541 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPCInfo
& rInfo
);
545 // cached name ================================================================
547 /** A name for various pivot table info structs. Includes 'use cache' state. */
548 struct XclPTCachedName
550 OUString maName
; /// The visible name, if used.
551 bool mbUseCache
; /// true = Use name in cache instead of maName.
553 explicit XclPTCachedName() : mbUseCache( true ) {}
556 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTCachedName
& rCachedName
);
557 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTCachedName
& rCachedName
);
559 /** Base struct for named info structs. Supports explicit naming and using the cache. */
560 struct XclPTVisNameInfo
562 XclPTCachedName maVisName
; /// The displayed name of the item.
564 /** Returns true, if the name is set explicitly (maVisName.mbUseCache is false). */
565 bool HasVisName() const { return !maVisName
.mbUseCache
; }
566 /** Returns the name, if set explicitly (maVisName.mbUseCache is false). */
567 const OUString
* GetVisName() const;
568 /** Sets the visible name and enables usage of cache if name is empty. */
569 void SetVisName( const OUString
& rName
);
572 // Field item settings ========================================================
574 /** Contains data for a pivot table data item (SXVI record). */
575 struct XclPTItemInfo
: public XclPTVisNameInfo
577 sal_uInt16 mnType
; /// Type of the item (e.g. data, function, grand total).
578 sal_uInt16 mnFlags
; /// Several flags.
579 sal_uInt16 mnCacheIdx
; /// Index into cache for item name.
581 explicit XclPTItemInfo();
584 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTItemInfo
& rInfo
);
585 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTItemInfo
& rInfo
);
587 // General field settings =====================================================
589 typedef ::std::vector
< ScGeneralFunction
> XclPTSubtotalVec
;
591 /** Contains data for a pivot table field (SXVD record). */
592 struct XclPTFieldInfo
: public XclPTVisNameInfo
594 sal_uInt16 mnAxes
; /// Flags for axes this field is part of.
595 sal_uInt16 mnSubtCount
; /// Number of subtotal functions.
596 sal_uInt16 mnSubtotals
; /// Bitfield for subtotal functions.
597 sal_uInt16 mnItemCount
; /// Number of items of this field.
598 sal_uInt16 mnCacheIdx
; /// Index into cache for field name (not part of record).
600 explicit XclPTFieldInfo();
602 /** Returns the API enum representing the orientation (first of row/col/page/data).
603 @param nMask Restricts the axes taken into account.
604 @return The first found axis orientation, that is allowed in nMask parameter. */
605 css::sheet::DataPilotFieldOrientation
GetApiOrient( sal_uInt16 nMask
) const;
606 /** Adds the axis orientation represented by the passed API enum. */
607 void AddApiOrient( css::sheet::DataPilotFieldOrientation eOrient
);
609 /** Returns a vector of all set subtotal functions. */
610 void GetSubtotals( XclPTSubtotalVec
& rSubtotals
) const;
611 /** Sets the subtotal functions contained in the passed sequence. */
612 void SetSubtotals( const XclPTSubtotalVec
& rSubtotals
);
615 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTFieldInfo
& rInfo
);
616 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTFieldInfo
& rInfo
);
618 // Extended field settings ====================================================
620 /** Contains extended data for a pivot table field (SXVDEX record). */
621 struct XclPTFieldExtInfo
623 sal_uInt32 mnFlags
; /// Several flags and number of items for AutoShow.
624 sal_uInt16 mnSortField
; /// Index to data field sorting bases on.
625 sal_uInt16 mnShowField
; /// Index to data field AutoShow bases on.
627 boost::optional
<OUString
> mpFieldTotalName
;
629 explicit XclPTFieldExtInfo();
631 /** Returns the API constant representing the sorting mode. */
632 sal_Int32
GetApiSortMode() const;
633 /** Sets the sorting mode represented by the passed API constant. */
634 void SetApiSortMode( sal_Int32 nSortMode
);
636 /** Returns the API constant representing the AutoShow mode. */
637 sal_Int32
GetApiAutoShowMode() const;
638 /** Sets the AutoShow mode represented by the passed API constant. */
639 void SetApiAutoShowMode( sal_Int32 nShowMode
);
641 /** Returns the number of items to be shown in AutoShow mode. */
642 sal_Int32
GetApiAutoShowCount() const;
643 /** Sets the number of items to be shown in AutoShow mode. */
644 void SetApiAutoShowCount( sal_Int32 nShowCount
);
646 /** Returns the API constant representing the layout mode. */
647 sal_Int32
GetApiLayoutMode() const;
648 /** Sets the layout mode represented by the passed API constant. */
649 void SetApiLayoutMode( sal_Int32 nLayoutMode
);
652 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTFieldExtInfo
& rInfo
);
653 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTFieldExtInfo
& rInfo
);
655 // Page field settings ========================================================
657 /** Contains data for a pivot table page field (part of SXPI record). */
658 struct XclPTPageFieldInfo
660 sal_uInt16 mnField
; /// Base field for this page info.
661 sal_uInt16 mnSelItem
; /// Index to selected item.
662 sal_uInt16 mnObjId
; /// Escher object ID of dropdown listbox.
664 explicit XclPTPageFieldInfo();
667 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTPageFieldInfo
& rInfo
);
668 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTPageFieldInfo
& rInfo
);
670 // Data field settings ========================================================
672 /** Contains data for a pivot table data field (SXDI record). */
673 struct XclPTDataFieldInfo
: public XclPTVisNameInfo
675 sal_uInt16 mnField
; /// Base field for this data info.
676 sal_uInt16 mnAggFunc
; /// Data aggregation function.
677 sal_uInt16 mnRefType
; /// Result reference type.
678 sal_uInt16 mnRefField
; /// Index to SXVD of referred field used for the results.
679 sal_uInt16 mnRefItem
; /// Index to SXVI of referred item of the used field.
680 sal_uInt16 mnNumFmt
; /// Number format of the results.
682 explicit XclPTDataFieldInfo();
684 /** Returns the API enum representing the aggregation function. */
685 ScGeneralFunction
GetApiAggFunc() const;
686 /** Sets the aggregation function represented by the passed API enum. */
687 void SetApiAggFunc( ScGeneralFunction eAggFunc
);
689 /** Returns the API constant representing the result reference type. */
690 sal_Int32
GetApiRefType() const;
691 /** Sets the result reference type represented by the passed API constant. */
692 void SetApiRefType( sal_Int32 nRefType
);
694 /** Returns the API constant representing the result reference item type. */
695 sal_Int32
GetApiRefItemType() const;
696 /** Sets the result reference item type represented by the passed API constant. */
697 void SetApiRefItemType( sal_Int32 nRefItemType
);
700 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTDataFieldInfo
& rInfo
);
701 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTDataFieldInfo
& rInfo
);
703 // Pivot table settings =======================================================
705 /** Contains data for a pivot table (SXVIEW record). */
708 OUString maTableName
; /// The name of the pivot table.
709 OUString maDataName
; /// The visible name of the data field.
710 XclRange maOutXclRange
; /// Output range.
711 XclAddress maDataXclPos
; /// First cell containing data.
712 sal_uInt16 mnFirstHeadRow
; /// First heading row.
713 sal_uInt16 mnCacheIdx
; /// 0-based index of the pivot cache.
714 sal_uInt16 mnDataAxis
; /// Orientation of data fields.
715 sal_uInt16 mnDataPos
; /// Position of data fields.
716 sal_uInt16 mnFields
; /// Number of all fields.
717 sal_uInt16 mnRowFields
; /// Number of row fields.
718 sal_uInt16 mnColFields
; /// Number of column fields.
719 sal_uInt16 mnPageFields
; /// Number of page fields.
720 sal_uInt16 mnDataFields
; /// Number of data fields.
721 sal_uInt16 mnDataRows
; /// Number of rows containing data.
722 sal_uInt16 mnDataCols
; /// Number of columns containing data.
723 sal_uInt16 mnFlags
; /// Flags for the entire pivot table.
724 sal_uInt16 mnAutoFmtIdx
; /// Index to pivot table autoformat.
726 explicit XclPTInfo();
729 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTInfo
& rInfo
);
730 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTInfo
& rInfo
);
732 // Extended pivot table settings ==============================================
734 /** Extended information about a pivot table (SXEX record). */
737 sal_uInt16 mnSxformulaRecs
; /// Number of SXFORMULA records.
738 sal_uInt16 mnSxselectRecs
; /// Number of SXSELECT records.
739 sal_uInt16 mnPagePerRow
; /// Number of page fields per row.
740 sal_uInt16 mnPagePerCol
; /// Number of page fields per column.
741 sal_uInt32 mnFlags
; /// Flags for the entire pivot table.
743 explicit XclPTExtInfo();
746 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTExtInfo
& rInfo
);
747 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTExtInfo
& rInfo
);
749 // Pivot table autoformat settings ==============================================
751 /** Pivot table autoformat settings (SXVIEWEX9 record). */
752 struct XclPTViewEx9Info
754 sal_uInt32 mbReport
; /// 2 for report* fmts ?
755 sal_uInt8 mnAutoFormat
; /// AutoFormat ID
756 sal_uInt8 mnGridLayout
; /// 0 == gridlayout, 0x10 == modern
757 OUString maGrandTotalName
;
759 explicit XclPTViewEx9Info();
760 void Init( const ScDPObject
& rDPObj
);
763 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclPTViewEx9Info
& rInfo
);
764 XclExpStream
& operator<<( XclExpStream
& rStrm
, const XclPTViewEx9Info
& rInfo
);
766 /** Additional pivot table settings (SXADDL record). */
770 explicit XclPTAddl();
773 XclImpStream
& operator>>(XclImpStream
& rStrm
, XclPTAddl
& rInfo
);
777 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */