diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-07-10 08:23:49 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-07-12 10:34:43 +0200 |
commit | e7c4fc8853e1f880149a4948680e0bd226390be4 (patch) | |
tree | 311a9a0337841f228d9b42e976eff9ca317cdff4 | |
parent | 0f9ebefd27eb7fbef951a960d9821ca646af3dda (diff) |
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.
(cherry picked from commit 1f2d523aeeafd241c71a468c970054120fb23b3d)
Conflicts:
sw/qa/filter/ww8/ww8.cxx
Change-Id: If9b4e1d3feeeaa24d6e84fea9a10ecdfd995c18f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154346
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc | bin | 0 -> 41472 bytes | |||
-rw-r--r-- | sw/qa/filter/ww8/ww8.cxx | 29 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 4 |
3 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc Binary files differnew file mode 100644 index 000000000000..d17bb5e886d3 --- /dev/null +++ b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index f91a518c44ee..85ba05483e1e 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -25,6 +25,7 @@ #include <rootfrm.hxx> #include <pagefrm.hxx> #include <IDocumentSettingAccess.hxx> +#include <sortedobjs.hxx> namespace { @@ -356,6 +357,34 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableThenFloattable) // anchor. CPPUNIT_ASSERT_EQUAL(nFly1Anchor + 1, nFly2Anchor); } + +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 a392b5585e4e..7bc6170730f4 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1856,6 +1856,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# |