summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2023-04-06 13:00:53 +0300
committerTomaž Vajngerl <quikee@gmail.com>2023-04-12 06:06:43 +0200
commit7e72c0cf0ac69f8c76ccaf0806ef85a8c1532664 (patch)
tree66022c7b165035f6fded61074ae00c626a14b571 /svx
parent83829de5ad87240d2c54925da23a84c1e8964c54 (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150236 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdattr.cxx1
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx14
2 files changed, 10 insertions, 5 deletions
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);