summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-18 16:56:10 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-18 16:59:43 -0500
commit898c527481059017c8f75ba51bfc80b297f0480d (patch)
treee42cb7b792c9832e1848d963a512cb9f52e47a4d
parentb352f5357c95cf37ffa1debb1ffe62b84c223509 (diff)
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.
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx20
-rw-r--r--sc/source/ui/inc/checklistmenu.hxx11
-rw-r--r--sc/source/ui/view/gridwin.cxx3
3 files changed, 33 insertions, 1 deletions
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<sal_uInt16>(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;
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 34b3be71cbef..4a1458aae95e 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -216,6 +216,15 @@ public:
*/
struct ExtendedData {};
+ /**
+ * Configuration options for this popup window.
+ */
+ struct Config
+ {
+ bool mbAllowEmptySet;
+ Config();
+ };
+
explicit ScCheckListMenuWindow(Window* pParent, ScDocument* pDoc);
virtual ~ScCheckListMenuWindow();
@@ -228,6 +237,7 @@ public:
void setMemberSize(size_t n);
void addMember(const ::rtl::OUString& rName, bool bVisible);
void initMembers();
+ void setConfig(const Config& rConfig);
const Size& getWindowSize() const;
@@ -318,6 +328,7 @@ private:
boost::scoped_ptr<Action> mpOKAction;
boost::scoped_ptr<Action> mpPopupEndAction;
+ Config maConfig;
Size maWndSize; /// whole window size.
Size maMenuSize; /// size of all menu items combined.
TriState mePrevToggleAllState;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index cb351dc61fa8..b533a82e03f0 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -715,6 +715,9 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup->addMenuItem(
ScResId::toString(ScResId(SCSTR_NOTEMPTY)), true, new AutoFilterAction(this, NonEmpty));
+ ScCheckListMenuWindow::Config aConfig;
+ aConfig.mbAllowEmptySet = false;
+ mpAutoFilterPopup->setConfig(aConfig);
mpAutoFilterPopup->launch(aCellRect);
}