sw/source/core/layout/flycnt.cxx | 7 +- writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx | 27 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx |binary writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 8 -- 4 files changed, 33 insertions(+), 9 deletions(-)
New commits: commit 5127b1961b762643d47a26704556fd9b8664c6fc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Sep 13 08:14:19 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Sep 13 11:35:07 2023 +0200 sw floattable, nesting: add DOCX import There were two problems here: 1) writerfilter/ didn't even try allowing split floating tables for the inner case, because layout didn't support that previously. 2) CppunitTest_writerfilter_dmapper's test3NestedFloatingTables crashed because we expected that in case a fly+table is not toplevel, then the parent is also a fly+table frame, but in this case the parent was just a table frame. Fix this by checking for a table parent instead of a fly parent when deciding if we handle the split as a nested case or a toplevel one. Change-Id: I4c58636ef80371b8ec51a96fe436fa6379c795d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156865 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index d6aa1b6b2321..2cba4e295728 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1611,10 +1611,11 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) } } - if (bLeftFly && pFlyAnchor && pFlyAnchor->IsInFly() - && FindFlyFrame() == pLayLeaf->FindFlyFrame()) + if (bLeftFly && pFlyAnchor && pFlyAnchor->IsInTab() + && FindTabFrame() == pLayLeaf->FindTabFrame()) { - // This is an inner fly, then the follow anchor will be just next to us. + // This is an inner fly (parent is an inline or a floating table), then the follow + // anchor will be just next to us. SwLayoutFrame* pFlyAnchorUpper = pFlyAnchor->GetUpper(); pOldLayLeaf = pLayLeaf; pLayLeaf = pFlyAnchorUpper; diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx index 90181e5f9716..34fee71efff3 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx @@ -133,6 +133,33 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableHiddenAnchor) // hidden. CPPUNIT_ASSERT(!bCharHidden); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableNested) +{ + // Given a document with nested, multi-page floating tables: + // When loading that document: + loadFromURL(u"floattable-nested.docx"); + + // Then make sure that both floating tables are allowed to split: + uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xFrames(xFramesSupplier->getTextFrames(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xFrames->getCount()); + // Outer frame: + uno::Reference<beans::XPropertySet> xFrame1; + xFrames->getByIndex(0) >>= xFrame1; + bool bIsSplitAllowed = false; + xFrame1->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed; + CPPUNIT_ASSERT(bIsSplitAllowed); + // Inner frame: + uno::Reference<beans::XPropertySet> xFrame2; + xFrames->getByIndex(1) >>= xFrame2; + bIsSplitAllowed = false; + xFrame2->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed; + // Without the accompanying fix in place, this test would have failed, the inner frame could not + // split. + CPPUNIT_ASSERT(bIsSplitAllowed); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx b/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx new file mode 100644 index 000000000000..655e6c0e0bad Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/floattable-nested.docx differ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index a942e303cae9..e2e8f8c54d78 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1587,12 +1587,8 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab comphelper::makePropertyValue("IsFollowingTextFlow", true)); } - if (nestedTableLevel <= 1) - { - // A text frame created for floating tables is allowed to split if it's a toplevel - // table. - aFrameProperties.push_back(comphelper::makePropertyValue("IsSplitAllowed", true)); - } + // A text frame created for floating tables is always allowed to split. + aFrameProperties.push_back(comphelper::makePropertyValue("IsSplitAllowed", true)); sal_Int32 nTableWidth = 0; m_aTableProperties->getValue(TablePropertyMap::TABLE_WIDTH, nTableWidth);