Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sc / source / core / data / pivot2.cxx
blobc854b452c20ef2e854778596e8b8ba8bb8593253
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 <pivot.hxx>
21 #include <utility>
23 #if DEBUG_PIVOT_TABLE
24 using std::cout;
25 using std::endl;
26 #endif
30 // ScDPName
32 ScDPName::ScDPName() : mnDupCount(0)
35 ScDPName::ScDPName(OUString aName, OUString aLayoutName, sal_uInt8 nDupCount) :
36 maName(std::move(aName)), maLayoutName(std::move(aLayoutName)), mnDupCount(nDupCount)
39 // ScDPLabelData
41 ScDPLabelData::Member::Member() :
42 mbVisible(true),
43 mbShowDetails(true)
46 OUString const & ScDPLabelData::Member::getDisplayName() const
48 if (!maLayoutName.isEmpty())
49 return maLayoutName;
51 return maName;
54 ScDPLabelData::ScDPLabelData() :
55 mnCol(-1),
56 mnOriginalDim(-1),
57 mnFuncMask(PivotFunc::NONE),
58 mnUsedHier(0),
59 mnFlags(0),
60 mnDupCount(0),
61 mbShowAll(false),
62 mbIsValue(false),
63 mbDataLayout(false),
64 mbRepeatItemLabels(false)
67 OUString const & ScDPLabelData::getDisplayName() const
69 if (!maLayoutName.isEmpty())
70 return maLayoutName;
72 return maName;
75 // ScPivotField
77 ScPivotField::ScPivotField(SCCOL nNewCol) :
78 mnOriginalDim(-1),
79 nFuncMask(PivotFunc::NONE),
80 nCol(nNewCol),
81 mnDupCount(0)
84 tools::Long ScPivotField::getOriginalDim() const
86 return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<tools::Long>(nCol);
89 // ScPivotParam
91 ScPivotParam::ScPivotParam() :
92 nCol(0), nRow(0), nTab(0),
93 bIgnoreEmptyRows(false), bDetectCategories(false),
94 bMakeTotalCol(true), bMakeTotalRow(true)
97 ScPivotParam::ScPivotParam( const ScPivotParam& r )
98 : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
99 maPageFields(r.maPageFields),
100 maColFields(r.maColFields),
101 maRowFields(r.maRowFields),
102 maDataFields(r.maDataFields),
103 bIgnoreEmptyRows(r.bIgnoreEmptyRows),
104 bDetectCategories(r.bDetectCategories),
105 bMakeTotalCol(r.bMakeTotalCol),
106 bMakeTotalRow(r.bMakeTotalRow)
108 SetLabelData(r.maLabelArray);
111 ScPivotParam::~ScPivotParam()
114 void ScPivotParam::SetLabelData(const ScDPLabelDataVector& rVector)
116 ScDPLabelDataVector aNewArray;
117 aNewArray.reserve(rVector.size());
118 for (const auto& rxData : rVector)
120 aNewArray.push_back(std::make_unique<ScDPLabelData>(*rxData));
122 maLabelArray.swap(aNewArray);
125 ScPivotParam& ScPivotParam::operator=( const ScPivotParam& rPivotParam )
127 nCol = rPivotParam.nCol;
128 nRow = rPivotParam.nRow;
129 nTab = rPivotParam.nTab;
130 bIgnoreEmptyRows = rPivotParam.bIgnoreEmptyRows;
131 bDetectCategories = rPivotParam.bDetectCategories;
132 bMakeTotalCol = rPivotParam.bMakeTotalCol;
133 bMakeTotalRow = rPivotParam.bMakeTotalRow;
135 maPageFields = rPivotParam.maPageFields;
136 maColFields = rPivotParam.maColFields;
137 maRowFields = rPivotParam.maRowFields;
138 maDataFields = rPivotParam.maDataFields;
140 SetLabelData(rPivotParam.maLabelArray);
141 return *this;
144 // ScPivotFuncData
146 ScPivotFuncData::ScPivotFuncData( SCCOL nCol, PivotFunc nFuncMask ) :
147 mnOriginalDim(-1),
148 mnFuncMask(nFuncMask),
149 mnCol( nCol ),
150 mnDupCount(0)
153 #if DEBUG_PIVOT_TABLE
154 void ScPivotFuncData::Dump() const
156 cout << "ScPivotFuncData: (col=" << mnCol << ", original dim=" << mnOriginalDim
157 << ", func mask=" << static_cast<int>(mnFuncMask) << ", duplicate count=" << static_cast<int>(mnDupCount)
158 << ")" << endl;
160 #endif
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */