LibreOffice Module sc (master) 1
dataproviderdlg.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
10#include <dataproviderdlg.hxx>
11
12#include <document.hxx>
13#include <dataprovider.hxx>
15#include <datamapper.hxx>
16#include <dbdata.hxx>
17
18#include <comphelper/string.hxx>
19#include <sal/log.hxx>
22#include <utility>
23#include <vcl/svapp.hxx>
24
26{
27protected:
28 std::unique_ptr<weld::Builder> mxBuilder;
29 std::unique_ptr<weld::Container> mxGrid;
31
32 sal_uInt32 mnIndex;
33
34public:
35 ScDataTransformationBaseControl(weld::Container* pParent, const OUString& rUIFile, sal_uInt32 nIndex);
37
38 void updateIndex(sal_uInt32 nIndex) { mnIndex = nIndex; }
39
40 virtual std::shared_ptr<sc::DataTransformation> getTransformation() = 0;
41
42 static SCROW getLastRow(const ScDocument& rDoc);
43 static SCCOL getLastCol(const ScDocument& rDoc);
44};
45
47{
48 SCROW nEndRow = rDoc.MaxRow();
49 return rDoc.GetLastDataRow(0, 0, 0, nEndRow);
50}
51
53{
54 for (SCCOL nCol = 1; nCol <= rDoc.MaxCol(); ++nCol)
55 {
56 if (rDoc.GetCellType(nCol, 0, 0) == CELLTYPE_NONE)
57 {
58 return static_cast<SCCOL>(nCol - 1 );
59 }
60 }
61 return rDoc.MaxCol();
62}
63
64ScDataTransformationBaseControl::ScDataTransformationBaseControl(weld::Container* pParent, const OUString& rUIFile, sal_uInt32 nIndex)
65 : mxBuilder(Application::CreateBuilder(pParent, rUIFile))
66 , mxGrid(mxBuilder->weld_container("grid"))
67 , mpContainer(pParent)
69{
70}
71
73{
74 mpContainer->move(mxGrid.get(), nullptr);
75}
76
77namespace {
78
79struct MenuData
80{
81 const char* aTransformationName;
82 std::function<void(ScDataProviderDlg*)> maCallback;
83};
84
85MenuData aTransformationData[] = {
86 { "Delete Column", &ScDataProviderDlg::deleteColumn },
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}
98};
99
100class ScDeleteColumnTransformationControl : public ScDataTransformationBaseControl
101{
102private:
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;
107
108public:
109 ScDeleteColumnTransformationControl(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 aIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
110
111 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
112 DECL_LINK(DeleteHdl, weld::Button&, void);
113};
114
115ScDeleteColumnTransformationControl::ScDeleteColumnTransformationControl(
116 const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
117 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/deletecolumnentry.ui", nIndex)
118 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
119 , mxDelete(mxBuilder->weld_button("ed_delete"))
120 , maDeleteTransformation(std::move(aDeleteTransformation))
121 , mpDoc(pDoc)
122{
123 mxDelete->connect_clicked(LINK(this,ScDeleteColumnTransformationControl, DeleteHdl));
124}
125
126std::shared_ptr<sc::DataTransformation> ScDeleteColumnTransformationControl::getTransformation()
127{
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)
132 {
133 sal_Int32 nCol = rColStr.toInt32();
134 if (nCol <= 0)
135 continue;
136
137 if (nCol > mpDoc->MaxCol())
138 continue;
139
140 // translate from 1-based column notations to internal Calc one
141 ColNums.insert(nCol - 1);
142 }
143
144 return std::make_shared<sc::ColumnRemoveTransformation>(std::move(ColNums));
145}
146
147class ScSplitColumnTransformationControl : public ScDataTransformationBaseControl
148{
149private:
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;
155
156public:
157 ScSplitColumnTransformationControl(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
158
159 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
160 DECL_LINK(DeleteHdl, weld::Button&, void);
161};
162
163ScSplitColumnTransformationControl::ScSplitColumnTransformationControl(
164 const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex,
165 std::function<void(sal_uInt32&)> aDeleteTransformation)
166 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/splitcolumnentry.ui", nIndex)
167 , mxSeparator(mxBuilder->weld_entry("ed_separator"))
168 , mxNumColumns(mxBuilder->weld_entry("num_cols"))
169 , mxDelete(mxBuilder->weld_button("ed_delete"))
170 , maDeleteTransformation(std::move(aDeleteTransformation))
171 , mpDoc(pDoc)
172{
173 mxDelete->connect_clicked(LINK(this,ScSplitColumnTransformationControl, DeleteHdl));
174}
175
176std::shared_ptr<sc::DataTransformation> ScSplitColumnTransformationControl::getTransformation()
177{
178 OUString aSeparator = mxSeparator->get_text();
179 sal_Unicode cSeparator = aSeparator.isEmpty() ? ',' : aSeparator[0];
180 OUString aColStr = mxNumColumns->get_text();
181 SCCOL mnCol = -1;
182 sal_Int32 nCol = aColStr.toInt32();
183 if (nCol > 0 && nCol <= mpDoc->MaxCol())
184 mnCol = nCol - 1;
185 return std::make_shared<sc::SplitColumnTransformation>(mnCol, cSeparator);
186}
187
188class ScMergeColumnTransformationControl : public ScDataTransformationBaseControl
189{
190private:
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;
196
197public:
198 ScMergeColumnTransformationControl(const ScDocument *pDoc, weld::Container* pParent, SCCOL nStartCol, SCCOL nEndCol, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
199
200 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
201 DECL_LINK(DeleteHdl, weld::Button&, void);
202};
203
204ScMergeColumnTransformationControl::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, "modules/scalc/ui/mergecolumnentry.ui", nIndex)
208 , mxSeparator(mxBuilder->weld_entry("ed_separator"))
209 , mxEdColumns(mxBuilder->weld_entry("ed_columns"))
210 , mxDelete(mxBuilder->weld_button("ed_delete"))
211 , maDeleteTransformation(std::move(aDeleteTransformation))
212 , mpDoc(pDoc)
213{
214 mxDelete->connect_clicked(LINK(this,ScMergeColumnTransformationControl, DeleteHdl));
215
216 OUStringBuffer aBuffer;
217
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)
221 {
222 aBuffer.append(";" + OUString::number(nCol + 1));
223 }
224
225 mxEdColumns->set_text(aBuffer.makeStringAndClear());
226}
227
228std::shared_ptr<sc::DataTransformation> ScMergeColumnTransformationControl::getTransformation()
229{
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)
234 {
235 sal_Int32 nCol = rColStr.toInt32();
236 if (nCol <= 0)
237 continue;
238
239 if (nCol > mpDoc->MaxCol())
240 continue;
241
242 // translate from 1-based column notations to internal Calc one
243 aMergedColumns.insert(nCol - 1);
244 }
245 return std::make_shared<sc::MergeColumnTransformation>(std::move(aMergedColumns), mxSeparator->get_text());
246}
247
248class ScSortTransformationControl : public ScDataTransformationBaseControl
249{
250private:
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;
256
257public:
258 ScSortTransformationControl(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
259
260 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
261 DECL_LINK(DeleteHdl, weld::Button&, void);
262};
263
264ScSortTransformationControl::ScSortTransformationControl(
265 const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
266 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/sorttransformationentry.ui", nIndex)
267 , mxType(mxBuilder->weld_combo_box("ed_ascending"))
268 , mxEdColumns(mxBuilder->weld_entry("ed_columns"))
269 , mxDelete(mxBuilder->weld_button("ed_delete"))
270 , maDeleteTransformation(std::move(aDeleteTransformation))
271 , mpDoc(pDoc)
272{
273 mxDelete->connect_clicked(LINK(this,ScSortTransformationControl, DeleteHdl));
274}
275
276std::shared_ptr<sc::DataTransformation> ScSortTransformationControl::getTransformation()
277{
278 OUString aColStr = mxEdColumns->get_text();
279 bool aIsAscending = mxType->get_active();
280 SCCOL aColumn = 0;
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
284
285 ScSortParam aSortParam;
286 aSortParam.nRow1=0;
287 aSortParam.nRow2=getLastRow(*mpDoc);
288 aSortParam.nCol1=0;
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);
294}
295
296class ScColumnTextTransformation : public ScDataTransformationBaseControl
297{
298private:
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;
304
305public:
306 ScColumnTextTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
307
308 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
309 DECL_LINK(DeleteHdl, weld::Button&, void);
310};
311
312ScColumnTextTransformation::ScColumnTextTransformation(
313 const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
314 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/texttransformationentry.ui", nIndex)
315 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
316 , mxType(mxBuilder->weld_combo_box("ed_lst"))
317 , mxDelete(mxBuilder->weld_button("ed_delete"))
318 , maDeleteTransformation(std::move(aDeleteTransformation))
319 , mpDoc(pDoc)
320{
321 mxDelete->connect_clicked(LINK(this,ScColumnTextTransformation, DeleteHdl));
322}
323
324std::shared_ptr<sc::DataTransformation> ScColumnTextTransformation::getTransformation()
325{
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)
330 {
331 sal_Int32 nCol = rColStr.toInt32();
332 if (nCol <= 0)
333 continue;
334
335 if (nCol > mpDoc->MaxCol())
336 continue;
337
338 // translate from 1-based column notations to internal Calc one
339 aColumns.insert(nCol - 1);
340 }
341
342 sal_Int32 nPos = mxType->get_active();
343 switch (nPos)
344 {
345 case 0:
346 return std::make_shared<sc::TextTransformation>(std::move(aColumns),sc::TEXT_TRANSFORM_TYPE::TO_LOWER);
347 case 1:
348 return std::make_shared<sc::TextTransformation>(std::move(aColumns),sc::TEXT_TRANSFORM_TYPE::TO_UPPER);
349 case 2:
350 return std::make_shared<sc::TextTransformation>(std::move(aColumns),sc::TEXT_TRANSFORM_TYPE::CAPITALIZE);
351 case 3:
352 return std::make_shared<sc::TextTransformation>(std::move(aColumns),sc::TEXT_TRANSFORM_TYPE::TRIM);
353 default:
354 assert(false);
355 }
356
357 return nullptr;
358}
359
360class ScAggregateFunction : public ScDataTransformationBaseControl
361{
362private:
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;
368
369public:
370 ScAggregateFunction(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
371
372 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
373 DECL_LINK(DeleteHdl, weld::Button&, void);
374};
375
376ScAggregateFunction::ScAggregateFunction(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex,
377 std::function<void(sal_uInt32&)> aDeleteTransformation)
378 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/aggregatefunctionentry.ui", nIndex)
379 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
380 , mxType(mxBuilder->weld_combo_box("ed_lst"))
381 , mxDelete(mxBuilder->weld_button("ed_delete"))
382 , maDeleteTransformation(std::move(aDeleteTransformation))
383 , mpDoc(pDoc)
384{
385 mxDelete->connect_clicked(LINK(this,ScAggregateFunction, DeleteHdl));
386}
387
388std::shared_ptr<sc::DataTransformation> ScAggregateFunction::getTransformation()
389{
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)
395 {
396 sal_Int32 nCol = rColStr.toInt32();
397 if (nCol <= 0)
398 continue;
399
400 if (nCol > mpDoc->MaxCol())
401 continue;
402
403 // translate from 1-based column notations to internal Calc one
404 aColumns.insert(nCol - 1);
405 }
406 switch (nPos)
407 {
408 case 0:
409 return std::make_shared<sc::AggregateFunction>(std::move(aColumns),sc::AGGREGATE_FUNCTION::SUM);
410 case 1:
411 return std::make_shared<sc::AggregateFunction>(std::move(aColumns),sc::AGGREGATE_FUNCTION::AVERAGE);
412 case 2:
413 return std::make_shared<sc::AggregateFunction>(std::move(aColumns),sc::AGGREGATE_FUNCTION::MIN);
414 case 3:
415 return std::make_shared<sc::AggregateFunction>(std::move(aColumns),sc::AGGREGATE_FUNCTION::MAX);
416 default:
417 assert(false);
418 }
419
420 return nullptr;
421}
422
423class ScNumberTransformation : public ScDataTransformationBaseControl
424{
425private:
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;
431
432public:
433 ScNumberTransformation(const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
434
435 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
436 DECL_LINK(DeleteHdl, weld::Button&, void);
437};
438
439ScNumberTransformation::ScNumberTransformation(
440 const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
441 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/numbertransformationentry.ui", nIndex)
442 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
443 , mxType(mxBuilder->weld_combo_box("ed_lst"))
444 , mxDelete(mxBuilder->weld_button("ed_delete"))
445 , maDeleteTransformation(std::move(aDeleteTransformation))
446 , mpDoc(pDoc)
447{
448 mxDelete->connect_clicked(LINK(this,ScNumberTransformation, DeleteHdl));
449}
450
451std::shared_ptr<sc::DataTransformation> ScNumberTransformation::getTransformation()
452{
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)
458 {
459 sal_Int32 nCol = rColStr.toInt32();
460 if (nCol <= 0)
461 continue;
462
463 if (nCol > mpDoc->MaxCol())
464 continue;
465
466 // translate from 1-based column notations to internal Calc one
467 aColumns.insert(nCol - 1);
468 }
469 switch (nPos)
470 {
471 case 0:
472 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::SIGN);
473 case 1:
474 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::ROUND);
475 case 2:
476 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::ROUND_UP);
477 case 3:
478 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::ROUND_DOWN);
479 case 4:
480 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::ABSOLUTE);
481 case 5:
482 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::LOG_E);
483 case 6:
484 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::LOG_10);
485 case 7:
486 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::CUBE);
487 case 8:
488 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::SQUARE);
489 case 9:
490 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::SQUARE_ROOT);
491 case 10:
492 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::EXPONENT);
493 case 11:
494 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::IS_EVEN);
495 case 12:
496 return std::make_shared<sc::NumberTransformation>(std::move(aColumns),sc::NUMBER_TRANSFORM_TYPE::IS_ODD);
497 default:
498 assert(false);
499 }
500
501 return nullptr;
502}
503
504class ScReplaceNullTransformation : public ScDataTransformationBaseControl
505{
506private:
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;
512
513public:
514
515 ScReplaceNullTransformation(const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
516
517 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
518 DECL_LINK(DeleteHdl, weld::Button&, void);
519};
520
521ScReplaceNullTransformation::ScReplaceNullTransformation(const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
522 : ScDataTransformationBaseControl(pParent,"modules/scalc/ui/replacenulltransformationentry.ui", nIndex)
523 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
524 , mxReplaceString(mxBuilder->weld_entry("ed_str"))
525 , mxDelete(mxBuilder->weld_button("ed_delete"))
526 , maDeleteTransformation(std::move(aDeleteTransformation))
527 , mpDoc(pDoc)
528{
529 mxDelete->connect_clicked(LINK(this,ScReplaceNullTransformation, DeleteHdl));
530}
531
532
533std::shared_ptr<sc::DataTransformation> ScReplaceNullTransformation::getTransformation()
534{
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)
540 {
541 sal_Int32 nCol = rColStr.toInt32();
542 if (nCol <= 0)
543 continue;
544
545 if (nCol > mpDoc->MaxCol())
546 continue;
547
548 // translate from 1-based column notations to internal Calc one
549 aColumns.insert(nCol - 1);
550 }
551
552 return std::make_shared<sc::ReplaceNullTransformation>(std::move(aColumns),aReplaceWithString);
553}
554
555class ScDateTimeTransformation : public ScDataTransformationBaseControl
556{
557private:
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;
563
564public:
565
566 ScDateTimeTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
567
568 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
569 DECL_LINK(DeleteHdl, weld::Button&, void);
570};
571
572ScDateTimeTransformation::ScDateTimeTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation)
573 : ScDataTransformationBaseControl(pParent,"modules/scalc/ui/datetimetransformationentry.ui", nIndex)
574 , mxColumnNums(mxBuilder->weld_entry("ed_columns"))
575 , mxType(mxBuilder->weld_combo_box("ed_lst"))
576 , mxDelete(mxBuilder->weld_button("ed_delete"))
577 , maDeleteTransformation(std::move(aDeleteTransformation))
578 , mpDoc(pDoc)
579{
580 mxDelete->connect_clicked(LINK(this,ScDateTimeTransformation, DeleteHdl));
581}
582
583std::shared_ptr<sc::DataTransformation> ScDateTimeTransformation::getTransformation()
584{
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)
590 {
591 sal_Int32 nCol = rColStr.toInt32();
592 if (nCol <= 0)
593 continue;
594
595 if (nCol > mpDoc->MaxCol())
596 continue;
597
598 // translate from 1-based column notations to internal Calc one
599 aColumns.insert(nCol - 1);
600 }
601 switch (nPos)
602 {
603 case 0:
604 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::DATE_STRING);
605 case 1:
606 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::YEAR);
607 case 2:
608 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_YEAR);
609 case 3:
610 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_YEAR);
611 case 4:
612 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::MONTH);
613 case 5:
614 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::MONTH_NAME);
615 case 6:
616 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_MONTH);
617 case 7:
618 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_MONTH);
619 case 8:
620 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::DAY);
621 case 9:
622 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_WEEK);
623 case 10:
624 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_YEAR);
625 case 11:
626 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::QUARTER);
627 case 12:
628 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::START_OF_QUARTER);
629 case 13:
630 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::END_OF_QUARTER);
631 case 14:
632 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::HOUR);
633 case 15:
634 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::MINUTE);
635 case 16:
636 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::SECOND);
637 case 17:
638 return std::make_shared<sc::DateTimeTransformation>(std::move(aColumns),sc::DATETIME_TRANSFORMATION_TYPE::TIME);
639 default:
640 assert(false);
641 }
642
643 return nullptr;
644}
645
646class ScFindReplaceTransformation : public ScDataTransformationBaseControl
647{
648private:
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;
655
656public:
657 ScFindReplaceTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
658
659 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
660 DECL_LINK(DeleteHdl, weld::Button&, void);
661};
662
663ScFindReplaceTransformation::ScFindReplaceTransformation(
664 const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex,
665 std::function<void(sal_uInt32&)> aDeleteTransformation)
666 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/findreplaceentry.ui", nIndex)
667 , mxFindString(mxBuilder->weld_entry("ed_find"))
668 , mxReplaceString(mxBuilder->weld_entry("ed_replace"))
669 , mxEdColumns(mxBuilder->weld_entry("ed_columns"))
670 , mxDelete(mxBuilder->weld_button("ed_delete"))
671 , maDeleteTransformation(std::move(aDeleteTransformation))
672 , mpDoc(pDoc)
673{
674 mxDelete->connect_clicked(LINK(this, ScFindReplaceTransformation, DeleteHdl));
675}
676
677std::shared_ptr<sc::DataTransformation> ScFindReplaceTransformation::getTransformation()
678{
679 OUString aColStr = mxEdColumns->get_text();
680 SCCOL aColumn = -1;
681 sal_Int32 nCol = aColStr.toInt32();
682 if (nCol > 0 && nCol <= mpDoc->MaxCol())
683 aColumn = nCol - 1;
684 return std::make_shared<sc::FindReplaceTransformation>(aColumn, mxFindString->get_text(), mxReplaceString->get_text());
685}
686
687class ScDeleteRowTransformation : public ScDataTransformationBaseControl
688{
689private:
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;
695
696public:
697 ScDeleteRowTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
698
699 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
700 DECL_LINK(DeleteHdl, weld::Button&, void);
701};
702
703ScDeleteRowTransformation::ScDeleteRowTransformation(
704 const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex,
705 std::function<void(sal_uInt32&)> aDeleteTransformation)
706 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/deleterowentry.ui", nIndex)
707 , mxFindString(mxBuilder->weld_entry("ed_find"))
708 , mxEdColumns(mxBuilder->weld_entry("ed_columns"))
709 , mxDelete(mxBuilder->weld_button("ed_delete"))
710 , maDeleteTransformation(std::move(aDeleteTransformation))
711 , mpDoc(pDoc)
712{
713 mxDelete->connect_clicked(LINK(this, ScDeleteRowTransformation, DeleteHdl));
714}
715
716std::shared_ptr<sc::DataTransformation> ScDeleteRowTransformation::getTransformation()
717{
718 OUString aColStr = mxEdColumns->get_text();
719 SCCOL aColumn = -1;
720 sal_Int32 nCol = aColStr.toInt32();
721 if (nCol > 0 && nCol <= mpDoc->MaxCol())
722 aColumn = nCol - 1;
723 return std::make_shared<sc::DeleteRowTransformation>(aColumn, mxFindString->get_text());
724}
725
726class ScSwapRowsTransformation : public ScDataTransformationBaseControl
727{
728private:
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;
734
735public:
736 ScSwapRowsTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
737
738 virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
739 DECL_LINK(DeleteHdl, weld::Button&, void);
740};
741
742ScSwapRowsTransformation::ScSwapRowsTransformation(
743 const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex,
744 std::function<void(sal_uInt32&)> aDeleteTransformation)
745 : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/swaprowsentry.ui", nIndex)
746 , mxRow(mxBuilder->weld_entry("ed_row1"))
747 , nxRow(mxBuilder->weld_entry("ed_row2"))
748 , mxDelete(mxBuilder->weld_button("ed_delete"))
749 , maDeleteTransformation(std::move(aDeleteTransformation))
750 , mpDoc(pDoc)
751{
752 mxDelete->connect_clicked(LINK(this, ScSwapRowsTransformation, DeleteHdl));
753}
754
755std::shared_ptr<sc::DataTransformation> ScSwapRowsTransformation::getTransformation()
756{
757 OUString aRowStr = mxRow->get_text();
758 OUString bRowStr = nxRow->get_text();
759 SCROW aRow = -1;
760 SCROW bRow = -1;
761 sal_Int32 mRow = aRowStr.toInt32();
762 sal_Int32 nRow = bRowStr.toInt32();
763 if (mRow > 0 && mRow <= mpDoc->MaxRow())
764 aRow = mRow - 1;
765 if (nRow > 0 && nRow <= mpDoc->MaxRow())
766 bRow = nRow - 1;
767 return std::make_shared<sc::SwapRowsTransformation>(aRow, bRow);
768}
769
770}
771
772ScDataProviderDlg::ScDataProviderDlg(weld::Window* pParent, std::shared_ptr<ScDocument> pDoc,
773 const ScDocument* pDocument)
774 : GenericDialogController(pParent, "modules/scalc/ui/dataproviderdlg.ui", "dataproviderdlg")
775 , mxDoc(std::move(pDoc))
776 , mxBox(m_xBuilder->weld_container("data_table"))
777 , m_xTableParent(mxBox->CreateChildFrame())
778 , mxTable(VclPtr<ScDataTableView>::Create(m_xTableParent, mxDoc))
779 , mxDBRanges(m_xBuilder->weld_combo_box("select_db_range"))
780 , mxOKBtn(m_xBuilder->weld_button("okay"))
781 , mxCancelBtn(m_xBuilder->weld_button("cancel"))
782 , mxAddTransformationBtn(m_xBuilder->weld_button("add_transformation"))
783 , mxScroll(m_xBuilder->weld_scrolled_window("scroll"))
784 , mxTransformationList(m_xBuilder->weld_container("transformation_ctrl"))
785 , mxTransformationBox(m_xBuilder->weld_combo_box("transformation_box"))
786 , mxProviderList(m_xBuilder->weld_combo_box("provider_lst"))
787 , mxEditURL(m_xBuilder->weld_entry("ed_url"))
788 , mxEditID(m_xBuilder->weld_entry("ed_id"))
789 , mxApplyBtn(m_xBuilder->weld_button("apply"))
790 , mxBrowseBtn(m_xBuilder->weld_button("browse"))
791 , maIdle("ScDataProviderDlg maIdle")
792 , mnIndex(0)
793{
794 Size aPrefSize = mxTable->GetOptimalSize();
795 mxBox->set_size_request(aPrefSize.Width(), aPrefSize.Height());
796 mxTable->Show();
797
798 ScDBCollection* pDBCollection = pDocument->GetDBCollection();
799 auto& rNamedDBs = pDBCollection->getNamedDBs();
800 for (auto& rNamedDB : rNamedDBs)
801 {
802 mxDBRanges->append_text(rNamedDB->GetName());
803 }
804
805 for (const auto& i : aTransformationData)
806 {
807 mxTransformationBox->append_text(OUString::createFromAscii(i.aTransformationName));
808 }
809
810 pDBData = new ScDBData("data", 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");
813
814 auto aDataProvider = sc::DataProviderFactory::getDataProviders();
815 for (const auto& rDataProvider : aDataProvider)
816 {
817 mxProviderList->append_text(rDataProvider);
818 }
819
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));
829
830 msApplyTooltip = mxApplyBtn->get_tooltip_text();
832 mxAddTransformationBtn->set_sensitive(false);
833 mxAddTransformationBtn->set_tooltip_text(OUString());
834 isValid();
835
836 maIdle.SetPriority( TaskPriority::LOWEST );
837 maIdle.SetInvokeHandler( LINK( this, ScDataProviderDlg, ScrollToEnd) );
838}
839
841{
843 m_xTableParent->dispose();
844 m_xTableParent.clear();
845}
846
848{
849 mxScroll->vadjustment_set_value(mxScroll->vadjustment_get_upper());
850}
851
853{
854 m_xDialog->response(RET_OK);
855}
856
858{
859 m_xDialog->response(RET_CANCEL);
860}
861
862IMPL_LINK_NOARG(ScDataProviderDlg, TransformationListHdl, weld::Button&, void)
863{
864 OUString transformation_string = mxTransformationBox->get_active_text();
865 for (auto& i: aTransformationData)
866 {
867 if (transformation_string == OUString::createFromAscii(i.aTransformationName))
868 {
869 i.maCallback(this);
870 maIdle.Start();
871 return;
872 }
873 }
874}
875
877{
878 isValid();
879}
880
882{
883 isValid();
884}
885
887{
888 isValid();
889}
890
892{
893 updateApplyBtn(true);
894 import(*mxDoc, true);
895}
896
898{
899 sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, m_xDialog.get());
901 if (aFileDialog.Execute() != ERRCODE_NONE)
902 return;
903
904 mxEditURL->set_text(aFileDialog.GetPath());
905 isValid();
906}
907
908IMPL_LINK_NOARG(ScDataProviderDlg, TransformationSelectHdl, weld::ComboBox&, void)
909{
910 mxAddTransformationBtn->set_sensitive(true);
911 mxAddTransformationBtn->set_tooltip_text(msAddTransformationToolTip);
912}
913
915{
916 OUString aURL = mxEditURL->get_text();
917 OUString aProvider = mxProviderList->get_active_text();
918 sc::ExternalDataSource aSource(aURL, aProvider, pDoc);
919
920 OUString aID = mxEditID->get_text();
921 aSource.setID(aID);
922 return aSource;
923}
924
926{
927 bool bValid = !mxProviderList->get_active_text().isEmpty();
928 bValid &= !mxEditURL->get_text().isEmpty();
929 updateApplyBtn(bValid);
930}
931
933{
934 if (!bValidConfig)
935 {
936 mxApplyBtn->set_sensitive(false);
937 mxApplyBtn->set_tooltip_text(OUString());
938 return;
939 }
940
941 mxApplyBtn->set_sensitive(true);
942 mxApplyBtn->set_tooltip_text(msApplyTooltip);
943}
944
946{
947 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
948 maControls.emplace_back(std::make_unique<ScDeleteColumnTransformationControl>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
949}
950
952{
953 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
954 maControls.emplace_back(std::make_unique<ScSplitColumnTransformationControl>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
955}
956
958{
959 SCCOL nStartCol = -1;
960 SCCOL nEndCol = -1;
961 mxTable->getColRange(nStartCol, nEndCol);
962 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
963 maControls.emplace_back(std::make_unique<ScMergeColumnTransformationControl>(mxDoc.get(), mxTransformationList.get(), nStartCol, nEndCol, mnIndex++, adeleteTransformation));
964}
965
967{
968 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
969 maControls.emplace_back(std::make_unique<ScColumnTextTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
970}
971
973{
974 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
975 maControls.emplace_back(std::make_unique<ScSortTransformationControl>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
976}
977
979{
980 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
981 maControls.emplace_back(std::make_unique<ScAggregateFunction>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
982}
983
985{
986 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
987 maControls.emplace_back(std::make_unique<ScNumberTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
988}
989
991{
992 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
993 maControls.emplace_back(std::make_unique<ScReplaceNullTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
994}
995
997{
998 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
999 maControls.emplace_back(std::make_unique<ScDateTimeTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
1000}
1001
1003{
1004 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList, this, std::placeholders::_1);
1005 maControls.emplace_back(std::make_unique<ScFindReplaceTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
1006}
1007
1009{
1010 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList, this, std::placeholders::_1);
1011 maControls.emplace_back(std::make_unique<ScDeleteRowTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
1012}
1013
1015{
1016 std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList, this, std::placeholders::_1);
1017 maControls.emplace_back(std::make_unique<ScSwapRowsTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
1018}
1019
1020namespace {
1021
1022bool hasDBName(const OUString& rName, ScDBCollection* pDBCollection)
1023{
1024 if (pDBCollection->getNamedDBs().findByUpperName(ScGlobal::getCharClass().uppercase(rName)))
1025 return true;
1026
1027 return false;
1028}
1029
1030}
1031
1032void ScDataProviderDlg::import(ScDocument& rDoc, bool bInternal)
1033{
1034 sc::ExternalDataSource aSource = getDataSource(&rDoc);
1035
1036 for (size_t i = 0; i < maControls.size(); ++i)
1037 {
1038 ScDataTransformationBaseControl* pTransformationCtrl = maControls[i].get();
1039 aSource.AddDataTransformation(pTransformationCtrl->getTransformation());
1040 }
1041 if (bInternal)
1042 aSource.setDBData(pDBData->GetName());
1043 else
1044 {
1045 aSource.setDBData(mxDBRanges->get_active_text());
1046 if (!hasDBName(aSource.getDBName(), rDoc.GetDBCollection()))
1047 return;
1049 }
1050 aSource.refresh(&rDoc, true);
1051 mxTable->Invalidate();
1052}
1053
1055{
1056 auto itr = maControls.erase(maControls.begin() + nIndex);
1057 while (itr != maControls.end())
1058 {
1059 (*itr)->updateIndex(nIndex++);
1060 ++itr;
1061 }
1062 --mnIndex;
1063}
1064
1065IMPL_LINK_NOARG(ScDeleteColumnTransformationControl, DeleteHdl, weld::Button&, void)
1066{
1067 maDeleteTransformation(mnIndex);
1068}
1069
1070IMPL_LINK_NOARG(ScSplitColumnTransformationControl, DeleteHdl, weld::Button&, void)
1071{
1072 maDeleteTransformation(mnIndex);
1073}
1074
1075IMPL_LINK_NOARG(ScMergeColumnTransformationControl, DeleteHdl, weld::Button&, void)
1076{
1077 maDeleteTransformation(mnIndex);
1078}
1079
1080IMPL_LINK_NOARG(ScNumberTransformation, DeleteHdl, weld::Button&, void)
1081{
1082 maDeleteTransformation(mnIndex);
1083}
1084
1085IMPL_LINK_NOARG(ScAggregateFunction, DeleteHdl, weld::Button&, void)
1086{
1087 maDeleteTransformation(mnIndex);
1088}
1089
1090IMPL_LINK_NOARG(ScSortTransformationControl, DeleteHdl, weld::Button&, void)
1091{
1092 maDeleteTransformation(mnIndex);
1093}
1094
1095IMPL_LINK_NOARG(ScColumnTextTransformation, DeleteHdl, weld::Button&, void)
1096{
1097 maDeleteTransformation(mnIndex);
1098}
1099
1100IMPL_LINK_NOARG(ScReplaceNullTransformation, DeleteHdl, weld::Button&, void)
1101{
1102 maDeleteTransformation(mnIndex);
1103}
1104
1105IMPL_LINK_NOARG(ScDateTimeTransformation, DeleteHdl, weld::Button&, void)
1106{
1107 maDeleteTransformation(mnIndex);
1108}
1109
1110IMPL_LINK_NOARG(ScFindReplaceTransformation, DeleteHdl, weld::Button&, void)
1111{
1112 maDeleteTransformation(mnIndex);
1113}
1114
1115IMPL_LINK_NOARG(ScDeleteRowTransformation, DeleteHdl, weld::Button&, void)
1116{
1117 maDeleteTransformation(mnIndex);
1118}
1119
1120IMPL_LINK_NOARG(ScSwapRowsTransformation, DeleteHdl, weld::Button&, void)
1121{
1122 maDeleteTransformation(mnIndex);
1123}
1124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int mnIndex
Reference< XExecutableDialog > m_xDialog
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1210
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:316
const OUString & GetName() const
Definition: dbdata.hxx:121
std::unique_ptr< weld::ComboBox > mxDBRanges
VclPtr< ScDataTableView > mxTable
void import(ScDocument &rDoc, bool bInternal=false)
std::unique_ptr< weld::Entry > mxEditURL
virtual ~ScDataProviderDlg() override
css::uno::Reference< css::awt::XWindow > m_xTableParent
ScDataProviderDlg(weld::Window *pWindow, std::shared_ptr< ScDocument > pDoc, const ScDocument *pDocument)
std::unique_ptr< weld::Button > mxAddTransformationBtn
std::unique_ptr< weld::Container > mxBox
std::unique_ptr< weld::Container > mxTransformationList
std::unique_ptr< weld::Entry > mxEditID
std::unique_ptr< weld::Button > mxOKBtn
sc::ExternalDataSource getDataSource(ScDocument *pDoc)
OUString msAddTransformationToolTip
std::vector< std::unique_ptr< ScDataTransformationBaseControl > > maControls
std::unique_ptr< weld::Button > mxBrowseBtn
std::unique_ptr< weld::ComboBox > mxProviderList
std::unique_ptr< weld::Button > mxCancelBtn
std::unique_ptr< weld::Button > mxApplyBtn
void updateApplyBtn(bool bValidConfig)
void deletefromList(sal_uInt32 nIndex)
std::shared_ptr< ScDocument > mxDoc
std::unique_ptr< weld::ComboBox > mxTransformationBox
virtual std::shared_ptr< sc::DataTransformation > getTransformation()=0
static SCROW getLastRow(const ScDocument &rDoc)
void updateIndex(sal_uInt32 nIndex)
std::unique_ptr< weld::Container > mxGrid
std::unique_ptr< weld::Builder > mxBuilder
static SCCOL getLastCol(const ScDocument &rDoc)
ScDataTransformationBaseControl(weld::Container *pParent, const OUString &rUIFile, sal_uInt32 nIndex)
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW GetLastDataRow(SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow) const
Return the last non-empty row position in given columns that's no greater than the initial last row p...
Definition: document.cxx:1089
SC_DLLPUBLIC sc::ExternalDataMapper & GetExternalDataMapper()
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:826
SC_DLLPUBLIC CellType GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3790
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void disposeAndClear()
static std::vector< OUString > getDataProviders()
void insertDataSource(const ExternalDataSource &rSource)
void setID(const OUString &rID)
void refresh(ScDocument *pDoc, bool bDeterministic=false)
OUString getDBName() const
void setDBData(const OUString &rDBName)
void AddDataTransformation(const std::shared_ptr< sc::DataTransformation > &mpDataTransformation)
OUString GetPath() const
void SetContext(Context _eNewContext)
virtual void move(weld::Widget *pWidget, weld::Container *pNewParent)=0
IMPL_LINK_NOARG(ScDataProviderDlg, ScrollToEnd, Timer *, void)
URL aURL
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
sal_Int32 mnCol
#define ERRCODE_NONE
@ CELLTYPE_NONE
Definition: global.hxx:272
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
std::vector< OUString > split(std::u16string_view rStr, sal_Unicode cSeparator)
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:121
sal_uInt16 sal_Unicode
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
RET_OK
RET_CANCEL
std::unique_ptr< char[]> aBuffer