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 : #include "scitems.hxx"
21 : #include <editeng/boxitem.hxx>
22 : #include <editeng/wghtitem.hxx>
23 : #include <svx/algitem.hxx>
24 : #include <unotools/transliterationwrapper.hxx>
25 :
26 : #include "globstr.hrc"
27 : #include "subtotal.hxx"
28 : #include "rangeutl.hxx"
29 : #include "attrib.hxx"
30 : #include "patattr.hxx"
31 : #include "docpool.hxx"
32 : #include "document.hxx"
33 : #include "userlist.hxx"
34 : #include "pivot.hxx"
35 : #include "rechead.hxx"
36 : #include "formula/errorcodes.hxx" // fuer errNoValue
37 : #include "refupdat.hxx"
38 : #include "stlpool.hxx"
39 : #include "stlsheet.hxx"
40 :
41 : #if DEBUG_PIVOT_TABLE
42 : using std::cout;
43 : using std::endl;
44 : #endif
45 :
46 : using ::com::sun::star::sheet::DataPilotFieldReference;
47 : using ::std::vector;
48 :
49 : namespace {
50 :
51 0 : bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right)
52 : {
53 0 : return (left.ReferenceType == right.ReferenceType)
54 0 : && (left.ReferenceField == right.ReferenceField)
55 0 : && (left.ReferenceItemType == right.ReferenceItemType)
56 0 : && (left.ReferenceItemName == right.ReferenceItemName);
57 : }
58 :
59 : }
60 :
61 : // ============================================================================
62 :
63 0 : ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName) :
64 0 : maName(rName), maLayoutName(rLayoutName) {}
65 :
66 : // ============================================================================
67 :
68 32 : ScDPLabelData::Member::Member() :
69 : mbVisible(true),
70 32 : mbShowDetails(true)
71 : {
72 32 : }
73 :
74 0 : OUString ScDPLabelData::Member::getDisplayName() const
75 : {
76 0 : if (!maLayoutName.isEmpty())
77 0 : return maLayoutName;
78 :
79 0 : return maName;
80 : }
81 :
82 4 : ScDPLabelData::ScDPLabelData() :
83 : mnCol(-1),
84 : mnOriginalDim(-1),
85 : mnFuncMask(PIVOT_FUNC_NONE),
86 : mnUsedHier(0),
87 : mnFlags(0),
88 : mbShowAll(false),
89 : mbIsValue(false),
90 4 : mbDataLayout(false)
91 : {
92 4 : }
93 :
94 0 : OUString ScDPLabelData::getDisplayName() const
95 : {
96 0 : if (!maLayoutName.isEmpty())
97 0 : return maLayoutName;
98 :
99 0 : return maName;
100 : }
101 :
102 0 : ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
103 : nCol( nNewCol ),
104 : mnOriginalDim(-1),
105 : nFuncMask( nNewFuncMask ),
106 0 : mnDupCount(0)
107 : {
108 0 : }
109 :
110 0 : ScPivotField::ScPivotField( const ScPivotField& r ) :
111 : nCol(r.nCol),
112 : mnOriginalDim(r.mnOriginalDim),
113 : nFuncMask(r.nFuncMask),
114 : mnDupCount(r.mnDupCount),
115 0 : maFieldRef(r.maFieldRef) {}
116 :
117 0 : long ScPivotField::getOriginalDim() const
118 : {
119 0 : return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<long>(nCol);
120 : }
121 :
122 0 : bool ScPivotField::operator==( const ScPivotField& r ) const
123 : {
124 0 : return (nCol == r.nCol)
125 0 : && (mnOriginalDim == r.mnOriginalDim)
126 0 : && (nFuncMask == r.nFuncMask)
127 0 : && equals(maFieldRef, r.maFieldRef);
128 : }
129 :
130 1 : ScPivotParam::ScPivotParam()
131 : : nCol(0), nRow(0), nTab(0),
132 : bIgnoreEmptyRows(false), bDetectCategories(false),
133 1 : bMakeTotalCol(true), bMakeTotalRow(true)
134 : {
135 1 : }
136 :
137 0 : ScPivotParam::ScPivotParam( const ScPivotParam& r )
138 : : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
139 : maPageFields(r.maPageFields),
140 : maColFields(r.maColFields),
141 : maRowFields(r.maRowFields),
142 : maDataFields(r.maDataFields),
143 : bIgnoreEmptyRows(r.bIgnoreEmptyRows),
144 : bDetectCategories(r.bDetectCategories),
145 : bMakeTotalCol(r.bMakeTotalCol),
146 0 : bMakeTotalRow(r.bMakeTotalRow)
147 : {
148 0 : SetLabelData(r.maLabelArray);
149 0 : }
150 :
151 1 : ScPivotParam::~ScPivotParam()
152 : {
153 1 : }
154 :
155 0 : void ScPivotParam::SetLabelData(const ScDPLabelDataVector& r)
156 : {
157 0 : ScDPLabelDataVector aNewArray;
158 0 : aNewArray.reserve(r.size());
159 0 : for (ScDPLabelDataVector::const_iterator itr = r.begin(), itrEnd = r.end();
160 : itr != itrEnd; ++itr)
161 0 : aNewArray.push_back(new ScDPLabelData(*itr));
162 :
163 0 : maLabelArray.swap(aNewArray);
164 0 : }
165 :
166 0 : ScPivotParam& ScPivotParam::operator=( const ScPivotParam& r )
167 : {
168 0 : nCol = r.nCol;
169 0 : nRow = r.nRow;
170 0 : nTab = r.nTab;
171 0 : bIgnoreEmptyRows = r.bIgnoreEmptyRows;
172 0 : bDetectCategories = r.bDetectCategories;
173 0 : bMakeTotalCol = r.bMakeTotalCol;
174 0 : bMakeTotalRow = r.bMakeTotalRow;
175 :
176 0 : maPageFields = r.maPageFields;
177 0 : maColFields = r.maColFields;
178 0 : maRowFields = r.maRowFields;
179 0 : maDataFields = r.maDataFields;
180 0 : SetLabelData(r.maLabelArray);
181 0 : return *this;
182 : }
183 :
184 0 : bool ScPivotParam::operator==( const ScPivotParam& r ) const
185 : {
186 0 : bool bEqual = (nCol == r.nCol)
187 0 : && (nRow == r.nRow)
188 0 : && (nTab == r.nTab)
189 0 : && (bIgnoreEmptyRows == r.bIgnoreEmptyRows)
190 0 : && (bDetectCategories == r.bDetectCategories)
191 0 : && (bMakeTotalCol == r.bMakeTotalCol)
192 0 : && (bMakeTotalRow == r.bMakeTotalRow)
193 0 : && (maLabelArray.size() == r.maLabelArray.size())
194 0 : && maPageFields == r.maPageFields
195 0 : && maColFields == r.maColFields
196 0 : && maRowFields == r.maRowFields
197 0 : && maDataFields == r.maDataFields;
198 :
199 0 : return bEqual;
200 : }
201 :
202 : // ============================================================================
203 :
204 0 : ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
205 : mnCol( nCol ),
206 : mnOriginalDim(-1),
207 : mnFuncMask( nFuncMask ),
208 0 : mnDupCount(0)
209 : {
210 0 : }
211 :
212 0 : ScPivotFuncData::ScPivotFuncData(
213 : SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
214 : const DataPilotFieldReference& rFieldRef) :
215 : mnCol( nCol ),
216 : mnOriginalDim(nOriginalDim),
217 : mnFuncMask( nFuncMask ),
218 : mnDupCount(nDupCount),
219 0 : maFieldRef( rFieldRef )
220 : {
221 0 : }
222 :
223 0 : bool ScPivotFuncData::operator== (const ScPivotFuncData& r) const
224 : {
225 0 : if (mnCol != r.mnCol || mnOriginalDim != r.mnOriginalDim || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount)
226 0 : return false;
227 :
228 0 : return equals(maFieldRef, r.maFieldRef);
229 93 : }
230 :
231 : #if DEBUG_PIVOT_TABLE
232 : void ScPivotFuncData::Dump() const
233 : {
234 : cout << "ScPivotFuncData: (col=" << mnCol << ", original dim=" << mnOriginalDim
235 : << ", func mask=" << mnFuncMask << ", duplicate count=" << static_cast<int>(mnDupCount)
236 : << ")" << endl;
237 : }
238 : #endif
239 :
240 : // ============================================================================
241 :
242 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|