Branch libreoffice-24-8-3
[LibreOffice.git] / sc / inc / pivot.hxx
blob10f3f7161473cacf99d3b0c231038c309ea17333
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 .
21 IMPORTANT:
22 Strictly adhere to the following sequence when creating a pivot table:
24 pPivot->SetColFields(aColArr, aColCount)
25 pPivot->SetRowFields(aRowArr, aRowCount)
26 pPivot->SetDataFields(aDataArr, aDataCount)
27 if (pPivot->CreateData())
29 pPivotDrawData();
30 pPivotReleaseData();
33 Make sure that either ColArr or RowArr contains a PivotDataField entry.
36 #pragma once
38 #include <rtl/ustring.hxx>
39 #include <tools/long.hxx>
40 #include "types.hxx"
41 #include "scdllapi.h"
42 #include "dpglobal.hxx"
43 #include "calcmacros.hxx"
45 #include <vector>
46 #include <memory>
48 #include <com/sun/star/uno/Sequence.hxx>
49 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
50 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
51 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
52 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
54 #define PIVOT_DATA_FIELD (SCCOL(-1))
56 struct SC_DLLPUBLIC ScDPName
58 OUString maName; ///< Original name of the dimension.
59 OUString maLayoutName; ///< Layout name (display name)
60 sal_uInt8 mnDupCount;
62 ScDPName();
63 explicit ScDPName(OUString aName, OUString aLayoutName, sal_uInt8 nDupCount);
66 struct ScDPLabelData
68 OUString maName; ///< Original name of the dimension.
69 OUString maLayoutName; ///< Layout name (display name)
70 OUString maSubtotalName;
71 SCCOL mnCol; ///< 0-based field index (not the source column index)
72 tools::Long mnOriginalDim; ///< original dimension index (>= 0 for duplicated dimension)
73 PivotFunc mnFuncMask; ///< Page/Column/Row subtotal function.
74 sal_Int32 mnUsedHier; ///< Used hierarchy.
75 sal_Int32 mnFlags; ///< Flags from the DataPilotSource dimension
76 sal_uInt8 mnDupCount;
77 bool mbShowAll:1; ///< true = Show all (also empty) results.
78 bool mbIsValue:1; ///< true = Sum or count in data field.
79 bool mbDataLayout:1;
80 bool mbRepeatItemLabels:1;
82 struct Member
84 OUString maName;
85 OUString maLayoutName;
86 bool mbVisible;
87 bool mbShowDetails;
89 Member();
91 /**
92 * @return the name that should be displayed in the dp dialogs i.e.
93 * when the layout name is present, use it, or else use the original
94 * name.
96 SC_DLLPUBLIC OUString const & getDisplayName() const;
98 std::vector<Member> maMembers;
99 css::uno::Sequence<OUString> maHiers; ///< Hierarchies.
100 css::sheet::DataPilotFieldSortInfo maSortInfo; ///< Sorting info.
101 css::sheet::DataPilotFieldLayoutInfo maLayoutInfo; ///< Layout info.
102 css::sheet::DataPilotFieldAutoShowInfo maShowInfo; ///< AutoShow info.
104 ScDPLabelData();
107 * @return the name that should be displayed in the dp dialogs i.e. when
108 * the layout name is present, use it, or else use the original name.
110 SC_DLLPUBLIC OUString const & getDisplayName() const;
113 typedef std::vector< std::unique_ptr<ScDPLabelData> > ScDPLabelDataVector;
115 struct ScPivotField
117 css::sheet::DataPilotFieldReference maFieldRef;
119 tools::Long mnOriginalDim; ///< >= 0 for duplicated field.
120 PivotFunc nFuncMask;
121 SCCOL nCol; ///< 0-based dimension index (not source column index)
122 sal_uInt8 mnDupCount;
124 explicit ScPivotField( SCCOL nNewCol = 0 );
126 tools::Long getOriginalDim() const;
129 typedef std::vector< ScPivotField > ScPivotFieldVector;
131 struct ScPivotParam
133 SCCOL nCol; ///< Cursor Position /
134 SCROW nRow; ///< or start of destination area
135 SCTAB nTab;
137 ScDPLabelDataVector maLabelArray;
138 ScPivotFieldVector maPageFields;
139 ScPivotFieldVector maColFields;
140 ScPivotFieldVector maRowFields;
141 ScPivotFieldVector maDataFields;
143 bool bIgnoreEmptyRows;
144 bool bDetectCategories;
145 bool bMakeTotalCol;
146 bool bMakeTotalRow;
148 ScPivotParam();
149 ScPivotParam( const ScPivotParam& r );
150 ~ScPivotParam();
152 ScPivotParam& operator= ( const ScPivotParam& r );
153 void SetLabelData(const ScDPLabelDataVector& r);
156 struct ScPivotFuncData
158 css::sheet::DataPilotFieldReference maFieldRef;
160 tools::Long mnOriginalDim;
161 PivotFunc mnFuncMask;
162 SCCOL mnCol;
163 sal_uInt8 mnDupCount;
165 explicit ScPivotFuncData( SCCOL nCol, PivotFunc nFuncMask );
167 #if DEBUG_PIVOT_TABLE
168 void Dump() const;
169 #endif
172 typedef std::vector<ScDPName> ScDPNameVec;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */