tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sc / source / filter / inc / xlpivot.hxx
blobeb9814926bd47dbb292d64306d9cd19cee7c532b
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 #pragma once
22 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
23 #include <tools/datetime.hxx>
24 #include "ftools.hxx"
25 #include "xladdress.hxx"
26 #include <dpobject.hxx>
28 #include <optional>
30 class XclImpStream;
31 class XclExpStream;
32 enum class ScGeneralFunction;
34 // Constants and Enumerations =================================================
36 // misc -----------------------------------------------------------------------
38 inline constexpr OUString EXC_STORAGE_PTCACHE = u"_SX_DB_CUR"_ustr;
40 // strings
41 const sal_uInt16 EXC_PT_NOSTRING = 0xFFFF;
42 const sal_uInt16 EXC_PT_MAXSTRLEN = 0xFFFE;
44 // pivot cache fields
45 const size_t EXC_PC_MAXFIELDCOUNT = 0xFFFE;
46 const sal_uInt16 EXC_PC_NOFIELD = 0xFFFF;
47 const sal_Int32 EXC_PC_MAXSTRLEN = 255;
49 // pivot cache items
50 const size_t EXC_PC_MAXITEMCOUNT = 32500;
51 const sal_uInt16 EXC_PC_NOITEM = 0xFFFF;
53 // pivot table fields
54 const sal_uInt16 EXC_PT_MAXFIELDCOUNT = 0xFFFE;
55 const sal_uInt16 EXC_PT_MAXROWCOLCOUNT = EXC_PT_MAXFIELDCOUNT;
56 const sal_uInt16 EXC_PT_MAXPAGECOUNT = 256;
57 const sal_uInt16 EXC_PT_MAXDATACOUNT = 256;
59 // pivot table items
60 const sal_uInt16 EXC_PT_MAXITEMCOUNT = 32500;
62 const sal_uInt16 EXC_PT_AUTOFMT_HEADER = 0x810;
63 const sal_uInt16 EXC_PT_AUTOFMT_ZERO = 0;
64 const sal_uInt32 EXC_PT_AUTOFMT_FLAGS = 0x20;
66 /** Data type of a pivot cache item. */
67 enum XclPCItemType
69 EXC_PCITEM_INVALID, /// Special state, not used in Excel files.
70 EXC_PCITEM_EMPTY, /// Empty cell.
71 EXC_PCITEM_TEXT, /// String data.
72 EXC_PCITEM_DOUBLE, /// Floating-point value.
73 EXC_PCITEM_DATETIME, /// Date/time.
74 EXC_PCITEM_INTEGER, /// 16-bit integer value.
75 EXC_PCITEM_BOOL, /// Boolean value.
76 EXC_PCITEM_ERROR /// Error code.
79 /** Specifies the type of a pivot cache field. */
80 enum XclPCFieldType
82 EXC_PCFIELD_STANDARD, /// Standard field without grouping.
83 EXC_PCFIELD_STDGROUP, /// Standard grouping field.
84 EXC_PCFIELD_NUMGROUP, /// Numeric grouping field.
85 EXC_PCFIELD_DATEGROUP, /// First date grouping field (opt. with child grouping field).
86 EXC_PCFIELD_DATECHILD, /// Additional date grouping field.
87 EXC_PCFIELD_CALCED, /// Calculated field.
88 EXC_PCFIELD_UNKNOWN /// Unknown field state, handled like standard field.
91 // (0x0051,0x0052) DCONREF, DCONNAME ------------------------------------------
93 const sal_uInt16 EXC_ID_DCONREF = 0x0051;
94 const sal_uInt16 EXC_ID_DCONNAME = 0x0052;
96 // (0x00B0) SXVIEW ------------------------------------------------------------
98 const sal_uInt16 EXC_ID_SXVIEW = 0x00B0;
100 const sal_uInt16 EXC_SXVIEW_ROWGRAND = 0x0001;
101 const sal_uInt16 EXC_SXVIEW_COLGRAND = 0x0002;
102 const sal_uInt16 EXC_SXVIEW_DEFAULTFLAGS = 0x0208;
104 const sal_uInt16 EXC_SXVIEW_DATALAST = 0xFFFF;
105 const sal_uInt16 EXC_SXVIEW_AUTOFMT = 0x0001;
107 // (0x00B1) SXVD --------------------------------------------------------------
108 const sal_uInt16 EXC_ID_SXVD = 0x00B1;
110 const sal_uInt16 EXC_SXVD_AXIS_NONE = 0x0000;
111 const sal_uInt16 EXC_SXVD_AXIS_ROW = 0x0001;
112 const sal_uInt16 EXC_SXVD_AXIS_COL = 0x0002;
113 const sal_uInt16 EXC_SXVD_AXIS_PAGE = 0x0004;
114 const sal_uInt16 EXC_SXVD_AXIS_DATA = 0x0008;
115 const sal_uInt16 EXC_SXVD_AXIS_ROWCOL = EXC_SXVD_AXIS_ROW | EXC_SXVD_AXIS_COL;
116 const sal_uInt16 EXC_SXVD_AXIS_ROWCOLPAGE = EXC_SXVD_AXIS_ROWCOL | EXC_SXVD_AXIS_PAGE;
118 const sal_uInt16 EXC_SXVD_SUBT_NONE = 0x0000;
119 const sal_uInt16 EXC_SXVD_SUBT_DEFAULT = 0x0001;
120 const sal_uInt16 EXC_SXVD_SUBT_SUM = 0x0002;
121 const sal_uInt16 EXC_SXVD_SUBT_COUNT = 0x0004;
122 const sal_uInt16 EXC_SXVD_SUBT_AVERAGE = 0x0008;
123 const sal_uInt16 EXC_SXVD_SUBT_MAX = 0x0010;
124 const sal_uInt16 EXC_SXVD_SUBT_MIN = 0x0020;
125 const sal_uInt16 EXC_SXVD_SUBT_PROD = 0x0040;
126 const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM = 0x0080;
127 const sal_uInt16 EXC_SXVD_SUBT_STDDEV = 0x0100;
128 const sal_uInt16 EXC_SXVD_SUBT_STDDEVP = 0x0200;
129 const sal_uInt16 EXC_SXVD_SUBT_VAR = 0x0400;
130 const sal_uInt16 EXC_SXVD_SUBT_VARP = 0x0800;
132 const sal_uInt16 EXC_SXVD_DEFAULT_CACHE = EXC_PC_NOFIELD;
134 // (0x00B2) SXVI --------------------------------------------------------------
135 const sal_uInt16 EXC_ID_SXVI = 0x00B2;
137 const sal_uInt16 EXC_SXVI_TYPE_PAGE = 0x00FE;
138 const sal_uInt16 EXC_SXVI_TYPE_NULL = 0x00FF;
139 const sal_uInt16 EXC_SXVI_TYPE_DATA = 0x0000;
140 const sal_uInt16 EXC_SXVI_TYPE_DEFAULT = 0x0001;
141 const sal_uInt16 EXC_SXVI_TYPE_SUM = 0x0002;
142 const sal_uInt16 EXC_SXVI_TYPE_COUNT = 0x0003;
143 const sal_uInt16 EXC_SXVI_TYPE_AVERAGE = 0x0004;
144 const sal_uInt16 EXC_SXVI_TYPE_MAX = 0x0005;
145 const sal_uInt16 EXC_SXVI_TYPE_MIN = 0x0006;
146 const sal_uInt16 EXC_SXVI_TYPE_PROD = 0x0007;
147 const sal_uInt16 EXC_SXVI_TYPE_COUNTNUM = 0x0008;
148 const sal_uInt16 EXC_SXVI_TYPE_STDDEV = 0x0009;
149 const sal_uInt16 EXC_SXVI_TYPE_STDDEVP = 0x000A;
150 const sal_uInt16 EXC_SXVI_TYPE_VAR = 0x000B;
151 const sal_uInt16 EXC_SXVI_TYPE_VARP = 0x000C;
152 const sal_uInt16 EXC_SXVI_TYPE_GRAND = 0x000D;
154 const sal_uInt16 EXC_SXVI_DEFAULTFLAGS = 0x0000;
155 const sal_uInt16 EXC_SXVI_HIDDEN = 0x0001;
156 const sal_uInt16 EXC_SXVI_HIDEDETAIL = 0x0002;
157 const sal_uInt16 EXC_SXVI_FORMULA = 0x0004;
158 const sal_uInt16 EXC_SXVI_MISSING = 0x0008;
160 const sal_uInt16 EXC_SXVI_DEFAULT_CACHE = EXC_PC_NOFIELD;
162 // (0x00B4) SXIVD -------------------------------------------------------------
163 const sal_uInt16 EXC_ID_SXIVD = 0x00B4;
164 const sal_uInt16 EXC_SXIVD_DATA = 0xFFFE;
166 // (0x00B5) SXLI --------------------------------------------------------------
167 const sal_uInt16 EXC_ID_SXLI = 0x00B5;
168 const sal_uInt16 EXC_SXLI_DEFAULTFLAGS = 0x0000;
170 // (0x00B6) SXPI --------------------------------------------------------------
171 const sal_uInt16 EXC_ID_SXPI = 0x00B6;
172 const sal_uInt16 EXC_SXPI_ALLITEMS = 0x7FFD;
174 // (0x00C5) SXDI --------------------------------------------------------------
175 const sal_uInt16 EXC_ID_SXDI = 0x00C5;
177 const sal_uInt16 EXC_SXDI_FUNC_SUM = 0x0000;
178 const sal_uInt16 EXC_SXDI_FUNC_COUNT = 0x0001;
179 const sal_uInt16 EXC_SXDI_FUNC_AVERAGE = 0x0002;
180 const sal_uInt16 EXC_SXDI_FUNC_MAX = 0x0003;
181 const sal_uInt16 EXC_SXDI_FUNC_MIN = 0x0004;
182 const sal_uInt16 EXC_SXDI_FUNC_PRODUCT = 0x0005;
183 const sal_uInt16 EXC_SXDI_FUNC_COUNTNUM = 0x0006;
184 const sal_uInt16 EXC_SXDI_FUNC_STDDEV = 0x0007;
185 const sal_uInt16 EXC_SXDI_FUNC_STDDEVP = 0x0008;
186 const sal_uInt16 EXC_SXDI_FUNC_VAR = 0x0009;
187 const sal_uInt16 EXC_SXDI_FUNC_VARP = 0x000A;
189 const sal_uInt16 EXC_SXDI_REF_NORMAL = 0x0000;
190 const sal_uInt16 EXC_SXDI_REF_DIFF = 0x0001;
191 const sal_uInt16 EXC_SXDI_REF_PERC = 0x0002;
192 const sal_uInt16 EXC_SXDI_REF_PERC_DIFF = 0x0003;
193 const sal_uInt16 EXC_SXDI_REF_RUN_TOTAL = 0x0004;
194 const sal_uInt16 EXC_SXDI_REF_PERC_ROW = 0x0005;
195 const sal_uInt16 EXC_SXDI_REF_PERC_COL = 0x0006;
196 const sal_uInt16 EXC_SXDI_REF_PERC_TOTAL = 0x0007;
197 const sal_uInt16 EXC_SXDI_REF_INDEX = 0x0008;
199 const sal_uInt16 EXC_SXDI_PREVITEM = 0x7FFB;
200 const sal_uInt16 EXC_SXDI_NEXTITEM = 0x7FFC;
202 // (0x00C6) SXDB --------------------------------------------------------------
203 const sal_uInt16 EXC_ID_SXDB = 0x00C6;
205 const sal_uInt16 EXC_SXDB_SAVEDATA = 0x0001;
206 const sal_uInt16 EXC_SXDB_INVALID = 0x0002;
207 const sal_uInt16 EXC_SXDB_REFRESH_LOAD = 0x0004;
208 const sal_uInt16 EXC_SXDB_OPT_CACHE = 0x0008;
209 const sal_uInt16 EXC_SXDB_BG_QUERY = 0x0010;
210 const sal_uInt16 EXC_SXDB_ENABLE_REFRESH = 0x0020;
211 const sal_uInt16 EXC_SXDB_DEFAULTFLAGS = EXC_SXDB_SAVEDATA | EXC_SXDB_ENABLE_REFRESH;
213 const sal_uInt16 EXC_SXDB_BLOCKRECS = 0x1FFF;
215 const sal_uInt16 EXC_SXDB_SRC_SHEET = 0x0001;
216 const sal_uInt16 EXC_SXDB_SRC_EXTERN = 0x0002;
217 const sal_uInt16 EXC_SXDB_SRC_CONSOLID = 0x0004;
218 const sal_uInt16 EXC_SXDB_SRC_SCENARIO = 0x0008;
220 // (0x00C7) SXFIELD -----------------------------------------------------------
221 const sal_uInt16 EXC_ID_SXFIELD = 0x00C7;
223 const sal_uInt16 EXC_SXFIELD_HASITEMS = 0x0001;
224 const sal_uInt16 EXC_SXFIELD_POSTPONE = 0x0002;
225 const sal_uInt16 EXC_SXFIELD_CALCED = 0x0004;
226 const sal_uInt16 EXC_SXFIELD_HASCHILD = 0x0008;
227 const sal_uInt16 EXC_SXFIELD_NUMGROUP = 0x0010;
228 const sal_uInt16 EXC_SXFIELD_16BIT = 0x0200;
230 const sal_uInt16 EXC_SXFIELD_DATA_MASK = 0x0DE0;
231 // known data types
232 const sal_uInt16 EXC_SXFIELD_DATA_NONE = 0x0000; /// Special state for groupings.
233 const sal_uInt16 EXC_SXFIELD_DATA_STR = 0x0480; /// Only strings, nothing else.
234 const sal_uInt16 EXC_SXFIELD_DATA_INT = 0x0520; /// Only integers, opt. with doubles.
235 const sal_uInt16 EXC_SXFIELD_DATA_DBL = 0x0560; /// Only doubles, nothing else.
236 const sal_uInt16 EXC_SXFIELD_DATA_STR_INT = 0x05A0; /// Only strings and integers, opt. with doubles.
237 const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL = 0x05E0; /// Only strings and doubles, nothing else.
238 const sal_uInt16 EXC_SXFIELD_DATA_DATE = 0x0900; /// Only dates, nothing else.
239 const sal_uInt16 EXC_SXFIELD_DATA_DATE_EMP = 0x0980; /// Dates and empty strings, nothing else (?).
240 const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM = 0x0D00; /// Dates with integers or doubles without strings.
241 const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR = 0x0D80; /// Dates and strings, opt. with integers or doubles.
243 const sal_uInt16 EXC_SXFIELD_INDEX_MIN = 0; /// List index for minimum item in groupings.
244 const sal_uInt16 EXC_SXFIELD_INDEX_MAX = 1; /// List index for maximum item in groupings.
245 const sal_uInt16 EXC_SXFIELD_INDEX_STEP = 2; /// List index for step item in groupings.
247 // (0x00C8) SXINDEXLIST -------------------------------------------------------
248 const sal_uInt16 EXC_ID_SXINDEXLIST = 0x00C8;
250 // (0x00C9) SXDOUBLE ----------------------------------------------------------
251 const sal_uInt16 EXC_ID_SXDOUBLE = 0x00C9;
253 // (0x00CA) SXBOOLEAN ---------------------------------------------------------
254 const sal_uInt16 EXC_ID_SXBOOLEAN = 0x00CA;
256 // (0x00CB) SXERROR -----------------------------------------------------------
257 const sal_uInt16 EXC_ID_SXERROR = 0x00CB;
259 // (0x00CC) SXINTEGER ---------------------------------------------------------
260 const sal_uInt16 EXC_ID_SXINTEGER = 0x00CC;
262 // (0x00CD) SXSTRING ----------------------------------------------------------
263 const sal_uInt16 EXC_ID_SXSTRING = 0x00CD;
265 // (0x00CE) SXDATETIME --------------------------------------------------------
266 const sal_uInt16 EXC_ID_SXDATETIME = 0x00CE;
268 // (0x00CF) SXEMPTY -----------------------------------------------------------
269 const sal_uInt16 EXC_ID_SXEMPTY = 0x00CF;
271 // (0x00D5) SXIDSTM -----------------------------------------------------------
272 const sal_uInt16 EXC_ID_SXIDSTM = 0x00D5;
274 // (0x00D8) SXNUMGROUP --------------------------------------------------------
275 const sal_uInt16 EXC_ID_SXNUMGROUP = 0x00D8;
277 const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN = 0x0001;
278 const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX = 0x0002;
280 const sal_uInt16 EXC_SXNUMGROUP_TYPE_SEC = 1;
281 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MIN = 2;
282 const sal_uInt16 EXC_SXNUMGROUP_TYPE_HOUR = 3;
283 const sal_uInt16 EXC_SXNUMGROUP_TYPE_DAY = 4;
284 const sal_uInt16 EXC_SXNUMGROUP_TYPE_MONTH = 5;
285 const sal_uInt16 EXC_SXNUMGROUP_TYPE_QUART = 6;
286 const sal_uInt16 EXC_SXNUMGROUP_TYPE_YEAR = 7;
287 const sal_uInt16 EXC_SXNUMGROUP_TYPE_NUM = 8;
289 // (0x00D9) SXGROUPINFO -------------------------------------------------------
290 const sal_uInt16 EXC_ID_SXGROUPINFO = 0x00D9;
292 // (0x00DC) SXEXT -------------------------------------------------------------
293 const sal_uInt16 EXC_ID_SXEXT = 0x00DC;
295 // (0x00E3) SXVS --------------------------------------------------------------
296 const sal_uInt16 EXC_ID_SXVS = 0x00E3;
298 const sal_uInt16 EXC_SXVS_UNKNOWN = 0x0000;
299 const sal_uInt16 EXC_SXVS_SHEET = 0x0001;
300 const sal_uInt16 EXC_SXVS_EXTERN = 0x0002;
301 const sal_uInt16 EXC_SXVS_CONSOLID = 0x0004;
302 const sal_uInt16 EXC_SXVS_PIVOTTAB = 0x0008;
303 const sal_uInt16 EXC_SXVS_SCENARIO = 0x0010;
305 // (0x00F0) SXRULE ------------------------------------------------------------
306 const sal_uInt16 EXC_ID_SXRULE = 0x00F0;
308 // (0x00F1) SXEX --------------------------------------------------------------
309 const sal_uInt16 EXC_ID_SXEX = 0x00F1;
311 const sal_uInt32 EXC_SXEX_DRILLDOWN = 0x00020000;
312 const sal_uInt32 EXC_SXEX_DEFAULTFLAGS = 0x004F0200;
314 // (0x00F2) SXFILT ------------------------------------------------------------
315 const sal_uInt16 EXC_ID_SXFILT = 0x00F2;
317 // (0x00F5) -------------------------------------------------------------------
318 const sal_uInt16 EXC_ID_00F5 = 0x00F5; /// Unknown record
320 // (0x00F6) SXNAME ------------------------------------------------------------
321 const sal_uInt16 EXC_ID_SXNAME = 0x00F6;
323 // (0x00F8) SXPAIR ------------------------------------------------------------
324 const sal_uInt16 EXC_ID_SXPAIR = 0x00F8;
326 // (0x00F9) SXFMLA ------------------------------------------------------------
327 const sal_uInt16 EXC_ID_SXFMLA = 0x00F9;
329 // (0x0100) SXVDEX ------------------------------------------------------------
330 const sal_uInt16 EXC_ID_SXVDEX = 0x0100;
332 const sal_uInt32 EXC_SXVDEX_SHOWALL = 0x00000001;
333 const sal_uInt32 EXC_SXVDEX_SORT = 0x00000200;
334 const sal_uInt32 EXC_SXVDEX_SORT_ASC = 0x00000400;
335 const sal_uInt32 EXC_SXVDEX_AUTOSHOW = 0x00000800;
336 const sal_uInt32 EXC_SXVDEX_AUTOSHOW_ASC = 0x00001000;
337 const sal_uInt32 EXC_SXVDEX_LAYOUT_REPORT = 0x00200000;
338 const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK = 0x00400000;
339 const sal_uInt32 EXC_SXVDEX_LAYOUT_TOP = 0x00800000;
340 const sal_uInt32 EXC_SXVDEX_DEFAULTFLAGS = 0x0A00001E | EXC_SXVDEX_SORT_ASC | EXC_SXVDEX_AUTOSHOW_ASC;
342 const sal_uInt16 EXC_SXVDEX_SORT_OWN = 0xFFFF;
343 const sal_uInt16 EXC_SXVDEX_SHOW_NONE = 0xFFFF;
344 const sal_uInt16 EXC_SXVDEX_FORMAT_NONE = 0x0000;
346 // (0x0103) SXFORMULA ---------------------------------------------------------
347 const sal_uInt16 EXC_ID_SXFORMULA = 0x0103;
349 // (0x0122) SXDBEX ------------------------------------------------------------
350 const sal_uInt16 EXC_ID_SXDBEX = 0x0122;
351 const double EXC_SXDBEX_CREATION_DATE = 51901.029652778;
353 // (0x01BB) SXFDBTYPE ---------------------------------------------------------
354 const sal_uInt16 EXC_ID_SXFDBTYPE = 0x01BB;
355 const sal_uInt16 EXC_SXFDBTYPE_DEFAULT = 0x0000;
357 // (0x0810) SXVIEWEX9 ---------------------------------------------------------
358 const sal_uInt16 EXC_ID_SXVIEWEX9 = 0x0810;
360 // (0x0864) SXADDL ("Pivot Table Additional Info") ----------------------------
361 const sal_uInt16 EXC_ID_SXADDL = 0x0864;
363 // Pivot cache
365 /** Represents a data item of any type in a pivot cache. Supposed as base class for import and export. */
366 class XclPCItem
368 public:
369 explicit XclPCItem();
370 virtual ~XclPCItem();
372 XclPCItem(XclPCItem const &) = default;
373 XclPCItem(XclPCItem &&) = default;
374 XclPCItem & operator =(XclPCItem const &) = default;
375 XclPCItem & operator =(XclPCItem &&) = default;
377 /** Sets the item to 'empty' type. */
378 void SetEmpty();
379 /** Sets the item to 'text' type and adds the passed text. */
380 void SetText( const OUString& rText );
381 /** Sets the item to 'double' type and adds the passed value. */
382 void SetDouble( double fValue, const OUString& rText = OUString() );
383 /** Sets the item to 'date/time' type and adds the passed date. */
384 void SetDateTime( const DateTime& rDateTime, const OUString& rText = OUString() );
385 /** Sets the item to 'integer' type and adds the passed value. */
386 void SetInteger( sal_Int16 nValue );
387 /** Sets the item to 'error' type and adds the passed Excel error code. */
388 void SetError( sal_uInt16 nError );
389 /** Sets the item to 'boolean' type and adds the passed Boolean value. */
390 void SetBool( bool bValue, const OUString& rText = OUString() );
392 /** Returns the text representation of the item. */
393 const OUString& ConvertToText() const { return maText; }
395 /** Returns true, if the passed term 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 /** Returns the type of the item */
414 XclPCItemType GetType() const;
416 private:
417 XclPCItemType meType; /// Type of the item.
418 OUString maText; /// Text representation of the item.
419 DateTime maDateTime; /// Value of a date/time item.
420 union
422 double mfValue; /// Value of a floating-point item.
423 sal_Int16 mnValue; /// Value of an integer item.
424 sal_uInt16 mnError; /// Error code of an error item.
425 bool mbValue; /// Value of a boolean item.
429 inline bool operator==( const XclPCItem& rLeft, const XclPCItem& rRight ) { return rLeft.IsEqual( rRight ); }
430 inline bool operator!=( const XclPCItem& rLeft, const XclPCItem& rRight ) { return !(rLeft == rRight); }
432 // Field settings =============================================================
434 /** Contains data for a pivot cache field (SXFIELD record). */
435 struct XclPCFieldInfo
437 OUString maName; /// Name of the pivot cache field.
438 sal_uInt16 mnFlags; /// Various flags.
439 sal_uInt16 mnGroupChild; /// Field containing grouping info for this field.
440 sal_uInt16 mnGroupBase; /// Base field if this field contains grouping info.
441 sal_uInt16 mnVisItems; /// Number of visible items for this field.
442 sal_uInt16 mnGroupItems; /// Number of special items in a grouping field.
443 sal_uInt16 mnBaseItems; /// Number of items in the base field.
444 sal_uInt16 mnOrigItems; /// Number of original source data items.
446 explicit XclPCFieldInfo();
449 XclImpStream& operator>>( XclImpStream& rStrm, XclPCFieldInfo& rInfo );
450 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCFieldInfo& rInfo );
452 // Numeric grouping field settings ============================================
454 /** Contains data for a numeric grouping field (SXNUMGROUP record). */
455 struct XclPCNumGroupInfo
457 sal_uInt16 mnFlags; /// Various flags.
459 explicit XclPCNumGroupInfo();
461 void SetNumType();
463 sal_Int32 GetScDateType() const;
464 void SetScDateType( sal_Int32 nScType );
466 sal_uInt16 GetXclDataType() const;
467 void SetXclDataType( sal_uInt16 nXclType );
470 XclImpStream& operator>>( XclImpStream& rStrm, XclPCNumGroupInfo& rInfo );
471 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCNumGroupInfo& rInfo );
473 // Base class for pivot cache fields ==========================================
475 /** Represents a field in a pivot cache. Supposed as base class for import and export. */
476 class XclPCField
478 public:
479 explicit XclPCField( XclPCFieldType eFieldType, sal_uInt16 nFieldIdx );
480 virtual ~XclPCField();
482 /** Returns the index of this field in the containing pivot cache. */
483 sal_uInt16 GetFieldIndex() const { return mnFieldIdx; }
485 /** Returns true, if the type of the field is supported by Calc. */
486 bool IsSupportedField() const;
488 /** Returns true, if this is a standard field build directly from source data. */
489 bool IsStandardField() const;
491 /** Returns true, if this field is a grouping field. */
492 bool IsStdGroupField() const;
493 /** Returns true, if this field is a numeric grouping field. */
494 bool IsNumGroupField() const;
495 /** Returns true, if this field is a date/time grouping field. */
496 bool IsDateGroupField() const;
497 /** Returns true, if this field is a grouping field of any type. */
498 bool IsGroupField() const;
500 /** Returns true, if this field has a child field in a grouping. */
501 bool IsGroupBaseField() const;
502 /** Returns true, if this field is a child field in a grouping (it has a base field). */
503 bool IsGroupChildField() const;
505 /** Returns true, if the field is based on a column in the source data area. */
506 bool HasOrigItems() const;
507 /** Returns true, if any items are stored after the SXFIELD record. */
508 bool HasInlineItems() const;
509 /** Returns true, if the items are stored separately after the last field. */
510 bool HasPostponedItems() const;
511 /** Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values. */
512 bool Has16BitIndexes() const;
514 protected:
515 XclPCFieldInfo maFieldInfo; /// Pivot cache field info (SXFIELD record).
516 XclPCFieldType meFieldType; /// Type of this pivot cache field.
517 sal_uInt16 mnFieldIdx; /// Own field index in pivot cache.
518 ScfUInt16Vec maGroupOrder; /// Order of items in a grouping field (SXGROUPINFO record).
519 XclPCNumGroupInfo maNumGroupInfo; /// Info for numeric grouping (SXNUMGROUP record).
522 // Pivot cache settings =======================================================
524 /** Contains data for a pivot cache (SXDB record). */
525 struct XclPCInfo
527 sal_uInt32 mnSrcRecs; /// Records in source database.
528 sal_uInt16 mnStrmId; /// Stream identifier.
529 sal_uInt16 mnFlags; /// Flags for the cache.
530 sal_uInt16 mnBlockRecs; /// Records in a source database block.
531 sal_uInt16 mnStdFields; /// Number of standard pivot cache fields.
532 sal_uInt16 mnTotalFields; /// Number of all fields (standard, grouped, calculated).
533 sal_uInt16 mnSrcType; /// Database type.
534 OUString maUserName; /// Name of user who last modified the cache.
536 explicit XclPCInfo();
539 XclImpStream& operator>>( XclImpStream& rStrm, XclPCInfo& rInfo );
540 XclExpStream& operator<<( XclExpStream& rStrm, const XclPCInfo& rInfo );
542 // Pivot table
544 // cached name ================================================================
546 /** A name for various pivot table info structs. Includes 'use cache' state. */
547 struct XclPTCachedName
549 OUString maName; /// The visible name, if used.
550 bool mbUseCache; /// true = Use name in cache instead of maName.
552 explicit XclPTCachedName() : mbUseCache( true ) {}
555 XclImpStream& operator>>( XclImpStream& rStrm, XclPTCachedName& rCachedName );
556 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTCachedName& rCachedName );
558 /** Base struct for named info structs. Supports explicit naming and using the cache. */
559 struct XclPTVisNameInfo
561 XclPTCachedName maVisName; /// The displayed name of the item.
563 /** Returns true, if the name is set explicitly (maVisName.mbUseCache is false). */
564 bool HasVisName() const { return !maVisName.mbUseCache; }
565 /** Returns the name, if set explicitly (maVisName.mbUseCache is false). */
566 const OUString* GetVisName() const;
567 /** Sets the visible name and enables usage of cache if name is empty. */
568 void SetVisName( const OUString& rName );
571 // Field item settings ========================================================
573 /** Contains data for a pivot table data item (SXVI record). */
574 struct XclPTItemInfo : public XclPTVisNameInfo
576 sal_uInt16 mnType; /// Type of the item (e.g. data, function, grand total).
577 sal_uInt16 mnFlags; /// Several flags.
578 sal_uInt16 mnCacheIdx; /// Index into cache for item name.
580 explicit XclPTItemInfo();
583 XclImpStream& operator>>( XclImpStream& rStrm, XclPTItemInfo& rInfo );
584 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTItemInfo& rInfo );
586 // General field settings =====================================================
588 typedef ::std::vector< ScGeneralFunction > XclPTSubtotalVec;
590 /** Contains data for a pivot table field (SXVD record). */
591 struct XclPTFieldInfo : public XclPTVisNameInfo
593 sal_uInt16 mnAxes; /// Flags for axes this field is part of.
594 sal_uInt16 mnSubtCount; /// Number of subtotal functions.
595 sal_uInt16 mnSubtotals; /// Bitfield for subtotal functions.
596 sal_uInt16 mnItemCount; /// Number of items of this field.
597 sal_uInt16 mnCacheIdx; /// Index into cache for field name (not part of record).
599 explicit XclPTFieldInfo();
601 /** Returns the API enum representing the orientation (first of row/col/page/data).
602 @param nMask Restricts the axes taken into account.
603 @return The first found axis orientation, that is allowed in nMask parameter. */
604 css::sheet::DataPilotFieldOrientation GetApiOrient( sal_uInt16 nMask ) const;
605 /** Adds the axis orientation represented by the passed API enum. */
606 void AddApiOrient( css::sheet::DataPilotFieldOrientation eOrient );
608 /** Returns a vector of all set subtotal functions. */
609 void GetSubtotals( XclPTSubtotalVec& rSubtotals ) const;
610 /** Sets the subtotal functions contained in the passed sequence. */
611 void SetSubtotals( const XclPTSubtotalVec& rSubtotals );
614 XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldInfo& rInfo );
615 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldInfo& rInfo );
617 // Extended field settings ====================================================
619 /** Contains extended data for a pivot table field (SXVDEX record). */
620 struct XclPTFieldExtInfo
622 sal_uInt32 mnFlags; /// Several flags and number of items for AutoShow.
623 sal_uInt16 mnSortField; /// Index to data field sorting bases on.
624 sal_uInt16 mnShowField; /// Index to data field AutoShow bases on.
625 sal_uInt16 mnNumFmt;
626 std::optional<OUString> mpFieldTotalName;
628 explicit XclPTFieldExtInfo();
630 /** Returns the API constant representing the sorting mode. */
631 sal_Int32 GetApiSortMode() const;
632 /** Sets the sorting mode represented by the passed API constant. */
633 void SetApiSortMode( sal_Int32 nSortMode );
635 /** Returns the API constant representing the AutoShow mode. */
636 sal_Int32 GetApiAutoShowMode() const;
637 /** Sets the AutoShow mode represented by the passed API constant. */
638 void SetApiAutoShowMode( sal_Int32 nShowMode );
640 /** Returns the number of items to be shown in AutoShow mode. */
641 sal_Int32 GetApiAutoShowCount() const;
642 /** Sets the number of items to be shown in AutoShow mode. */
643 void SetApiAutoShowCount( sal_Int32 nShowCount );
645 /** Returns the API constant representing the layout mode. */
646 sal_Int32 GetApiLayoutMode() const;
647 /** Sets the layout mode represented by the passed API constant. */
648 void SetApiLayoutMode( sal_Int32 nLayoutMode );
651 XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldExtInfo& rInfo );
652 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo );
654 // Page field settings ========================================================
656 /** Contains data for a pivot table page field (part of SXPI record). */
657 struct XclPTPageFieldInfo
659 sal_uInt16 mnField; /// Base field for this page info.
660 sal_uInt16 mnSelItem; /// Index to selected item.
661 sal_uInt16 mnObjId; /// Escher object ID of dropdown listbox.
663 explicit XclPTPageFieldInfo();
666 XclImpStream& operator>>( XclImpStream& rStrm, XclPTPageFieldInfo& rInfo );
667 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTPageFieldInfo& rInfo );
669 // Data field settings ========================================================
671 /** Contains data for a pivot table data field (SXDI record). */
672 struct XclPTDataFieldInfo : public XclPTVisNameInfo
674 sal_uInt16 mnField; /// Base field for this data info.
675 sal_uInt16 mnAggFunc; /// Data aggregation function.
676 sal_uInt16 mnRefType; /// Result reference type.
677 sal_uInt16 mnRefField; /// Index to SXVD of referred field used for the results.
678 sal_uInt16 mnRefItem; /// Index to SXVI of referred item of the used field.
679 sal_uInt16 mnNumFmt; /// Number format of the results.
681 explicit XclPTDataFieldInfo();
683 /** Returns the API enum representing the aggregation function. */
684 ScGeneralFunction GetApiAggFunc() const;
685 /** Sets the aggregation function represented by the passed API enum. */
686 void SetApiAggFunc( ScGeneralFunction eAggFunc );
688 /** Returns the API constant representing the result reference type. */
689 sal_Int32 GetApiRefType() const;
690 /** Sets the result reference type represented by the passed API constant. */
691 void SetApiRefType( sal_Int32 nRefType );
693 /** Returns the API constant representing the result reference item type. */
694 sal_Int32 GetApiRefItemType() const;
695 /** Sets the result reference item type represented by the passed API constant. */
696 void SetApiRefItemType( sal_Int32 nRefItemType );
699 XclImpStream& operator>>( XclImpStream& rStrm, XclPTDataFieldInfo& rInfo );
700 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTDataFieldInfo& rInfo );
702 // Pivot table settings =======================================================
704 /** Contains data for a pivot table (SXVIEW record). */
705 struct XclPTInfo
707 OUString maTableName; /// The name of the pivot table.
708 OUString maDataName; /// The visible name of the data field.
709 XclRange maOutXclRange; /// Output range.
710 XclAddress maDataXclPos; /// First cell containing data.
711 sal_uInt16 mnFirstHeadRow; /// First heading row.
712 sal_uInt16 mnCacheIdx; /// 0-based index of the pivot cache.
713 sal_uInt16 mnDataAxis; /// Orientation of data fields.
714 sal_uInt16 mnDataPos; /// Position of data fields.
715 sal_uInt16 mnFields; /// Number of all fields.
716 sal_uInt16 mnRowFields; /// Number of row fields.
717 sal_uInt16 mnColFields; /// Number of column fields.
718 sal_uInt16 mnPageFields; /// Number of page fields.
719 sal_uInt16 mnDataFields; /// Number of data fields.
720 sal_uInt16 mnDataRows; /// Number of rows containing data.
721 sal_uInt16 mnDataCols; /// Number of columns containing data.
722 sal_uInt16 mnFlags; /// Flags for the entire pivot table.
723 sal_uInt16 mnAutoFmtIdx; /// Index to pivot table autoformat.
725 explicit XclPTInfo();
728 XclImpStream& operator>>( XclImpStream& rStrm, XclPTInfo& rInfo );
729 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTInfo& rInfo );
731 // Extended pivot table settings ==============================================
733 /** Extended information about a pivot table (SXEX record). */
734 struct XclPTExtInfo
736 sal_uInt16 mnSxformulaRecs; /// Number of SXFORMULA records.
737 sal_uInt16 mnSxselectRecs; /// Number of SXSELECT records.
738 sal_uInt16 mnPagePerRow; /// Number of page fields per row.
739 sal_uInt16 mnPagePerCol; /// Number of page fields per column.
740 sal_uInt32 mnFlags; /// Flags for the entire pivot table.
742 explicit XclPTExtInfo();
745 XclImpStream& operator>>( XclImpStream& rStrm, XclPTExtInfo& rInfo );
746 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo );
748 // Pivot table autoformat settings ==============================================
750 /** Pivot table autoformat settings (SXVIEWEX9 record). */
751 struct XclPTViewEx9Info
753 sal_uInt32 mbReport; /// 2 for report* fmts ?
754 sal_uInt8 mnAutoFormat; /// AutoFormat ID
755 sal_uInt8 mnGridLayout; /// 0 == gridlayout, 0x10 == modern
756 OUString maGrandTotalName;
758 explicit XclPTViewEx9Info();
759 void Init( const ScDPObject& rDPObj );
762 XclImpStream& operator>>( XclImpStream& rStrm, XclPTViewEx9Info& rInfo );
763 XclExpStream& operator<<( XclExpStream& rStrm, const XclPTViewEx9Info& rInfo );
765 /** Additional pivot table settings (SXADDL record). */
766 struct XclPTAddl
768 bool mbCompactMode;
769 explicit XclPTAddl();
772 XclImpStream& operator>>(XclImpStream& rStrm, XclPTAddl& rInfo);
774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */