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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_PIVOTTABLEBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_PIVOTTABLEBUFFER_HXX
22 
23 #include "pivotcachebuffer.hxx"
24 #include "stylesbuffer.hxx"
25 
26 namespace com::sun::star {
27  namespace sheet { class XDataPilotDescriptor; }
28  namespace sheet { class XDataPilotField; }
29 }
30 
31 class ScDPObject;
32 
33 namespace oox::xls {
34 
35 class PivotTable;
36 
38 {
39  sal_Int32 mnCacheItem;
40  sal_Int32 mnType;
41  OUString msCaption;
43  bool mbHidden;
44 
45  explicit PTFieldItemModel();
46 
48  void setBiffType( sal_uInt16 nType );
49 };
50 
52 {
53  sal_Int32 mnAxis;
54  sal_Int32 mnNumFmtId;
55  sal_Int32 mnAutoShowItems;
56  sal_Int32 mnAutoShowRankBy;
57  sal_Int32 mnSortType;
58  sal_Int32 mnSortRefField;
59  sal_Int32 mnSortRefItem;
60  bool mbDataField;
73  bool mbShowAll;
74  bool mbOutline;
78  bool mbAutoShow;
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 {
117 public:
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 
132  void importPTFItem( SequenceInputStream& rStrm );
134  void importPTReference( SequenceInputStream& rStrm );
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 
167 private:
169  css::uno::Reference< css::sheet::XDataPilotField >
170  convertRowColPageField( sal_Int32 nAxis );
171 
172 private:
173  typedef ::std::vector< PTFieldItemModel > ItemModelVector;
174 
176  ItemModelVector maItems;
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;
196  bool mbTopFilter;
197 
198  explicit PTFilterModel();
199 };
200 
202 {
203 public:
204  explicit PivotTableFilter( const PivotTable& rPivotTable );
205 
207  void importFilter( const AttributeList& rAttribs );
209  void importTop10( const AttributeList& rAttribs );
210 
214  void importTop10Filter( SequenceInputStream& rStrm );
215 
217  void finalizeImport();
218 
219 private:
222 };
223 
225 {
226  OUString maName;
227  OUString maDataCaption;
231  OUString maErrorCaption;
233  OUString maPageStyle;
235  OUString maVacatedStyle;
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 {
273  sal_Int32 mnFirstHeaderRow;
274  sal_Int32 mnFirstDataRow;
275  sal_Int32 mnFirstDataCol;
276  sal_Int32 mnRowPageCount;
277  sal_Int32 mnColPageCount;
278 
279  explicit PTLocationModel();
280 };
281 
283 {
284 public:
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 );
307  void importPTRowFields( SequenceInputStream& rStrm );
309  void importPTColFields( SequenceInputStream& rStrm );
311  void importPTPageField( SequenceInputStream& rStrm );
313  void importPTDataField( SequenceInputStream& rStrm );
314 
320  void finalizeImport();
322  void finalizeFieldsImport();
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 
353 private:
356  typedef ::std::vector< sal_Int32 > IndexVector;
357  typedef ::std::vector< PTPageFieldModel > PageFieldVector;
358  typedef ::std::vector< PTDataFieldModel > DataFieldVector;
359 
360 private:
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 
369 private:
371  PivotTableFieldVector maFields;
373  IndexVector maRowFields;
374  IndexVector maColFields;
375  PageFieldVector maPageFields;
376  DataFieldVector maDataFields;
377  PivotTableFilterVector maFilters;
381  css::uno::Reference< css::sheet::XDataPilotDescriptor >
383  std::map<OUString, css::uno::Any> maInteropGrabBag;
384 
385 };
386 
388 {
389 public:
390  explicit PivotTableBuffer( const WorkbookHelper& rHelper );
391 
394 
396  void finalizeImport();
397 
398 private:
400  PivotTableVector maTables;
401 };
402 
403 } // namespace oox::xls
404 
405 #endif
406 
407 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 mnEvalOrder
Filter type.
Helper class to provide access to global workbook data.
void convertHiddenField()
Converts dimension and other settings for a hidden field.
void setBiffType(sal_uInt16 nType)
Sets item type for BIFF import.
bool mbProductSubtotal
True = show minimum subtotals.
void finalizeImport()
Inserts the pivot table into the sheet.
bool mbTopFilter
Hierarchy for filter calculation.
std::map< OUString, css::uno::Any > maInteropGrabBag
Descriptor of the DataPilot object.
PivotCache * mpPivotCache
Location settings of the pivot table.
ItemModelVector maItems
The parent pivot table object.
bool mbMultiPageItems
True = auto show filter shows top entries, false = bottom.
ScDPObject * getDPObject()
bool mbTopAutoShow
True = auto show (top 10) filter enabled.
sal_Int32 mnField
Unique name of the page field.
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Finalizes the grouped field after import.
void finalizeImport()
Inserts all pivot tables into the sheet.
sal_Int32 mnMeasureField
Unique identifier.
sal_Int32 mnSortRefItem
Reference field for autosorting.
PTFilterModel()
True = filter shows top entries, false = bottom.
bool mbStdDevPSubtotal
True = show standard deviation subtotals.
void importRowField(const AttributeList &rAttribs)
Reads the index of a field located in the row dimension.
void importPTReferenceItem(SequenceInputStream &rStrm)
Imports pivot field item reference settings from the PTREFERENCEITEM record.
sal_Int32 mnFieldIndex
Name of the field in DataPilot field collection.
OUString maStrValue2
First string value for label filter.
sal_Int32 mnFirstDataCol
First row of data cells (relative in pivot table).
::std::vector< sal_Int32 > IndexVector
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.
const PivotTable & mrPivotTable
void importColField(const AttributeList &rAttribs)
Reads the index of a field located in the column dimension.
css::uno::Reference< css::sheet::XDataPilotField > convertRowColPageField(sal_Int32 nAxis)
Converts dimension and other settings for row, column, page, or hidden fields.
exports com.sun.star. sheet
void importDataField(const AttributeList &rAttribs)
Reads the settings of a field located in the data dimension from the dataField element.
void importPTFItem(SequenceInputStream &rStrm)
Imports settings of an item in this pivot field from the PTFITEM record.
bool mbOutline
True = show items without data.
::std::vector< PTFieldItemModel > ItemModelVector
sal_Int32 mnItem
Base pivot field.
sal_Int32 mnSubtotal
Base pivot field.
PTFieldModel()
True = multiple items selectable in page dimension.
static void importFields(IndexVector &orFields, SequenceInputStream &rStrm)
Reads an array of field indexes for the row or column dimension.
sal_Int32 mnFirstDataRow
First row of header cells (relative in pivot table).
void importLocation(const AttributeList &rAttribs, sal_Int16 nSheet)
Reads the location of the pivot table from the location element.
sal_Int32 mnColPageCount
Number of rows in page filter area.
void finalizeImport(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
Finalizes the field after import, creates grouping and other settings.
css::uno::Reference< css::sheet::XDataPilotDescriptor > mxDPDescriptor
The pivot cache this table is based on.
sal_Int32 mnField
Number of items or percent or sum to be shown.
void setBiffSubtotal(sal_Int32 nSubtotal)
Sets the subtotal aggregation function for BIFF import.
void setBiffShowDataAs(sal_Int32 nShowDataAs)
Sets the 'show data as' type for BIFF import.
void importTop10Filter(SequenceInputStream &rStrm)
Reads additional settings of a field filter from the TOP10FILTER record.
void finalizeFieldsImport()
Finalizes all fields, finds field names and creates grouping fields.
const char * sName
bool mbHidden
True = show item details (items of child fields).
bool mbInsertBlankRow
True = show subtotals on top of items in outline or compact mode.
void importPivotTableDefinition(const AttributeList &rAttribs)
Reads global pivot table settings from the pivotTableDefinition element.
void importPageField(const AttributeList &rAttribs)
Reads the settings of a field located in the page dimension from the pageField element.
bool mbInsertPageBreak
True = insert blank rows after items.
bool mbCountASubtotal
True = show sum subtotals.
bool mbDataField
Item in reference field for autosorting.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the pivot field with the passed index, or -1.
double mfValue
Second string value for label filter.
void importPTPageField(SequenceInputStream &rStrm)
Reads the settings of a field located in the page dimension from the PTPAGEFIELD record.
sal_Int32 mnFirstHeaderRow
Target cell range for the pivot table.
PTFieldItemModel()
True = item is hidden.
IndexVector maRowFields
Data layout field.
void importFilter(const AttributeList &rAttribs)
Reads the settings of a field filter from the filter element.
::std::vector< PTPageFieldModel > PageFieldVector
bool mbAutoShow
True = insert page breaks after items.
PTLocationModel maLocationModel
Global pivot table settings.
static void importField(IndexVector &orFields, const AttributeList &rAttribs)
Reads a field index for the row or column dimension.
PivotTableFieldVector maFields
const PivotCacheField * getCacheFieldOfDataField(sal_Int32 nDataItemIdx) const
Returns the base cache field of the data field item with the specified index.
PivotTable(const WorkbookHelper &rHelper)
void finalizeImport()
Applies the filter to the associated pivot table field if possible.
sal_Int32 mnShowDataAs
Subtotal aggregation function.
sal_Int32 mnNumFmtId
Base item for 'show data as'.
bool mbSubtotalTop
True = show in outline view, false = show in tabular view.
RefVector< PivotTableField > PivotTableFieldVector
void putToInteropGrabBag(const OUString &sName, const AttributeList &rAttribs)
Puts the attributes to the named grab bag value.
void importPTRowFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the row dimension from a PTROWFIELDS record.
bool mbShowAll
True = show variance of population subtotals.
sal_Int32 mnAutoShowRankBy
Number of items (or percent/sum) to be shown in auto show filter.
css::uno::Reference< css::sheet::XDataPilotField > getDataPilotField(const OUString &rFieldName) const
Returns the associated data pilot field for the specified pivot table field.
sal_Int32 mnType
Member property field.
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 importPTDefinition(SequenceInputStream &rStrm)
Reads global pivot table settings from the PTDEFINITION record.
void convertPageField(const PTPageFieldModel &rPageField)
Converts dimension and other settings for a page field.
void setBiffAxis(sal_uInt8 nAxisFlags)
Sets axis type for BIFF import.
css::uno::Reference< css::sheet::XDataPilotField > getDataLayoutField() const
Returns the data layout field used to store all data fields in row/col dimension. ...
bool mbStdDevSubtotal
True = show count numbers subtotals.
bool mbMaxSubtotal
True = show average subtotals.
OUString maDPFieldName
Pivot field settings.
PTPageFieldModel()
Index of field item that is shown by the page field.
PivotTableField & createTableField()
Creates and returns a new pivot table field.
void importPTLocation(SequenceInputStream &rStrm, sal_Int16 nSheet)
Reads the location of the pivot table from the PTLOCATION record.
void importPTDataField(SequenceInputStream &rStrm)
Reads the settings of a field located in the data dimension from the PTDATAFIELD record.
bool mbVarSubtotal
True = show standard deviation of population subtotals.
PivotTableFilterVector maFilters
Settings for all fields in data area.
void convertDataField(const PTDataFieldModel &rDataField)
Converts dimension and other settings for a data field.
sal_Int32 mnMeasureHier
Data field for filter calculation.
DataFieldVector maDataFields
Settings for all fields in page dimension.
sal_Int32 mnBaseField
Show data as, based on another field.
void importPTField(SequenceInputStream &rStrm)
Imports pivot field settings from the PTFIELD record.
void importTop10(const AttributeList &rAttribs)
Reads additional settings of a field filter from the top10 element.
unsigned char sal_uInt8
bool mbShowDetails
User caption of the item.
::std::vector< PTDataFieldModel > DataFieldVector
sal_Int32 mnSortType
Index of the data field auto show filter is based on.
sal_Int32 mnNumFmtId
Axis this field is assigned to (none, row, column, page).
PivotTableField maDataField
All pivot table fields.
OUString msCaption
Type of the item.
void importItem(const AttributeList &rAttribs)
Imports settings of an item in this pivot field from the item element.
sal_Int32 mnRowPageCount
First column of data cells (relative in pivot table).
void convertColField()
Converts dimension and other settings for a column field.
void importReferenceItem(const AttributeList &rAttribs)
Imports pivot field item reference settings from the x element.
PTDefinitionModel maDefModel
All field filters.
bool mbVarPSubtotal
True = show variance subtotals.
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:400
bool mbSumSubtotal
True = show default subtotals.
PivotTable & createPivotTable()
Creates and returns a new pivot table.
OUString maStrValue1
Description of the field filter.
sal_Int32 mnAutoShowItems
Number format for field items.
IndexVector maColFields
Indexes to fields in row dimension.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
sal_Int32 mnId
Evaluation order index.
void importReference(const AttributeList &rAttribs)
Imports pivot field reference settings from the reference element.
sal_Int32 mnMemPropField
Base pivot field.
sal_Int32 mnSortRefField
Autosorting type.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Finalizes the grouped date field after import.
sal_Int32 mnField
Name of the data field.
const OUString & getDPFieldName() const
Returns the name of the DataPilot field in the fields collection.
PTDataFieldModel()
Number format for the result.
PivotTableBuffer(const WorkbookHelper &rHelper)
bool mbAverageSubtotal
True = show count all subtotals.
PivotTableFilter & createTableFilter()
Creates and returns a new pivot table filter.
void finalizeImportBasedOnCache(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
RefVector< PivotTable > PivotTableVector
PivotTableField * getTableField(sal_Int32 nFieldIdx)
Returns a pivot table field by its index.
void importPTReference(SequenceInputStream &rStrm)
Imports pivot field reference settings from the PTREFERENCE record.
void SvStream & rStrm
void importPTFilter(SequenceInputStream &rStrm)
Reads the settings of a field filter from the PTFILTER record.
void importPivotField(const AttributeList &rAttribs)
Imports pivot field settings from the pivotField element.
bool mbCountSubtotal
True = show product subtotals.
PageFieldVector maPageFields
Indexes to fields in column dimension.
PTFieldModel maModel
All items of this field.
sal_Int32 mnBaseItem
Base field for 'show data as'.
OUString maDescription
Name of the field filter.
void convertRowField()
Converts dimension and other settings for a row field.
PTLocationModel()
Number of columns in page filter area.
bool mbMinSubtotal
True = show maximum subtotals.
PivotTableField(PivotTable &rPivotTable, sal_Int32 nFieldIndex)
void importPTColFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the column dimension from a PTCOLFIELDS record...
RefVector< PivotTableFilter > PivotTableFilterVector
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
bool mbDefaultSubtotal
True = field appears in data area.
PivotTableFilter(const PivotTable &rPivotTable)
sal_Int32 mnType
Index to shared item in pivot cache.