From 898c527481059017c8f75ba51bfc80b297f0480d Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 18 Nov 2011 16:56:10 -0500 Subject: Disable the OK button when no items are selected. When filtering by equality, we need to have at least one value to compare to, or else bad things may happen. The pivot table OTOH can handle empty set. So over there, it's okay to allow no items to be selected. --- sc/source/ui/cctrl/checklistmenu.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'sc/source/ui/cctrl') diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 3835ab96cebd..e96e6d410b2b 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -747,6 +747,11 @@ void ScMenuFloatingWindow::terminateAllPopupMenus() // ============================================================================ +ScCheckListMenuWindow::Config::Config() : + mbAllowEmptySet(true) +{ +} + ScCheckListMenuWindow::Member::Member() : mbVisible(true) { @@ -958,7 +963,11 @@ void ScCheckListMenuWindow::setAllMemberState(bool bSet) { size_t n = maMembers.size(); for (size_t i = 0; i < n; ++i) - maChecks.CheckEntryPos(static_cast< sal_uInt16 >( i ), bSet); + maChecks.CheckEntryPos(static_cast(i), bSet); + + if (!maConfig.mbAllowEmptySet) + // We need to have at least one member selected. + maBtnOk.Enable(maChecks.GetCheckedEntryCount() != 0); } void ScCheckListMenuWindow::selectCurrentMemberOnly(bool bSet) @@ -1047,6 +1056,10 @@ IMPL_LINK( ScCheckListMenuWindow, CheckHdl, SvTreeListBox*, pChecks ) else maChkToggleAll.SetState(STATE_DONTKNOW); + if (!maConfig.mbAllowEmptySet) + // We need to have at least one member selected. + maBtnOk.Enable(nNumChecked != 0); + mePrevToggleAllState = maChkToggleAll.GetState(); return 0; } @@ -1177,6 +1190,11 @@ void ScCheckListMenuWindow::initMembers() } } +void ScCheckListMenuWindow::setConfig(const Config& rConfig) +{ + maConfig = rConfig; +} + const Size& ScCheckListMenuWindow::getWindowSize() const { return maWndSize; -- cgit