[Libreoffice-commits] core.git: sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 7 15:17:17 UTC 2019


 sc/source/ui/attrdlg/tabpages.cxx |   71 +++++++++++++++++++++++++++++++-------
 sc/source/ui/inc/tabpages.hxx     |   25 ++++++++++++-
 2 files changed, 81 insertions(+), 15 deletions(-)

New commits:
commit eef7b7c467c44f86ce77f1ec483ca05f176440a7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 7 12:06:30 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 7 17:16:21 2019 +0200

    Resolves: tdf#125106 fix cell protect TriState toggles
    
    Change-Id: I1f145558fe9d86682e03481fb2800386d04d2b1d
    Reviewed-on: https://gerrit.libreoffice.org/71904
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/attrdlg/tabpages.cxx b/sc/source/ui/attrdlg/tabpages.cxx
index d974baf6bcf2..c0c2ff5ddabc 100644
--- a/sc/source/ui/attrdlg/tabpages.cxx
+++ b/sc/source/ui/attrdlg/tabpages.cxx
@@ -47,10 +47,10 @@ ScTabPageProtection::ScTabPageProtection(TabPageParent pParent, const SfxItemSet
     //  States will be set in Reset
     bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false;
 
-    m_xBtnProtect->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
-    m_xBtnHideCell->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
-    m_xBtnHideFormula->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
-    m_xBtnHidePrint->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
+    m_xBtnProtect->connect_toggled(LINK(this, ScTabPageProtection, ProtectClickHdl));
+    m_xBtnHideCell->connect_toggled(LINK(this, ScTabPageProtection, HideCellClickHdl));
+    m_xBtnHideFormula->connect_toggled(LINK(this, ScTabPageProtection, HideFormulaClickHdl));
+    m_xBtnHidePrint->connect_toggled(LINK(this, ScTabPageProtection, HidePrintClickHdl));
 }
 
 ScTabPageProtection::~ScTabPageProtection()
@@ -96,14 +96,10 @@ void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
         bHidePrint = pProtAttr->GetHidePrint();
     }
 
-    //  Start Controls
-    if (bTriEnabled)
-    {
-        m_xBtnProtect->set_state(TRISTATE_INDET);
-        m_xBtnHideCell->set_state(TRISTATE_INDET);
-        m_xBtnHideFormula->set_state(TRISTATE_INDET);
-        m_xBtnHidePrint->set_state(TRISTATE_INDET);
-    }
+    aHideCellState.bTriStateEnabled = bTriEnabled;
+    aProtectState.bTriStateEnabled = bTriEnabled;
+    aHideFormulaState.bTriStateEnabled = bTriEnabled;
+    aHidePrintState.bTriStateEnabled = bTriEnabled;
 
     UpdateButtons();
 }
@@ -146,7 +142,51 @@ DeactivateRC ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     return DeactivateRC::LeavePage;
 }
 
-IMPL_LINK(ScTabPageProtection, ButtonClickHdl, weld::ToggleButton&, rBox, void)
+void TriStateEnabled::ButtonToggled(weld::ToggleButton& rToggle)
+{
+    if (bTriStateEnabled)
+    {
+        switch (eState)
+        {
+            case TRISTATE_INDET:
+                rToggle.set_state(TRISTATE_FALSE);
+                break;
+            case TRISTATE_TRUE:
+                rToggle.set_state(TRISTATE_INDET);
+                break;
+            case TRISTATE_FALSE:
+                rToggle.set_state(TRISTATE_TRUE);
+                break;
+        }
+    }
+    eState = rToggle.get_state();
+}
+
+IMPL_LINK(ScTabPageProtection, ProtectClickHdl, weld::ToggleButton&, rBox, void)
+{
+    aProtectState.ButtonToggled(rBox);
+    ButtonClick(rBox);
+}
+
+IMPL_LINK(ScTabPageProtection, HideCellClickHdl, weld::ToggleButton&, rBox, void)
+{
+    aHideCellState.ButtonToggled(rBox);
+    ButtonClick(rBox);
+}
+
+IMPL_LINK(ScTabPageProtection, HideFormulaClickHdl, weld::ToggleButton&, rBox, void)
+{
+    aHideFormulaState.ButtonToggled(rBox);
+    ButtonClick(rBox);
+}
+
+IMPL_LINK(ScTabPageProtection, HidePrintClickHdl, weld::ToggleButton&, rBox, void)
+{
+    aHidePrintState.ButtonToggled(rBox);
+    ButtonClick(rBox);
+}
+
+void ScTabPageProtection::ButtonClick(weld::ToggleButton& rBox)
 {
     TriState eState = rBox.get_state();
     if (eState == TRISTATE_INDET)
@@ -190,6 +230,11 @@ void ScTabPageProtection::UpdateButtons()
         m_xBtnHidePrint->set_state(bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE);
     }
 
+    aHideCellState.eState = m_xBtnHideCell->get_state();
+    aProtectState.eState = m_xBtnProtect->get_state();
+    aHideFormulaState.eState = m_xBtnHideFormula->get_state();
+    aHidePrintState.eState = m_xBtnHidePrint->get_state();
+
     bool bEnable = (m_xBtnHideCell->get_state() != TRISTATE_TRUE);
     {
         m_xBtnProtect->set_sensitive(bEnable);
diff --git a/sc/source/ui/inc/tabpages.hxx b/sc/source/ui/inc/tabpages.hxx
index 8abd667ca7c7..5d195bb3cde2 100644
--- a/sc/source/ui/inc/tabpages.hxx
+++ b/sc/source/ui/inc/tabpages.hxx
@@ -22,6 +22,18 @@
 
 #include <sfx2/tabdlg.hxx>
 
+struct TriStateEnabled
+{
+    TriState eState;
+    bool bTriStateEnabled;
+    TriStateEnabled()
+        : eState(TRISTATE_INDET)
+        , bTriStateEnabled(true)
+    {
+    }
+    void ButtonToggled(weld::ToggleButton& rToggle);
+};
+
 class ScTabPageProtection : public SfxTabPage
 {
     friend class VclPtr<ScTabPageProtection>;
@@ -50,14 +62,23 @@ private:
     bool            bHideCell;
     bool            bHidePrint;
 
+    TriStateEnabled aHideCellState;
+    TriStateEnabled aProtectState;
+    TriStateEnabled aHideFormulaState;
+    TriStateEnabled aHidePrintState;
+
     std::unique_ptr<weld::CheckButton> m_xBtnHideCell;
     std::unique_ptr<weld::CheckButton> m_xBtnProtect;
     std::unique_ptr<weld::CheckButton> m_xBtnHideFormula;
     std::unique_ptr<weld::CheckButton> m_xBtnHidePrint;
 
     // Handler:
-    DECL_LINK(ButtonClickHdl, weld::ToggleButton&, void);
-    void        UpdateButtons();
+    DECL_LINK(ProtectClickHdl, weld::ToggleButton&, void);
+    DECL_LINK(HideCellClickHdl, weld::ToggleButton&, void);
+    DECL_LINK(HideFormulaClickHdl, weld::ToggleButton&, void);
+    DECL_LINK(HidePrintClickHdl, weld::ToggleButton&, void);
+    void ButtonClick(weld::ToggleButton& rBox);
+    void UpdateButtons();
 };
 
 #endif // INCLUDED_SC_SOURCE_UI_INC_TABPAGES_HXX


More information about the Libreoffice-commits mailing list