summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-07-18 08:30:04 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-07-18 11:41:10 +0200
commit9a5d1c250cbaac855b3e63d8c5fa0882ba7d14a2 (patch)
treeef844fba0a4668b5e19cf3f4a528ca2ddbf02b7d /sw
parent007ef352c2e6a061c52a45a35d3930d318b8ca8b (diff)
tdf#120262 sw floattable, legacy: go outside body only for page frame vert pos
The bugdoc has to pages, the floating table from the top of page 2 is partially moved to page 1 and overlaps with the footer text. Part of the reason this happens is that in case the vertical position is relative to the page frame, then Word allows using the footer area for floating tables (see tdf#155118), but turns out that in case the position is relative to other places (e.g. paragraph), then this is not necessary. Fix the problem by making the "is legacy" condition in GetFlyAnchorBottom() more strict, which keeps tdf#155118 fixed, but improves this bugdoc. Leave the layout unchanged for cases where the floating table is not in the body text (e.g. footnotes). Now the overlap is fixed, but still a bug remains where the first row on this split table is not moved page 2. Change-Id: I96d6eb527d7f33dd65de8a66f815219c02625d93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154573 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/layout/data/floattable-no-footer-overlap.docxbin0 -> 20043 bytes
-rw-r--r--sw/qa/core/layout/flycnt.cxx22
-rw-r--r--sw/source/core/layout/fly.cxx8
3 files changed, 28 insertions, 2 deletions
diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx
new file mode 100644
index 000000000000..ca2f0d6d7244
--- /dev/null
+++ b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx
Binary files differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 7d89a34ac914..106be77ceac2 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -946,6 +946,28 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext)
const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap)
+{
+ // Given a document with 2 pages, a floating table on both pages:
+ createSwDoc("floattable-no-footer-overlap.docx");
+
+ // When calculating the layout:
+ calcLayout();
+
+ // Then make sure the second page has a floating table:
+ SwDoc* pDoc = getSwDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+ CPPUNIT_ASSERT(pPage1);
+ auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext());
+ // Without the accompanying fix in place, this test would have failed, there was no page 2, both
+ // floating tables were on page 1.
+ CPPUNIT_ASSERT(pPage2);
+ CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+ const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index d03e015f2c14..68184da48fd6 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -99,8 +99,12 @@ SwTwips GetFlyAnchorBottom(SwFlyFrame* pFly, const SwFrame& rAnchor)
return 0;
}
- const IDocumentSettingAccess& rIDSA = pFly->GetFrameFormat().getIDocumentSettingAccess();
- bool bLegacy = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN);
+ const auto& rFrameFormat = pFly->GetFrameFormat();
+ const IDocumentSettingAccess& rIDSA = rFrameFormat.getIDocumentSettingAccess();
+ // Allow overlap with bottom margin / footer only in case we're relative to the page frame.
+ bool bVertPageFrame = rFrameFormat.GetVertOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME;
+ bool bInBody = rAnchor.IsInDocBody();
+ bool bLegacy = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN) && (bVertPageFrame || !bInBody);
if (bLegacy)
{
// Word <= 2010 style: the fly can overlap with the bottom margin / footer area in case the