[Libreoffice-commits] core.git: sc/source sc/uiconfig sc/UIConfig_scalc.mk
tushar (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 17 05:56:36 UTC 2021
sc/UIConfig_scalc.mk | 1
sc/source/ui/dataprovider/datatransformation.cxx | 44 ++++++++++++
sc/source/ui/inc/dataproviderdlg.hxx | 1
sc/source/ui/inc/datatransformation.hxx | 16 ++++
sc/source/ui/miscdlgs/dataproviderdlg.cxx | 53 ++++++++++++++-
sc/uiconfig/scalc/ui/deleterowentry.ui | 80 +++++++++++++++++++++++
6 files changed, 193 insertions(+), 2 deletions(-)
New commits:
commit 77814f90aef50902383cba3aa4e37c68b6ca2b12
Author: tushar <tusharrai282 at gmail.com>
AuthorDate: Wed Aug 11 01:36:34 2021 +0530
Commit: Heiko Tietze <heiko.tietze at documentfoundation.org>
CommitDate: Tue Aug 17 07:56:03 2021 +0200
Add Delete Row Transformation.
Rows having specific value in a column will be deleted.
Change-Id: I0b39e1127215c59062db11351a656e75d71a04aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120296
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Reviewed-by: Heiko Tietze <heiko.tietze at documentfoundation.org>
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index c7ddfa38f88f..114be7d8f602 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -170,6 +170,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/replacenulltransformationentry \
sc/uiconfig/scalc/ui/datetimetransformationentry \
sc/uiconfig/scalc/ui/findreplaceentry \
+ sc/uiconfig/scalc/ui/deleterowentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx
index 22861b8e4ccd..e1013baa1e47 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -1217,6 +1217,50 @@ const OUString& FindReplaceTransformation::getReplaceString() const
return maReplaceString;
}
+DeleteRowTransformation::DeleteRowTransformation(SCCOL nCol, const OUString& aFindString)
+ : mnCol(nCol)
+ , maFindString(aFindString)
+{
+}
+
+void DeleteRowTransformation::Transform(ScDocument& rDoc) const
+{
+ sal_Int32 nIncrementIndex = 0;
+ if (mnCol == -1)
+ return;
+
+ SCROW nEndRow = getLastRow(rDoc, mnCol);
+ for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
+ {
+ CellType eType;
+ rDoc.GetCellType(mnCol, nRow - nIncrementIndex, 0, eType);
+ if (eType != CELLTYPE_NONE)
+ {
+ OUString aStr = rDoc.GetString(mnCol, nRow - nIncrementIndex, 0);
+ if (aStr == maFindString)
+ {
+ rDoc.DeleteRow(0, 0, rDoc.MaxCol(), 0, nRow - nIncrementIndex, 1);
+ nIncrementIndex++;
+ }
+ }
+ }
+}
+
+TransformationType DeleteRowTransformation::getTransformationType() const
+{
+ return TransformationType::DELETEROW_TRANSFORMATION;
+}
+
+SCCOL DeleteRowTransformation::getColumn() const
+{
+ return mnCol;
+}
+
+const OUString& DeleteRowTransformation::getFindString() const
+{
+ return maFindString;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx
index 5f275eace855..ec054d283149 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -86,6 +86,7 @@ public:
void replaceNullTransformation();
void dateTimeTransformation();
void findReplaceTransformation();
+ void deleteRowTransformation();
void updateApplyBtn(bool bValidConfig);
void isValid();
diff --git a/sc/source/ui/inc/datatransformation.hxx b/sc/source/ui/inc/datatransformation.hxx
index 5c0741553f64..c82422db5a38 100644
--- a/sc/source/ui/inc/datatransformation.hxx
+++ b/sc/source/ui/inc/datatransformation.hxx
@@ -31,7 +31,8 @@ enum class TransformationType
NUMBER_TRANSFORMATION,
REMOVE_NULL_TRANSFORMATION,
DATETIME_TRANSFORMATION,
- FINDREPLACE_TRANSFORMATION
+ FINDREPLACE_TRANSFORMATION,
+ DELETEROW_TRANSFORMATION
};
enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM };
@@ -197,6 +198,19 @@ class SC_DLLPUBLIC FindReplaceTransformation : public DataTransformation
const OUString & getReplaceString() const;
};
+class SC_DLLPUBLIC DeleteRowTransformation : public DataTransformation
+{
+ SCCOL mnCol;
+ OUString maFindString;
+
+ public:
+ DeleteRowTransformation(SCCOL nCol, const OUString& aFindString);
+ virtual void Transform(ScDocument& rDoc) const override;
+ virtual TransformationType getTransformationType() const override;
+ SCCOL getColumn() const;
+ const OUString & getFindString() const;
+};
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 8ad7dd2177aa..8c11a831ebb3 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -64,6 +64,7 @@ struct MenuData
MenuData aTransformationData[] = {
{ "Delete Column", &ScDataProviderDlg::deleteColumn },
+ { "Delete Row", &ScDataProviderDlg::deleteRowTransformation},
{ "Split Column", &ScDataProviderDlg::splitColumn },
{ "Merge Columns", &ScDataProviderDlg::mergeColumns },
{ "Text Transformation", &ScDataProviderDlg::textTransformation },
@@ -72,7 +73,7 @@ MenuData aTransformationData[] = {
{ "Number Transformations", &ScDataProviderDlg::numberTransformation },
{ "Replace Null Transformations", &ScDataProviderDlg::replaceNullTransformation },
{ "Date & Time Transformations", &ScDataProviderDlg::dateTimeTransformation },
- { "Find Replace Transformation", &ScDataProviderDlg::findReplaceTransformation},
+ { "Find Replace Transformation", &ScDataProviderDlg::findReplaceTransformation}
};
class ScDeleteColumnTransformationControl : public ScDataTransformationBaseControl
@@ -655,6 +656,45 @@ std::shared_ptr<sc::DataTransformation> ScFindReplaceTransformation::getTransfor
return std::make_shared<sc::FindReplaceTransformation>(aColumn, mxFindString->get_text(), mxReplaceString->get_text());
}
+class ScDeleteRowTransformation : public ScDataTransformationBaseControl
+{
+private:
+ std::unique_ptr<weld::Entry> mxFindString;
+ std::unique_ptr<weld::Entry> mxEdColumns;
+ std::unique_ptr<weld::Button> mxDelete;
+ std::function<void(sal_uInt32&)> maDeleteTransformation;
+ const ScDocument* mpDoc;
+
+public:
+ ScDeleteRowTransformation(const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
+
+ virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
+ DECL_LINK(DeleteHdl, weld::Button&, void);
+};
+
+ScDeleteRowTransformation::ScDeleteRowTransformation(
+ const ScDocument *pDoc, weld::Container* pParent, sal_uInt32 nIndex,
+ std::function<void(sal_uInt32&)> aDeleteTransformation)
+ : ScDataTransformationBaseControl(pParent, "modules/scalc/ui/deleterowentry.ui", nIndex)
+ , mxFindString(mxBuilder->weld_entry("ed_find"))
+ , mxEdColumns(mxBuilder->weld_entry("ed_columns"))
+ , mxDelete(mxBuilder->weld_button("ed_delete"))
+ , maDeleteTransformation(std::move(aDeleteTransformation))
+ , mpDoc(pDoc)
+{
+ mxDelete->connect_clicked(LINK(this, ScDeleteRowTransformation, DeleteHdl));
+}
+
+std::shared_ptr<sc::DataTransformation> ScDeleteRowTransformation::getTransformation()
+{
+ OUString aColStr = mxEdColumns->get_text();
+ SCCOL aColumn = -1;
+ sal_Int32 nCol = aColStr.toInt32();
+ if (nCol > 0 && nCol <= mpDoc->MaxCol())
+ aColumn = nCol - 1;
+ return std::make_shared<sc::DeleteRowTransformation>(aColumn, mxFindString->get_text());
+}
+
}
ScDataProviderDlg::ScDataProviderDlg(weld::Window* pParent, std::shared_ptr<ScDocument> pDoc,
@@ -896,6 +936,12 @@ void ScDataProviderDlg::findReplaceTransformation()
maControls.emplace_back(std::make_unique<ScFindReplaceTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
}
+void ScDataProviderDlg::deleteRowTransformation()
+{
+ std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList, this, std::placeholders::_1);
+ maControls.emplace_back(std::make_unique<ScDeleteRowTransformation>(mxDoc.get(), mxTransformationList.get(), mnIndex++, adeleteTransformation));
+}
+
namespace {
bool hasDBName(const OUString& rName, ScDBCollection* pDBCollection)
@@ -990,4 +1036,9 @@ IMPL_LINK_NOARG(ScFindReplaceTransformation, DeleteHdl, weld::Button&, void)
{
maDeleteTransformation(mnIndex);
}
+
+IMPL_LINK_NOARG(ScDeleteRowTransformation, DeleteHdl, weld::Button&, void)
+{
+ maDeleteTransformation(mnIndex);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/deleterowentry.ui b/sc/uiconfig/scalc/ui/deleterowentry.ui
new file mode 100644
index 000000000000..b0004f8db83a
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/deleterowentry.ui
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.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="margin-end">6</property>
+ <property name="border_width">6</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes" context="deleterow|delete_label">Delete Row Action</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">ed_find</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="ed_find">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="width_chars">10</property>
+ <property name="truncate_multiline">True</property>
+ <property name="placeholder_text" translatable="yes" context="deleterow|value">Enter Value</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="ed_columns">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="width_chars">10</property>
+ <property name="truncate_multiline">True</property>
+ <property name="placeholder_text" translatable="yes" context="deleterow|column">Column</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ed_delete">
+ <property name="label" translatable="yes" context="deleterow|delete_btn">Delete</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">end</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ </object>
+</interface>
More information about the Libreoffice-commits
mailing list