tdf#76898 add ability to reset standard filter
Change-Id: If0694fe521770b86f4367fc39c087df8a89a976c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94767
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index addfedb..22cc256 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -80,6 +80,7 @@ ScFilterDlg::ScFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pPa
, m_xContents(m_xBuilder->weld_widget("grid"))
, m_xScrollBar(m_xBuilder->weld_scrolled_window("scrollbar"))
, m_xExpander(m_xBuilder->weld_expander("more"))
, m_xBtnClear(m_xBuilder->weld_button("clear"))
, m_xBtnOk(m_xBuilder->weld_button("ok"))
, m_xBtnCancel(m_xBuilder->weld_button("cancel"))
, m_xBtnCase(m_xBuilder->weld_check_button("case"))
@@ -121,6 +122,7 @@ void ScFilterDlg::Init( const SfxItemSet& rArgSet )
const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(
rArgSet.Get( nWhichQuery ));
m_xBtnClear->connect_clicked ( LINK( this, ScFilterDlg, BtnClearHdl ) );
m_xBtnOk->connect_clicked ( LINK( this, ScFilterDlg, EndDlgHdl ) );
m_xBtnCancel->connect_clicked ( LINK( this, ScFilterDlg, EndDlgHdl ) );
m_xBtnHeader->connect_clicked ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
@@ -630,6 +632,61 @@ bool ScFilterDlg::IsRefInputMode() const
// Handler:
IMPL_LINK( ScFilterDlg, BtnClearHdl, weld::Button&, rBtn, void )
{
if ( &rBtn == m_xBtnClear.get() )
{
// scroll to the top
m_xScrollBar->vadjustment_set_value(0);
size_t nOffset = 0;
RefreshEditRow( nOffset);
// clear all conditions
m_xLbConnect1->set_active(-1);
m_xLbConnect2->set_active(-1);
m_xLbConnect3->set_active(-1);
m_xLbConnect4->set_active(-1);
m_xLbField1->set_active(0);
m_xLbField2->set_active(0);
m_xLbField3->set_active(0);
m_xLbField4->set_active(0);
m_xLbCond1->set_active(0);
m_xLbCond2->set_active(0);
m_xLbCond3->set_active(0);
m_xLbCond4->set_active(0);
ClearValueList( 1 );
ClearValueList( 2 );
ClearValueList( 3 );
ClearValueList( 4 );
// disable fields for second row onward
m_xLbConnect2->set_sensitive(false);
m_xLbConnect3->set_sensitive(false);
m_xLbConnect4->set_sensitive(false);
m_xLbField2->set_sensitive(false);
m_xLbField3->set_sensitive(false);
m_xLbField4->set_sensitive(false);
m_xLbCond2->set_sensitive(false);
m_xLbCond3->set_sensitive(false);
m_xLbCond4->set_sensitive(false);
m_xEdVal2->set_sensitive(false);
m_xEdVal3->set_sensitive(false);
m_xEdVal4->set_sensitive(false);
// clear query data objects
SCSIZE nCount = theQueryData.GetEntryCount();
if (maRefreshExceptQuery.size() < nCount + 1)
maRefreshExceptQuery.resize(nCount + 1, false);
for (SCSIZE i = 0; i < nCount; ++i)
{
theQueryData.GetEntry(i).bDoQuery = false;
maRefreshExceptQuery[i] = false;
theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
}
maRefreshExceptQuery[0] = true;
}
}
IMPL_LINK( ScFilterDlg, EndDlgHdl, weld::Button&, rBtn, void )
{
if ( &rBtn == m_xBtnOk.get() )
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
index 8445f1c..e6c2d37 100644
--- a/sc/source/ui/inc/filtdlg.hxx
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -118,6 +118,7 @@ private:
std::unique_ptr<weld::ScrolledWindow> m_xScrollBar;
std::unique_ptr<weld::Expander> m_xExpander;
std::unique_ptr<weld::Button> m_xBtnClear;
std::unique_ptr<weld::Button> m_xBtnOk;
std::unique_ptr<weld::Button> m_xBtnCancel;
@@ -146,6 +147,7 @@ private:
DECL_LINK( LbSelectHdl, weld::ComboBox&, void );
DECL_LINK( ValModifyHdl, weld::ComboBox&, void );
DECL_LINK( CheckBoxHdl, weld::Button&, void );
DECL_LINK( BtnClearHdl, weld::Button&, void );
DECL_LINK( EndDlgHdl, weld::Button&, void );
DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
DECL_LINK( MoreExpandedHdl, weld::Expander&, void );
diff --git a/sc/uiconfig/scalc/ui/standardfilterdialog.ui b/sc/uiconfig/scalc/ui/standardfilterdialog.ui
index a71da96..b657df6 100644
--- a/sc/uiconfig/scalc/ui/standardfilterdialog.ui
+++ b/sc/uiconfig/scalc/ui/standardfilterdialog.ui
@@ -25,6 +25,21 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="clear">
<property name="label">gtk-clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
@@ -37,7 +52,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -52,7 +67,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -67,7 +82,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
@@ -842,6 +857,7 @@
</object>
</child>
<action-widgets>
<action-widget response="100">clear</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>