[Libreoffice-commits] core.git: Branch 'libreoffice-6-2-4' - cui/source include/vcl sc/source vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri May 17 19:14:36 UTC 2019


 cui/source/inc/paragrph.hxx       |   28 +++++---------------
 cui/source/tabpages/paragrph.cxx  |   20 --------------
 include/vcl/weld.hxx              |   12 ++++++++
 sc/source/ui/attrdlg/tabpages.cxx |   51 ++++++++++++++++++++++++++++----------
 sc/source/ui/inc/tabpages.hxx     |   13 ++++++++-
 vcl/source/app/salvtables.cxx     |   20 ++++++++++++++
 6 files changed, 89 insertions(+), 55 deletions(-)

New commits:
commit 64576639c4f2d42268692dde8edb53d6791354cd
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: Fri May 17 21:13:49 2019 +0200

    Resolves: tdf#125106 fix cell protect TriState toggles
    
    and merge duplicated TriStateEnabled class
    
    Reviewed-on: https://gerrit.libreoffice.org/71905
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 2376db068d8194d3455681a559369e50743e29f3)
    
    Change-Id: I1f145558fe9d86682e03481fb2800386d04d2b1d
    Reviewed-on: https://gerrit.libreoffice.org/71994
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx
index 183dbba699dc..b741934754ef 100644
--- a/cui/source/inc/paragrph.hxx
+++ b/cui/source/inc/paragrph.hxx
@@ -184,18 +184,6 @@ public:
     virtual void            PageCreated(const SfxAllItemSet& aSet) override;
 };
 
-struct TriStateEnabled
-{
-    TriState eState;
-    bool bTriStateEnabled;
-    TriStateEnabled()
-        : eState(TRISTATE_INDET)
-        , bTriStateEnabled(true)
-    {
-    }
-    void ButtonToggled(weld::ToggleButton& rToggle);
-};
-
 // class SvxExtParagraphTabPage ------------------------------------------
 /*
     [Description]
@@ -235,14 +223,14 @@ protected:
 private:
     SvxExtParagraphTabPage(TabPageParent pParent, const SfxItemSet& rSet);
 
-    TriStateEnabled aHyphenState;
-    TriStateEnabled aPageBreakState;
-    TriStateEnabled aApplyCollState;
-    TriStateEnabled aPageNumState;
-    TriStateEnabled aKeepTogetherState;
-    TriStateEnabled aKeepParaState;
-    TriStateEnabled aOrphanState;
-    TriStateEnabled aWidowState;
+    weld::TriStateEnabled aHyphenState;
+    weld::TriStateEnabled aPageBreakState;
+    weld::TriStateEnabled aApplyCollState;
+    weld::TriStateEnabled aPageNumState;
+    weld::TriStateEnabled aKeepTogetherState;
+    weld::TriStateEnabled aKeepParaState;
+    weld::TriStateEnabled aOrphanState;
+    weld::TriStateEnabled aWidowState;
 
     bool                bPageBreak;
     bool                bHtmlMode;
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index a8d9d8ab6003..35515175c760 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -2063,26 +2063,6 @@ IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::ToggleButton&, rToggle, v
     WidowHdl();
 }
 
-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(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::ToggleButton&, rToggle, void)
 {
     aOrphanState.ButtonToggled(rToggle);
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 449829015054..a124cd09786d 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -627,6 +627,18 @@ public:
     virtual void connect_toggled(const Link<ToggleButton&, void>& rLink) { m_aToggleHdl = rLink; }
 };
 
+struct VCL_DLLPUBLIC TriStateEnabled
+{
+    TriState eState;
+    bool bTriStateEnabled;
+    TriStateEnabled()
+        : eState(TRISTATE_INDET)
+        , bTriStateEnabled(true)
+    {
+    }
+    void ButtonToggled(ToggleButton& rToggle);
+};
+
 class VCL_DLLPUBLIC MenuButton : virtual public ToggleButton
 {
 protected:
diff --git a/sc/source/ui/attrdlg/tabpages.cxx b/sc/source/ui/attrdlg/tabpages.cxx
index 4e82125791dc..8795514813aa 100644
--- a/sc/source/ui/attrdlg/tabpages.cxx
+++ b/sc/source/ui/attrdlg/tabpages.cxx
@@ -49,10 +49,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()
@@ -98,14 +98,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();
 }
@@ -148,7 +144,31 @@ DeactivateRC ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     return DeactivateRC::LeavePage;
 }
 
-IMPL_LINK(ScTabPageProtection, ButtonClickHdl, weld::ToggleButton&, rBox, void)
+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)
@@ -192,6 +212,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..16046ab4f6bc 100644
--- a/sc/source/ui/inc/tabpages.hxx
+++ b/sc/source/ui/inc/tabpages.hxx
@@ -50,14 +50,23 @@ private:
     bool            bHideCell;
     bool            bHidePrint;
 
+    weld::TriStateEnabled aHideCellState;
+    weld::TriStateEnabled aProtectState;
+    weld::TriStateEnabled aHideFormulaState;
+    weld::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
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index bce3b3815f06..0f925613ac8e 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3836,6 +3836,26 @@ namespace weld
             m_xContentArea->move(m_xRelocate.get(), m_xOrigParent.get());
         }
     }
+
+    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();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list