1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <dataproviderdlg.hxx>
12 #include <document.hxx>
13 #include <dataprovider.hxx>
14 #include <datatransformation.hxx>
15 #include <datamapper.hxx>
18 #include <comphelper/string.hxx>
19 #include <sal/log.hxx>
20 #include <sfx2/filedlghelper.hxx>
21 #include <unotools/charclass.hxx>
23 #include <vcl/svapp.hxx>
25 class ScDataTransformationBaseControl
28 std::unique_ptr
<weld::Builder
> mxBuilder
;
29 std::unique_ptr
<weld::Container
> mxGrid
;
30 weld::Container
* mpContainer
;
35 ScDataTransformationBaseControl(weld::Container
* pParent
, const OUString
& rUIFile
, sal_uInt32 nIndex
);
36 virtual ~ScDataTransformationBaseControl();
38 void updateIndex(sal_uInt32 nIndex
) { mnIndex
= nIndex
; }
40 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() = 0;
42 static SCROW
getLastRow(const ScDocument
& rDoc
);
43 static SCCOL
getLastCol(const ScDocument
& rDoc
);
46 SCROW
ScDataTransformationBaseControl::getLastRow(const ScDocument
& rDoc
)
48 SCROW nEndRow
= rDoc
.MaxRow();
49 return rDoc
.GetLastDataRow(0, 0, 0, nEndRow
);
52 SCCOL
ScDataTransformationBaseControl::getLastCol(const ScDocument
& rDoc
)
54 for (SCCOL nCol
= 1; nCol
<= rDoc
.MaxCol(); ++nCol
)
56 if (rDoc
.GetCellType(nCol
, 0, 0) == CELLTYPE_NONE
)
58 return static_cast<SCCOL
>(nCol
- 1 );
64 ScDataTransformationBaseControl::ScDataTransformationBaseControl(weld::Container
* pParent
, const OUString
& rUIFile
, sal_uInt32 nIndex
)
65 : mxBuilder(Application::CreateBuilder(pParent
, rUIFile
))
66 , mxGrid(mxBuilder
->weld_container(u
"grid"_ustr
))
67 , mpContainer(pParent
)
72 ScDataTransformationBaseControl::~ScDataTransformationBaseControl()
74 mpContainer
->move(mxGrid
.get(), nullptr);
81 const char* aTransformationName
;
82 std::function
<void(ScDataProviderDlg
*)> maCallback
;
85 MenuData aTransformationData
[] = {
86 { "Delete Column", &ScDataProviderDlg::deleteColumn
},
87 { "Delete Row", &ScDataProviderDlg::deleteRowTransformation
},
88 { "Swap Rows", &ScDataProviderDlg::swapRowsTransformation
},
89 { "Split Column", &ScDataProviderDlg::splitColumn
},
90 { "Merge Columns", &ScDataProviderDlg::mergeColumns
},
91 { "Text Transformation", &ScDataProviderDlg::textTransformation
},
92 { "Sort Columns", &ScDataProviderDlg::sortTransformation
},
93 { "Aggregate Functions", &ScDataProviderDlg::aggregateFunction
},
94 { "Number Transformations", &ScDataProviderDlg::numberTransformation
},
95 { "Replace Null Transformations", &ScDataProviderDlg::replaceNullTransformation
},
96 { "Date & Time Transformations", &ScDataProviderDlg::dateTimeTransformation
},
97 { "Find Replace Transformation", &ScDataProviderDlg::findReplaceTransformation
}
100 class ScDeleteColumnTransformationControl
: public ScDataTransformationBaseControl
103 std::unique_ptr
<weld::Entry
> mxColumnNums
;
104 std::unique_ptr
<weld::Button
> mxDelete
;
105 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
106 const ScDocument
* mpDoc
;
109 ScDeleteColumnTransformationControl(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 aIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
111 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
112 DECL_LINK(DeleteHdl
, weld::Button
&, void);
115 ScDeleteColumnTransformationControl::ScDeleteColumnTransformationControl(
116 const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
117 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/deletecolumnentry.ui"_ustr
, nIndex
)
118 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
119 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
120 , maDeleteTransformation(std::move(aDeleteTransformation
))
123 mxDelete
->connect_clicked(LINK(this,ScDeleteColumnTransformationControl
, DeleteHdl
));
126 std::shared_ptr
<sc::DataTransformation
> ScDeleteColumnTransformationControl::getTransformation()
128 OUString aColumnString
= mxColumnNums
->get_text();
129 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
130 std::set
<SCCOL
> ColNums
;
131 for (const auto& rColStr
: aSplitColumns
)
133 sal_Int32 nCol
= rColStr
.toInt32();
137 if (nCol
> mpDoc
->MaxCol())
140 // translate from 1-based column notations to internal Calc one
141 ColNums
.insert(nCol
- 1);
144 return std::make_shared
<sc::ColumnRemoveTransformation
>(std::move(ColNums
));
147 class ScSplitColumnTransformationControl
: public ScDataTransformationBaseControl
150 std::unique_ptr
<weld::Entry
> mxSeparator
;
151 std::unique_ptr
<weld::Entry
> mxNumColumns
;
152 std::unique_ptr
<weld::Button
> mxDelete
;
153 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
154 const ScDocument
* mpDoc
;
157 ScSplitColumnTransformationControl(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
159 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
160 DECL_LINK(DeleteHdl
, weld::Button
&, void);
163 ScSplitColumnTransformationControl::ScSplitColumnTransformationControl(
164 const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
,
165 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
166 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/splitcolumnentry.ui"_ustr
, nIndex
)
167 , mxSeparator(mxBuilder
->weld_entry(u
"ed_separator"_ustr
))
168 , mxNumColumns(mxBuilder
->weld_entry(u
"num_cols"_ustr
))
169 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
170 , maDeleteTransformation(std::move(aDeleteTransformation
))
173 mxDelete
->connect_clicked(LINK(this,ScSplitColumnTransformationControl
, DeleteHdl
));
176 std::shared_ptr
<sc::DataTransformation
> ScSplitColumnTransformationControl::getTransformation()
178 OUString aSeparator
= mxSeparator
->get_text();
179 sal_Unicode cSeparator
= aSeparator
.isEmpty() ? ',' : aSeparator
[0];
180 OUString aColStr
= mxNumColumns
->get_text();
182 sal_Int32 nCol
= aColStr
.toInt32();
183 if (nCol
> 0 && nCol
<= mpDoc
->MaxCol())
185 return std::make_shared
<sc::SplitColumnTransformation
>(mnCol
, cSeparator
);
188 class ScMergeColumnTransformationControl
: public ScDataTransformationBaseControl
191 std::unique_ptr
<weld::Entry
> mxSeparator
;
192 std::unique_ptr
<weld::Entry
> mxEdColumns
;
193 std::unique_ptr
<weld::Button
> mxDelete
;
194 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
195 const ScDocument
* mpDoc
;
198 ScMergeColumnTransformationControl(const ScDocument
*pDoc
, weld::Container
* pParent
, SCCOL nStartCol
, SCCOL nEndCol
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
200 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
201 DECL_LINK(DeleteHdl
, weld::Button
&, void);
204 ScMergeColumnTransformationControl::ScMergeColumnTransformationControl(
205 const ScDocument
* pDoc
, weld::Container
* pParent
, SCCOL nStartCol
, SCCOL nEndCol
, sal_uInt32 nIndex
,
206 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
207 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/mergecolumnentry.ui"_ustr
, nIndex
)
208 , mxSeparator(mxBuilder
->weld_entry(u
"ed_separator"_ustr
))
209 , mxEdColumns(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
210 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
211 , maDeleteTransformation(std::move(aDeleteTransformation
))
214 mxDelete
->connect_clicked(LINK(this,ScMergeColumnTransformationControl
, DeleteHdl
));
216 OUStringBuffer aBuffer
;
218 // map from zero based to one based column numbers
219 aBuffer
.append(static_cast<sal_Int32
>(nStartCol
+ 1));
220 for ( SCCOL nCol
= nStartCol
+ 1; nCol
<= nEndCol
; ++nCol
)
222 aBuffer
.append(";" + OUString::number(nCol
+ 1));
225 mxEdColumns
->set_text(aBuffer
.makeStringAndClear());
228 std::shared_ptr
<sc::DataTransformation
> ScMergeColumnTransformationControl::getTransformation()
230 OUString aColumnString
= mxEdColumns
->get_text();
231 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
232 std::set
<SCCOL
> aMergedColumns
;
233 for (const auto& rColStr
: aSplitColumns
)
235 sal_Int32 nCol
= rColStr
.toInt32();
239 if (nCol
> mpDoc
->MaxCol())
242 // translate from 1-based column notations to internal Calc one
243 aMergedColumns
.insert(nCol
- 1);
245 return std::make_shared
<sc::MergeColumnTransformation
>(std::move(aMergedColumns
), mxSeparator
->get_text());
248 class ScSortTransformationControl
: public ScDataTransformationBaseControl
251 std::unique_ptr
<weld::ComboBox
> mxType
;
252 std::unique_ptr
<weld::Entry
> mxEdColumns
;
253 std::unique_ptr
<weld::Button
> mxDelete
;
254 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
255 const ScDocument
* mpDoc
;
258 ScSortTransformationControl(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
260 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
261 DECL_LINK(DeleteHdl
, weld::Button
&, void);
264 ScSortTransformationControl::ScSortTransformationControl(
265 const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
266 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/sorttransformationentry.ui"_ustr
, nIndex
)
267 , mxType(mxBuilder
->weld_combo_box(u
"ed_ascending"_ustr
))
268 , mxEdColumns(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
269 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
270 , maDeleteTransformation(std::move(aDeleteTransformation
))
273 mxDelete
->connect_clicked(LINK(this,ScSortTransformationControl
, DeleteHdl
));
276 std::shared_ptr
<sc::DataTransformation
> ScSortTransformationControl::getTransformation()
278 OUString aColStr
= mxEdColumns
->get_text();
279 bool aIsAscending
= mxType
->get_active();
281 sal_Int32 nCol
= aColStr
.toInt32();
282 if (nCol
> 0 && nCol
<= mpDoc
->MaxCol())
283 aColumn
= nCol
- 1; // translate from 1-based column notations to internal Calc one
285 ScSortParam aSortParam
;
287 aSortParam
.nRow2
=getLastRow(*mpDoc
);
289 aSortParam
.nCol2
=getLastCol(*mpDoc
);
290 aSortParam
.maKeyState
[0].bDoSort
= true;
291 aSortParam
.maKeyState
[0].nField
= aColumn
;
292 aSortParam
.maKeyState
[0].bAscending
= aIsAscending
;
293 return std::make_shared
<sc::SortTransformation
>(aSortParam
);
296 class ScColumnTextTransformation
: public ScDataTransformationBaseControl
299 std::unique_ptr
<weld::Entry
> mxColumnNums
;
300 std::unique_ptr
<weld::ComboBox
> mxType
;
301 std::unique_ptr
<weld::Button
> mxDelete
;
302 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
303 const ScDocument
* mpDoc
;
306 ScColumnTextTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
308 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
309 DECL_LINK(DeleteHdl
, weld::Button
&, void);
312 ScColumnTextTransformation::ScColumnTextTransformation(
313 const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
314 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/texttransformationentry.ui"_ustr
, nIndex
)
315 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
316 , mxType(mxBuilder
->weld_combo_box(u
"ed_lst"_ustr
))
317 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
318 , maDeleteTransformation(std::move(aDeleteTransformation
))
321 mxDelete
->connect_clicked(LINK(this,ScColumnTextTransformation
, DeleteHdl
));
324 std::shared_ptr
<sc::DataTransformation
> ScColumnTextTransformation::getTransformation()
326 OUString aColumnString
= mxColumnNums
->get_text();
327 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
328 std::set
<SCCOL
> aColumns
;
329 for (const auto& rColStr
: aSplitColumns
)
331 sal_Int32 nCol
= rColStr
.toInt32();
335 if (nCol
> mpDoc
->MaxCol())
338 // translate from 1-based column notations to internal Calc one
339 aColumns
.insert(nCol
- 1);
342 sal_Int32 nPos
= mxType
->get_active();
346 return std::make_shared
<sc::TextTransformation
>(std::move(aColumns
),sc::TEXT_TRANSFORM_TYPE::TO_LOWER
);
348 return std::make_shared
<sc::TextTransformation
>(std::move(aColumns
),sc::TEXT_TRANSFORM_TYPE::TO_UPPER
);
350 return std::make_shared
<sc::TextTransformation
>(std::move(aColumns
),sc::TEXT_TRANSFORM_TYPE::CAPITALIZE
);
352 return std::make_shared
<sc::TextTransformation
>(std::move(aColumns
),sc::TEXT_TRANSFORM_TYPE::TRIM
);
360 class ScAggregateFunction
: public ScDataTransformationBaseControl
363 std::unique_ptr
<weld::Entry
> mxColumnNums
;
364 std::unique_ptr
<weld::ComboBox
> mxType
;
365 std::unique_ptr
<weld::Button
> mxDelete
;
366 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
367 const ScDocument
* mpDoc
;
370 ScAggregateFunction(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
372 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
373 DECL_LINK(DeleteHdl
, weld::Button
&, void);
376 ScAggregateFunction::ScAggregateFunction(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
,
377 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
378 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/aggregatefunctionentry.ui"_ustr
, nIndex
)
379 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
380 , mxType(mxBuilder
->weld_combo_box(u
"ed_lst"_ustr
))
381 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
382 , maDeleteTransformation(std::move(aDeleteTransformation
))
385 mxDelete
->connect_clicked(LINK(this,ScAggregateFunction
, DeleteHdl
));
388 std::shared_ptr
<sc::DataTransformation
> ScAggregateFunction::getTransformation()
390 OUString aColumnString
= mxColumnNums
->get_text();
391 sal_Int32 nPos
= mxType
->get_active();
392 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
393 std::set
<SCCOL
> aColumns
;
394 for (const auto& rColStr
: aSplitColumns
)
396 sal_Int32 nCol
= rColStr
.toInt32();
400 if (nCol
> mpDoc
->MaxCol())
403 // translate from 1-based column notations to internal Calc one
404 aColumns
.insert(nCol
- 1);
409 return std::make_shared
<sc::AggregateFunction
>(std::move(aColumns
),sc::AGGREGATE_FUNCTION::SUM
);
411 return std::make_shared
<sc::AggregateFunction
>(std::move(aColumns
),sc::AGGREGATE_FUNCTION::AVERAGE
);
413 return std::make_shared
<sc::AggregateFunction
>(std::move(aColumns
),sc::AGGREGATE_FUNCTION::MIN
);
415 return std::make_shared
<sc::AggregateFunction
>(std::move(aColumns
),sc::AGGREGATE_FUNCTION::MAX
);
423 class ScNumberTransformation
: public ScDataTransformationBaseControl
426 std::unique_ptr
<weld::Entry
> mxColumnNums
;
427 std::unique_ptr
<weld::ComboBox
> mxType
;
428 std::unique_ptr
<weld::Button
> mxDelete
;
429 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
430 const ScDocument
* mpDoc
;
433 ScNumberTransformation(const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
435 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
436 DECL_LINK(DeleteHdl
, weld::Button
&, void);
439 ScNumberTransformation::ScNumberTransformation(
440 const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
441 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/numbertransformationentry.ui"_ustr
, nIndex
)
442 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
443 , mxType(mxBuilder
->weld_combo_box(u
"ed_lst"_ustr
))
444 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
445 , maDeleteTransformation(std::move(aDeleteTransformation
))
448 mxDelete
->connect_clicked(LINK(this,ScNumberTransformation
, DeleteHdl
));
451 std::shared_ptr
<sc::DataTransformation
> ScNumberTransformation::getTransformation()
453 OUString aColumnString
= mxColumnNums
->get_text();
454 sal_Int32 nPos
= mxType
->get_active();
455 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
456 std::set
<SCCOL
> aColumns
;
457 for (const auto& rColStr
: aSplitColumns
)
459 sal_Int32 nCol
= rColStr
.toInt32();
463 if (nCol
> mpDoc
->MaxCol())
466 // translate from 1-based column notations to internal Calc one
467 aColumns
.insert(nCol
- 1);
472 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::SIGN
);
474 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::ROUND
);
476 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::ROUND_UP
);
478 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::ROUND_DOWN
);
480 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::ABSOLUTE
);
482 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::LOG_E
);
484 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::LOG_10
);
486 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::CUBE
);
488 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::SQUARE
);
490 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::SQUARE_ROOT
);
492 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::EXPONENT
);
494 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::IS_EVEN
);
496 return std::make_shared
<sc::NumberTransformation
>(std::move(aColumns
),sc::NUMBER_TRANSFORM_TYPE::IS_ODD
);
504 class ScReplaceNullTransformation
: public ScDataTransformationBaseControl
507 std::unique_ptr
<weld::Entry
> mxColumnNums
;
508 std::unique_ptr
<weld::Entry
> mxReplaceString
;
509 std::unique_ptr
<weld::Button
> mxDelete
;
510 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
511 const ScDocument
*mpDoc
;
515 ScReplaceNullTransformation(const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
517 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
518 DECL_LINK(DeleteHdl
, weld::Button
&, void);
521 ScReplaceNullTransformation::ScReplaceNullTransformation(const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
522 : ScDataTransformationBaseControl(pParent
,u
"modules/scalc/ui/replacenulltransformationentry.ui"_ustr
, nIndex
)
523 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
524 , mxReplaceString(mxBuilder
->weld_entry(u
"ed_str"_ustr
))
525 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
526 , maDeleteTransformation(std::move(aDeleteTransformation
))
529 mxDelete
->connect_clicked(LINK(this,ScReplaceNullTransformation
, DeleteHdl
));
533 std::shared_ptr
<sc::DataTransformation
> ScReplaceNullTransformation::getTransformation()
535 OUString aColumnString
= mxColumnNums
->get_text();
536 OUString aReplaceWithString
= mxReplaceString
->get_text();
537 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
538 std::set
<SCCOL
> aColumns
;
539 for (const auto& rColStr
: aSplitColumns
)
541 sal_Int32 nCol
= rColStr
.toInt32();
545 if (nCol
> mpDoc
->MaxCol())
548 // translate from 1-based column notations to internal Calc one
549 aColumns
.insert(nCol
- 1);
552 return std::make_shared
<sc::ReplaceNullTransformation
>(std::move(aColumns
),aReplaceWithString
);
555 class ScDateTimeTransformation
: public ScDataTransformationBaseControl
558 std::unique_ptr
<weld::Entry
> mxColumnNums
;
559 std::unique_ptr
<weld::ComboBox
> mxType
;
560 std::unique_ptr
<weld::Button
> mxDelete
;
561 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
562 const ScDocument
* mpDoc
;
566 ScDateTimeTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
568 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
569 DECL_LINK(DeleteHdl
, weld::Button
&, void);
572 ScDateTimeTransformation::ScDateTimeTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
573 : ScDataTransformationBaseControl(pParent
,u
"modules/scalc/ui/datetimetransformationentry.ui"_ustr
, nIndex
)
574 , mxColumnNums(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
575 , mxType(mxBuilder
->weld_combo_box(u
"ed_lst"_ustr
))
576 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
577 , maDeleteTransformation(std::move(aDeleteTransformation
))
580 mxDelete
->connect_clicked(LINK(this,ScDateTimeTransformation
, DeleteHdl
));
583 std::shared_ptr
<sc::DataTransformation
> ScDateTimeTransformation::getTransformation()
585 OUString aColumnString
= mxColumnNums
->get_text();
586 sal_Int32 nPos
= mxType
->get_active();
587 std::vector
<OUString
> aSplitColumns
= comphelper::string::split(aColumnString
, ';');
588 std::set
<SCCOL
> aColumns
;
589 for (const auto& rColStr
: aSplitColumns
)
591 sal_Int32 nCol
= rColStr
.toInt32();
595 if (nCol
> mpDoc
->MaxCol())
598 // translate from 1-based column notations to internal Calc one
599 aColumns
.insert(nCol
- 1);
604 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::DATE_STRING
);
606 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::YEAR
);
608 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_YEAR
);
610 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_YEAR
);
612 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::MONTH
);
614 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::MONTH_NAME
);
616 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_MONTH
);
618 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_MONTH
);
620 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::DAY
);
622 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_WEEK
);
624 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_YEAR
);
626 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::QUARTER
);
628 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_QUARTER
);
630 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_QUARTER
);
632 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::HOUR
);
634 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::MINUTE
);
636 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::SECOND
);
638 return std::make_shared
<sc::DateTimeTransformation
>(std::move(aColumns
),sc::DATETIME_TRANSFORMATION_TYPE::TIME
);
646 class ScFindReplaceTransformation
: public ScDataTransformationBaseControl
649 std::unique_ptr
<weld::Entry
> mxFindString
;
650 std::unique_ptr
<weld::Entry
> mxReplaceString
;
651 std::unique_ptr
<weld::Entry
> mxEdColumns
;
652 std::unique_ptr
<weld::Button
> mxDelete
;
653 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
654 const ScDocument
* mpDoc
;
657 ScFindReplaceTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
659 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
660 DECL_LINK(DeleteHdl
, weld::Button
&, void);
663 ScFindReplaceTransformation::ScFindReplaceTransformation(
664 const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
,
665 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
666 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/findreplaceentry.ui"_ustr
, nIndex
)
667 , mxFindString(mxBuilder
->weld_entry(u
"ed_find"_ustr
))
668 , mxReplaceString(mxBuilder
->weld_entry(u
"ed_replace"_ustr
))
669 , mxEdColumns(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
670 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
671 , maDeleteTransformation(std::move(aDeleteTransformation
))
674 mxDelete
->connect_clicked(LINK(this, ScFindReplaceTransformation
, DeleteHdl
));
677 std::shared_ptr
<sc::DataTransformation
> ScFindReplaceTransformation::getTransformation()
679 OUString aColStr
= mxEdColumns
->get_text();
681 sal_Int32 nCol
= aColStr
.toInt32();
682 if (nCol
> 0 && nCol
<= mpDoc
->MaxCol())
684 return std::make_shared
<sc::FindReplaceTransformation
>(aColumn
, mxFindString
->get_text(), mxReplaceString
->get_text());
687 class ScDeleteRowTransformation
: public ScDataTransformationBaseControl
690 std::unique_ptr
<weld::Entry
> mxFindString
;
691 std::unique_ptr
<weld::Entry
> mxEdColumns
;
692 std::unique_ptr
<weld::Button
> mxDelete
;
693 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
694 const ScDocument
* mpDoc
;
697 ScDeleteRowTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
699 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
700 DECL_LINK(DeleteHdl
, weld::Button
&, void);
703 ScDeleteRowTransformation::ScDeleteRowTransformation(
704 const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
,
705 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
706 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/deleterowentry.ui"_ustr
, nIndex
)
707 , mxFindString(mxBuilder
->weld_entry(u
"ed_find"_ustr
))
708 , mxEdColumns(mxBuilder
->weld_entry(u
"ed_columns"_ustr
))
709 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
710 , maDeleteTransformation(std::move(aDeleteTransformation
))
713 mxDelete
->connect_clicked(LINK(this, ScDeleteRowTransformation
, DeleteHdl
));
716 std::shared_ptr
<sc::DataTransformation
> ScDeleteRowTransformation::getTransformation()
718 OUString aColStr
= mxEdColumns
->get_text();
720 sal_Int32 nCol
= aColStr
.toInt32();
721 if (nCol
> 0 && nCol
<= mpDoc
->MaxCol())
723 return std::make_shared
<sc::DeleteRowTransformation
>(aColumn
, mxFindString
->get_text());
726 class ScSwapRowsTransformation
: public ScDataTransformationBaseControl
729 std::unique_ptr
<weld::Entry
> mxRow
;
730 std::unique_ptr
<weld::Entry
> nxRow
;
731 std::unique_ptr
<weld::Button
> mxDelete
;
732 std::function
<void(sal_uInt32
&)> maDeleteTransformation
;
733 const ScDocument
* mpDoc
;
736 ScSwapRowsTransformation(const ScDocument
* pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
, std::function
<void(sal_uInt32
&)> aDeleteTransformation
);
738 virtual std::shared_ptr
<sc::DataTransformation
> getTransformation() override
;
739 DECL_LINK(DeleteHdl
, weld::Button
&, void);
742 ScSwapRowsTransformation::ScSwapRowsTransformation(
743 const ScDocument
*pDoc
, weld::Container
* pParent
, sal_uInt32 nIndex
,
744 std::function
<void(sal_uInt32
&)> aDeleteTransformation
)
745 : ScDataTransformationBaseControl(pParent
, u
"modules/scalc/ui/swaprowsentry.ui"_ustr
, nIndex
)
746 , mxRow(mxBuilder
->weld_entry(u
"ed_row1"_ustr
))
747 , nxRow(mxBuilder
->weld_entry(u
"ed_row2"_ustr
))
748 , mxDelete(mxBuilder
->weld_button(u
"ed_delete"_ustr
))
749 , maDeleteTransformation(std::move(aDeleteTransformation
))
752 mxDelete
->connect_clicked(LINK(this, ScSwapRowsTransformation
, DeleteHdl
));
755 std::shared_ptr
<sc::DataTransformation
> ScSwapRowsTransformation::getTransformation()
757 OUString aRowStr
= mxRow
->get_text();
758 OUString bRowStr
= nxRow
->get_text();
761 sal_Int32 mRow
= aRowStr
.toInt32();
762 sal_Int32 nRow
= bRowStr
.toInt32();
763 if (mRow
> 0 && mRow
<= mpDoc
->MaxRow())
765 if (nRow
> 0 && nRow
<= mpDoc
->MaxRow())
767 return std::make_shared
<sc::SwapRowsTransformation
>(aRow
, bRow
);
772 ScDataProviderDlg::ScDataProviderDlg(weld::Window
* pParent
, std::shared_ptr
<ScDocument
> pDoc
,
773 const ScDocument
* pDocument
)
774 : GenericDialogController(pParent
, u
"modules/scalc/ui/dataproviderdlg.ui"_ustr
, u
"dataproviderdlg"_ustr
)
775 , mxDoc(std::move(pDoc
))
776 , mxBox(m_xBuilder
->weld_container(u
"data_table"_ustr
))
777 , m_xTableParent(mxBox
->CreateChildFrame())
778 , mxTable(VclPtr
<ScDataTableView
>::Create(m_xTableParent
, mxDoc
))
779 , mxDBRanges(m_xBuilder
->weld_combo_box(u
"select_db_range"_ustr
))
780 , mxOKBtn(m_xBuilder
->weld_button(u
"ok"_ustr
))
781 , mxCancelBtn(m_xBuilder
->weld_button(u
"cancel"_ustr
))
782 , mxAddTransformationBtn(m_xBuilder
->weld_button(u
"add_transformation"_ustr
))
783 , mxScroll(m_xBuilder
->weld_scrolled_window(u
"scroll"_ustr
))
784 , mxTransformationList(m_xBuilder
->weld_container(u
"transformation_ctrl"_ustr
))
785 , mxTransformationBox(m_xBuilder
->weld_combo_box(u
"transformation_box"_ustr
))
786 , mxProviderList(m_xBuilder
->weld_combo_box(u
"provider_lst"_ustr
))
787 , mxEditURL(m_xBuilder
->weld_entry(u
"ed_url"_ustr
))
788 , mxEditID(m_xBuilder
->weld_entry(u
"ed_id"_ustr
))
789 , mxApplyBtn(m_xBuilder
->weld_button(u
"apply"_ustr
))
790 , mxBrowseBtn(m_xBuilder
->weld_button(u
"browse"_ustr
))
791 , maIdle("ScDataProviderDlg maIdle")
794 Size aPrefSize
= mxTable
->GetOptimalSize();
795 mxBox
->set_size_request(aPrefSize
.Width(), aPrefSize
.Height());
798 ScDBCollection
* pDBCollection
= pDocument
->GetDBCollection();
799 auto& rNamedDBs
= pDBCollection
->getNamedDBs();
800 for (auto& rNamedDB
: rNamedDBs
)
802 mxDBRanges
->append_text(rNamedDB
->GetName());
805 for (const auto& i
: aTransformationData
)
807 mxTransformationBox
->append_text(OUString::createFromAscii(i
.aTransformationName
));
810 pDBData
= new ScDBData(u
"data"_ustr
, 0, 0, 0, mxDoc
->MaxCol(), mxDoc
->MaxRow());
811 bool bSuccess
= mxDoc
->GetDBCollection()->getNamedDBs().insert(std::unique_ptr
<ScDBData
>(pDBData
));
812 SAL_WARN_IF(!bSuccess
, "sc", "temporary warning");
814 auto aDataProvider
= sc::DataProviderFactory::getDataProviders();
815 for (const auto& rDataProvider
: aDataProvider
)
817 mxProviderList
->append_text(rDataProvider
);
820 mxOKBtn
->connect_clicked(LINK(this, ScDataProviderDlg
, ApplyQuitHdl
));
821 mxCancelBtn
->connect_clicked(LINK(this, ScDataProviderDlg
, CancelQuitHdl
));
822 mxAddTransformationBtn
->connect_clicked(LINK(this, ScDataProviderDlg
, TransformationListHdl
));
823 mxApplyBtn
->connect_clicked(LINK(this, ScDataProviderDlg
, ApplyBtnHdl
));
824 mxBrowseBtn
->connect_clicked(LINK(this, ScDataProviderDlg
, BrowseBtnHdl
));
825 mxTransformationBox
->connect_changed(LINK(this, ScDataProviderDlg
, TransformationSelectHdl
));
826 mxProviderList
->connect_changed(LINK(this, ScDataProviderDlg
, ProviderSelectHdl
));
827 mxEditID
->connect_changed(LINK(this, ScDataProviderDlg
, IDEditHdl
));
828 mxEditURL
->connect_changed(LINK(this, ScDataProviderDlg
, URLEditHdl
));
830 msApplyTooltip
= mxApplyBtn
->get_tooltip_text();
831 msAddTransformationToolTip
= mxAddTransformationBtn
->get_tooltip_text();
832 mxAddTransformationBtn
->set_sensitive(false);
833 mxAddTransformationBtn
->set_tooltip_text(OUString());
836 maIdle
.SetPriority( TaskPriority::LOWEST
);
837 maIdle
.SetInvokeHandler( LINK( this, ScDataProviderDlg
, ScrollToEnd
) );
840 ScDataProviderDlg::~ScDataProviderDlg()
842 mxTable
.disposeAndClear();
843 m_xTableParent
->dispose();
844 m_xTableParent
.clear();
847 IMPL_LINK_NOARG(ScDataProviderDlg
, ScrollToEnd
, Timer
*, void)
849 mxScroll
->vadjustment_set_value(mxScroll
->vadjustment_get_upper());
852 IMPL_LINK_NOARG(ScDataProviderDlg
, ApplyQuitHdl
, weld::Button
&, void)
854 m_xDialog
->response(RET_OK
);
857 IMPL_LINK_NOARG(ScDataProviderDlg
, CancelQuitHdl
, weld::Button
&, void)
859 m_xDialog
->response(RET_CANCEL
);
862 IMPL_LINK_NOARG(ScDataProviderDlg
, TransformationListHdl
, weld::Button
&, void)
864 OUString transformation_string
= mxTransformationBox
->get_active_text();
865 for (auto& i
: aTransformationData
)
867 if (transformation_string
== OUString::createFromAscii(i
.aTransformationName
))
876 IMPL_LINK_NOARG(ScDataProviderDlg
, ProviderSelectHdl
, weld::ComboBox
&, void)
881 IMPL_LINK_NOARG(ScDataProviderDlg
, IDEditHdl
, weld::Entry
&, void)
886 IMPL_LINK_NOARG(ScDataProviderDlg
, URLEditHdl
, weld::Entry
&, void)
891 IMPL_LINK_NOARG(ScDataProviderDlg
, ApplyBtnHdl
, weld::Button
&, void)
893 updateApplyBtn(true);
894 import(*mxDoc
, true);
897 IMPL_LINK_NOARG(ScDataProviderDlg
, BrowseBtnHdl
, weld::Button
&, void)
899 sfx2::FileDialogHelper
aFileDialog(0, FileDialogFlags::NONE
, m_xDialog
.get());
900 aFileDialog
.SetContext(sfx2::FileDialogHelper::CalcDataProvider
);
901 if (aFileDialog
.Execute() != ERRCODE_NONE
)
904 mxEditURL
->set_text(aFileDialog
.GetPath());
908 IMPL_LINK_NOARG(ScDataProviderDlg
, TransformationSelectHdl
, weld::ComboBox
&, void)
910 mxAddTransformationBtn
->set_sensitive(true);
911 mxAddTransformationBtn
->set_tooltip_text(msAddTransformationToolTip
);
914 sc::ExternalDataSource
ScDataProviderDlg::getDataSource(ScDocument
* pDoc
)
916 sc::ExternalDataSource
aSource(mxEditURL
->get_text(), mxProviderList
->get_active_text(), pDoc
);
918 OUString aID
= mxEditID
->get_text();
923 void ScDataProviderDlg::isValid()
925 bool bValid
= !mxProviderList
->get_active_text().isEmpty();
926 bValid
&= !mxEditURL
->get_text().isEmpty();
927 updateApplyBtn(bValid
);
930 void ScDataProviderDlg::updateApplyBtn(bool bValidConfig
)
934 mxApplyBtn
->set_sensitive(false);
935 mxApplyBtn
->set_tooltip_text(OUString());
939 mxApplyBtn
->set_sensitive(true);
940 mxApplyBtn
->set_tooltip_text(msApplyTooltip
);
943 void ScDataProviderDlg::deleteColumn()
945 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
946 maControls
.emplace_back(std::make_unique
<ScDeleteColumnTransformationControl
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
949 void ScDataProviderDlg::splitColumn()
951 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
952 maControls
.emplace_back(std::make_unique
<ScSplitColumnTransformationControl
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
955 void ScDataProviderDlg::mergeColumns()
957 SCCOL nStartCol
= -1;
959 mxTable
->getColRange(nStartCol
, nEndCol
);
960 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
961 maControls
.emplace_back(std::make_unique
<ScMergeColumnTransformationControl
>(mxDoc
.get(), mxTransformationList
.get(), nStartCol
, nEndCol
, mnIndex
++, adeleteTransformation
));
964 void ScDataProviderDlg::textTransformation()
966 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
967 maControls
.emplace_back(std::make_unique
<ScColumnTextTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
970 void ScDataProviderDlg::sortTransformation()
972 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
973 maControls
.emplace_back(std::make_unique
<ScSortTransformationControl
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
976 void ScDataProviderDlg::aggregateFunction()
978 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
979 maControls
.emplace_back(std::make_unique
<ScAggregateFunction
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
982 void ScDataProviderDlg::numberTransformation()
984 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
985 maControls
.emplace_back(std::make_unique
<ScNumberTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
988 void ScDataProviderDlg::replaceNullTransformation()
990 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
991 maControls
.emplace_back(std::make_unique
<ScReplaceNullTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
994 void ScDataProviderDlg::dateTimeTransformation()
996 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
,this, std::placeholders::_1
);
997 maControls
.emplace_back(std::make_unique
<ScDateTimeTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
1000 void ScDataProviderDlg::findReplaceTransformation()
1002 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
, this, std::placeholders::_1
);
1003 maControls
.emplace_back(std::make_unique
<ScFindReplaceTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
1006 void ScDataProviderDlg::deleteRowTransformation()
1008 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
, this, std::placeholders::_1
);
1009 maControls
.emplace_back(std::make_unique
<ScDeleteRowTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
1012 void ScDataProviderDlg::swapRowsTransformation()
1014 std::function
<void(sal_uInt32
&)> adeleteTransformation
= std::bind(&ScDataProviderDlg::deletefromList
, this, std::placeholders::_1
);
1015 maControls
.emplace_back(std::make_unique
<ScSwapRowsTransformation
>(mxDoc
.get(), mxTransformationList
.get(), mnIndex
++, adeleteTransformation
));
1020 bool hasDBName(const OUString
& rName
, ScDBCollection
* pDBCollection
)
1022 if (pDBCollection
->getNamedDBs().findByUpperName(ScGlobal::getCharClass().uppercase(rName
)))
1030 void ScDataProviderDlg::import(ScDocument
& rDoc
, bool bInternal
)
1032 sc::ExternalDataSource aSource
= getDataSource(&rDoc
);
1034 for (size_t i
= 0; i
< maControls
.size(); ++i
)
1036 ScDataTransformationBaseControl
* pTransformationCtrl
= maControls
[i
].get();
1037 aSource
.AddDataTransformation(pTransformationCtrl
->getTransformation());
1040 aSource
.setDBData(pDBData
->GetName());
1043 aSource
.setDBData(mxDBRanges
->get_active_text());
1044 if (!hasDBName(aSource
.getDBName(), rDoc
.GetDBCollection()))
1046 rDoc
.GetExternalDataMapper().insertDataSource(aSource
);
1048 aSource
.refresh(&rDoc
, true);
1049 mxTable
->Invalidate();
1052 void ScDataProviderDlg::deletefromList(sal_uInt32 nIndex
)
1054 auto itr
= maControls
.erase(maControls
.begin() + nIndex
);
1055 while (itr
!= maControls
.end())
1057 (*itr
)->updateIndex(nIndex
++);
1063 IMPL_LINK_NOARG(ScDeleteColumnTransformationControl
, DeleteHdl
, weld::Button
&, void)
1065 maDeleteTransformation(mnIndex
);
1068 IMPL_LINK_NOARG(ScSplitColumnTransformationControl
, DeleteHdl
, weld::Button
&, void)
1070 maDeleteTransformation(mnIndex
);
1073 IMPL_LINK_NOARG(ScMergeColumnTransformationControl
, DeleteHdl
, weld::Button
&, void)
1075 maDeleteTransformation(mnIndex
);
1078 IMPL_LINK_NOARG(ScNumberTransformation
, DeleteHdl
, weld::Button
&, void)
1080 maDeleteTransformation(mnIndex
);
1083 IMPL_LINK_NOARG(ScAggregateFunction
, DeleteHdl
, weld::Button
&, void)
1085 maDeleteTransformation(mnIndex
);
1088 IMPL_LINK_NOARG(ScSortTransformationControl
, DeleteHdl
, weld::Button
&, void)
1090 maDeleteTransformation(mnIndex
);
1093 IMPL_LINK_NOARG(ScColumnTextTransformation
, DeleteHdl
, weld::Button
&, void)
1095 maDeleteTransformation(mnIndex
);
1098 IMPL_LINK_NOARG(ScReplaceNullTransformation
, DeleteHdl
, weld::Button
&, void)
1100 maDeleteTransformation(mnIndex
);
1103 IMPL_LINK_NOARG(ScDateTimeTransformation
, DeleteHdl
, weld::Button
&, void)
1105 maDeleteTransformation(mnIndex
);
1108 IMPL_LINK_NOARG(ScFindReplaceTransformation
, DeleteHdl
, weld::Button
&, void)
1110 maDeleteTransformation(mnIndex
);
1113 IMPL_LINK_NOARG(ScDeleteRowTransformation
, DeleteHdl
, weld::Button
&, void)
1115 maDeleteTransformation(mnIndex
);
1118 IMPL_LINK_NOARG(ScSwapRowsTransformation
, DeleteHdl
, weld::Button
&, void)
1120 maDeleteTransformation(mnIndex
);
1122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */