summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/layout/data/table-fly-overlap-spacing.docxbin0 -> 27719 bytes
-rw-r--r--sw/qa/core/layout/layout.cxx17
-rw-r--r--sw/source/core/layout/tabfrm.cxx9
3 files changed, 24 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/core/layout/data/table-fly-overlap-spacing.docx
Binary files 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.