diff options
author | László Németh <nemeth@numbertext.org> | 2024-03-18 21:55:23 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2024-03-20 13:04:09 +0100 |
commit | 3a332d9f1cacb3c6f81fcf6c08afa51d091ddff4 (patch) | |
tree | 69e2b79224aeea2e74bee4922f1e6cc254dd64c9 /include | |
parent | e68a15941926965575cedcacbe0d301111388bef (diff) |
tdf#158885 cui offapi sw xmloff: fix hyphenation at stem boundary
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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/editrids.hrc | 1 | ||||
-rw-r--r-- | include/editeng/hyphenzoneitem.hxx | 4 | ||||
-rw-r--r-- | include/editeng/memberids.h | 1 | ||||
-rw-r--r-- | include/linguistic/lngprophelp.hxx | 4 | ||||
-rw-r--r-- | include/unotools/linguprops.hxx | 2 | ||||
-rw-r--r-- | include/xmloff/xmltoken.hxx | 1 |
6 files changed, 13 insertions, 0 deletions
diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc index 2fd74999c980..0f1a198dffc8 100644 --- a/include/editeng/editrids.hrc +++ b/include/editeng/editrids.hrc @@ -230,6 +230,7 @@ #define RID_SVXITEMS_ORPHANS_COMPLETE NC_("RID_SVXITEMS_ORPHANS_COMPLETE", "Orphan control") #define RID_SVXITEMS_HYPHEN_MINLEAD NC_("RID_SVXITEMS_HYPHEN_MINLEAD", "%1 characters at end of line") #define RID_SVXITEMS_HYPHEN_MINTRAIL NC_("RID_SVXITEMS_HYPHEN_MINTRAIL", "%1 characters at beginning of line") +#define RID_SVXITEMS_HYPHEN_COMPOUND_MINLEAD NC_("RID_SVXITEMS_HYPHEN_COMPOUND_MINLEAD", "%1 compound word characters at end of line") #define RID_SVXITEMS_HYPHEN_MAX NC_("RID_SVXITEMS_HYPHEN_MAX", "%1 hyphens") #define RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE NC_("RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE", "Not hyphenated CAPS") #define RID_SVXITEMS_HYPHEN_LAST_WORD_TRUE NC_("RID_SVXITEMS_HYPHEN_NO_CAPS_FALSE", "Not hyphenated last word") diff --git a/include/editeng/hyphenzoneitem.hxx b/include/editeng/hyphenzoneitem.hxx index cbe4a503a0a6..0c7fe7fb6fed 100644 --- a/include/editeng/hyphenzoneitem.hxx +++ b/include/editeng/hyphenzoneitem.hxx @@ -42,6 +42,7 @@ class EDITENG_DLLPUBLIC SvxHyphenZoneItem final : public SfxPoolItem sal_uInt8 nMinWordLength; // hyphenate only words with at least nMinWordLength characters sal_uInt16 nTextHyphenZone; // don't force hyphenation at line end, allow this extra white space sal_uInt8 nKeep; // avoid hyphenation across page etc., see ParagraphHyphenationKeep + sal_uInt8 nCompoundMinLead; // min. characters between compound word boundary and hyphenation public: static SfxPoolItem* CreateDefault(); @@ -78,6 +79,9 @@ public: sal_uInt8 &GetMinTrail() { return nMinTrail; } sal_uInt8 GetMinTrail() const { return nMinTrail; } + sal_uInt8 &GetCompoundMinLead() { return nCompoundMinLead; } + sal_uInt8 GetCompoundMinLead() const { return nCompoundMinLead; } + sal_uInt8 &GetMaxHyphens() { return nMaxHyphens; } sal_uInt8 GetMaxHyphens() const { return nMaxHyphens; } diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index d1245172eee5..f913921a6ee8 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -52,6 +52,7 @@ #define MID_HYPHEN_MIN_WORD_LENGTH 6 #define MID_HYPHEN_ZONE 7 #define MID_HYPHEN_KEEP 8 +#define MID_HYPHEN_COMPOUND_MIN_LEAD 9 // SvxBoxInfoItem #define MID_HORIZONTAL 1 diff --git a/include/linguistic/lngprophelp.hxx b/include/linguistic/lngprophelp.hxx index 854c2310a0c7..d9a2bd505960 100644 --- a/include/linguistic/lngprophelp.hxx +++ b/include/linguistic/lngprophelp.hxx @@ -238,6 +238,7 @@ class PropertyHelper_Hyphen final : // default values sal_Int16 nHyphMinLeading, nHyphMinTrailing, + nHyphCompoundMinLeading, nHyphMinWordLength, nHyphTextHyphenZone; bool bNoHyphenateCaps; @@ -245,6 +246,7 @@ class PropertyHelper_Hyphen final : // return values, will be set to default value or current temporary value sal_Int16 nResHyphMinLeading, nResHyphMinTrailing, + nResHyphCompoundMinLeading, nResHyphMinWordLength, nResHyphTextHyphenZone; bool bResNoHyphenateCaps; @@ -272,6 +274,7 @@ public: sal_Int16 GetMinLeading() const { return nResHyphMinLeading; } sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; } + sal_Int16 GetCompoundMinLeading() const { return nResHyphCompoundMinLeading; } sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; } sal_Int16 GetTextHyphenZone() const { return nResHyphTextHyphenZone; } bool IsNoHyphenateCaps() const { return bResNoHyphenateCaps; } @@ -296,6 +299,7 @@ public: void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); sal_Int16 GetMinLeading() const; sal_Int16 GetMinTrailing() const; + sal_Int16 GetCompoundMinLeading() const; sal_Int16 GetMinWordLength() const; sal_Int16 GetTextHyphenZone() const; bool IsNoHyphenateCaps() const; diff --git a/include/unotools/linguprops.hxx b/include/unotools/linguprops.hxx index 4c04e982cfa5..f6f0ffc1aa40 100644 --- a/include/unotools/linguprops.hxx +++ b/include/unotools/linguprops.hxx @@ -37,6 +37,7 @@ inline constexpr OUString UPN_IS_SPELL_WITH_DIGITS = u"IsSpellWithDig // UNO property names for Hyphenator inline constexpr OUString UPN_HYPH_MIN_LEADING = u"HyphMinLeading"_ustr; inline constexpr OUString UPN_HYPH_MIN_TRAILING = u"HyphMinTrailing"_ustr; +inline constexpr OUString UPN_HYPH_COMPOUND_MIN_LEADING = u"HyphCompoundMinLeading"_ustr; inline constexpr OUString UPN_HYPH_MIN_WORD_LENGTH = u"HyphMinWordLength"_ustr; inline constexpr OUString UPN_HYPH_NO_CAPS = u"HyphNoCaps"_ustr; inline constexpr OUString UPN_HYPH_NO_LAST_WORD = u"HyphNoLastWord"_ustr; @@ -109,6 +110,7 @@ inline constexpr OUString UPN_IS_GRAMMAR_INTERACTIVE = u"IsInteractiveG #define UPH_HYPH_NO_LAST_WORD 32 #define UPH_HYPH_ZONE 33 #define UPH_HYPH_KEEP 34 +#define UPH_HYPH_COMPOUND_MIN_LEADING 35 #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index ce732e3911a6..e5c34c8cafbc 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -1063,6 +1063,7 @@ namespace xmloff::token { XML_HYPHENATION_NO_LAST_WORD, XML_HYPHENATION_WORD_CHAR_COUNT, XML_HYPHENATION_ZONE, + XML_HYPHENATION_COMPOUND_REMAIN_CHAR_COUNT, XML_I, XML_ICON, XML_ICON_SET, |