Line data Source code
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 : /*
21 : IMPORTANT:
22 : Strictly adhere to the following sequence when creating a pivot table:
23 :
24 : pPivot->SetColFields(aColArr, aColCount)
25 : pPivot->SetRowFields(aRowArr, aRowCount)
26 : pPivot->SetDataFields(aDataArr, aDataCount)
27 : if (pPivot->CreateData())
28 : {
29 : pPivotDrawData();
30 : pPivotReleaseData();
31 : }
32 :
33 : Make sure that either ColArr or RowArr contains a PivotDataField entry.
34 : */
35 :
36 :
37 : #ifndef SC_PIVOT_HXX
38 : #define SC_PIVOT_HXX
39 :
40 : #include "global.hxx"
41 : #include "address.hxx"
42 : #include "dpglobal.hxx"
43 : #include "calcmacros.hxx"
44 :
45 : #include <vector>
46 : #include <boost/ptr_container/ptr_vector.hpp>
47 :
48 : #define PIVOT_DATA_FIELD (MAXCOLCOUNT)
49 : #include <com/sun/star/uno/Sequence.hxx>
50 : #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
51 : #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
52 : #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
53 : #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
54 :
55 :
56 0 : struct ScDPName
57 : {
58 : OUString maName; /// Original name of the dimension.
59 : OUString maLayoutName; /// Layout name (display name)
60 :
61 : explicit ScDPName(const OUString& rName, const OUString& rLayoutName);
62 : };
63 :
64 : // ============================================================================
65 :
66 4 : struct ScDPLabelData
67 : {
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 : long mnOriginalDim; /// original dimension index (>= 0 for duplicated dimension)
73 : sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function.
74 : sal_Int32 mnUsedHier; /// Used hierarchy.
75 : sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension
76 : bool mbShowAll:1; /// true = Show all (also empty) results.
77 : bool mbIsValue:1; /// true = Sum or count in data field.
78 : bool mbDataLayout:1;
79 :
80 96 : struct Member
81 : {
82 : OUString maName;
83 : OUString maLayoutName;
84 : bool mbVisible;
85 : bool mbShowDetails;
86 :
87 : Member();
88 :
89 : /**
90 : * return the name that should be displayed in the dp dialogs i.e.
91 : * when the layout name is present, use it, or else use the original
92 : * name.
93 : */
94 : OUString SC_DLLPUBLIC getDisplayName() const;
95 : };
96 : ::std::vector<Member> maMembers;
97 : ::com::sun::star::uno::Sequence< OUString > maHiers; /// Hierarchies.
98 : ::com::sun::star::sheet::DataPilotFieldSortInfo maSortInfo; /// Sorting info.
99 : ::com::sun::star::sheet::DataPilotFieldLayoutInfo maLayoutInfo; /// Layout info.
100 : ::com::sun::star::sheet::DataPilotFieldAutoShowInfo maShowInfo; /// AutoShow info.
101 :
102 : ScDPLabelData();
103 :
104 : /**
105 : * return the name that should be displayed in the dp dialogs i.e. when
106 : * the layout name is present, use it, or else use the original name.
107 : */
108 : OUString SC_DLLPUBLIC getDisplayName() const;
109 : };
110 :
111 : typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVector;
112 :
113 0 : struct ScPivotField
114 : {
115 : SCCOL nCol; /// 0-based dimension index (not source column index)
116 : long mnOriginalDim; /// >= 0 for duplicated field.
117 : sal_uInt16 nFuncMask;
118 : sal_uInt8 mnDupCount;
119 : ::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
120 :
121 : explicit ScPivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
122 : ScPivotField( const ScPivotField& r );
123 :
124 : long getOriginalDim() const;
125 : bool operator==( const ScPivotField& r ) const;
126 : };
127 :
128 : typedef ::std::vector< ScPivotField > ScPivotFieldVector;
129 :
130 : struct ScPivotParam
131 : {
132 : SCCOL nCol; // Cursor Position /
133 : SCROW nRow; // or start of destination area
134 : SCTAB nTab;
135 : ScDPLabelDataVector maLabelArray;
136 : ScPivotFieldVector maPageFields;
137 : ScPivotFieldVector maColFields;
138 : ScPivotFieldVector maRowFields;
139 : ScPivotFieldVector maDataFields;
140 : bool bIgnoreEmptyRows;
141 : bool bDetectCategories;
142 : bool bMakeTotalCol;
143 : bool bMakeTotalRow;
144 :
145 : ScPivotParam();
146 : ScPivotParam( const ScPivotParam& r );
147 : ~ScPivotParam();
148 :
149 : ScPivotParam& operator= ( const ScPivotParam& r );
150 : bool operator== ( const ScPivotParam& r ) const;
151 : void SetLabelData(const ScDPLabelDataVector& r);
152 : };
153 :
154 0 : struct ScPivotFuncData
155 : {
156 : SCCOL mnCol;
157 : long mnOriginalDim;
158 : sal_uInt16 mnFuncMask;
159 : sal_uInt8 mnDupCount;
160 : ::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
161 :
162 : explicit ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask );
163 : explicit ScPivotFuncData(
164 : SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
165 : const ::com::sun::star::sheet::DataPilotFieldReference& rFieldRef );
166 :
167 : bool operator== (const ScPivotFuncData& r) const;
168 :
169 : #if DEBUG_PIVOT_TABLE
170 : void Dump() const;
171 : #endif
172 : };
173 :
174 : typedef ::std::vector< ScPivotFuncData > ScPivotFuncDataVector;
175 : typedef std::vector<ScDPName> ScDPNameVec;
176 :
177 : #endif
178 :
179 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|