Related: tdf#129300 add ScHyphenateCell to provide a description

Change-Id: If00a50a36cf2bb5c9b775a4ca1000af5c5be7bf4
Reviewed-on: https://gerrit.libreoffice.org/84892
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 1994a7e8..ead7d7d 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -298,7 +298,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )

    if (m_xBtnHyphen->get_state_changed_from_saved())
    {
        rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_HYPHENATION), m_xBtnHyphen->get_active()));
        const SfxBoolItem* pHyphItem = static_cast<const SfxBoolItem*>(GetOldItem(
                                            *rSet, SID_ATTR_ALIGN_HYPHENATION));
        assert(pHyphItem);
        std::unique_ptr<SfxBoolItem> pNewHyphItem(static_cast<SfxBoolItem*>(pHyphItem->Clone()));
        pNewHyphItem->SetValue(m_xBtnHyphen->get_active());
        rSet->Put(*pNewHyphItem);
        bChanged = true;
    }

diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 100766e..59be64fb 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -333,6 +333,18 @@ public:
                                 const IntlWrapper& rIntl) const override;
};

class SC_DLLPUBLIC ScHyphenateCell final : public SfxBoolItem
{
public:
    ScHyphenateCell(bool bHyphenate= false);
    virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override;
    virtual bool GetPresentation(SfxItemPresentation ePres,
                                 MapUnit eCoreMetric,
                                 MapUnit ePresMetric,
                                 OUString &rText,
                                 const IntlWrapper& rIntl) const override;
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 518d033..4f13865 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -521,6 +521,8 @@
#define STR_VERTICALSTACKCELL_OFF               NC_("STR_VERTICALSTACKCELL_OFF", "Vertically stacked: Off")
#define STR_LINEBREAKCELL_ON                    NC_("STR_LINEBREAKCELL_ON", "Wrap text automatically: On")
#define STR_LINEBREAKCELL_OFF                   NC_("STR_LINEBREAKCELL_OFF", "Wrap text automatically: Off")
#define STR_HYPHENATECELL_ON                    NC_("STR_HYPHENATECELL_ON", "Hyphenate: On")
#define STR_HYPHENATECELL_OFF                   NC_("STR_HYPHENATECELL_OFF", "Hyphenate: Off")

#endif

diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index ce40a2c..674bf07 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -111,7 +111,7 @@ class SvxSizeItem;
#define ATTR_USERDEF            TypedWhichId<SvXMLAttrContainerItem>(122)    // not saved in binary files
#define ATTR_FONT_WORDLINE      TypedWhichId<SvxWordLineModeItem>(123)
#define ATTR_FONT_RELIEF        TypedWhichId<SvxCharReliefItem>(124)
#define ATTR_HYPHENATE          TypedWhichId<SfxBoolItem>(125)
#define ATTR_HYPHENATE          TypedWhichId<ScHyphenateCell>(125)
#define ATTR_SCRIPTSPACE        TypedWhichId<SvxScriptSpaceItem>(126)
#define ATTR_HANGPUNCTUATION    TypedWhichId<SvxHangingPunctuationItem>(127)
#define ATTR_FORBIDDEN_RULES    TypedWhichId<SvxForbiddenRuleItem>(128)
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 75337c0..4ed6188 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -808,4 +808,24 @@ bool ScLineBreakCell::GetPresentation(SfxItemPresentation,
    return true;
}

ScHyphenateCell::ScHyphenateCell(bool bHyphenate)
    : SfxBoolItem(ATTR_HYPHENATE, bHyphenate)
{
}

ScHyphenateCell* ScHyphenateCell::Clone(SfxItemPool*) const
{
    return new ScHyphenateCell(GetValue());
}

bool ScHyphenateCell::GetPresentation(SfxItemPresentation,
                                      MapUnit, MapUnit,
                                      OUString& rText,
                                      const IntlWrapper&) const
{
    const char* pId = GetValue() ? STR_HYPHENATECELL_ON : STR_HYPHENATECELL_OFF;
    rText = ScResId(pId);
    return true;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 2df0bfc..148438d 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -240,7 +240,7 @@ ScDocumentPool::ScDocumentPool()
    mvPoolDefaults[ ATTR_USERDEF         - ATTR_STARTINDEX ] = new SvXMLAttrContainerItem( ATTR_USERDEF );
    mvPoolDefaults[ ATTR_FONT_WORDLINE   - ATTR_STARTINDEX ] = new SvxWordLineModeItem(false, ATTR_FONT_WORDLINE );
    mvPoolDefaults[ ATTR_FONT_RELIEF     - ATTR_STARTINDEX ] = new SvxCharReliefItem( FontRelief::NONE, ATTR_FONT_RELIEF );
    mvPoolDefaults[ ATTR_HYPHENATE       - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_HYPHENATE );
    mvPoolDefaults[ ATTR_HYPHENATE       - ATTR_STARTINDEX ] = new ScHyphenateCell();
    mvPoolDefaults[ ATTR_SCRIPTSPACE     - ATTR_STARTINDEX ] = new SvxScriptSpaceItem( false, ATTR_SCRIPTSPACE);
    mvPoolDefaults[ ATTR_HANGPUNCTUATION - ATTR_STARTINDEX ] = new SvxHangingPunctuationItem( false, ATTR_HANGPUNCTUATION);
    mvPoolDefaults[ ATTR_FORBIDDEN_RULES - ATTR_STARTINDEX ] = new SvxForbiddenRuleItem( false, ATTR_FORBIDDEN_RULES);
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 996afb8..d7fc012 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -663,7 +663,7 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& r

        if ( pCondSet->GetItemState( ATTR_HYPHENATE, true, &pItem ) != SfxItemState::SET )
            pItem = &rSrcSet.Get( ATTR_HYPHENATE );
        bHyphenate = static_cast<const SfxBoolItem*>(pItem)->GetValue();
        bHyphenate = static_cast<const ScHyphenateCell*>(pItem)->GetValue();

        if ( pCondSet->GetItemState( ATTR_WRITINGDIR, true, &pItem ) != SfxItemState::SET )
            pItem = &rSrcSet.Get( ATTR_WRITINGDIR );