sw/qa/extras/ww8export/ww8export2.cxx |   23 ++++++++++++++++-------
 sw/source/core/layout/fly.cxx         |    6 ++++++
 2 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit 16b59cee44c7f728b2fe6d7b624c494f649ee79f
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Apr 18 08:16:02 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Apr 18 10:09:08 2023 +0200

    sw floattable, layout: don't split inside headers/footers
    
    CppunitTest_sw_ww8export2's testTdf128700_relativeTableWidth had a
    layout loop in the SW_FORCE_FLY_SPLIT=1 case.
    
    This seems to happen because the footer had a big floating table, which
    doesn't fit the anchor's upper, but adding more pages won't help the
    table to fit.
    
    Fix the problem by not trying to split floating tables in
    headers/footers.
    
    An alternative would be to filter this out at import time, but then we
    would loose the setting on DOCX/DOC roundtrip, which is not ideal.
    
    Change-Id: Ice97159563812acee823dbd00b364601db293ed9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150535
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index 8252f63504f0..4c829aed0204 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -85,15 +85,24 @@ DECLARE_WW8EXPORT_TEST(testTdf55528_relativeTableWidth, 
"tdf55528_relativeTableW
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Table relative width percent", 
sal_Int16(98), getProperty<sal_Int16>(xTable, "RelativeWidth"));
  }
 
-DECLARE_WW8EXPORT_TEST(testTdf128700_relativeTableWidth, 
"tdf128700_relativeTableWidth.doc")
+CPPUNIT_TEST_FIXTURE(Test, testTdf128700_relativeTableWidth)
 {
-    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> 
xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
-    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+    SwModelTestBase::FlySplitGuard aGuard;
 
-    // Since the table has been converted into a floating frame, the relative 
width either needed to be transferred
-    // onto the frame, or else just thrown out. Otherwise it becomes relative 
to the size of the frame.
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Floated table can't use relative width", 
sal_Int16(0), getProperty<sal_Int16>(xTable, "RelativeWidth"));
+    auto verify = [this]() {
+        uno::Reference<text::XTextTablesSupplier> 
xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XIndexAccess> 
xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+        uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+
+        // Since the table has been converted into a floating frame, the 
relative width either needed to be transferred
+        // onto the frame, or else just thrown out. Otherwise it becomes 
relative to the size of the frame.
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Floated table can't use relative width", 
sal_Int16(0), getProperty<sal_Int16>(xTable, "RelativeWidth"));
+    };
+    // This also resulted in a layout loop when flys were allowed to split in 
footers.
+    createSwDoc("tdf128700_relativeTableWidth.doc");
+    verify();
+    reload(mpFilter, "tdf128700_relativeTableWidth.doc");
+    verify();
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf116436_tableBackground)
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 0158a93a46df..47a82a228a1f 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -660,6 +660,12 @@ bool SwFlyFrame::IsFlySplitAllowed() const
         return false;
     }
 
+    if (FindFooterOrHeader())
+    {
+        // Adding a new page would not increase the header/footer area.
+        return false;
+    }
+
     return GetFormat()->GetFlySplit().GetValue();
 }
 

Reply via email to