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 : using ::com::sun::star::sheet::DataPilotFieldReference;
47 : using ::rtl::OUString;
48 : using ::std::vector;
49 :
50 : namespace {
51 :
52 0 : bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right)
53 : {
54 : return (left.ReferenceType == right.ReferenceType)
55 0 : && (left.ReferenceField == right.ReferenceField)
56 : && (left.ReferenceItemType == right.ReferenceItemType)
57 0 : && (left.ReferenceItemName == right.ReferenceItemName);
58 : }
59 :
60 : }
61 :
62 : // ============================================================================
63 :
64 0 : ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName) :
65 0 : maName(rName), maLayoutName(rLayoutName) {}
66 :
67 : // ============================================================================
68 :
69 54 : ScDPLabelData::Member::Member() :
70 : mbVisible(true),
71 54 : mbShowDetails(true)
72 : {
73 54 : }
74 :
75 0 : OUString ScDPLabelData::Member::getDisplayName() const
76 : {
77 0 : if (!maLayoutName.isEmpty())
78 0 : return maLayoutName;
79 :
80 0 : return maName;
81 : }
82 :
83 8 : ScDPLabelData::ScDPLabelData() :
84 : mnCol(-1),
85 : mnOriginalDim(-1),
86 : mnFuncMask(PIVOT_FUNC_NONE),
87 : mnUsedHier(0),
88 : mnFlags(0),
89 : mbShowAll(false),
90 : mbIsValue(false),
91 8 : mbDataLayout(false)
92 : {
93 8 : }
94 :
95 0 : OUString ScDPLabelData::getDisplayName() const
96 : {
97 0 : if (!maLayoutName.isEmpty())
98 0 : return maLayoutName;
99 :
100 0 : return maName;
101 : }
102 :
103 0 : ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
104 : nCol( nNewCol ),
105 : mnOriginalDim(-1),
106 : nFuncMask( nNewFuncMask ),
107 0 : mnDupCount(0)
108 : {
109 0 : }
110 :
111 0 : ScPivotField::ScPivotField( const ScPivotField& r ) :
112 : nCol(r.nCol),
113 : mnOriginalDim(r.mnOriginalDim),
114 : nFuncMask(r.nFuncMask),
115 : mnDupCount(r.mnDupCount),
116 0 : maFieldRef(r.maFieldRef) {}
117 :
118 0 : long ScPivotField::getOriginalDim() const
119 : {
120 0 : return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<long>(nCol);
121 : }
122 :
123 0 : bool ScPivotField::operator==( const ScPivotField& r ) const
124 : {
125 : return (nCol == r.nCol)
126 : && (mnOriginalDim == r.mnOriginalDim)
127 : && (nFuncMask == r.nFuncMask)
128 0 : && equals(maFieldRef, r.maFieldRef);
129 : }
130 :
131 2 : ScPivotParam::ScPivotParam()
132 : : nCol(0), nRow(0), nTab(0),
133 : bIgnoreEmptyRows(false), bDetectCategories(false),
134 2 : bMakeTotalCol(true), bMakeTotalRow(true)
135 : {
136 2 : }
137 :
138 0 : ScPivotParam::ScPivotParam( const ScPivotParam& r )
139 : : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
140 : maPageFields(r.maPageFields),
141 : maColFields(r.maColFields),
142 : maRowFields(r.maRowFields),
143 : maDataFields(r.maDataFields),
144 : bIgnoreEmptyRows(r.bIgnoreEmptyRows),
145 : bDetectCategories(r.bDetectCategories),
146 : bMakeTotalCol(r.bMakeTotalCol),
147 0 : bMakeTotalRow(r.bMakeTotalRow)
148 : {
149 0 : SetLabelData(r.maLabelArray);
150 0 : }
151 :
152 2 : ScPivotParam::~ScPivotParam()
153 : {
154 2 : }
155 :
156 0 : void ScPivotParam::SetLabelData(const ScDPLabelDataVector& r)
157 : {
158 0 : ScDPLabelDataVector aNewArray;
159 0 : aNewArray.reserve(r.size());
160 0 : for (ScDPLabelDataVector::const_iterator itr = r.begin(), itrEnd = r.end();
161 : itr != itrEnd; ++itr)
162 0 : aNewArray.push_back(new ScDPLabelData(*itr));
163 :
164 0 : maLabelArray.swap(aNewArray);
165 0 : }
166 :
167 0 : ScPivotParam& ScPivotParam::operator=( const ScPivotParam& r )
168 : {
169 0 : nCol = r.nCol;
170 0 : nRow = r.nRow;
171 0 : nTab = r.nTab;
172 0 : bIgnoreEmptyRows = r.bIgnoreEmptyRows;
173 0 : bDetectCategories = r.bDetectCategories;
174 0 : bMakeTotalCol = r.bMakeTotalCol;
175 0 : bMakeTotalRow = r.bMakeTotalRow;
176 :
177 0 : maPageFields = r.maPageFields;
178 0 : maColFields = r.maColFields;
179 0 : maRowFields = r.maRowFields;
180 0 : maDataFields = r.maDataFields;
181 0 : SetLabelData(r.maLabelArray);
182 0 : return *this;
183 : }
184 :
185 0 : bool ScPivotParam::operator==( const ScPivotParam& r ) const
186 : {
187 : bool bEqual = (nCol == r.nCol)
188 : && (nRow == r.nRow)
189 : && (nTab == r.nTab)
190 : && (bIgnoreEmptyRows == r.bIgnoreEmptyRows)
191 : && (bDetectCategories == r.bDetectCategories)
192 : && (bMakeTotalCol == r.bMakeTotalCol)
193 : && (bMakeTotalRow == r.bMakeTotalRow)
194 0 : && (maLabelArray.size() == r.maLabelArray.size())
195 0 : && maPageFields == r.maPageFields
196 0 : && maColFields == r.maColFields
197 0 : && maRowFields == r.maRowFields
198 0 : && maDataFields == r.maDataFields;
199 :
200 0 : return bEqual;
201 : }
202 :
203 : // ============================================================================
204 :
205 0 : ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
206 : mnCol( nCol ),
207 : mnOriginalDim(-1),
208 : mnFuncMask( nFuncMask ),
209 0 : mnDupCount(0)
210 : {
211 0 : }
212 :
213 0 : ScPivotFuncData::ScPivotFuncData(
214 : SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
215 : const DataPilotFieldReference& rFieldRef) :
216 : mnCol( nCol ),
217 : mnOriginalDim(nOriginalDim),
218 : mnFuncMask( nFuncMask ),
219 : mnDupCount(nDupCount),
220 0 : maFieldRef( rFieldRef )
221 : {
222 0 : }
223 :
224 0 : bool ScPivotFuncData::operator== (const ScPivotFuncData& r) const
225 : {
226 0 : if (mnCol != r.mnCol || mnOriginalDim != r.mnOriginalDim || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount)
227 0 : return false;
228 :
229 0 : return equals(maFieldRef, r.maFieldRef);
230 : }
231 :
232 : // ============================================================================
233 :
234 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|