diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2023-04-06 13:00:53 +0300 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-04-10 08:52:42 +0200 |
commit | 1934698260222f6727ac43118933094fa84dcdea (patch) | |
tree | a4035ba860f5cf0eaed11691af935575957fadf4 /svx | |
parent | 185cf4496d8750c9e4905c4e384252b01b85d130 (diff) |
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 <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svdotextdecomposition.cxx | 14 |
2 files changed, 10 insertions, 5 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 3503fae4f6ce..5af9956fc45d 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -171,6 +171,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 ddbc6bfe540a..138b709e9769 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1103,19 +1103,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); } } @@ -1159,6 +1161,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); |