fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / pivot2.cxx
blobd0ae6ccc2205b892d7d2561ba91ee50aca58c2a5
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 .
20 #include "scitems.hxx"
21 #include <editeng/boxitem.hxx>
22 #include <editeng/wghtitem.hxx>
23 #include <svx/algitem.hxx>
24 #include <unotools/transliterationwrapper.hxx>
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>
37 #include "refupdat.hxx"
38 #include "stlpool.hxx"
39 #include "stlsheet.hxx"
41 #if DEBUG_PIVOT_TABLE
42 using std::cout;
43 using std::endl;
44 #endif
46 using css::sheet::DataPilotFieldReference;
47 using std::vector;
49 namespace
52 bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right)
54 return (left.ReferenceType == right.ReferenceType)
55 && (left.ReferenceField == right.ReferenceField)
56 && (left.ReferenceItemType == right.ReferenceItemType)
57 && (left.ReferenceItemName == right.ReferenceItemName);
60 } // namespace
62 // ScDPName
64 ScDPName::ScDPName() : mnDupCount(0)
67 ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName, sal_uInt8 nDupCount) :
68 maName(rName), maLayoutName(rLayoutName), mnDupCount(nDupCount)
71 // ScDPLabelData
73 ScDPLabelData::Member::Member() :
74 mbVisible(true),
75 mbShowDetails(true)
78 OUString ScDPLabelData::Member::getDisplayName() const
80 if (!maLayoutName.isEmpty())
81 return maLayoutName;
83 return maName;
86 ScDPLabelData::ScDPLabelData() :
87 mnCol(-1),
88 mnOriginalDim(-1),
89 mnFuncMask(PIVOT_FUNC_NONE),
90 mnUsedHier(0),
91 mnFlags(0),
92 mnDupCount(0),
93 mbShowAll(false),
94 mbIsValue(false),
95 mbDataLayout(false),
96 mbRepeatItemLabels(false)
99 OUString ScDPLabelData::getDisplayName() const
101 if (!maLayoutName.isEmpty())
102 return maLayoutName;
104 return maName;
107 // ScPivotField
109 ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
110 nCol(nNewCol),
111 mnOriginalDim(-1),
112 nFuncMask(nNewFuncMask),
113 mnDupCount(0)
116 ScPivotField::ScPivotField( const ScPivotField& rPivotField ) :
117 nCol(rPivotField.nCol),
118 mnOriginalDim(rPivotField.mnOriginalDim),
119 nFuncMask(rPivotField.nFuncMask),
120 mnDupCount(rPivotField.mnDupCount),
121 maFieldRef(rPivotField.maFieldRef)
124 long ScPivotField::getOriginalDim() const
126 return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<long>(nCol);
129 bool ScPivotField::operator==( const ScPivotField& r ) const
131 return (nCol == r.nCol)
132 && (mnOriginalDim == r.mnOriginalDim)
133 && (nFuncMask == r.nFuncMask)
134 && equals(maFieldRef, r.maFieldRef);
137 // ScPivotParam
139 ScPivotParam::ScPivotParam() :
140 nCol(0), nRow(0), nTab(0),
141 bIgnoreEmptyRows(false), bDetectCategories(false),
142 bMakeTotalCol(true), bMakeTotalRow(true)
145 ScPivotParam::ScPivotParam( const ScPivotParam& r )
146 : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
147 maPageFields(r.maPageFields),
148 maColFields(r.maColFields),
149 maRowFields(r.maRowFields),
150 maDataFields(r.maDataFields),
151 bIgnoreEmptyRows(r.bIgnoreEmptyRows),
152 bDetectCategories(r.bDetectCategories),
153 bMakeTotalCol(r.bMakeTotalCol),
154 bMakeTotalRow(r.bMakeTotalRow)
156 SetLabelData(r.maLabelArray);
159 ScPivotParam::~ScPivotParam()
162 void ScPivotParam::SetLabelData(const ScDPLabelDataVector& rVector)
164 ScDPLabelDataVector aNewArray;
165 aNewArray.reserve(rVector.size());
166 ScDPLabelDataVector::const_iterator it;
167 for (it = rVector.begin(); it != rVector.end(); ++it)
169 aNewArray.push_back(new ScDPLabelData(*it));
171 maLabelArray.swap(aNewArray);
174 ScPivotParam& ScPivotParam::operator=( const ScPivotParam& rPivotParam )
176 nCol = rPivotParam.nCol;
177 nRow = rPivotParam.nRow;
178 nTab = rPivotParam.nTab;
179 bIgnoreEmptyRows = rPivotParam.bIgnoreEmptyRows;
180 bDetectCategories = rPivotParam.bDetectCategories;
181 bMakeTotalCol = rPivotParam.bMakeTotalCol;
182 bMakeTotalRow = rPivotParam.bMakeTotalRow;
184 maPageFields = rPivotParam.maPageFields;
185 maColFields = rPivotParam.maColFields;
186 maRowFields = rPivotParam.maRowFields;
187 maDataFields = rPivotParam.maDataFields;
189 SetLabelData(rPivotParam.maLabelArray);
190 return *this;
193 bool ScPivotParam::operator==( const ScPivotParam& rPivotParam ) const
195 bool bEqual = (nCol == rPivotParam.nCol &&
196 nRow == rPivotParam.nRow &&
197 nTab == rPivotParam.nTab &&
198 bIgnoreEmptyRows == rPivotParam.bIgnoreEmptyRows &&
199 bDetectCategories == rPivotParam.bDetectCategories &&
200 bMakeTotalCol == rPivotParam.bMakeTotalCol &&
201 bMakeTotalRow == rPivotParam.bMakeTotalRow &&
202 maLabelArray.size() == rPivotParam.maLabelArray.size() &&
203 maPageFields == rPivotParam.maPageFields &&
204 maColFields == rPivotParam.maColFields &&
205 maRowFields == rPivotParam.maRowFields &&
206 maDataFields == rPivotParam.maDataFields);
207 return bEqual;
210 // ScPivotFuncData
212 ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
213 mnCol( nCol ),
214 mnOriginalDim(-1),
215 mnFuncMask(nFuncMask),
216 mnDupCount(0)
219 bool ScPivotFuncData::operator== (const ScPivotFuncData& rFuncData) const
221 if (mnCol != rFuncData.mnCol ||
222 mnOriginalDim != rFuncData.mnOriginalDim ||
223 mnFuncMask != rFuncData.mnFuncMask ||
224 mnDupCount != rFuncData.mnDupCount)
226 return false;
228 return equals(maFieldRef, rFuncData.maFieldRef);
231 #if DEBUG_PIVOT_TABLE
232 void ScPivotFuncData::Dump() const
234 cout << "ScPivotFuncData: (col=" << mnCol << ", original dim=" << mnOriginalDim
235 << ", func mask=" << mnFuncMask << ", duplicate count=" << static_cast<int>(mnDupCount)
236 << ")" << endl;
238 #endif
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */