sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                |   17 ++++++++++-----
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    7 +++---
 2 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit a1b935ca1bb6d48241e73e7206a367fe2b51f948
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Mar 22 08:28:34 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Mar 22 08:35:05 2023 +0000

    sw floattable: fix inner floating table inside normal outer table from DOCX
    
    The problem was that CppunitTest_sw_ooxmlexport9's testTdf79329 has a
    normal outer table and a floating inner table; the inner table was
    already not floating (so that's not a new problem), but
    SW_FORCE_FLY_SPLIT=1 even failed the text-to-table conversion for the
    outer table, so we just had 1 table, not 2 tables.
    
    The problem seems to be that the start/end positions for the outer table
    cell get invalidated by the inner table-to-frame conversion, so the
    outer table conversion will fail as well.
    
    Fix the problem by limiting the table-to-frame conversion for toplevel
    tables: this avoids the failing text-to-table conversion in the
    SW_FORCE_FLY_SPLIT=1 case.
    
    At some stage I should revisit this, since the DOC import has working
    floating tables for the inner case, for now just make sure that the DOCX
    import result has two tables, as before.
    
    Change-Id: I39aa00e46c12a32117c334cb97e1cc0270b77651
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149284
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index c821953f1160..50c07f693c25 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -848,12 +848,19 @@ DECLARE_OOXMLEXPORT_TEST(testBnc519228OddBreaks, 
"bnc519228_odd-breaksB.docx")
     getParagraphOfText( 1, getProperty< uno::Reference<text::XText> 
>(page5Style, "HeaderText"), "This is the header for odd pages");
 }
 
-DECLARE_OOXMLEXPORT_TEST(testTdf79329, "tdf79329.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf79329)
 {
-    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
-    // This was 1: only the inner, not the outer table was created.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xTables->getCount());
+    SwModelTestBase::FlySplitGuard aGuard;
+    auto verify = [this]() {
+        uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+        uno::Reference<container::XIndexAccess> 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+        // This was 1: only the inner, not the outer table was created.
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xTables->getCount());
+    };
+    createSwDoc("tdf79329.docx");
+    verify();
+    reload(mpFilter, "tdf79329.docx");
+    verify();
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf103982)
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 97b9e3c64991..70fdcae061de 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1618,9 +1618,10 @@ 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.
-                // Tables starting at cell start are not a problem if we don't 
delay via
-                // m_aPendingFloatingTables.
-                if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || 
IsFlySplitAllowed()))
+                // Multi-page floating tables works if an outer/toplevel table 
is floating, but not
+                // when an inner table would float.
+                bool bToplevelSplitFly = IsFlySplitAllowed() && 
nestedTableLevel <= 1;
+                if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || 
bToplevelSplitFly))
                 {
                     std::deque<css::uno::Any> aFramedRedlines = 
m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME];
                     std::vector<sal_Int32> redPos, redLen;

Reply via email to