summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-05-10 23:28:03 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-05-11 09:34:00 +0200
commit1b5bc2ae2f19a190bf588a5a26c4d125c3960991 (patch)
tree5c38676d21fa9915a40c138b8f33b11b90238134 /sw/qa
parent7c6d409d252825b2407f3892f4eac35fc0c8c1ed (diff)
tdf#154775 sw layout: fix unexpected large table print area left margin
The bugdoc had 2 pages, but the second page's content was mostly a table. This table was rendered outside the page frame, so it was practically invisible. This started after commit fd7749fddc5a767461dfced55369af48e5a6d561 (sw: fix handling of table vs fly overlaps in the AddVerticalFlyOffsets case, 2020-02-14), and that behavior is still wanted to have correct table borders, but that change introduced an inconsistent case: we started to always accept an invalid frame area definition of the fly, but we only shifted the content down in the text::HoriOrientation::NONE case. Fix the problem by limiting the "accept invalid frame area definition" based on the horizontal orientation, so we either both ignore the validity flag & shift down or do none of this. This keeps the original bug fixed, but addresses the new "no visible table" problem. Note that this only fixes the regression part; once the image from the header is removed and undo is invoked, a similar problem still happens. But that is a pre-existing, separate problem. Change-Id: Id752c169b7c7fb6b75e6603ad29aaafbb676b8a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151652 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/core/layout/data/table-print-area-left.docxbin0 -> 11807 bytes
-rw-r--r--sw/qa/core/layout/tabfrm.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/table-print-area-left.docx b/sw/qa/core/layout/data/table-print-area-left.docx
new file mode 100644
index 000000000000..e326bed82f39
--- /dev/null
+++ b/sw/qa/core/layout/data/table-print-area-left.docx
Binary files differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
new file mode 100644
index 000000000000..4b991c27dbf8
--- /dev/null
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -0,0 +1,38 @@
+/* -*- 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>
+
+/// Covers sw/source/core/layout/tabfrm.cxx fixes.
+class Test : public SwModelTestBase
+{
+public:
+ Test()
+ : SwModelTestBase("/sw/qa/core/layout/data/")
+ {
+ }
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testTablePrintAreaLeft)
+{
+ // Given a document with a header containing an image, and also with an overlapping table:
+ createSwDoc("table-print-area-left.docx");
+
+ // When laying out that document & parsing the left margin of the table:
+ SwTwips nTablePrintLeft = parseDump("//tab/infos/prtBounds", "left").toInt32();
+
+ // Then make sure it has ~no left margin:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 5
+ // - Actual : 10646
+ // i.e. the table was shifted outside the page, was invisible.
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(5), nTablePrintLeft);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */