summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-05-26 19:01:07 +0200
committerLászló Németh <nemeth@numbertext.org>2022-05-26 20:25:35 +0200
commit29359fc15c435cec17987fd6221ab6833d38746e (patch)
treec4bc33e84fee7414c0e0d5e9e6b9c77526e2aa68 /sw/source
parent3cde7345199b535763bb7d83a87096e9157b7317 (diff)
tdf#149324 sw offapi xmloff: add option to not hyphenate short words
Add paragraph property to disable automatic hyphenation of short words based on a minimum character count. Note: there is a (broken) global option for Minimum Word Length at hyphenation, see "Minimal number of characters for hyphenation" in Tools->Options->Language Settings->Writing Aids), but for better/comfortable paragraph-level adjustment of typesetting, add a paragraph property for it. The same option is available e.g. in Adobe InDesign and in CSS Text Module Level 4 (hyphenate-limit-chars). * Add checkbox to Text Flow in paragraph dialog * Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationMinWordLength) * Add ODF import/export * Add ODF unit test * Add layout test Follow-up to commit 8c018910ae4d8701b1ce2a95727b9baed4016da3 "tdf#149248 sw offapi xmloff: add option to not hyphenate last word". Change-Id: I68715f47d17b5c022430bd0e74c88a97bc7f81f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135028 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/text/inftxt.cxx14
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx2
-rw-r--r--sw/source/uibase/app/docshini.cxx1
-rw-r--r--sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx1
4 files changed, 14 insertions, 4 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 6f22e920d135..5a794370b6da 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1361,13 +1361,13 @@ void SwTextPaintInfo::DrawViewOpt( const SwLinePortion &rPor,
static void lcl_InitHyphValues( PropertyValues &rVals,
sal_Int16 nMinLeading, sal_Int16 nMinTrailing,
- bool bNoCapsHyphenation, bool bNoLastWordHyphenation )
+ bool bNoCapsHyphenation, bool bNoLastWordHyphenation, sal_Int16 nMinWordLength )
{
sal_Int32 nLen = rVals.getLength();
if (0 == nLen) // yet to be initialized?
{
- rVals.realloc( 4 );
+ rVals.realloc( 5 );
PropertyValue *pVal = rVals.getArray();
pVal[0].Name = UPN_HYPH_MIN_LEADING;
@@ -1385,14 +1385,19 @@ static void lcl_InitHyphValues( PropertyValues &rVals,
pVal[3].Name = UPN_HYPH_NO_LAST_WORD;
pVal[3].Handle = UPH_HYPH_NO_LAST_WORD;
pVal[3].Value <<= bNoLastWordHyphenation;
+
+ pVal[4].Name = UPN_HYPH_MIN_WORD_LENGTH;
+ pVal[4].Handle = UPH_HYPH_MIN_WORD_LENGTH;
+ pVal[4].Value <<= nMinWordLength;
}
- else if (4 == nLen) // already initialized once?
+ else if (5 == nLen) // already initialized once?
{
PropertyValue *pVal = rVals.getArray();
pVal[0].Value <<= nMinLeading;
pVal[1].Value <<= nMinTrailing;
pVal[2].Value <<= bNoCapsHyphenation;
pVal[3].Value <<= bNoLastWordHyphenation;
+ pVal[4].Value <<= nMinWordLength;
}
else {
OSL_FAIL( "unexpected size of sequence" );
@@ -1419,10 +1424,11 @@ bool SwTextFormatInfo::InitHyph( const bool bAutoHyphen )
{
const sal_Int16 nMinimalLeading = std::max(rAttr.GetMinLead(), sal_uInt8(2));
const sal_Int16 nMinimalTrailing = rAttr.GetMinTrail();
+ const sal_Int16 nMinimalWordLength = rAttr.GetMinWordLength();
const bool bNoCapsHyphenation = rAttr.IsNoCapsHyphenation();
const bool bNoLastWordHyphenation = rAttr.IsNoLastWordHyphenation();
lcl_InitHyphValues( m_aHyphVals, nMinimalLeading, nMinimalTrailing,
- bNoCapsHyphenation, bNoLastWordHyphenation );
+ bNoCapsHyphenation, bNoLastWordHyphenation, nMinimalWordLength );
}
return bAuto;
}
diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx
index ec9ce71977af..1f679b2e38fd 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -117,6 +117,7 @@
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_LEADING_CHARS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_LEAD }, \
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_TRAILING_CHARS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_TRAIL }, \
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_HYPHENS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MAX_HYPHENS }, \
+ { u"" UNO_NAME_PARA_HYPHENATION_MIN_WORD_LENGTH, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_WORD_LENGTH }, \
{ u"" UNO_NAME_CHAR_AUTO_KERNING, RES_CHRATR_AUTOKERN, cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, 0 }, \
{ u"" UNO_NAME_CHAR_BACK_COLOR, RES_CHRATR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, MID_BACK_COLOR }, \
{ u"" UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, MID_BACK_COLOR }, \
@@ -440,6 +441,7 @@
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_LEADING_CHARS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_LEAD },\
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_TRAILING_CHARS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_TRAIL },\
{ u"" UNO_NAME_PARA_HYPHENATION_MAX_HYPHENS, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MAX_HYPHENS},\
+ { u"" UNO_NAME_PARA_HYPHENATION_MIN_WORD_LENGTH, RES_PARATR_HYPHENZONE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_HYPHEN_MIN_WORD_LENGTH},\
{ u"" UNO_NAME_NUMBERING_STYLE_NAME, RES_PARATR_NUMRULE, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0},\
{ UNO_NAME_NUMBERING_LEVEL, RES_PARATR_LIST_LEVEL, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, 0},\
{ u"" UNO_NAME_PARA_USER_DEFINED_ATTRIBUTES, RES_UNKNOWNATR_CONTAINER, cppu::UnoType<css::container::XNameContainer>::get(), PropertyAttribute::MAYBEVOID, 0 },\
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
index 21cefad272cd..c5432a98af29 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -659,6 +659,7 @@ void SwDocShell::SubInitNew()
SvxHyphenZoneItem aHyp( m_xDoc->GetDefault(RES_PARATR_HYPHENZONE) );
aHyp.GetMinLead() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinLeading);
aHyp.GetMinTrail() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinTrailing);
+ aHyp.GetMinWordLength() = static_cast< sal_uInt8 >(aLinguOpt.nHyphMinWordLength);
aDfltSet.Put( aHyp );
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index 59108e4ed1f8..46b1486f5e57 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -253,6 +253,7 @@ static OUString PropertyNametoRID(const OUString& rName)
{ "ParaHyphenationMaxTrailingChars", RID_PARA_HYPHENATION_MAX_TRAILING_CHARS },
{ "ParaHyphenationNoCaps", RID_PARA_HYPHENATION_NO_CAPS },
{ "ParaHyphenationNoLastWord", RID_PARA_HYPHENATION_NO_LAST_WORD },
+ { "ParaHyphenationMinWordLength", RID_PARA_HYPHENATION_MIN_WORD_LENGTH },
{ "ParaInteropGrabBag", RID_PARA_INTEROP_GRAB_BAG },
{ "ParaIsAutoFirstLineIndent", RID_PARA_IS_AUTO_FIRST_LINE_INDENT },
{ "ParaIsCharacterDistance", RID_PARA_IS_CHARACTER_DISTANCE },