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