diff options
author | László Németh <nemeth@numbertext.org> | 2022-06-01 16:38:28 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-06-02 09:57:39 +0200 |
commit | 7a1d4b7d1db93ca1f541856a8d00d621d50e7bd6 (patch) | |
tree | 62c14075edae32b552caf8688623d11327bc17cc /editeng/source | |
parent | 6585fe3fc154c518d657202295a2c5214de55b56 (diff) |
tdf#149420 sw offapi xmloff: add hyphenation zone
Add hyphenation zone support, i.e. allow the specified
amount of extra space in lines instead of forcing hyphenation.
It's for limiting hyphenation, used especially with
not justified paragraph alignment.
Note: this is an OOXML interoperability feature,
used also in DTP software and CSS.
* Add checkbox to Text Flow in paragraph dialog
* Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationZone)
* Add ODF import/export
* Add ODF unit test
* Add layout test
Note: extend SvxHyphenZoneItem::GetPresentation() with
missing No CAPS and No last word hyphenation options.
Note: fix OSL_ENSURE condition in SwTextFormatInfo::GetHyphValues().
Follow-up to commit 29359fc15c435cec17987fd6221ab6833d38746e
"tdf#149324 sw offapi xmloff: add option to not hyphenate short words".
Change-Id: Ib8eff6ea98a9aa5ca6cb9d17faa0bbb789687ce9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135247
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/items/paraitem.cxx | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index 202341caa949..9368dfdf3c2a 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -559,7 +559,8 @@ SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph, const sal_uInt16 nId ) : nMinLead(0), nMinTrail(0), nMaxHyphens(255), - nMinWordLength(0) + nMinWordLength(0), + nTextHyphenZone(0) { } @@ -590,6 +591,9 @@ bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) con case MID_HYPHEN_MIN_WORD_LENGTH: rVal <<= static_cast<sal_Int16>(nMinWordLength); break; + case MID_HYPHEN_ZONE: + rVal <<= static_cast<sal_Int16>(nTextHyphenZone); + break; } return true; } @@ -629,6 +633,9 @@ bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) case MID_HYPHEN_MIN_WORD_LENGTH: nMinWordLength = static_cast<sal_uInt8>(nNewVal); break; + case MID_HYPHEN_ZONE: + nTextHyphenZone = nNewVal; + break; } return true; } @@ -646,7 +653,8 @@ bool SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const && rItem.nMinLead == nMinLead && rItem.nMinTrail == nMinTrail && rItem.nMaxHyphens == nMaxHyphens - && rItem.nMinWordLength == nMinWordLength ); + && rItem.nMinWordLength == nMinWordLength + && rItem.nTextHyphenZone == nTextHyphenZone ); } SvxHyphenZoneItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const @@ -657,9 +665,9 @@ SvxHyphenZoneItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const bool SvxHyphenZoneItem::GetPresentation ( SfxItemPresentation ePres, - MapUnit /*eCoreUnit*/, - MapUnit /*ePresUnit*/, - OUString& rText, const IntlWrapper& + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, const IntlWrapper& rIntl ) const { OUString cpDelimTmp(cpDelim); @@ -680,7 +688,16 @@ bool SvxHyphenZoneItem::GetPresentation OUString::number( nMinLead ) + cpDelimTmp + OUString::number( nMinTrail ) + cpDelimTmp + OUString::number( nMaxHyphens ) + cpDelimTmp + - OUString::number( nMinWordLength ); + OUString::number( nMinWordLength ) + cpDelimTmp + + GetMetricText( nTextHyphenZone, eCoreUnit, ePresUnit, &rIntl ) + + " " + EditResId(GetMetricId(ePresUnit)); + + if ( bNoCapsHyphenation ) + rText += cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE); + + if ( bNoLastWordHyphenation ) + rText += cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_LAST_WORD_TRUE); + return true; } case SfxItemPresentation::Complete: @@ -703,6 +720,20 @@ bool SvxHyphenZoneItem::GetPresentation EditResId(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens)) + cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_MINWORDLEN).replaceAll("%1", OUString::number(nMinWordLength)); + + if ( nTextHyphenZone > 0 ) + { + rText += cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_ZONE) + + GetMetricText( nTextHyphenZone, eCoreUnit, ePresUnit, &rIntl ) + + " " + EditResId(GetMetricId(ePresUnit)); + } + + if ( bNoCapsHyphenation ) + rText += cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE); + + if ( bNoLastWordHyphenation ) + rText += cpDelimTmp + EditResId(RID_SVXITEMS_HYPHEN_LAST_WORD_TRUE); + return true; } default: ;//prevent warning |