[Libreoffice-commits] core.git: sc/source sc/uiconfig sc/UIConfig_scalc.mk
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 5 16:53:51 UTC 2018
sc/UIConfig_scalc.mk | 1
sc/source/ui/inc/dataproviderdlg.hxx | 1
sc/source/ui/miscdlgs/dataproviderdlg.cxx | 81 ++++++++++++
sc/uiconfig/scalc/ui/replacenulltransformationentry.ui | 112 +++++++++++++++++
4 files changed, 194 insertions(+), 1 deletion(-)
New commits:
commit e5587c96b43ff2958ae994a43532da4a5795ee93
Author: Manuj Vashist <manujvashist at gmail.com>
AuthorDate: Mon Aug 13 14:23:08 2018 +0530
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Wed Sep 5 18:53:28 2018 +0200
Added Replace Null Transformation in data provider dlg
Change-Id: I5e1541e87f1eabd1bf564c7a8c6721377b51cffe
Reviewed-on: https://gerrit.libreoffice.org/58911
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 70d17e3ace35..d7311f495f39 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -160,6 +160,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/sorttransformationentry \
sc/uiconfig/scalc/ui/aggregatefunctionentry \
sc/uiconfig/scalc/ui/numbertransformationentry \
+ sc/uiconfig/scalc/ui/replacenulltransformationentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx
index 059737cb8fc7..969daeef770e 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -66,6 +66,7 @@ public:
void aggregateFunction();
void numberTransformation();
void deletefromList(sal_uInt32 nIndex);
+ void replaceNullTransformation();
void import(ScDocument* pDoc, bool bInternal = false);
};
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 0318574762c6..b637c5d4770d 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -198,7 +198,8 @@ MenuData aColumnData[] = {
{ 3, "Text Transformation", &ScDataProviderDlg::textTransformation },
{ 4, "Sort Columns", &ScDataProviderDlg::sortTransformation },
{ 5, "Aggregate Functions", &ScDataProviderDlg::aggregateFunction},
- { 6, "Number Transformations", &ScDataProviderDlg::numberTransformation }
+ { 6, "Number Transformations", &ScDataProviderDlg::numberTransformation },
+ { 7, "Replace Null Transformations", &ScDataProviderDlg::replaceNullTransformation }
};
class ScDataTransformationBaseControl : public VclContainer,
@@ -757,6 +758,72 @@ std::shared_ptr<sc::DataTransformation> ScNumberTransformation::getTransformatio
return nullptr;
}
+class ScReplaceNullTransformation : public ScDataTransformationBaseControl
+{
+private:
+ VclPtr<Edit> maColumnNums;
+ VclPtr<Edit> maReplaceString;
+ VclPtr<PushButton> maDelete;
+ sal_uInt32 maIndex;
+ std::function<void(sal_uInt32&)> maDeleteTransformation;
+
+public:
+
+ ScReplaceNullTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
+ ~ScReplaceNullTransformation() override;
+
+ virtual void dispose() override;
+
+ virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
+ DECL_LINK(DeleteHdl, Button*, void);
+};
+
+ScReplaceNullTransformation::ScReplaceNullTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function<void(sal_uInt32&)> aDeleteTransformation):
+ ScDataTransformationBaseControl(pParent,"modules/scalc/ui/replacenulltransformationentry.ui"),
+ maIndex(aIndex),
+ maDeleteTransformation(aDeleteTransformation)
+{
+ get(maColumnNums, "ed_columns");
+ get(maReplaceString, "ed_str");
+ get(maDelete, "ed_delete");
+ maDelete->SetClickHdl(LINK(this,ScReplaceNullTransformation, DeleteHdl));
+}
+
+ScReplaceNullTransformation::~ScReplaceNullTransformation()
+{
+ disposeOnce();
+}
+
+void ScReplaceNullTransformation::dispose()
+{
+ maColumnNums.clear();
+ maReplaceString.clear();
+ maDelete.clear();
+ ScDataTransformationBaseControl::dispose();
+}
+
+std::shared_ptr<sc::DataTransformation> ScReplaceNullTransformation::getTransformation()
+{
+ OUString aColumnString = maColumnNums->GetText();
+ OUString aReplaceWithString = maReplaceString->GetText();
+ std::vector<OUString> aSplitColumns = comphelper::string::split(aColumnString, ';');
+ std::set<SCCOL> aColumns;
+ 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
+ aColumns.insert(nCol - 1);
+ }
+
+ return std::make_shared<sc::ReplaceNullTransformation>(aColumns,aReplaceWithString);
+}
+
}
ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr<ScDocument> pDoc, ScDocument* pDocument):
@@ -934,6 +1001,13 @@ void ScDataProviderDlg::numberTransformation()
mpList->addEntry(pNumberTransformationEntry);
}
+void ScDataProviderDlg::replaceNullTransformation()
+{
+ std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
+ VclPtr<ScReplaceNullTransformation> pReplaceNullTransformationEntry = VclPtr<ScReplaceNullTransformation>::Create(mpList, mpIndex++, adeleteTransformation);
+ mpList->addEntry(pReplaceNullTransformationEntry);
+}
+
void ScDataProviderDlg::import(ScDocument* pDoc, bool bInternal)
{
sc::ExternalDataSource aSource = mpDataProviderCtrl->getDataSource(pDoc);
@@ -999,4 +1073,9 @@ IMPL_LINK_NOARG(ScColumnTextTransformation, DeleteHdl, Button*, void)
maDeleteTransformation(maIndex);
}
+IMPL_LINK_NOARG(ScReplaceNullTransformation, DeleteHdl, Button*, void)
+{
+ maDeleteTransformation(maIndex);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui b/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui
new file mode 100644
index 000000000000..050e8a602b90
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/replacenulltransformationentry.ui
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.2 -->
+<interface domain="sc">
+ <requires lib="gtk+" version="3.18"/>
+ <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="replacenulltransformationentry|name">Replace Null Transformation</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" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="replacenulltransformationentry|type">Replace with</property>
+ <accessibility>
+ <relation type="label-for" target="ed_str"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="replacenulltransformationentry|columns">Columns:</property>
+ <accessibility>
+ <relation type="label-for" target="ed_columns"/>
+ </accessibility>
+ </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>
+ <accessibility>
+ <relation type="labelled-by" target="label2"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="ed_str">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <accessibility>
+ <relation type="labelled-by" target="label1"/>
+ </accessibility>
+ </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>
+ <child>
+ <object class="GtkButton" id="ed_delete">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes" context="replacenulltransformationentry|delete">Cancel</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>
More information about the Libreoffice-commits
mailing list