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.
Change-Id: I9202050befebf2efdbb5395ded6fcb52b378d8e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88724
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-02-14 16:29:44 +01:00
|
|
|
/* -*- 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);
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:03:59 +01:00
|
|
|
CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBorderCollapseCompat)
|
|
|
|
{
|
|
|
|
// Load a document with a border conflict: top cell has a dotted bottom border, bottom cell has
|
|
|
|
// a solid upper border.
|
|
|
|
load(DATA_DIRECTORY, "border-collapse-compat.docx");
|
|
|
|
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
|
|
|
|
SwDocShell* pShell = pTextDoc->GetDocShell();
|
|
|
|
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
|
|
|
|
MetafileXmlDump aDumper;
|
|
|
|
xmlDocPtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
|
|
|
|
|
|
|
|
// Make sure the solid border has priority.
|
|
|
|
// Without the accompanying fix in place, this test would have failed with:
|
|
|
|
// - Expected: 1
|
|
|
|
// - Actual : 48
|
|
|
|
// i.e. there was no single cell border with width=20, rather there were 48 border parts
|
|
|
|
// (forming a dotted border), all with width=40.
|
|
|
|
assertXPath(pXmlDoc, "//polyline[@style='solid']", "width", "20");
|
|
|
|
}
|
|
|
|
|
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.
Change-Id: I9202050befebf2efdbb5395ded6fcb52b378d8e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88724
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-02-14 16:29:44 +01:00
|
|
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|