summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTomofumi Yagi <yagitmknada@gmail.com>2020-10-10 14:54:30 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-11 11:45:35 +0200
commite0c1fdcab23dbd2b7a0a7227557d7afc41b49bd7 (patch)
treeef546f26016b8f93dc82f7c43376f08e98aff8be /sc
parentee8d735f0a59f41fb1f5cbabfe089c222ca948e3 (diff)
tdf#133886 - Libreoffice Calc Subtotals check all columns at once
"Select all columns" checkbox is added to the subtotal group page. Change-Id: Iee5be3218ecb6d74c7c65b2bf49febf0703ebf35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104135 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx64
-rw-r--r--sc/source/ui/inc/tpsubt.hxx2
-rw-r--r--sc/uiconfig/scalc/ui/subtotalgrppage.ui14
3 files changed, 66 insertions, 14 deletions
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
index 30133dce08ad..953c4cf50ff3 100644
--- a/sc/source/ui/dbgui/tpsubt.cxx
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -49,6 +49,7 @@ ScTpSubTotalGroup::ScTpSubTotalGroup(weld::Container* pPage, weld::DialogControl
, mxLbGroup(m_xBuilder->weld_combo_box("group_by"))
, mxLbColumns(m_xBuilder->weld_tree_view("columns"))
, mxLbFunctions(m_xBuilder->weld_tree_view("functions"))
+ , mxLbSelectAllColumns(m_xBuilder->weld_check_button("select_all_columns_button"))
{
for (size_t i = 0; i < SAL_N_ELEMENTS(SCSTR_SUBTOTALS); ++i)
mxLbFunctions->append_text(ScResId(SCSTR_SUBTOTALS[i]));
@@ -80,11 +81,28 @@ void ScTpSubTotalGroup::Init()
mxLbColumns->connect_changed( LINK( this, ScTpSubTotalGroup, SelectTreeListBoxHdl ) );
mxLbColumns->connect_toggled( LINK( this, ScTpSubTotalGroup, CheckHdl ) );
mxLbFunctions->connect_changed( LINK( this, ScTpSubTotalGroup, SelectTreeListBoxHdl) );
+ mxLbSelectAllColumns->connect_clicked( LINK( this, ScTpSubTotalGroup, CheckBoxHdl ) );
nFieldArr[0] = 0;
FillListBoxes();
}
+namespace
+{
+ int GetCheckedEntryCount(weld::TreeView& rTreeView)
+ {
+ int nRet = 0;
+
+ rTreeView.all_foreach([&](const weld::TreeIter& rEntry) {
+ if ( rTreeView.get_toggle(rEntry) == TRISTATE_TRUE )
+ ++nRet;
+ return false;
+ });
+
+ return nRet;
+ }
+}
+
bool ScTpSubTotalGroup::DoReset( sal_uInt16 nGroupNo,
const SfxItemSet& rArgSet )
{
@@ -139,21 +157,12 @@ bool ScTpSubTotalGroup::DoReset( sal_uInt16 nGroupNo,
mxLbFunctions->select( 0 );
}
- return true;
-}
+ if ( mxLbColumns->n_children() == GetCheckedEntryCount(*mxLbColumns) )
+ mxLbSelectAllColumns->set_active( true );
+ else
+ mxLbSelectAllColumns->set_active( false );
-namespace
-{
- int GetCheckedEntryCount(const weld::TreeView& rTreeView)
- {
- int nRet = 0;
- for (sal_Int32 i=0, nEntryCount = rTreeView.n_children(); i < nEntryCount; ++i)
- {
- if (rTreeView.get_toggle(i) == TRISTATE_TRUE)
- ++nRet;
- }
- return nRet;
- }
+ return true;
}
bool ScTpSubTotalGroup::DoFillItemSet( sal_uInt16 nGroupNo,
@@ -335,6 +344,11 @@ sal_uInt16 ScTpSubTotalGroup::FuncToLbPos( ScSubTotalFunc eFunc )
IMPL_LINK(ScTpSubTotalGroup, SelectTreeListBoxHdl, weld::TreeView&, rLb, void)
{
SelectHdl(&rLb);
+
+ if ( mxLbColumns->n_children() == GetCheckedEntryCount(*mxLbColumns) )
+ mxLbSelectAllColumns->set_active( true );
+ else
+ mxLbSelectAllColumns->set_active( false );
}
IMPL_LINK(ScTpSubTotalGroup, SelectListBoxHdl, weld::ComboBox&, rLb, void)
@@ -366,6 +380,11 @@ IMPL_LINK( ScTpSubTotalGroup, CheckHdl, const weld::TreeView::iter_col&, rRowCol
{
mxLbColumns->select(rRowCol.first);
SelectHdl(mxLbColumns.get());
+
+ if ( mxLbColumns->n_children() == GetCheckedEntryCount(*mxLbColumns) )
+ mxLbSelectAllColumns->set_active( true );
+ else
+ mxLbSelectAllColumns->set_active( false );
}
// Derived Group TabPages:
@@ -570,6 +589,23 @@ IMPL_LINK(ScTpSubTotalOptions, CheckHdl, weld::Button&, rBox, void)
}
}
+IMPL_LINK(ScTpSubTotalGroup, CheckBoxHdl, weld::Button&, rBox, void)
+{
+ if (&rBox == mxLbSelectAllColumns.get())
+ {
+ bool bChecked = mxLbSelectAllColumns->get_active();
+
+ mxLbColumns->all_foreach([&](const weld::TreeIter& rEntry) {
+ if ( bChecked )
+ mxLbColumns->set_toggle(rEntry, TRISTATE_TRUE);
+ else
+ mxLbColumns->set_toggle(rEntry, TRISTATE_FALSE);
+
+ return false;
+ });
+ }
+}
+
ScTpSubTotalGroup1::~ScTpSubTotalGroup1()
{
}
diff --git a/sc/source/ui/inc/tpsubt.hxx b/sc/source/ui/inc/tpsubt.hxx
index d5a2ca023eed..93652127d026 100644
--- a/sc/source/ui/inc/tpsubt.hxx
+++ b/sc/source/ui/inc/tpsubt.hxx
@@ -57,6 +57,7 @@ protected:
std::unique_ptr<weld::ComboBox> mxLbGroup;
std::unique_ptr<weld::TreeView> mxLbColumns;
std::unique_ptr<weld::TreeView> mxLbFunctions;
+ std::unique_ptr<weld::CheckButton> mxLbSelectAllColumns;
private:
void Init ();
@@ -69,6 +70,7 @@ private:
DECL_LINK( SelectListBoxHdl, weld::ComboBox&, void );
DECL_LINK( SelectTreeListBoxHdl, weld::TreeView&, void );
DECL_LINK(CheckHdl, const weld::TreeView::iter_col&, void);
+ DECL_LINK(CheckBoxHdl, weld::Button&, void);
void SelectHdl(const weld::Widget*);
};
diff --git a/sc/uiconfig/scalc/ui/subtotalgrppage.ui b/sc/uiconfig/scalc/ui/subtotalgrppage.ui
index 85970080de74..085580595f9f 100644
--- a/sc/uiconfig/scalc/ui/subtotalgrppage.ui
+++ b/sc/uiconfig/scalc/ui/subtotalgrppage.ui
@@ -68,6 +68,20 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="select_all_columns_button">
+ <property name="label" translatable="yes" context="subtotalgrppage|select_all_columns_button">Select all columns</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>