1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <types.hxx>
#include <scdllapi.h>
#include <sortparam.hxx>
#include <set>
class ScDocument;
namespace sc {
enum class TransformationType
{
MERGE_TRANSFORMATION,
SPLIT_TRANSFORMATION,
DELETE_TRANSFORMATION,
SORT_TRANSFORMATION,
TEXT_TRANSFORMATION,
AGGREGATE_FUNCTION,
NUMBER_TRANSFORMATION,
REMOVE_NULL_TRANSFORMATION,
DATETIME_TRANSFORMATION,
FINDREPLACE_TRANSFORMATION,
DELETEROW_TRANSFORMATION,
SWAPROWS_TRANSFORMATION
};
enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM };
enum class AGGREGATE_FUNCTION { SUM, AVERAGE, MIN, MAX };
enum class NUMBER_TRANSFORM_TYPE { ROUND, ROUND_UP, ROUND_DOWN, ABSOLUTE, LOG_E, LOG_10, CUBE,
SQUARE, SQUARE_ROOT, EXPONENT, IS_EVEN, IS_ODD, SIGN };
enum class DATETIME_TRANSFORMATION_TYPE { DATE_STRING, YEAR, START_OF_YEAR, END_OF_YEAR, MONTH,
MONTH_NAME, START_OF_MONTH, END_OF_MONTH, DAY, DAY_OF_WEEK, DAY_OF_YEAR, QUARTER, START_OF_QUARTER,
END_OF_QUARTER, TIME, HOUR, MINUTE, SECOND };
class SC_DLLPUBLIC DataTransformation
{
protected:
static SCROW getLastRow(const ScDocument& rDoc, SCCOL nCol);
public:
virtual ~DataTransformation();
virtual void Transform(ScDocument& rDoc) const = 0;
virtual TransformationType getTransformationType() const = 0;
};
class SC_DLLPUBLIC ColumnRemoveTransformation : public DataTransformation
{
std::set<SCCOL> maColumns;
public:
ColumnRemoveTransformation(std::set<SCCOL>&& rColumns);
virtual ~ColumnRemoveTransformation() override;
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
const std::set<SCCOL> & getColumns() const;
};
class SC_DLLPUBLIC SplitColumnTransformation : public DataTransformation
{
SCCOL mnCol;
sal_Unicode mcSeparator;
public:
SplitColumnTransformation(SCCOL nCol, sal_Unicode cSeparator);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
SCCOL getColumn() const;
sal_Unicode getSeparator() const;
};
class SC_DLLPUBLIC MergeColumnTransformation : public DataTransformation
{
std::set<SCCOL> maColumns;
OUString maMergeString;
public:
MergeColumnTransformation(std::set<SCCOL>&& rColumns, const OUString& rMergeString);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
const OUString & getMergeString() const;
const std::set<SCCOL> & getColumns() const;
};
class SortTransformation : public DataTransformation
{
ScSortParam maSortParam;
public:
SortTransformation(const ScSortParam& rParam);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
const ScSortParam & getSortParam() const;
};
class SC_DLLPUBLIC TextTransformation : public DataTransformation
{
std::set<SCCOL> mnCol;
TEXT_TRANSFORM_TYPE maType;
public:
TextTransformation(std::set<SCCOL>&& nCol, const TEXT_TRANSFORM_TYPE rType);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
TEXT_TRANSFORM_TYPE getTextTransformationType() const;
const std::set<SCCOL>& getColumns() const;
};
class SC_DLLPUBLIC AggregateFunction : public DataTransformation
{
std::set<SCCOL> maColumns;
AGGREGATE_FUNCTION maType;
public:
AggregateFunction(std::set<SCCOL>&& rColumns, const AGGREGATE_FUNCTION rType);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
AGGREGATE_FUNCTION getAggregateType() const;
const std::set<SCCOL>& getColumns() const;
};
class SC_DLLPUBLIC NumberTransformation : public DataTransformation
{
std::set<SCCOL> mnCol;
NUMBER_TRANSFORM_TYPE maType;
int maPrecision;
public:
NumberTransformation(std::set<SCCOL>&& nCol, const NUMBER_TRANSFORM_TYPE rType);
NumberTransformation(std::set<SCCOL>&& nCol, const NUMBER_TRANSFORM_TYPE rType,
int nPrecision);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
NUMBER_TRANSFORM_TYPE getNumberTransformationType() const;
int getPrecision() const;
const std::set<SCCOL>& getColumn() const;
};
class SC_DLLPUBLIC ReplaceNullTransformation : public DataTransformation
{
std::set<SCCOL> mnCol;
OUString msReplaceWith;
public:
ReplaceNullTransformation(std::set<SCCOL>&& nCol, const OUString& sReplaceWith);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
const std::set<SCCOL>& getColumn() const;
const OUString& getReplaceString() const;
};
class SC_DLLPUBLIC DateTimeTransformation : public DataTransformation
{
std::set<SCCOL> mnCol;
DATETIME_TRANSFORMATION_TYPE maType;
public:
DateTimeTransformation(std::set<SCCOL>&& nCol,
const DATETIME_TRANSFORMATION_TYPE rType);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
DATETIME_TRANSFORMATION_TYPE getDateTimeTransformationType() const;
const std::set<SCCOL>& getColumn() const;
};
class FindReplaceTransformation : public DataTransformation
{
SCCOL mnCol;
OUString maFindString;
OUString maReplaceString;
public:
FindReplaceTransformation(SCCOL nCol, const OUString& aFindString, const OUString& aReplaceString);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
SCCOL getColumn() const;
const OUString & getFindString() const;
const OUString & getReplaceString() const;
};
class DeleteRowTransformation : public DataTransformation
{
SCCOL mnCol;
OUString maFindString;
public:
DeleteRowTransformation(SCCOL nCol, const OUString& aFindString);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
SCCOL getColumn() const;
const OUString & getFindString() const;
};
class SwapRowsTransformation : public DataTransformation
{
SCROW mxRow, nxRow;
public:
SwapRowsTransformation(SCROW mRow, SCROW nRow);
virtual void Transform(ScDocument& rDoc) const override;
virtual TransformationType getTransformationType() const override;
SCROW getFirstRow() const;
SCROW getSecondRow() const;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|