LibreOffice Module sc (master) 1
pivot2.cxx
Go to the documentation of this file.
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 <pivot.hxx>
21#include <utility>
22
23#if DEBUG_PIVOT_TABLE
24using std::cout;
25using std::endl;
26#endif
27
28
29
30// ScDPName
31
32ScDPName::ScDPName() : mnDupCount(0)
33{}
34
35ScDPName::ScDPName(OUString aName, OUString aLayoutName, sal_uInt8 nDupCount) :
36 maName(std::move(aName)), maLayoutName(std::move(aLayoutName)), mnDupCount(nDupCount)
37{}
38
39// ScDPLabelData
40
42 mbVisible(true),
43 mbShowDetails(true)
44{}
45
47{
48 if (!maLayoutName.isEmpty())
49 return maLayoutName;
50
51 return maName;
52}
53
55 mnCol(-1),
56 mnOriginalDim(-1),
58 mnUsedHier(0),
59 mnFlags(0),
60 mnDupCount(0),
61 mbShowAll(false),
62 mbIsValue(false),
63 mbDataLayout(false),
65{}
66
67OUString const & ScDPLabelData::getDisplayName() const
68{
69 if (!maLayoutName.isEmpty())
70 return maLayoutName;
71
72 return maName;
73}
74
75// ScPivotField
76
78 mnOriginalDim(-1),
79 nFuncMask(PivotFunc::NONE),
80 nCol(nNewCol),
81 mnDupCount(0)
82{}
83
85{
86 return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<tools::Long>(nCol);
87}
88
89// ScPivotParam
90
92 nCol(0), nRow(0), nTab(0),
93 bIgnoreEmptyRows(false), bDetectCategories(false),
94 bMakeTotalCol(true), bMakeTotalRow(true)
95{}
96
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)
107{
109}
110
112{}
113
115{
116 ScDPLabelDataVector aNewArray;
117 aNewArray.reserve(rVector.size());
118 for (const auto& rxData : rVector)
119 {
120 aNewArray.push_back(std::make_unique<ScDPLabelData>(*rxData));
121 }
122 maLabelArray.swap(aNewArray);
123}
124
126{
127 nCol = rPivotParam.nCol;
128 nRow = rPivotParam.nRow;
129 nTab = rPivotParam.nTab;
132 bMakeTotalCol = rPivotParam.bMakeTotalCol;
133 bMakeTotalRow = rPivotParam.bMakeTotalRow;
134
135 maPageFields = rPivotParam.maPageFields;
136 maColFields = rPivotParam.maColFields;
137 maRowFields = rPivotParam.maRowFields;
138 maDataFields = rPivotParam.maDataFields;
139
140 SetLabelData(rPivotParam.maLabelArray);
141 return *this;
142}
143
144// ScPivotFuncData
145
147 mnOriginalDim(-1),
148 mnFuncMask(nFuncMask),
149 mnCol( nCol ),
150 mnDupCount(0)
151{}
152
153#if DEBUG_PIVOT_TABLE
154void ScPivotFuncData::Dump() const
155{
156 cout << "ScPivotFuncData: (col=" << mnCol << ", original dim=" << mnOriginalDim
157 << ", func mask=" << static_cast<int>(mnFuncMask) << ", duplicate count=" << static_cast<int>(mnDupCount)
158 << ")" << endl;
159}
160#endif
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maName
PivotFunc
Definition: dpglobal.hxx:24
sal_Int32 mnCol
OUString aName
NONE
long Long
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
Definition: pivot.hxx:113
TOOLS_DLLPUBLIC SvStream & endl(SvStream &rStr)
SC_DLLPUBLIC OUString const & getDisplayName() const
Definition: pivot2.cxx:46
sal_Int32 mnUsedHier
Used hierarchy.
Definition: pivot.hxx:74
bool mbRepeatItemLabels
Definition: pivot.hxx:80
tools::Long mnOriginalDim
original dimension index (>= 0 for duplicated dimension)
Definition: pivot.hxx:72
bool mbIsValue
true = Sum or count in data field.
Definition: pivot.hxx:78
SCCOL mnCol
0-based field index (not the source column index)
Definition: pivot.hxx:71
OUString maName
Original name of the dimension.
Definition: pivot.hxx:68
bool mbDataLayout
Definition: pivot.hxx:79
bool mbShowAll
true = Show all (also empty) results.
Definition: pivot.hxx:77
OUString maLayoutName
Layout name (display name)
Definition: pivot.hxx:69
sal_uInt8 mnDupCount
Definition: pivot.hxx:76
PivotFunc mnFuncMask
Page/Column/Row subtotal function.
Definition: pivot.hxx:73
SC_DLLPUBLIC OUString const & getDisplayName() const
Definition: pivot2.cxx:67
sal_Int32 mnFlags
Flags from the DataPilotSource dimension.
Definition: pivot.hxx:75
ScDPName()
Definition: pivot2.cxx:32
SCCOL nCol
0-based dimension index (not source column index)
Definition: pivot.hxx:121
tools::Long getOriginalDim() const
Definition: pivot2.cxx:84
ScPivotField(SCCOL nNewCol=0)
Definition: pivot2.cxx:77
tools::Long mnOriginalDim
>= 0 for duplicated field.
Definition: pivot.hxx:119
sal_uInt8 mnDupCount
Definition: pivot.hxx:163
ScPivotFuncData(SCCOL nCol, PivotFunc nFuncMask)
Definition: pivot2.cxx:146
tools::Long mnOriginalDim
Definition: pivot.hxx:160
PivotFunc mnFuncMask
Definition: pivot.hxx:161
bool bMakeTotalRow
Definition: pivot.hxx:146
ScDPLabelDataVector maLabelArray
Definition: pivot.hxx:137
ScPivotFieldVector maDataFields
Definition: pivot.hxx:141
ScPivotFieldVector maRowFields
Definition: pivot.hxx:140
SCTAB nTab
Definition: pivot.hxx:135
bool bDetectCategories
Definition: pivot.hxx:144
SCCOL nCol
Cursor Position /.
Definition: pivot.hxx:133
SCROW nRow
or start of destination area
Definition: pivot.hxx:134
bool bIgnoreEmptyRows
Definition: pivot.hxx:143
bool bMakeTotalCol
Definition: pivot.hxx:145
ScPivotFieldVector maColFields
Definition: pivot.hxx:139
ScPivotParam()
Definition: pivot2.cxx:91
ScPivotParam & operator=(const ScPivotParam &r)
Definition: pivot2.cxx:125
void SetLabelData(const ScDPLabelDataVector &r)
Definition: pivot2.cxx:114
ScPivotFieldVector maPageFields
Definition: pivot.hxx:138
bool mbVisible
unsigned char sal_uInt8
sal_Int16 SCCOL
Definition: types.hxx:21