diff options
author | László Németh <nemeth@numbertext.org> | 2022-05-26 09:09:38 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-05-26 16:37:02 +0200 |
commit | 8c018910ae4d8701b1ce2a95727b9baed4016da3 (patch) | |
tree | e0155b8a29d3b60cd78dd98c8bcf57df612d477a /sw/source/core/text/inftxt.cxx | |
parent | ec694a32ea6c9f0287e8c12f4de62047abfcde72 (diff) |
tdf#149248 sw offapi xmloff: add option to not hyphenate last word
Add option to disable automatic hyphenation of the last word of
paragraphs for better typography.
Note: the same option used e.g. in Adobe InDesign, and a
similar one in CSS Text Module Level 4 (hyphenate-limit-last).
* Add checkbox to Text Flow in paragraph dialog
* Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationNoLastWord)
* Add ODF import/export
* Add ODF unit test
* Add layout test
Follow-up to commit 72bd0df107ee47c4d54fa88b4960d32ea03e9f69
"tdf#121658 Add option to not hyphenate words in CAPS".
Change-Id: Ida29c65b5a7cbfd7c399c342781531a6fb86f639
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134985
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/text/inftxt.cxx')
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 5f4cbb95b6fc..6f22e920d135 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1360,13 +1360,14 @@ void SwTextPaintInfo::DrawViewOpt( const SwLinePortion &rPor, } static void lcl_InitHyphValues( PropertyValues &rVals, - sal_Int16 nMinLeading, sal_Int16 nMinTrailing, bool bNoCapsHyphenation ) + sal_Int16 nMinLeading, sal_Int16 nMinTrailing, + bool bNoCapsHyphenation, bool bNoLastWordHyphenation ) { sal_Int32 nLen = rVals.getLength(); if (0 == nLen) // yet to be initialized? { - rVals.realloc( 3 ); + rVals.realloc( 4 ); PropertyValue *pVal = rVals.getArray(); pVal[0].Name = UPN_HYPH_MIN_LEADING; @@ -1380,13 +1381,18 @@ static void lcl_InitHyphValues( PropertyValues &rVals, pVal[2].Name = UPN_HYPH_NO_CAPS; pVal[2].Handle = UPH_HYPH_NO_CAPS; pVal[2].Value <<= bNoCapsHyphenation; + + pVal[3].Name = UPN_HYPH_NO_LAST_WORD; + pVal[3].Handle = UPH_HYPH_NO_LAST_WORD; + pVal[3].Value <<= bNoLastWordHyphenation; } - else if (3 == nLen) // already initialized once? + else if (4 == nLen) // already initialized once? { PropertyValue *pVal = rVals.getArray(); pVal[0].Value <<= nMinLeading; pVal[1].Value <<= nMinTrailing; pVal[2].Value <<= bNoCapsHyphenation; + pVal[3].Value <<= bNoLastWordHyphenation; } else { OSL_FAIL( "unexpected size of sequence" ); @@ -1395,7 +1401,7 @@ static void lcl_InitHyphValues( PropertyValues &rVals, const PropertyValues & SwTextFormatInfo::GetHyphValues() const { - OSL_ENSURE( 3 == m_aHyphVals.getLength(), + OSL_ENSURE( 4 == m_aHyphVals.getLength(), "hyphenation values not yet initialized" ); return m_aHyphVals; } @@ -1414,7 +1420,9 @@ bool SwTextFormatInfo::InitHyph( const bool bAutoHyphen ) const sal_Int16 nMinimalLeading = std::max(rAttr.GetMinLead(), sal_uInt8(2)); const sal_Int16 nMinimalTrailing = rAttr.GetMinTrail(); const bool bNoCapsHyphenation = rAttr.IsNoCapsHyphenation(); - lcl_InitHyphValues( m_aHyphVals, nMinimalLeading, nMinimalTrailing, bNoCapsHyphenation); + const bool bNoLastWordHyphenation = rAttr.IsNoLastWordHyphenation(); + lcl_InitHyphValues( m_aHyphVals, nMinimalLeading, nMinimalTrailing, + bNoCapsHyphenation, bNoLastWordHyphenation ); } return bAuto; } |