summaryrefslogtreecommitdiff
path: root/sw/qa/core
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-14 16:29:44 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-17 11:38:01 +0100
commit63211894e28aa43e2c54eb9a5d6c3e7669a02142 (patch)
tree21d8cf6feac382105197fd37711984220f045d65 /sw/qa/core
parent91b906181522362e83ffaf27b658bff78082a380 (diff)
sw: fix handling of table vs fly overlaps in the AddVerticalFlyOffsets case
When a table overlaps with a fly frame, Writer creates a fly portion inside the relevant cell frame (increasing its height), and Word shifts the table down. Both are valid approaches, but the rendering result is different in case the table has a border. So keep the default unchanged, but in case the AddVerticalFlyOffsets compat flag (set by the Word importers) is set, avoid the overlap the Word way. Note that the table frame uses the full width (available in the body) even for e.g. 50% width tables, so check for the overlap using the print area, which does not always overlap. Finally, don't always require a valid frame area definition from the fly frame: - the mentioned i#46807 bugdoc currently doesn't need that check - the fly frame area definition becomes valid only after already positioning the table, leading to an overlap Keep that check for the non-compat case, though. (cherry picked from commit fd7749fddc5a767461dfced55369af48e5a6d561) Conflicts: sw/Module_sw.mk Change-Id: I9202050befebf2efdbb5395ded6fcb52b378d8e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88851 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/core')
-rw-r--r--sw/qa/core/layout/data/table-fly-overlap.docxbin0 -> 17718 bytes
-rw-r--r--sw/qa/core/layout/layout.cxx48
2 files changed, 48 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/table-fly-overlap.docx b/sw/qa/core/layout/data/table-fly-overlap.docx
new file mode 100644
index 000000000000..a819e855b2eb
--- /dev/null
+++ b/sw/qa/core/layout/data/table-fly-overlap.docx
Binary files differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
new file mode 100644
index 000000000000..cbea578be4cc
--- /dev/null
+++ b/sw/qa/core/layout/layout.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <vcl/gdimtf.hxx>
+#include <comphelper/classids.hxx>
+#include <tools/globname.hxx>
+#include <svtools/embedhlp.hxx>
+
+#include <wrtsh.hxx>
+#include <fmtanchr.hxx>
+
+static char const DATA_DIRECTORY[] = "/sw/qa/core/layout/data/";
+
+/// Covers sw/source/core/layout/ fixes.
+class SwCoreLayoutTest : public SwModelTestBase
+{
+};
+
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlap)
+{
+ // Load a document that has an image anchored in the header.
+ // It also has a table which has the wrap around the image.
+ load(DATA_DIRECTORY, "table-fly-overlap.docx");
+ SwTwips nFlyTop = parseDump("//header/txt/anchored/fly/infos/bounds", "top").toInt32();
+ SwTwips nFlyHeight = parseDump("//header/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: 3579
+ // - Actual : 2210
+ // i.e. the table's top border overlapped with the image, even if the image's wrap mode was set
+ // to parallel.
+ CPPUNIT_ASSERT_GREATEREQUAL(nFlyBottom, nTableTop);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */