From 3a332d9f1cacb3c6f81fcf6c08afa51d091ddff4 Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 18 Mar 2024 21:55:23 +0100 Subject: tdf#158885 cui offapi sw xmloff: fix hyphenation at stem boundary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new hyphenation option "Compound characters at line end", equivalent of libhyphen's COMPOUNDLEFTHYPHENMIN, to limit bad pattern based hyphenation of compound words using morphological analysis of Hunspell. * Add checkbox to Text Flow in paragraph formatting dialog window * Store property in paragraph model: css::style::ParagraphProperties::ParaHyphenationCompoundMinLeadingChars * Add ODF import/export (loext:hyphenation-compound-remain-char-count) * Add ODF unit tests Note: slower Hunspell based hyphenation is used only if ParaHyphenationCompoundMinLeadingChars >= 3 (we assume that libhyphen hyphenation patterns cover the smaller distances correctly). Hunpell based hyphenation doesn't introduce new hyphenation breaks, only detects the stem boundaries from the libhyphen based hyphenation breaks. Follow-up to commit c899d3608d30f3ab4c2bc193c1fcd765221614a4 "tdf#158885 sw: don't hyphenate right after a stem boundary", replacing hyphenation zone dependence with the new "Compound characters at line end". Note: preset COMPOUNDLEFTHYPHENMIN values aren't loaded yet from hyphenation dictionaries. Note: the suffix of the last stem of the compound is always hyphenated, i.e. the distance limits only hyphenation inside the stem, not inside its suffix or at the end of the stem before the suffix. Change-Id: I46a0288929a66f7453e3ff97fbc5a0c6a01f038f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164983 Tested-by: László Németh Reviewed-by: László Németh --- editeng/source/items/paraitem.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'editeng') diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index 40a057abf1b1..3e99813f628d 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -568,7 +568,8 @@ SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph, const sal_uInt16 nId ) : nMaxHyphens(255), nMinWordLength(0), nTextHyphenZone(0), - nKeep(0) // TODO change default value to COLUMN + nKeep(0), // TODO change default value to COLUMN + nCompoundMinLead(0) { } @@ -605,6 +606,9 @@ bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) con case MID_HYPHEN_KEEP: rVal <<= static_cast(nKeep); break; + case MID_HYPHEN_COMPOUND_MIN_LEAD: + rVal <<= static_cast(nCompoundMinLead); + break; } return true; } @@ -650,6 +654,9 @@ bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) case MID_HYPHEN_KEEP: nKeep = static_cast(nNewVal); break; + case MID_HYPHEN_COMPOUND_MIN_LEAD: + nCompoundMinLead = static_cast(nNewVal); + break; } return true; } @@ -666,6 +673,7 @@ bool SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const && rItem.bPageEnd == bPageEnd && rItem.nMinLead == nMinLead && rItem.nMinTrail == nMinTrail + && rItem.nCompoundMinLead == nCompoundMinLead && rItem.nMaxHyphens == nMaxHyphens && rItem.nMinWordLength == nMinWordLength && rItem.nTextHyphenZone == nTextHyphenZone @@ -702,6 +710,7 @@ bool SvxHyphenZoneItem::GetPresentation rText += EditResId(pId) + cpDelimTmp + OUString::number( nMinLead ) + cpDelimTmp + OUString::number( nMinTrail ) + cpDelimTmp + + OUString::number( nCompoundMinLead ) + cpDelimTmp + OUString::number( nMaxHyphens ) + cpDelimTmp + OUString::number( nMinWordLength ) + cpDelimTmp + GetMetricText( nTextHyphenZone, eCoreUnit, ePresUnit, &rIntl ) + @@ -733,6 +742,8 @@ bool SvxHyphenZoneItem::GetPresentation cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_MINTRAIL).replaceAll("%1", OUString::number(nMinTrail)) + cpDelimTmp + + EditResId(RID_SVXITEMS_HYPHEN_COMPOUND_MINLEAD).replaceAll("%1", OUString::number(nCompoundMinLead)) + + cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens)) + cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_MINWORDLEN).replaceAll("%1", OUString::number(nMinWordLength)); -- cgit libreoffice-7-5+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author