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