Kaydet (Commit) bb11b48e authored tarafından Manuj Vashist's avatar Manuj Vashist Kaydeden (comit) Markus Mohrhard

Added Date and Time Transformation in data provider dlg

Change-Id: Iead6b030d54983d08543656d2b62e42ba38b946e
Reviewed-on: https://gerrit.libreoffice.org/58912
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst ce9fd6d1
......@@ -161,6 +161,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/aggregatefunctionentry \
sc/uiconfig/scalc/ui/numbertransformationentry \
sc/uiconfig/scalc/ui/replacenulltransformationentry \
sc/uiconfig/scalc/ui/datetimetransformationentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
......
......@@ -67,6 +67,7 @@ public:
void numberTransformation();
void deletefromList(sal_uInt32 nIndex);
void replaceNullTransformation();
void dateTimeTransformation();
void import(ScDocument* pDoc, bool bInternal = false);
};
......
......@@ -200,7 +200,8 @@ MenuData aColumnData[] = {
{ 4, "Sort Columns", &ScDataProviderDlg::sortTransformation },
{ 5, "Aggregate Functions", &ScDataProviderDlg::aggregateFunction},
{ 6, "Number Transformations", &ScDataProviderDlg::numberTransformation },
{ 7, "Replace Null Transformations", &ScDataProviderDlg::replaceNullTransformation }
{ 7, "Replace Null Transformations", &ScDataProviderDlg::replaceNullTransformation },
{ 8, "Date & Time Transformations", &ScDataProviderDlg::dateTimeTransformation }
};
class ScDataTransformationBaseControl : public VclContainer,
......@@ -834,6 +835,113 @@ std::shared_ptr<sc::DataTransformation> ScReplaceNullTransformation::getTransfor
return std::make_shared<sc::ReplaceNullTransformation>(aColumns,aReplaceWithString);
}
class ScDateTimeTransformation : public ScDataTransformationBaseControl
{
private:
VclPtr<Edit> maColumnNums;
VclPtr<ListBox> maType;
VclPtr<PushButton> maDelete;
sal_uInt32 maIndex;
std::function<void(sal_uInt32&)> maDeleteTransformation;
public:
ScDateTimeTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function<void(sal_uInt32&)> aDeleteTransformation);
~ScDateTimeTransformation() override;
virtual void dispose() override;
virtual std::shared_ptr<sc::DataTransformation> getTransformation() override;
DECL_LINK(DeleteHdl, Button*, void);
};
ScDateTimeTransformation::ScDateTimeTransformation(vcl::Window* pParent, sal_uInt32 aIndex, std::function<void(sal_uInt32&)> aDeleteTransformation):
ScDataTransformationBaseControl(pParent,"modules/scalc/ui/datetimetransformationentry.ui"),
maIndex(aIndex),
maDeleteTransformation(aDeleteTransformation)
{
get(maColumnNums, "ed_columns");
get(maType, "ed_lst");
get(maDelete, "ed_delete");
maDelete->SetClickHdl(LINK(this,ScDateTimeTransformation, DeleteHdl));
}
ScDateTimeTransformation::~ScDateTimeTransformation()
{
disposeOnce();
}
void ScDateTimeTransformation::dispose()
{
maColumnNums.clear();
maType.clear();
maDelete.clear();
ScDataTransformationBaseControl::dispose();
}
std::shared_ptr<sc::DataTransformation> ScDateTimeTransformation::getTransformation()
{
OUString aColumnString = maColumnNums->GetText();
sal_Int32 nPos = maType->GetSelectedEntryPos();
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);
}
switch (nPos)
{
case 0:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::DATE_STRING);
case 1:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::YEAR);
case 2:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::START_OF_YEAR);
case 3:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::END_OF_YEAR);
case 4:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::MONTH);
case 5:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::MONTH_NAME);
case 6:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::START_OF_MONTH);
case 7:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::END_OF_MONTH);
case 8:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::DAY);
case 9:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_WEEK);
case 10:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::DAY_OF_YEAR);
case 11:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::QUARTER);
case 12:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::START_OF_QUARTER);
case 13:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::END_OF_QUARTER);
case 14:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::HOUR);
case 15:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::MINUTE);
case 16:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::SECOND);
case 17:
return std::make_shared<sc::DateTimeTransformation>(aColumns,sc::DATETIME_TRANSFORMATION_TYPE::TIME);
default:
assert(false);
}
return nullptr;
}
}
ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr<ScDocument> pDoc,
......@@ -1019,6 +1127,13 @@ void ScDataProviderDlg::replaceNullTransformation()
mpList->addEntry(pReplaceNullTransformationEntry);
}
void ScDataProviderDlg::dateTimeTransformation()
{
std::function<void(sal_uInt32&)> adeleteTransformation = std::bind(&ScDataProviderDlg::deletefromList,this, std::placeholders::_1);
VclPtr<ScDateTimeTransformation> pDateTimeTransformationEntry = VclPtr<ScDateTimeTransformation>::Create(mpList, mpIndex++, adeleteTransformation);
mpList->addEntry(pDateTimeTransformationEntry);
}
void ScDataProviderDlg::import(ScDocument* pDoc, bool bInternal)
{
sc::ExternalDataSource aSource = mpDataProviderCtrl->getDataSource(pDoc);
......@@ -1089,4 +1204,8 @@ IMPL_LINK_NOARG(ScReplaceNullTransformation, DeleteHdl, Button*, void)
maDeleteTransformation(maIndex);
}
IMPL_LINK_NOARG(ScDateTimeTransformation, DeleteHdl, Button*, void)
{
maDeleteTransformation(maIndex);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?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="datetimetransformationentry|name">Date Time Transformations</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="datetimetransformationentry|type">Type:</property>
<accessibility>
<relation type="label-for" target="ed_lst"/>
</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="datetimetransformationentry|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="GtkComboBoxText" id="ed_lst">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<property name="active_id">0</property>
<items>
<item id="0" translatable="yes" context="datetimetransformationentry|datestring">Date String</item>
<item id="1" translatable="yes" context="datetimetransformationentry|year">Year</item>
<item id="2" translatable="yes" context="datetimetransformationentry|startofyear">Start of Year</item>
<item id="3" translatable="yes" context="datetimetransformationentry|endofyear">End of Year</item>
<item id="4" translatable="yes" context="datetimetransformationentry|month">Month</item>
<item id="5" translatable="yes" context="datetimetransformationentry|monthname">Month Name</item>
<item id="6" translatable="yes" context="datetimetransformationentry|startofmonth">Start of Month</item>
<item id="7" translatable="yes" context="datetimetransformationentry|endofmonth">End of Month</item>
<item id="8" translatable="yes" context="datetimetransformationentry|day">Day</item>
<item id="9" translatable="yes" context="datetimetransformationentry|dayofweek">Day of Week</item>
<item id="10" translatable="yes" context="datetimetransformationentry|dayofyear">Day of Year</item>
<item id="11" translatable="yes" context="datetimetransformationentry|quarter">Quarter</item>
<item id="12" translatable="yes" context="datetimetransformationentry|startofquarter">Start of Quarter</item>
<item id="12" translatable="yes" context="datetimetransformationentry|endofquarter">End of Quarter</item>
<item id="12" translatable="yes" context="datetimetransformationentry|hour">Hour</item>
<item id="12" translatable="yes" context="datetimetransformationentry|minute">Minute</item>
<item id="12" translatable="yes" context="datetimetransformationentry|second">Second</item>
<item id="12" translatable="yes" context="datetimetransformationentry|time">Time</item>
</items>
<accessibility>
<relation type="labelled-by" target="label1"/>
</accessibility>
</object>
<packing>
<property name="left_attach">1</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>
<accessibility>
<relation type="labelled-by" target="label2"/>
</accessibility>
</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>
<child>
<object class="GtkButton" id="ed_delete">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes" context="datetimetransformationentry|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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment