dev/null                                                 |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                |   17 ++++++++++-----
 sw/qa/extras/uiwriter/uiwriter2.cxx                      |   17 +++------------
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    7 +++---
 4 files changed, 20 insertions(+), 21 deletions(-)

New commits:
commit df412d63d436ed4d84a40cdbbf02b7840c78c7c1
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Mar 22 09:37:28 2023 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Mar 24 07:04:54 2023 +0000

    sw floattable: limit the unfloat button to non-DOCX files
    
    CppunitTest_sw_uiwriter2's testUnfloatButton and testUnfloating failed
    in the SW_FORCE_FLY_SPLIT=1 case.
    
    The trouble was that it assumed that floating tables from DOCX are
    imported as tables in non-split flys, which is no longer the case.
    
    Fix the problem by limiting the test to ODT and DOC files.
    
    Once the DOC filter is there for SwFormatFlySplit, this can be
    restricted further to ODT files only (or perhaps it should be removed
    completely).
    
    (cherry picked from commit 2b7b272e28bf95c4ed85cb118eacf065fb6dca3c)
    
    Change-Id: Ie1db9a66c862c196aa3bf5326dfb20c67b9b493a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149375
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/qa/extras/uiwriter/data/unfloatable_floating_table.docx 
b/sw/qa/extras/uiwriter/data/unfloatable_floating_table.docx
deleted file mode 100644
index cef1f7bf685d..000000000000
Binary files a/sw/qa/extras/uiwriter/data/unfloatable_floating_table.docx and 
/dev/null differ
diff --git a/sw/qa/extras/uiwriter/data/unfloatable_small_floating_table.docx 
b/sw/qa/extras/uiwriter/data/unfloatable_small_floating_table.docx
deleted file mode 100644
index d51056af1177..000000000000
Binary files a/sw/qa/extras/uiwriter/data/unfloatable_small_floating_table.docx 
and /dev/null differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 622512119faf..0e9fa8ebdedc 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2472,12 +2472,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testUnfloatButtonSmallTable)
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloatButton)
 {
+    SwModelTestBase::FlySplitGuard aGuard;
     // Different use cases where unfloat button should be visible
     const std::vector<OUString> aTestFiles = {
         "unfloatable_floating_table.odt", // Typical use case of multipage 
floating table
-        "unfloatable_floating_table.docx", // Need to test the DOCX import 
whether we detect the floating table correctly
         "unfloatable_floating_table.doc", // Also the DOC import
-        "unfloatable_small_floating_table.docx" // Atypical use case, when the 
table is small, but because of it's position is it broken to two pages
     };
 
     for (const OUString& aTestFile : aTestFiles)
@@ -2491,15 +2490,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloatButton)
         CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pWrtShell);
 
         const SwSortedObjs* pAnchored;
-        if (sTestFileName == "unfloatable_small_floating_table.docx")
-            pAnchored = pWrtShell->GetLayout()
-                            ->GetLower()
-                            ->GetLower()
-                            ->GetLower()
-                            ->GetNext()
-                            ->GetDrawObjs();
-        else
-            pAnchored = 
pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
+        pAnchored = 
pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
         CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pAnchored);
         CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), 
static_cast<size_t>(1),
                                      pAnchored->size());
@@ -2545,10 +2536,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testUnfloatButtonReadOnlyMode)
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloating)
 {
+    SwModelTestBase::FlySplitGuard aGuard;
     // Test unfloating with tables imported from different file formats
     const std::vector<OUString> aTestFiles = {
         "unfloatable_floating_table.odt",
-        "unfloatable_floating_table.docx",
         "unfloatable_floating_table.doc",
     };
 
@@ -2558,7 +2549,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloating)
         OString sFailureMessage = OString::Concat("Failure in the test file: 
") + sTestFileName;
 
         // Test what happens when pushing the unfloat button
-        createSwDoc("unfloatable_floating_table.docx");
+        createSwDoc(sTestFileName.getStr());
         SwDoc* pDoc = getSwDoc();
         SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
         CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pWrtShell);
commit 38d07cfa9ef66c15ca1919b356614e628203de77
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Mar 22 08:28:34 2023 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Mar 24 07:04:47 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.
    
    (cherry picked from commit a1b935ca1bb6d48241e73e7206a367fe2b51f948)
    
    Change-Id: I39aa00e46c12a32117c334cb97e1cc0270b77651
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149374
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index b0b7d81a602a..25df3b484da6 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 1c1682608962..d19f1750c4df 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1619,9 +1619,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