LibreOffice Module sc (master) 1
pivottablebuffer.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "pivotcachebuffer.hxx"
23#include "stylesbuffer.hxx"
24
25namespace com::sun::star {
26 namespace sheet { class XDataPilotDescriptor; }
27 namespace sheet { class XDataPilotField; }
28}
29
30class ScDPObject;
31
32namespace oox::xls {
33
34class PivotTable;
35
37{
38 sal_Int32 mnCacheItem;
39 sal_Int32 mnType;
40 OUString msCaption;
42 bool mbHidden;
43
44 explicit PTFieldItemModel();
45
47 void setBiffType( sal_uInt16 nType );
48};
49
51{
52 sal_Int32 mnAxis;
53 sal_Int32 mnNumFmtId;
54 sal_Int32 mnAutoShowItems;
55 sal_Int32 mnAutoShowRankBy;
56 sal_Int32 mnSortType;
57 sal_Int32 mnSortRefField;
58 sal_Int32 mnSortRefItem;
72 bool mbShowAll;
73 bool mbOutline;
75 bool mbCompact;
81
82 explicit PTFieldModel();
83
85 void setBiffAxis( sal_uInt8 nAxisFlags );
86};
87
89{
90 OUString maName;
91 sal_Int32 mnField;
92 sal_Int32 mnItem;
93
94 explicit PTPageFieldModel();
95};
96
98{
99 OUString maName;
100 sal_Int32 mnField;
101 sal_Int32 mnSubtotal;
102 sal_Int32 mnShowDataAs;
103 sal_Int32 mnBaseField;
104 sal_Int32 mnBaseItem;
105 sal_Int32 mnNumFmtId;
106
107 explicit PTDataFieldModel();
108
110 void setBiffSubtotal( sal_Int32 nSubtotal );
112 void setBiffShowDataAs( sal_Int32 nShowDataAs );
113};
114
116{
117public:
118 explicit PivotTableField( PivotTable& rPivotTable, sal_Int32 nFieldIndex );
119
121 void importPivotField( const AttributeList& rAttribs );
123 void importItem( const AttributeList& rAttribs );
125 void importReference( const AttributeList& rAttribs );
127 void importReferenceItem( const AttributeList& rAttribs );
128
137
139 void finalizeImport(
140 const css::uno::Reference< css::sheet::XDataPilotDescriptor >& rxDPDesc );
143 const css::uno::Reference< css::sheet::XDataPilotField >& rxBaseDPField,
144 sal_Int32 nBaseFieldIdx );
147 const css::uno::Reference< css::sheet::XDataPilotField >& rxBaseDPField,
148 const PivotCacheField& rBaseCacheField,
149 PivotCacheGroupItemVector& orItemNames );
151 const css::uno::Reference< css::sheet::XDataPilotDescriptor >& rxDPDesc);
152
154 const OUString& getDPFieldName() const { return maDPFieldName; }
155
157 void convertRowField();
159 void convertColField();
161 void convertHiddenField();
163 void convertPageField( const PTPageFieldModel& rPageField );
165 void convertDataField( const PTDataFieldModel& rDataField );
166
167private:
169 css::uno::Reference< css::sheet::XDataPilotField >
170 convertRowColPageField( sal_Int32 nAxis );
171
172private:
173 typedef ::std::vector< PTFieldItemModel > ItemModelVector;
174
178 OUString maDPFieldName;
179 sal_Int32 mnFieldIndex;
180};
181
183{
184 OUString maName;
185 OUString maDescription;
186 OUString maStrValue1;
187 OUString maStrValue2;
188 double mfValue;
189 sal_Int32 mnField;
190 sal_Int32 mnMemPropField;
191 sal_Int32 mnType;
192 sal_Int32 mnEvalOrder;
193 sal_Int32 mnId;
194 sal_Int32 mnMeasureField;
195 sal_Int32 mnMeasureHier;
197
198 explicit PTFilterModel();
199};
200
202{
203public:
204 explicit PivotTableFilter( const PivotTable& rPivotTable );
205
207 void importFilter( const AttributeList& rAttribs );
209 void importTop10( const AttributeList& rAttribs );
210
215
217 void finalizeImport();
218
219private:
222};
223
225{
226 OUString maName;
233 OUString maPageStyle;
236 OUString maTag;
237 sal_Int32 mnCacheId;
238 sal_Int32 mnDataPosition;
239 sal_Int32 mnPageWrap;
240 sal_Int32 mnIndent;
241 sal_Int32 mnChartFormat;
266
267 explicit PTDefinitionModel();
268};
269
271{
274 sal_Int32 mnFirstDataRow;
275 sal_Int32 mnFirstDataCol;
276 sal_Int32 mnRowPageCount;
277 sal_Int32 mnColPageCount;
278
279 explicit PTLocationModel();
280};
281
283{
284public:
285 explicit PivotTable( const WorkbookHelper& rHelper );
286
288 void importPivotTableDefinition( const AttributeList& rAttribs );
290 void importLocation( const AttributeList& rAttribs, sal_Int16 nSheet );
292 void importRowField( const AttributeList& rAttribs );
294 void importColField( const AttributeList& rAttribs );
296 void importPageField( const AttributeList& rAttribs );
298 void importDataField( const AttributeList& rAttribs );
300 void putToInteropGrabBag(const OUString& sName, const AttributeList& rAttribs);
301
305 void importPTLocation( SequenceInputStream& rStrm, sal_Int16 nSheet );
314
320 void finalizeImport();
325 const css::uno::Reference< css::sheet::XDataPilotField >& rxBaseDPField,
326 sal_Int32 nBaseFieldIdx );
329 const css::uno::Reference< css::sheet::XDataPilotField >& rxBaseDPField,
330 const PivotCacheField& rBaseCacheField,
331 PivotCacheGroupItemVector& orItemNames );
332
334 css::uno::Reference< css::sheet::XDataPilotField >
335 getDataPilotField( const OUString& rFieldName ) const;
337 css::uno::Reference< css::sheet::XDataPilotField >
338 getDataPilotField( sal_Int32 nFieldIdx ) const;
340 css::uno::Reference< css::sheet::XDataPilotField >
341 getDataLayoutField() const;
342
344 PivotCacheField* getCacheField( sal_Int32 nFieldIdx );
345 const PivotCacheField* getCacheField( sal_Int32 nFieldIdx ) const;
347 const PivotCacheField* getCacheFieldOfDataField( sal_Int32 nDataItemIdx ) const;
349 sal_Int32 getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const;
350
352
353private:
356 typedef ::std::vector< sal_Int32 > IndexVector;
357 typedef ::std::vector< PTPageFieldModel > PageFieldVector;
358 typedef ::std::vector< PTDataFieldModel > DataFieldVector;
359
360private:
362 PivotTableField* getTableField( sal_Int32 nFieldIdx );
363
365 static void importField( IndexVector& orFields, const AttributeList& rAttribs );
367 static void importFields( IndexVector& orFields, SequenceInputStream& rStrm );
368
369private:
381 css::uno::Reference< css::sheet::XDataPilotDescriptor >
383 std::map<OUString, css::uno::Any> maInteropGrabBag;
384
385};
386
388{
389public:
390 explicit PivotTableBuffer( const WorkbookHelper& rHelper );
391
394
396 void finalizeImport();
397
398private:
401};
402
403} // namespace oox::xls
404
405/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PivotTableBuffer(const WorkbookHelper &rHelper)
RefVector< PivotTable > PivotTableVector
PivotTable & createPivotTable()
Creates and returns a new pivot table.
void finalizeImport()
Inserts all pivot tables into the sheet.
void importPTReference(SequenceInputStream &rStrm)
Imports pivot field reference settings from the PTREFERENCE record.
sal_Int32 mnFieldIndex
Name of the field in DataPilot field collection.
void convertHiddenField()
Converts dimension and other settings for a hidden field.
void convertRowField()
Converts dimension and other settings for a row field.
void convertColField()
Converts dimension and other settings for a column field.
void finalizeImport(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
Finalizes the field after import, creates grouping and other settings.
void importPivotField(const AttributeList &rAttribs)
Imports pivot field settings from the pivotField element.
void convertPageField(const PTPageFieldModel &rPageField)
Converts dimension and other settings for a page field.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Finalizes the grouped date field after import.
void importReference(const AttributeList &rAttribs)
Imports pivot field reference settings from the reference element.
void importReferenceItem(const AttributeList &rAttribs)
Imports pivot field item reference settings from the x element.
void importPTFItem(SequenceInputStream &rStrm)
Imports settings of an item in this pivot field from the PTFITEM record.
void finalizeImportBasedOnCache(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Finalizes the grouped field after import.
OUString maDPFieldName
Pivot field settings.
void importItem(const AttributeList &rAttribs)
Imports settings of an item in this pivot field from the item element.
PivotTableField(PivotTable &rPivotTable, sal_Int32 nFieldIndex)
css::uno::Reference< css::sheet::XDataPilotField > convertRowColPageField(sal_Int32 nAxis)
Converts dimension and other settings for row, column, page, or hidden fields.
ItemModelVector maItems
The parent pivot table object.
const OUString & getDPFieldName() const
Returns the name of the DataPilot field in the fields collection.
void importPTReferenceItem(SequenceInputStream &rStrm)
Imports pivot field item reference settings from the PTREFERENCEITEM record.
::std::vector< PTFieldItemModel > ItemModelVector
void convertDataField(const PTDataFieldModel &rDataField)
Converts dimension and other settings for a data field.
void importPTField(SequenceInputStream &rStrm)
Imports pivot field settings from the PTFIELD record.
PTFieldModel maModel
All items of this field.
PivotTableFilter(const PivotTable &rPivotTable)
void importFilter(const AttributeList &rAttribs)
Reads the settings of a field filter from the filter element.
void finalizeImport()
Applies the filter to the associated pivot table field if possible.
void importTop10Filter(SequenceInputStream &rStrm)
Reads additional settings of a field filter from the TOP10FILTER record.
void importPTFilter(SequenceInputStream &rStrm)
Reads the settings of a field filter from the PTFILTER record.
const PivotTable & mrPivotTable
void importTop10(const AttributeList &rAttribs)
Reads additional settings of a field filter from the top10 element.
void importPTDataField(SequenceInputStream &rStrm)
Reads the settings of a field located in the data dimension from the PTDATAFIELD record.
void finalizeImport()
Inserts the pivot table into the sheet.
void importDataField(const AttributeList &rAttribs)
Reads the settings of a field located in the data dimension from the dataField element.
PTLocationModel maLocationModel
Global pivot table settings.
css::uno::Reference< css::sheet::XDataPilotField > getDataLayoutField() const
Returns the data layout field used to store all data fields in row/col dimension.
IndexVector maColFields
Indexes to fields in row dimension.
css::uno::Reference< css::sheet::XDataPilotField > getDataPilotField(const OUString &rFieldName) const
Returns the associated data pilot field for the specified pivot table field.
PivotTableField & createTableField()
Creates and returns a new pivot table field.
void importPivotTableDefinition(const AttributeList &rAttribs)
Reads global pivot table settings from the pivotTableDefinition element.
void importLocation(const AttributeList &rAttribs, sal_Int16 nSheet)
Reads the location of the pivot table from the location element.
::std::vector< sal_Int32 > IndexVector
static void importField(IndexVector &orFields, const AttributeList &rAttribs)
Reads a field index for the row or column dimension.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the pivot field with the passed index, or -1.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Creates all date group fields for the specified cache field after import.
PivotTableFilterVector maFilters
Settings for all fields in data area.
PivotTableFieldVector maFields
static void importFields(IndexVector &orFields, SequenceInputStream &rStrm)
Reads an array of field indexes for the row or column dimension.
DataFieldVector maDataFields
Settings for all fields in page dimension.
ScDPObject * getDPObject()
PivotTable(const WorkbookHelper &rHelper)
void putToInteropGrabBag(const OUString &sName, const AttributeList &rAttribs)
Puts the attributes to the named grab bag value.
void importPTLocation(SequenceInputStream &rStrm, sal_Int16 nSheet)
Reads the location of the pivot table from the PTLOCATION record.
RefVector< PivotTableField > PivotTableFieldVector
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Creates all grouped fields for the specified cache field after import.
void importColField(const AttributeList &rAttribs)
Reads the index of a field located in the column dimension.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
::std::vector< PTPageFieldModel > PageFieldVector
PTDefinitionModel maDefModel
All field filters.
RefVector< PivotTableFilter > PivotTableFilterVector
const PivotCacheField * getCacheFieldOfDataField(sal_Int32 nDataItemIdx) const
Returns the base cache field of the data field item with the specified index.
void importPTPageField(SequenceInputStream &rStrm)
Reads the settings of a field located in the page dimension from the PTPAGEFIELD record.
::std::vector< PTDataFieldModel > DataFieldVector
css::uno::Reference< css::sheet::XDataPilotDescriptor > mxDPDescriptor
The pivot cache this table is based on.
PivotCache * mpPivotCache
Location settings of the pivot table.
void importRowField(const AttributeList &rAttribs)
Reads the index of a field located in the row dimension.
PivotTableFilter & createTableFilter()
Creates and returns a new pivot table filter.
void importPTRowFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the row dimension from a PTROWFIELDS record.
void importPageField(const AttributeList &rAttribs)
Reads the settings of a field located in the page dimension from the pageField element.
IndexVector maRowFields
Data layout field.
std::map< OUString, css::uno::Any > maInteropGrabBag
Descriptor of the DataPilot object.
void importPTColFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the column dimension from a PTCOLFIELDS record.
PivotTableField * getTableField(sal_Int32 nFieldIdx)
Returns a pivot table field by its index.
void importPTDefinition(SequenceInputStream &rStrm)
Reads global pivot table settings from the PTDEFINITION record.
void finalizeFieldsImport()
Finalizes all fields, finds field names and creates grouping fields.
PageFieldVector maPageFields
Indexes to fields in column dimension.
PivotTableField maDataField
All pivot table fields.
Helper class to provide access to global workbook data.
OUString sName
void SvStream & rStrm
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
sal_Int32 mnShowDataAs
Subtotal aggregation function.
sal_Int32 mnBaseField
Show data as, based on another field.
sal_Int32 mnSubtotal
Base pivot field.
void setBiffSubtotal(sal_Int32 nSubtotal)
Sets the subtotal aggregation function for BIFF import.
sal_Int32 mnBaseItem
Base field for 'show data as'.
void setBiffShowDataAs(sal_Int32 nShowDataAs)
Sets the 'show data as' type for BIFF import.
sal_Int32 mnField
Name of the data field.
sal_Int32 mnNumFmtId
Base item for 'show data as'.
PTDataFieldModel()
Number format for the result.
bool mbShowDetails
User caption of the item.
sal_Int32 mnType
Index to shared item in pivot cache.
PTFieldItemModel()
True = item is hidden.
OUString msCaption
Type of the item.
void setBiffType(sal_uInt16 nType)
Sets item type for BIFF import.
bool mbHidden
True = show item details (items of child fields).
bool mbVarSubtotal
True = show standard deviation of population subtotals.
bool mbCountASubtotal
True = show sum subtotals.
bool mbAutoShow
True = insert page breaks after items.
bool mbStdDevSubtotal
True = show count numbers subtotals.
bool mbVarPSubtotal
True = show variance subtotals.
bool mbProductSubtotal
True = show minimum subtotals.
bool mbTopAutoShow
True = auto show (top 10) filter enabled.
bool mbSumSubtotal
True = show default subtotals.
sal_Int32 mnSortRefField
Autosorting type.
void setBiffAxis(sal_uInt8 nAxisFlags)
Sets axis type for BIFF import.
sal_Int32 mnSortType
Index of the data field auto show filter is based on.
bool mbDataField
Item in reference field for autosorting.
sal_Int32 mnAutoShowRankBy
Number of items (or percent/sum) to be shown in auto show filter.
bool mbInsertPageBreak
True = insert blank rows after items.
bool mbStdDevPSubtotal
True = show standard deviation subtotals.
sal_Int32 mnNumFmtId
Axis this field is assigned to (none, row, column, page).
sal_Int32 mnSortRefItem
Reference field for autosorting.
bool mbSubtotalTop
True = show in outline view, false = show in tabular view.
bool mbCountSubtotal
True = show product subtotals.
bool mbMultiPageItems
True = auto show filter shows top entries, false = bottom.
bool mbDefaultSubtotal
True = field appears in data area.
bool mbOutline
True = show items without data.
sal_Int32 mnAutoShowItems
Number format for field items.
PTFieldModel()
True = multiple items selectable in page dimension.
bool mbInsertBlankRow
True = show in compact view, false = show in either outline or tabular view.
bool mbAverageSubtotal
True = show count all subtotals.
bool mbShowAll
True = show variance of population subtotals.
bool mbMinSubtotal
True = show maximum subtotals.
bool mbCompact
True = show subtotals on top of items in outline or compact mode.
bool mbMaxSubtotal
True = show average subtotals.
double mfValue
Second string value for label filter.
sal_Int32 mnMeasureHier
Data field for filter calculation.
sal_Int32 mnMemPropField
Base pivot field.
bool mbTopFilter
Hierarchy for filter calculation.
sal_Int32 mnEvalOrder
Filter type.
sal_Int32 mnId
Evaluation order index.
sal_Int32 mnType
Member property field.
PTFilterModel()
True = filter shows top entries, false = bottom.
OUString maStrValue2
First string value for label filter.
OUString maStrValue1
Description of the field filter.
sal_Int32 mnField
Number of items or percent or sum to be shown.
sal_Int32 mnMeasureField
Unique identifier.
OUString maDescription
Name of the field filter.
sal_Int32 mnRowPageCount
First column of data cells (relative in pivot table).
sal_Int32 mnFirstDataCol
First row of data cells (relative in pivot table).
sal_Int32 mnFirstHeaderRow
Target cell range for the pivot table.
sal_Int32 mnFirstDataRow
First row of header cells (relative in pivot table).
sal_Int32 mnColPageCount
Number of rows in page filter area.
PTLocationModel()
Number of columns in page filter area.
sal_Int32 mnItem
Base pivot field.
PTPageFieldModel()
Index of field item that is shown by the page field.
sal_Int32 mnField
Unique name of the page field.
unsigned char sal_uInt8