Resolves: tdf#124467 enable wrap text to return to TRISTATE_INDET

Change-Id: Ie956560885fd9bb9e7367018a2f6e37a26c3c6af
Reviewed-on: https://gerrit.libreoffice.org/72494
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/align.hxx b/cui/source/inc/align.hxx
index 374a57c..063d5b1 100644
--- a/cui/source/inc/align.hxx
+++ b/cui/source/inc/align.hxx
@@ -71,9 +71,19 @@ private:
    bool                HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const;

    DECL_LINK(UpdateEnableHdl, weld::ComboBox&, void);
    DECL_LINK(UpdateEnableClickHdl, weld::ToggleButton&, void);
    DECL_LINK(StackedClickHdl, weld::ToggleButton&, void);
    DECL_LINK(AsianModeClickHdl, weld::ToggleButton&, void);
    DECL_LINK(WrapClickHdl, weld::ToggleButton&, void);
    DECL_LINK(HyphenClickHdl, weld::ToggleButton&, void);
    DECL_LINK(ShrinkClickHdl, weld::ToggleButton&, void);

private:
    weld::TriStateEnabled m_aStackedState;
    weld::TriStateEnabled m_aAsianModeState;
    weld::TriStateEnabled m_aWrapState;
    weld::TriStateEnabled m_aHyphenState;
    weld::TriStateEnabled m_aShrinkState;

    SvxDialControl m_aCtrlDial;
    SvtValueSet m_aVsRefEdge;

diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index e9cf393..900a91f 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -143,8 +143,12 @@ AlignmentTabPage::AlignmentTabPage(TabPageParent pParent, const SfxItemSet& rCor
    InitVsRefEgde();

    m_xLbHorAlign->connect_changed(LINK(this, AlignmentTabPage, UpdateEnableHdl));
    m_xBtnWrap->connect_toggled(LINK(this, AlignmentTabPage, UpdateEnableClickHdl));
    m_xCbStacked->connect_toggled(LINK(this, AlignmentTabPage, UpdateEnableClickHdl));

    m_xCbStacked->connect_toggled(LINK(this, AlignmentTabPage, StackedClickHdl));
    m_xCbAsianMode->connect_toggled(LINK(this, AlignmentTabPage, AsianModeClickHdl));
    m_xBtnWrap->connect_toggled(LINK(this, AlignmentTabPage, WrapClickHdl));
    m_xBtnHyphen->connect_toggled(LINK(this, AlignmentTabPage, HyphenClickHdl));
    m_xBtnShrink->connect_toggled(LINK(this, AlignmentTabPage, ShrinkClickHdl));

    // Asian vertical mode
    m_xCbAsianMode->set_visible(SvtCJKOptions().IsVerticalTextEnabled());
@@ -322,26 +326,30 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )

namespace
{
    void ResetBool(sal_uInt16 nWhich, const SfxItemSet* pSet, weld::CheckButton& rBtn)
    void ResetBool(sal_uInt16 nWhich, const SfxItemSet* pSet, weld::CheckButton& rBtn, weld::TriStateEnabled& rTriState)
    {
        SfxItemState eState = pSet->GetItemState(nWhich);
        switch (eState)
        {
            case SfxItemState::UNKNOWN:
                rBtn.hide();
                rTriState.bTriStateEnabled = false;
                break;
            case SfxItemState::DISABLED:
            case SfxItemState::READONLY:
                rBtn.set_sensitive(false);
                rTriState.bTriStateEnabled = false;
                break;
            case SfxItemState::DONTCARE:
                rBtn.set_state(TRISTATE_INDET);
                rTriState.bTriStateEnabled = true;
                break;
            case SfxItemState::DEFAULT:
            case SfxItemState::SET:
            {
                const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(pSet->Get(nWhich));
                rBtn.set_state(static_cast<TriState>(rItem.GetValue()));
                rTriState.bTriStateEnabled = false;
                break;
            }
        }
@@ -353,11 +361,11 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs)
{
    SfxTabPage::Reset(pCoreAttrs);

    ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED), pCoreAttrs, *m_xCbStacked);
    ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), pCoreAttrs, *m_xCbAsianMode);
    ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK), pCoreAttrs, *m_xBtnWrap);
    ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION), pCoreAttrs, *m_xBtnHyphen);
    ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), pCoreAttrs, *m_xBtnShrink);
    ResetBool(GetWhich(SID_ATTR_ALIGN_STACKED), pCoreAttrs, *m_xCbStacked, m_aStackedState);
    ResetBool(GetWhich(SID_ATTR_ALIGN_ASIANVERTICAL), pCoreAttrs, *m_xCbAsianMode, m_aAsianModeState);
    ResetBool(GetWhich(SID_ATTR_ALIGN_LINEBREAK), pCoreAttrs, *m_xBtnWrap, m_aWrapState);
    ResetBool(GetWhich(SID_ATTR_ALIGN_HYPHENATION), pCoreAttrs, *m_xBtnHyphen, m_aHyphenState);
    ResetBool(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), pCoreAttrs, *m_xBtnShrink, m_aShrinkState);

    sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
    SfxItemState eState = pCoreAttrs->GetItemState(nWhich);
@@ -676,8 +684,30 @@ bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 n
    return eMethodOld != eMethodNew;
}

IMPL_LINK_NOARG(AlignmentTabPage, UpdateEnableClickHdl, weld::ToggleButton&, void)
IMPL_LINK(AlignmentTabPage, StackedClickHdl, weld::ToggleButton&, rToggle, void)
{
    m_aStackedState.ButtonToggled(rToggle);
    UpdateEnableControls();
}

IMPL_LINK(AlignmentTabPage, AsianModeClickHdl, weld::ToggleButton&, rToggle, void)
{
    m_aAsianModeState.ButtonToggled(rToggle);
}

IMPL_LINK(AlignmentTabPage, WrapClickHdl, weld::ToggleButton&, rToggle, void)
{
    m_aWrapState.ButtonToggled(rToggle);
}

IMPL_LINK(AlignmentTabPage, HyphenClickHdl, weld::ToggleButton&, rToggle, void)
{
    m_aHyphenState.ButtonToggled(rToggle);
}

IMPL_LINK(AlignmentTabPage, ShrinkClickHdl, weld::ToggleButton&, rToggle, void)
{
    m_aShrinkState.ButtonToggled(rToggle);
    UpdateEnableControls();
}