diff options
-rw-r--r-- | sc/UIConfig_scalc.mk | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/dataproviderdlg.cxx | 79 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/deletecolumnentry.ui | 68 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/mergecolumnentry.ui | 89 |
4 files changed, 227 insertions, 11 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 845ede98034b..2e8c1ad945c3 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -116,6 +116,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/definedatabaserangedialog \ sc/uiconfig/scalc/ui/definename \ sc/uiconfig/scalc/ui/deletecells \ + sc/uiconfig/scalc/ui/deletecolumnentry \ sc/uiconfig/scalc/ui/deletecontents \ sc/uiconfig/scalc/ui/descriptivestatisticsdialog \ sc/uiconfig/scalc/ui/dropmenu \ @@ -152,6 +153,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/notebookbar_groupedbar_compact \ sc/uiconfig/scalc/ui/managenamesdialog \ sc/uiconfig/scalc/ui/mergecellsdialog \ + sc/uiconfig/scalc/ui/mergecolumnentry \ sc/uiconfig/scalc/ui/movecopysheet \ sc/uiconfig/scalc/ui/movingaveragedialog \ sc/uiconfig/scalc/ui/multipleoperationsdialog \ diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index 11fa52ee2927..78953cb3d4fd 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -13,6 +13,8 @@ #include <dataprovider.hxx> #include <datatransformation.hxx> +#include <comphelper/string.hxx> + #include <vcl/lstbox.hxx> constexpr int MENU_START = 0; @@ -202,7 +204,6 @@ IMPL_LINK_NOARG(ScDataProviderBaseControl, ApplyBtnHdl, Button*, void) maImportCallback.Call(this); } - namespace { struct MenuData @@ -275,9 +276,10 @@ class ScSplitColumnTransformationControl : public ScDataTransformationBaseContro private: VclPtr<Edit> maSeparator; VclPtr<NumericField> maNumColumns; + SCCOL mnCol; public: - ScSplitColumnTransformationControl(vcl::Window* pParent); + ScSplitColumnTransformationControl(vcl::Window* pParent, SCCOL nCol); ~ScSplitColumnTransformationControl() override; virtual void dispose() override; @@ -285,8 +287,9 @@ public: virtual std::shared_ptr<sc::DataTransformation> getTransformation() override; }; -ScSplitColumnTransformationControl::ScSplitColumnTransformationControl(vcl::Window* pParent): - ScDataTransformationBaseControl(pParent, "modules/scalc/ui/splitcolumnentry.ui") +ScSplitColumnTransformationControl::ScSplitColumnTransformationControl(vcl::Window* pParent, SCCOL nCol): + ScDataTransformationBaseControl(pParent, "modules/scalc/ui/splitcolumnentry.ui"), + mnCol(nCol) { get(maSeparator, "ed_separator"); get(maNumColumns, "num_cols"); @@ -307,28 +310,76 @@ void ScSplitColumnTransformationControl::dispose() std::shared_ptr<sc::DataTransformation> ScSplitColumnTransformationControl::getTransformation() { - return std::make_shared<sc::SplitColumnTransformation>(0, ','); + OUString aSeparator = maSeparator->GetText(); + sal_Unicode cSeparator = aSeparator.isEmpty() ? ',' : aSeparator[0]; + return std::make_shared<sc::SplitColumnTransformation>(mnCol, cSeparator); } class ScMergeColumnTransformationControl : public ScDataTransformationBaseControl { private: + VclPtr<Edit> mpSeparator; + VclPtr<Edit> mpEdColumns; + public: - ScMergeColumnTransformationControl(vcl::Window* pParent); + ScMergeColumnTransformationControl(vcl::Window* pParent, SCCOL nStartCol, SCCOL nEndCol); + ~ScMergeColumnTransformationControl() override; + + virtual void dispose() override; virtual std::shared_ptr<sc::DataTransformation> getTransformation() override; }; -ScMergeColumnTransformationControl::ScMergeColumnTransformationControl(vcl::Window* pParent): +ScMergeColumnTransformationControl::ScMergeColumnTransformationControl(vcl::Window* pParent, SCCOL nStartCol, SCCOL nEndCol): ScDataTransformationBaseControl(pParent, "modules/scalc/ui/mergecolumnentry.ui") { + get(mpSeparator, "ed_separator"); + get(mpEdColumns, "ed_columns"); + + OUStringBuffer aBuffer; + + // map from zero based to one based column numbers + aBuffer.append(OUString::number(nStartCol + 1)); + for ( SCCOL nCol = nStartCol + 1; nCol <= nEndCol; ++nCol) + { + aBuffer.append(";").append(OUString::number(nCol + 1)); + } + + mpEdColumns->SetText(aBuffer.makeStringAndClear()); +} + +ScMergeColumnTransformationControl::~ScMergeColumnTransformationControl() +{ + disposeOnce(); +} + +void ScMergeColumnTransformationControl::dispose() +{ + mpSeparator.clear(); + mpEdColumns.clear(); + + ScDataTransformationBaseControl::dispose(); } std::shared_ptr<sc::DataTransformation> ScMergeColumnTransformationControl::getTransformation() { - std::set<SCCOL> maColumns = {0, 1}; - return std::make_shared<sc::MergeColumnTransformation>(maColumns, ","); + OUString aColumnString = mpEdColumns->GetText(); + std::vector<OUString> aSplitColumns = comphelper::string::split(aColumnString, ';'); + std::set<SCCOL> aMergedColumns; + for (auto& rColStr : aSplitColumns) + { + sal_Int32 nCol = rColStr.toInt32(); + if (nCol <= 0) + continue; + + if (nCol > MAXCOL) + continue; + + // translate from 1-based column notations to internal Calc one + aMergedColumns.insert(nCol - 1); + } + return std::make_shared<sc::MergeColumnTransformation>(aMergedColumns, mpSeparator->GetText()); } } @@ -454,13 +505,19 @@ void ScDataProviderDlg::deleteColumn() void ScDataProviderDlg::splitColumn() { - VclPtr<ScSplitColumnTransformationControl> pSplitColumnEntry = VclPtr<ScSplitColumnTransformationControl>::Create(mpList); + SCCOL nStartCol = -1; + SCCOL nEndCol = -1; + mpTable->getColRange(nStartCol, nEndCol); + VclPtr<ScSplitColumnTransformationControl> pSplitColumnEntry = VclPtr<ScSplitColumnTransformationControl>::Create(mpList, nStartCol); mpList->addEntry(pSplitColumnEntry); } void ScDataProviderDlg::mergeColumns() { - VclPtr<ScMergeColumnTransformationControl> pMergeColumnEntry = VclPtr<ScMergeColumnTransformationControl>::Create(mpList); + SCCOL nStartCol = -1; + SCCOL nEndCol = -1; + mpTable->getColRange(nStartCol, nEndCol); + VclPtr<ScMergeColumnTransformationControl> pMergeColumnEntry = VclPtr<ScMergeColumnTransformationControl>::Create(mpList, nStartCol, nEndCol); mpList->addEntry(pMergeColumnEntry); } diff --git a/sc/uiconfig/scalc/ui/deletecolumnentry.ui b/sc/uiconfig/scalc/ui/deletecolumnentry.ui new file mode 100644 index 000000000000..03bfcd48bd03 --- /dev/null +++ b/sc/uiconfig/scalc/ui/deletecolumnentry.ui @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkGrid" id="grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="border_width">6</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="deletecolumnentry|name">Delete Columns Action</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid_details"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="deletecolumnentry|separator">Columns (List of ';' separated columns)</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ed_columns"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> +</interface> diff --git a/sc/uiconfig/scalc/ui/mergecolumnentry.ui b/sc/uiconfig/scalc/ui/mergecolumnentry.ui new file mode 100644 index 000000000000..2c032d8cb3ac --- /dev/null +++ b/sc/uiconfig/scalc/ui/mergecolumnentry.ui @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.2 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkGrid" id="grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="border_width">6</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="mergecolumnentry|name">Merge Column Action</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid_details"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="mergecolumnentry|separator">Separator:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ed_separator"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="mergecolumnentry|columns">Columns:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ed_columns"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> +</interface> |