[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Nov 18 13:59:47 PST 2011


 sc/source/ui/cctrl/checklistmenu.cxx |   20 +++++++++++++++++++-
 sc/source/ui/inc/checklistmenu.hxx   |   11 +++++++++++
 sc/source/ui/view/gridwin.cxx        |    3 +++
 3 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 898c527481059017c8f75ba51bfc80b297f0480d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Nov 18 16:56:10 2011 -0500

    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.

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 3835ab9..e96e6d4 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 34b3be7..4a1458a 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 cb351dc..b533a82 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);
 }
 


More information about the Libreoffice-commits mailing list