summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/tabfrm.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-12-05 08:39:10 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-12-05 10:15:52 +0100
commit868140fcc1311259b9d5f666637b33d226511a53 (patch)
treeb34ad49c9f4f9b6d25d5e0d67a2fc345893be5de /sw/source/core/layout/tabfrm.cxx
parent5b78bb218cc48207bc3943bd1eb0a34a9f7b60c3 (diff)
tdf#60558 sw floattable: allow wrap of table on the right of a floattable
The bugdoc shows that Word wraps inline tables around floating tables if they have enough space, but Writer didn't do this. Table frames may wrap fly frames by adding some top, left or right margin to the table at a layout level, this is calculated in SwTabFrame::CalcFlyOffsets(). There we currently decide the give a top margin to such tables, which fixes the overlap problem, but the bugdoc is now of 2 pages instead of 1 page, since we don't wrap. Fix the problem by improving the "shift down" case by checking if shifting to the right would also work (has enough space). If so, do that in case the fly frame is a split fly. Note that this could be done for all flys as well, but that would have to be conditional on some Word compat flag and that's not needed to fix the bugdoc, so leave that for later. Change-Id: Idb45413257758fd0334b17ef348ba28010a52316 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160331 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.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 4367d86255a2..c1acc0c9e9fe 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3179,6 +3179,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
nSurround = text::WrapTextMode_PARALLEL;
bool bShiftDown = css::text::WrapTextMode_NONE == nSurround;
+ bool bSplitFly = pFly->IsFlySplitAllowed();
if (!bShiftDown && bAddVerticalFlyOffsets)
{
if (nSurround == text::WrapTextMode_PARALLEL && isHoriOrientShiftDown)
@@ -3201,6 +3202,18 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
// normally an SwFlyPortion is created instead that increases the height
// of the first table row.
bShiftDown = aTabRange.overlaps(aFlyRange);
+
+ if (bSplitFly && pFly->GetAnchorFrame()->GetUpper() == GetUpper())
+ {
+ // Split fly followed by an inline table. Check if we have enough space to shift
+ // to the right instead.
+ SwTwips nShiftedTabRight = aFlyRectWithoutSpaces.Right() + getFramePrintArea().Width();
+ SwTwips nRightShiftDeadline = pFly->GetAnchorFrame()->GetUpper()->getFrameArea().Right();
+ if (aRectFnSet.XDiff(nRightShiftDeadline, nShiftedTabRight) >= 0)
+ {
+ bShiftDown = false;
+ }
+ }
}
}
@@ -3241,9 +3254,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;
+ }
if ((css::text::WrapTextMode_RIGHT == nSurround
|| css::text::WrapTextMode_PARALLEL == nSurround)
- && text::HoriOrientation::LEFT == rHori.GetHoriOrient()
+ && bFlyHoriOrientLeft
&& !bShiftDown)
{
const tools::Long nWidth