sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc |binary sw/qa/filter/ww8/ww8.cxx | 29 +++++++++++++++ sw/source/filter/ww8/ww8par.cxx | 4 ++ 3 files changed, 33 insertions(+)
New commits: commit 1f2d523aeeafd241c71a468c970054120fb23b3d Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jul 10 08:23:49 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 10 09:17:10 2023 +0200 sw floattable: enable AddVerticalFrameOffsets compat flag for DOC The bugdoc has a floating table, followed by an inline table. The inline table should be on the second page, but instead it's on the first page, overlapping with the floating table. It seems this works already for DOCX since commit 50223ea6e212b60b7d33839c2753c5601fb50f95 (tdf#98987 sw: add AddVerticalFrameOffsets compat mode, 2016-03-31). Fix the problem by enabling the same compat flag for DOC, since the intention was to have this on for Word formats in general. The original bnc#816603 bugdoc still needs more work, though. Change-Id: If9b4e1d3feeeaa24d6e84fea9a10ecdfd995c18f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154235 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc new file mode 100644 index 000000000000..d17bb5e886d3 Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc differ diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 20c1b993caa8..d7af2b675f24 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -26,6 +26,7 @@ #include <pagefrm.hxx> #include <ftnfrm.hxx> #include <IDocumentSettingAccess.hxx> +#include <sortedobjs.hxx> namespace { @@ -358,6 +359,34 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCFloatingTableHiddenAnchor) // i.e. the floating table was lost. assertXPath(pLayout, "//tab", 2); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCVerticalFlyOffset) +{ + // Given a document with 2 pages, a floating table on the first page and an inline table on the + // second page: + createSwDoc("floattable-vertical-fly-offset.doc"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the tables don't overlap: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + // Page 1 has a floating table: + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs.size()); + auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, there was no second page. + CPPUNIT_ASSERT(pPage2); + SwFrame* pBody2 = pPage2->GetLower(); + SwFrame* pTable2 = pBody2->GetLower(); + CPPUNIT_ASSERT(pTable2); + // Page 2 starts with an inline table: + CPPUNIT_ASSERT(pTable2->IsTabFrame()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 1a328ebf8e54..abd7cf4c0345 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1902,6 +1902,10 @@ void SwWW8ImplReader::ImportDop() m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_VIRTUAL_DEVICE, !m_xWDop->fUsePrinterMetrics); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE, true); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_FLY_OFFSETS, true ); + + // No vertical offsets would lead to e.g. overlap of table and fly frames. + m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS, true ); + m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_EXT_LEADING, !m_xWDop->fNoLeading); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::OLD_NUMBERING, false); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, false); // #i47448#