sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 61 ++++++++------- sw/source/filter/ww8/docxtableexport.cxx | 2 writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 4 3 files changed, 39 insertions(+), 28 deletions(-)
New commits: commit 48818dd359fbf0f37e1b318de89ab2ea7d735f58 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Mar 20 12:14:53 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Mar 20 12:30:47 2023 +0000 sw floattable: fix handling of nested non-floating tables at cell start CppunitTest_sw_ooxmlexport8's testN779642 failed in the SW_FORCE_FLY_SPLIT=1 case. The bugdoc has a floating table, then an inner, non-floating table. The conversion to floating tables was disabled by the c1eebcdac9f2b289fd363399130c485ca5ff444c (tdf#79329 DOCX import: fix missing outer table with floattable at cell start, 2016-11-08). Given that SwFormatFlySplit doesn't need the delayed text frame conversion, we can get rid of this workaround. Fix a similar problem on the export side as well, where the positioning properties of the outer table leaked into the inner table. Once both the import and export are fixed, the test passes. Change-Id: I884ad38cbc247c885991b0faf0d37221b70a6ba7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149154 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 8cd6d4961f38..dbcd48aca0b6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -720,34 +720,41 @@ DECLARE_OOXMLEXPORT_TEST(testN793998, "n793998.docx") CPPUNIT_ASSERT(nTextPortion + nTabPortion > nParagraph - nRightMargin); } -DECLARE_OOXMLEXPORT_TEST(testN779642, "n779642.docx") +CPPUNIT_TEST_FIXTURE(Test, testN779642) { - uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); - - // First problem: check that we have 2 tables, nesting caused the - // creation of outer one to fail - uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong number of imported tables", sal_Int32(2), xTables->getCount()); - - // Second problem: check that the outer table is in a frame, at the bottom of the page - uno::Reference<text::XTextTable> xTextTable(xTextTablesSupplier->getTextTables()->getByName("Table2"), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xAnchor(xTextTable->getAnchor(), uno::UNO_QUERY); - uno::Any aFrame = xAnchor->getPropertyValue("TextFrame"); - uno::Reference<beans::XPropertySet> xFrame; - aFrame >>= xFrame; - sal_Int16 nValue; - xFrame->getPropertyValue("VertOrient") >>= nValue; - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation", text::VertOrientation::BOTTOM, nValue); - xFrame->getPropertyValue("VertOrientRelation") >>= nValue; - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation relation", text::RelOrientation::PAGE_PRINT_AREA, nValue); - - // tdf#106572 - perhaps not the best test to hijack since this file - // produces an error in Word, but it nicely matches danger points, - // and has a different first footer, so nice visual confirmation. - discardDumpedLayout(); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // There is no footer text on the first page. - assertXPath(pXmlDoc, "/root/page[1]/footer/txt", 0); + SwModelTestBase::FlySplitGuard aGuard; + auto verify = [this]() { + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + + // First problem: check that we have 2 tables, nesting caused the + // creation of outer one to fail + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong number of imported tables", sal_Int32(2), xTables->getCount()); + + // Second problem: check that the outer table is in a frame, at the bottom of the page + uno::Reference<text::XTextTable> xTextTable(xTextTablesSupplier->getTextTables()->getByName("Table2"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xAnchor(xTextTable->getAnchor(), uno::UNO_QUERY); + uno::Any aFrame = xAnchor->getPropertyValue("TextFrame"); + uno::Reference<beans::XPropertySet> xFrame; + aFrame >>= xFrame; + sal_Int16 nValue; + xFrame->getPropertyValue("VertOrient") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation", text::VertOrientation::BOTTOM, nValue); + xFrame->getPropertyValue("VertOrientRelation") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation relation", text::RelOrientation::PAGE_PRINT_AREA, nValue); + + // tdf#106572 - perhaps not the best test to hijack since this file + // produces an error in Word, but it nicely matches danger points, + // and has a different first footer, so nice visual confirmation. + discardDumpedLayout(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // There is no footer text on the first page. + assertXPath(pXmlDoc, "/root/page[1]/footer/txt", 0); + }; + createSwDoc("n779642.docx"); + verify(); + reload(mpFilter, "n779642.docx"); + verify(); } DECLARE_OOXMLEXPORT_TEST(testTbLrHeight, "tblr-height.docx") diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx index 36f45edf4e12..1f4f06a41aa3 100644 --- a/sw/source/filter/ww8/docxtableexport.cxx +++ b/sw/source/filter/ww8/docxtableexport.cxx @@ -279,6 +279,8 @@ void DocxAttributeOutput::TableDefinition( pAttributes); m_pSerializer->singleElementNS(XML_w, XML_tblpPr, pAttributes); bFloatingTableWritten = true; + // The outer table was floating, make sure potential inner tables are not floating. + m_rExport.SetFloatingTableFrame(nullptr); } // Extract properties from grab bag diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index bd81fb9df941..97b9e3c64991 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1618,7 +1618,9 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab // Only execute the conversion if the table is not anchored at // the start of an outer table cell, that's not yet // implemented. - if (xTextAppendAndConvert.is() && !bTableStartsAtCellStart) + // Tables starting at cell start are not a problem if we don't delay via + // m_aPendingFloatingTables. + if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || IsFlySplitAllowed())) { std::deque<css::uno::Any> aFramedRedlines = m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME]; std::vector<sal_Int32> redPos, redLen;