[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 24 08:07:55 UTC 2020
sw/qa/core/layout/data/table-fly-overlap-spacing.docx |binary
sw/qa/core/layout/layout.cxx | 17 +++++++++++++++++
sw/source/core/layout/tabfrm.cxx | 9 +++++++--
3 files changed, 24 insertions(+), 2 deletions(-)
New commits:
commit e68d961a361a784df1000a978bd02eca57e30565
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 23 21:05:43 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Mar 24 09:07:21 2020 +0100
tdf#131282 sw layout: fix shifted down table next to a fly frame
Regression from commit fd7749fddc5a767461dfced55369af48e5a6d561 (sw: fix
handling of table vs fly overlaps in the AddVerticalFlyOffsets case,
2020-02-14), the problem was that the rectangle of the fly frame
included spacing when overlapping was checked.
Given that this code was explicitly added for Word compat purposes,
change it to ignore spacing. You can see that Word doesn't care about
spacing: increase the left margin of e.g. the pie chart in the bugdoc to
some large value and the table is still not shifted down.
Writer shifted the table down as the small spacing was already enough to
detect an overlap:
debug:21457:21457: SwTabFrame::CalcFlyOffsets: aTabRange is 896 -> 3698
debug:21457:21457: SwTabFrame::CalcFlyOffsets: aFlyRange is 3650 -> 6290
If we don't include that ~3 px spacing, then we don't overlap, similar
to Word.
Change-Id: I154c211bb0700d132fd168f49c1bbfb29e8caeb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90939
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/qa/core/layout/data/table-fly-overlap-spacing.docx b/sw/qa/core/layout/data/table-fly-overlap-spacing.docx
new file mode 100644
index 000000000000..648c8b93df29
Binary files /dev/null and b/sw/qa/core/layout/data/table-fly-overlap-spacing.docx differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index cd71d9e2a99b..7f8d885301d7 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -75,6 +75,23 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBtlrTableRowSpan)
assertXPathContent(pXmlDoc, "//textarray[1]/text", "USA");
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlapSpacing)
+{
+ // Load a document that has an image on the right of a table. The table wraps around the image.
+ load(DATA_DIRECTORY, "table-fly-overlap-spacing.docx");
+ SwTwips nFlyTop = parseDump("//body/txt/anchored/fly/infos/bounds", "top").toInt32();
+ SwTwips nFlyHeight = parseDump("//body/txt/anchored/fly/infos/bounds", "height").toInt32();
+ SwTwips nFlyBottom = nFlyTop + nFlyHeight;
+ SwTwips nTableFrameTop = parseDump("//tab/infos/bounds", "top").toInt32();
+ SwTwips nTablePrintTop = parseDump("//tab/infos/prtBounds", "top").toInt32();
+ SwTwips nTableTop = nTableFrameTop + nTablePrintTop;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected greater or equal than: 3993
+ // - Actual : 3993
+ // i.e. the table was below the image, not on the left of the image.
+ CPPUNIT_ASSERT_LESS(nFlyBottom, nTableTop);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 9beef619ed4a..be9fb1aef224 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2806,8 +2806,13 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
aRectFnSet.GetLeft(aRect) + aRectFnSet.GetLeft(getFramePrintArea()),
aRectFnSet.GetLeft(aRect) + aRectFnSet.GetLeft(getFramePrintArea())
+ aRectFnSet.GetWidth(getFramePrintArea()));
- basegfx::B1DRange aFlyRange(aRectFnSet.GetLeft(aFlyRect),
- aRectFnSet.GetRight(aFlyRect));
+
+ // 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));
+
// If it does, shift the table down. Do this only in the compat case,
// normally an SwFlyPortion is created instead that increases the height
// of the first table row.
More information about the Libreoffice-commits
mailing list