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

New commits:
commit d75dbb88cf5dde1bc9512bb1c8aac2bdcaef2b25
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Apr 18 08:16:02 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Apr 20 08:30:36 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.
    
    (cherry picked from commit 16b59cee44c7f728b2fe6d7b624c494f649ee79f)
    
    Change-Id: Ice97159563812acee823dbd00b364601db293ed9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150593
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index b2f8ee739a9a..3570f68010a7 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;
+
+    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"));
+        // 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 6c6a2933952b..e06483be8653 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -659,6 +659,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