Kaydet (Commit) eef7b7c4 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#125106 fix cell protect TriState toggles

Change-Id: I1f145558fe9d86682e03481fb2800386d04d2b1d
Reviewed-on: https://gerrit.libreoffice.org/71904Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 25876150
...@@ -47,10 +47,10 @@ ScTabPageProtection::ScTabPageProtection(TabPageParent pParent, const SfxItemSet ...@@ -47,10 +47,10 @@ ScTabPageProtection::ScTabPageProtection(TabPageParent pParent, const SfxItemSet
// States will be set in Reset // States will be set in Reset
bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false; bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false;
m_xBtnProtect->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl)); m_xBtnProtect->connect_toggled(LINK(this, ScTabPageProtection, ProtectClickHdl));
m_xBtnHideCell->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl)); m_xBtnHideCell->connect_toggled(LINK(this, ScTabPageProtection, HideCellClickHdl));
m_xBtnHideFormula->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl)); m_xBtnHideFormula->connect_toggled(LINK(this, ScTabPageProtection, HideFormulaClickHdl));
m_xBtnHidePrint->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl)); m_xBtnHidePrint->connect_toggled(LINK(this, ScTabPageProtection, HidePrintClickHdl));
} }
ScTabPageProtection::~ScTabPageProtection() ScTabPageProtection::~ScTabPageProtection()
...@@ -96,14 +96,10 @@ void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs ) ...@@ -96,14 +96,10 @@ void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
bHidePrint = pProtAttr->GetHidePrint(); bHidePrint = pProtAttr->GetHidePrint();
} }
// Start Controls aHideCellState.bTriStateEnabled = bTriEnabled;
if (bTriEnabled) aProtectState.bTriStateEnabled = bTriEnabled;
{ aHideFormulaState.bTriStateEnabled = bTriEnabled;
m_xBtnProtect->set_state(TRISTATE_INDET); aHidePrintState.bTriStateEnabled = bTriEnabled;
m_xBtnHideCell->set_state(TRISTATE_INDET);
m_xBtnHideFormula->set_state(TRISTATE_INDET);
m_xBtnHidePrint->set_state(TRISTATE_INDET);
}
UpdateButtons(); UpdateButtons();
} }
...@@ -146,7 +142,51 @@ DeactivateRC ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP ) ...@@ -146,7 +142,51 @@ DeactivateRC ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
return DeactivateRC::LeavePage; 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(); TriState eState = rBox.get_state();
if (eState == TRISTATE_INDET) if (eState == TRISTATE_INDET)
...@@ -190,6 +230,11 @@ void ScTabPageProtection::UpdateButtons() ...@@ -190,6 +230,11 @@ void ScTabPageProtection::UpdateButtons()
m_xBtnHidePrint->set_state(bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE); 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); bool bEnable = (m_xBtnHideCell->get_state() != TRISTATE_TRUE);
{ {
m_xBtnProtect->set_sensitive(bEnable); m_xBtnProtect->set_sensitive(bEnable);
......
...@@ -22,6 +22,18 @@ ...@@ -22,6 +22,18 @@
#include <sfx2/tabdlg.hxx> #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 class ScTabPageProtection : public SfxTabPage
{ {
friend class VclPtr<ScTabPageProtection>; friend class VclPtr<ScTabPageProtection>;
...@@ -50,14 +62,23 @@ private: ...@@ -50,14 +62,23 @@ private:
bool bHideCell; bool bHideCell;
bool bHidePrint; bool bHidePrint;
TriStateEnabled aHideCellState;
TriStateEnabled aProtectState;
TriStateEnabled aHideFormulaState;
TriStateEnabled aHidePrintState;
std::unique_ptr<weld::CheckButton> m_xBtnHideCell; std::unique_ptr<weld::CheckButton> m_xBtnHideCell;
std::unique_ptr<weld::CheckButton> m_xBtnProtect; std::unique_ptr<weld::CheckButton> m_xBtnProtect;
std::unique_ptr<weld::CheckButton> m_xBtnHideFormula; std::unique_ptr<weld::CheckButton> m_xBtnHideFormula;
std::unique_ptr<weld::CheckButton> m_xBtnHidePrint; std::unique_ptr<weld::CheckButton> m_xBtnHidePrint;
// Handler: // Handler:
DECL_LINK(ButtonClickHdl, weld::ToggleButton&, void); DECL_LINK(ProtectClickHdl, weld::ToggleButton&, void);
void UpdateButtons(); 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 #endif // INCLUDED_SC_SOURCE_UI_INC_TABPAGES_HXX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment