From 29359fc15c435cec17987fd6221ab6833d38746e Mon Sep 17 00:00:00 2001 From: László Németh Date: Thu, 26 May 2022 19:01:07 +0200 Subject: tdf#149324 sw offapi xmloff: add option to not hyphenate short words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- editeng/source/items/paraitem.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'editeng') diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index 56d9628276b3..202341caa949 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -558,7 +558,8 @@ SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph, const sal_uInt16 nId ) : bNoLastWordHyphenation(false), nMinLead(0), nMinTrail(0), - nMaxHyphens(255) + nMaxHyphens(255), + nMinWordLength(0) { } @@ -586,6 +587,9 @@ bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) con case MID_HYPHEN_NO_LAST_WORD: rVal <<= bNoLastWordHyphenation; break; + case MID_HYPHEN_MIN_WORD_LENGTH: + rVal <<= static_cast(nMinWordLength); + break; } return true; } @@ -622,6 +626,9 @@ bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) case MID_HYPHEN_NO_LAST_WORD: bNoLastWordHyphenation = Any2Bool(rVal); break; + case MID_HYPHEN_MIN_WORD_LENGTH: + nMinWordLength = static_cast(nNewVal); + break; } return true; } @@ -638,7 +645,8 @@ bool SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const && rItem.bPageEnd == bPageEnd && rItem.nMinLead == nMinLead && rItem.nMinTrail == nMinTrail - && rItem.nMaxHyphens == nMaxHyphens ); + && rItem.nMaxHyphens == nMaxHyphens + && rItem.nMinWordLength == nMinWordLength ); } SvxHyphenZoneItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const @@ -671,7 +679,8 @@ bool SvxHyphenZoneItem::GetPresentation rText += EditResId(pId) + cpDelimTmp + OUString::number( nMinLead ) + cpDelimTmp + OUString::number( nMinTrail ) + cpDelimTmp + - OUString::number( nMaxHyphens ); + OUString::number( nMaxHyphens ) + cpDelimTmp + + OUString::number( nMinWordLength ); return true; } case SfxItemPresentation::Complete: @@ -691,7 +700,9 @@ bool SvxHyphenZoneItem::GetPresentation cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_MINTRAIL).replaceAll("%1", OUString::number(nMinTrail)) + cpDelimTmp + - EditResId(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens)); + EditResId(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens)) + + cpDelimTmp + + EditResId(RID_SVXITEMS_HYPHEN_MINWORDLEN).replaceAll("%1", OUString::number(nMinWordLength)); return true; } default: ;//prevent warning -- cgit