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