diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-01-23 15:34:07 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-01-23 19:19:07 +0100 |
commit | 6e3ad6ca0ae6cf62056610ddae9097973a887d99 (patch) | |
tree | 1118c5725953471e0fe6edc6e709202ee9e79250 /sw/source/core/layout/tabfrm.cxx | |
parent | 063781f4a94e3960a2cb40d1981c0e0ef9a73153 (diff) |
tdf#159017 sw floattable: only shift to the right when needed
Regression from commit 868140fcc1311259b9d5f666637b33d226511a53
(tdf#60558 sw floattable: allow wrap of table on the right of a
floattable, 2023-12-05), the document had an inline table, followed by a
floating table, and we moved the inline table to the right even if the
left hand side of the floating table already had enough space.
What happens here is that nominally the inline table's original position
overlaps, but because the table width is small enough, such an overlap
doesn't actually happen. In this case, it's not needed to shift the
inline table to the right.
Fix the problem by making the check that decides whether it's necessary
to increment the left margin of the table more strict: it's not enough
to have enough space on the right of the fly, it's also needed to *not*
have enough space on the left side.
This keeps the original "floating table wrapped by inline table on the
right" use-case working, but restores the ~no left margin for the inline
table for the new bugdoc.
Change-Id: Ifb30d90ca6dba7cc4a402d8a4445251120b575ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162447
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/layout/tabfrm.cxx')
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 71f677d613f5..98dc1f2743b4 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3296,6 +3296,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bool bShiftDown = css::text::WrapTextMode_NONE == nSurround; bool bSplitFly = pFly->IsFlySplitAllowed(); + const SwRect aFlyRectWithoutSpaces = pFly->GetObjRect(); if (!bShiftDown && bAddVerticalFlyOffsets) { if (nSurround == text::WrapTextMode_PARALLEL && isHoriOrientShiftDown) @@ -3310,7 +3311,6 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, // Ignore spacing when determining the left/right edge of the fly, like // Word does. - const SwRect aFlyRectWithoutSpaces = pFly->GetObjRect(); basegfx::B1DRange aFlyRange(aRectFnSet.GetLeft(aFlyRectWithoutSpaces), aRectFnSet.GetRight(aFlyRectWithoutSpaces)); @@ -3373,9 +3373,16 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bool bFlyHoriOrientLeft = text::HoriOrientation::LEFT == rHori.GetHoriOrient(); if (bSplitFly && !bFlyHoriOrientLeft) { - // If a split fly is oriented "from left", we already checked if it has enough space on - // the right, so from-left and left means the same here. - bFlyHoriOrientLeft = rHori.GetHoriOrient() == text::HoriOrientation::NONE; + // Only shift to the right if we don't have enough space on the left. + SwTwips nTabWidth = getFramePrintArea().Width(); + SwTwips nWidthDeadline = aFlyRectWithoutSpaces.Left() + - pFly->GetAnchorFrame()->GetUpper()->getFrameArea().Left(); + if (nTabWidth > nWidthDeadline) + { + // If a split fly is oriented "from left", we already checked if it has enough space on + // the right, so from-left and left means the same here. + bFlyHoriOrientLeft = rHori.GetHoriOrient() == text::HoriOrientation::NONE; + } } if ((css::text::WrapTextMode_RIGHT == nSurround || css::text::WrapTextMode_PARALLEL == nSurround) |