svx/source/sdr/primitive2d/sdrdecompositiontools.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
New commits: commit c0693ef135f4654d69451fc9ca5a735931aebde2 Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Mon Jan 26 14:04:42 2026 +0100 Commit: Stephan Bergmann <[email protected]> CommitDate: Mon Jan 26 16:14:45 2026 +0100 tdf#165732 Fix misaligned text when text box is too small Change-Id: Iaabc61c545d579edd02cdcb5685e8417a387b99c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198147 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 71b818d1d11d..b0237633303f 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -143,8 +143,16 @@ basegfx::B2DRange getTextAnchorRange(const attribute::SdrTextAttribute& rText, const basegfx::B2DPoint aBottomRight(rSnapRange.getMaxX() - fDistanceForTextR, rSnapRange.getMaxY() - fDistanceForTextB); basegfx::B2DRange aAnchorRange; - aAnchorRange.expand(aTopLeft); - aAnchorRange.expand(aBottomRight); + + // tdf#165732 Margins are too large in some cases (left > right or top > bottom) + // - in this case do not expand the range + bool bInvalidMargins + = (aTopLeft.getX() >= aBottomRight.getX() || aTopLeft.getY() >= aBottomRight.getY()); + if (!bInvalidMargins) + { + aAnchorRange.expand(aTopLeft); + aAnchorRange.expand(aBottomRight); + } // If the shape has no width, then don't attempt to break the text into multiple // lines, not a single character would satisfy a zero width requirement.
