include/editeng/unoprnms.hxx | 1 + include/svx/svddef.hxx | 3 ++- include/svx/unoshprp.hxx | 1 + svx/source/svdraw/svdattr.cxx | 1 + svx/source/svdraw/svdotextdecomposition.cxx | 14 +++++++++----- 5 files changed, 14 insertions(+), 6 deletions(-)
New commits: commit 7e72c0cf0ac69f8c76ccaf0806ef85a8c1532664 Author: Sarper Akdemir <sarper.akde...@collabora.com> AuthorDate: Thu Apr 6 13:00:53 2023 +0300 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Apr 12 06:06:43 2023 +0200 editeng, svx: introduce ability to clip vertical text overflow Introduces editeng text property TextClipVerticalOverflow. Which when set causes vertical text that is overflown out of a frame/shape truncated. (Only when text isn't being edited) This is implemented as two steps: (if text overflows) 1 - Vertical adjust is forced to top. (Forcing vert adjust to top isn't the desired behavior normally, but good enough for a first cut I'd say.) -> The desired behavior would be after the overflown text is truncated, doing a vertical adjust (of center/bottom/top) on that piece of text. 2 - ClipRange is set to the height of the frame/shape. This appears to work with different text directions too (vertical etc.). Change-Id: I697715a7d28bde94a6650609b16505ffab92173f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150106 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150236 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index a85afe0788f8..d47a2337e247 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -124,6 +124,7 @@ #define UNO_NAME_TEXT_FONTINDEPENDENTLINESPACING "FontIndependentLineSpacing" #define UNO_NAME_TEXT_WORDWRAP "TextWordWrap" #define UNO_NAME_TEXT_CHAINNEXTNAME "TextChainNextName" +#define UNO_NAME_TEXT_CLIPVERTOVERFLOW u"TextClipVerticalOverflow" #define UNO_NAME_MEASUREKIND "MeasureKind" #define UNO_NAME_MEASURETEXTHPOS "MeasureTextHorizontalPosition" diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx index 9332dc65a59f..9b3b1a358369 100644 --- a/include/svx/svddef.hxx +++ b/include/svx/svddef.hxx @@ -231,7 +231,8 @@ constexpr TypedWhichId<SvXMLAttrContainerItem> SDRATTR_XMLATTRIBUTES constexpr TypedWhichId<SdrTextFixedCellHeightItem> SDRATTR_TEXT_USEFIXEDCELLHEIGHT (SDRATTR_MISC_FIRST +23); /* 1121 */ /* 1121 */ /* 1104 */ /* Pool V2 */ constexpr TypedWhichId<SdrOnOffItem> SDRATTR_TEXT_WORDWRAP (SDRATTR_MISC_FIRST +24); /* 1122 */ /* 1122 */ /* 1105 */ /* Pool V2 */ constexpr TypedWhichId<SfxStringItem> SDRATTR_TEXT_CHAINNEXTNAME (SDRATTR_MISC_FIRST +25); /* 1123 */ /* 1123 */ /* 1106 */ /* Pool V2 */ -constexpr sal_uInt16 SDRATTR_MISC_LAST (SDRATTR_TEXT_CHAINNEXTNAME); /* 1125 */ /* 1125 */ /* 1108 */ /* Pool V1: 1056 */ +constexpr TypedWhichId<SdrOnOffItem> SDRATTR_TEXT_CLIPVERTOVERFLOW (SDRATTR_MISC_FIRST +26); +constexpr sal_uInt16 SDRATTR_MISC_LAST (SDRATTR_TEXT_CLIPVERTOVERFLOW); /* 1126 */ /* 1125 */ /* 1108 */ /* Pool V1: 1056 */ constexpr sal_uInt16 SDRATTR_EDGE_FIRST (SDRATTR_MISC_LAST + 1); /* 1127 */ /* Pool V4 */ constexpr TypedWhichId<SdrEdgeKindItem> SDRATTR_EDGEKIND (SDRATTR_EDGE_FIRST + 0); /* 1127 */ /* Pool V4 */ diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx index 4deec20d7783..99d305644282 100644 --- a/include/svx/unoshprp.hxx +++ b/include/svx/unoshprp.hxx @@ -325,6 +325,7 @@ { u"" UNO_NAME_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, cppu::UnoType<css::drawing::TextVerticalAdjust>::get(), 0, 0},\ { u"" UNO_NAME_TEXT_WORDWRAP, SDRATTR_TEXT_WORDWRAP, cppu::UnoType<bool>::get(), 0, 0}, \ { u"" UNO_NAME_TEXT_CHAINNEXTNAME, SDRATTR_TEXT_CHAINNEXTNAME, ::cppu::UnoType<OUString>::get(), 0, 0}, \ + { u"" UNO_NAME_TEXT_CLIPVERTOVERFLOW, SDRATTR_TEXT_CLIPVERTOVERFLOW, cppu::UnoType<bool>::get(), 0, 0}, \ { u"TextColumns", OWN_ATTR_TEXTCOLUMNS, cppu::UnoType<css::text::XTextColumns>::get(), 0, 0 }, \ SVX_UNOEDIT_CHAR_PROPERTIES, \ SVX_UNOEDIT_PARA_PROPERTIES, diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index b0df93a13855..b71ac9919f4a 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -170,6 +170,7 @@ SdrItemPool::SdrItemPool( rPoolDefaults[SDRATTR_TEXT_CHAINNEXTNAME -SDRATTR_START]=new SfxStringItem(SDRATTR_TEXT_CHAINNEXTNAME, ""); rPoolDefaults[SDRATTR_TEXT_USEFIXEDCELLHEIGHT -SDRATTR_START]=new SdrTextFixedCellHeightItem; rPoolDefaults[SDRATTR_TEXT_WORDWRAP -SDRATTR_START]=new SdrOnOffItem(SDRATTR_TEXT_WORDWRAP, true); + rPoolDefaults[SDRATTR_TEXT_CLIPVERTOVERFLOW-SDRATTR_START]=new SdrOnOffItem(SDRATTR_TEXT_CLIPVERTOVERFLOW, false); rPoolDefaults[SDRATTR_EDGEKIND -SDRATTR_START]=new SdrEdgeKindItem; rPoolDefaults[SDRATTR_EDGENODE1HORZDIST-SDRATTR_START]=new SdrEdgeNode1HorzDistItem(nDefEdgeDist); rPoolDefaults[SDRATTR_EDGENODE1VERTDIST-SDRATTR_START]=new SdrEdgeNode1VertDistItem(nDefEdgeDist); diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index dfc4acbb9aa9..311cca6c38e4 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1080,19 +1080,21 @@ void SdrTextObj::impDecomposeBlockTextPrimitive( } } + const double fFreeVerticalSpace(aAnchorTextRange.getHeight() - aOutlinerScale.getY()); + bool bClipVerticalTextOverflow = fFreeVerticalSpace < 0 + && GetObjectItemSet().Get(SDRATTR_TEXT_CLIPVERTOVERFLOW).GetValue(); // correct vertical translation using the now known text size - if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj) + if((SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj) + && !bClipVerticalTextOverflow) { - const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY()); - if(SDRTEXTVERTADJUST_CENTER == eVAdj) { - aAdjustTranslate.setY(fFree / 2.0); + aAdjustTranslate.setY(fFreeVerticalSpace / 2.0); } if(SDRTEXTVERTADJUST_BOTTOM == eVAdj) { - aAdjustTranslate.setY(fFree); + aAdjustTranslate.setY(fFreeVerticalSpace); } } @@ -1136,6 +1138,8 @@ void SdrTextObj::impDecomposeBlockTextPrimitive( // create ClipRange (if needed) basegfx::B2DRange aClipRange; + if(bClipVerticalTextOverflow) + aClipRange = {0, 0, std::numeric_limits<double>::max(), aAnchorTextRange.getHeight()}; // now break up text primitives. impTextBreakupHandler aConverter(rOutliner);