sw/qa/extras/layout/data/tdf163285.fodt |  108 ++++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout3.cxx         |   17 +++++
 sw/source/core/layout/tabfrm.cxx        |    9 ++
 3 files changed, 133 insertions(+), 1 deletion(-)

New commits:
commit 229964ac9321530991639812050d0065c1d532ec
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 5 15:11:12 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Oct 5 14:03:38 2024 +0200

    tdf#163285: consider page body frame height to allow the split
    
    This improves on commit b271cc46851c61ddef20dc869bf339c857f76b18
    (tdf#123116 sw layout: allow rows larger than page to split anyway,
    2020-03-12).
    
    Change-Id: I9327a18146d795c65528b0f16cefc81721266046
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174534
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/qa/extras/layout/data/tdf163285.fodt 
b/sw/qa/extras/layout/data/tdf163285.fodt
new file mode 100644
index 000000000000..0fee84515aca
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf163285.fodt
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" 
fo:hyphenation-keep="auto" style:text-autospace="ideograph-alpha" 
style:punctuation-wrap="hanging" style:line-break="strict" 
style:tab-stop-distance="36pt" style:writing-mode="page"/>
+   <style:text-properties style:font-name="Liberation Sans" 
fo:font-size="10pt" style:letter-kerning="false" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:default-style style:family="table">
+   <style:table-properties table:border-model="collapsing"/>
+  </style:default-style>
+  <style:default-style style:family="table-row">
+   <style:table-row-properties fo:keep-together="auto"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="8pt" 
style:contextual-spacing="false" fo:line-height="108%" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2" 
style:writing-mode="lr-tb"/>
+  </style:style>
+  <style:default-page-layout>
+   <style:page-layout-properties style:writing-mode="lr-tb" 
style:layout-grid-standard-mode="true"/>
+  </style:default-page-layout>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="Table1" style:family="table">
+   <style:table-properties style:width="11cm" fo:margin-left="0" 
fo:margin-top="0" fo:margin-bottom="0cm" table:align="left" 
style:writing-mode="page"/>
+  </style:style>
+  <style:style style:name="Table1.A" style:family="table-column">
+   <style:table-column-properties style:column-width="11cm"/>
+  </style:style>
+  <style:style style:name="Table1.1" style:family="table-row">
+   <style:table-row-properties style:min-row-height="1cm" 
fo:keep-together="always"/>
+  </style:style>
+  <style:style style:name="Table1.A1" style:family="table-cell">
+   <style:table-cell-properties fo:padding-left="1mm" fo:padding-right="1mm" 
fo:padding-top="0" fo:padding-bottom="0" fo:border="1pt solid #000000"/>
+  </style:style>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard">
+   <style:paragraph-properties fo:margin-bottom="0pt" 
style:contextual-spacing="false" fo:orphans="0" fo:widows="0"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="11cm" fo:page-height="19cm" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="0" 
fo:margin-bottom="0cm" fo:margin-left="0" fo:margin-right="0" 
style:writing-mode="lr-tb"/>
+   <style:header-style>
+    <style:header-footer-properties fo:min-height="1cm" fo:margin-left="0" 
fo:margin-right="0" fo:margin-bottom="0cm" style:dynamic-spacing="true"/>
+   </style:header-style>
+   <style:footer-style>
+    <style:header-footer-properties fo:min-height="1cm" fo:margin-left="0" 
fo:margin-right="0" fo:margin-top="0" style:dynamic-spacing="true"/>
+   </style:footer-style>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1">
+   <style:header>
+    <text:p/>
+   </style:header>
+   <style:footer>
+    <text:p/>
+   </style:footer>
+  </style:master-page>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <table:table table:name="Table1" table:style-name="Table1">
+    <table:table-column table:style-name="Table1.A"/>
+    <table:table-row table:style-name="Table1.1">
+     <table:table-cell table:style-name="Table1.A1">
+      <text:p>pg_1 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st:</text:p>
+      <text:list>
+       <text:list-item>
+        <text:p>aaa</text:p>
+       </text:list-item>
+       <text:list-item>
+        <text:p>bbb</text:p>
+       </text:list-item>
+       <text:list-item>
+        <text:p>cccc</text:p>
+       </text:list-item>
+       <text:list-item>
+        <text:p>ddd</text:p>
+       </text:list-item>
+      </text:list>
+      <text:p text:style-name="P1">1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st.</text:p>
+      <text:p/>
+      <text:p text:style-name="P1">1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st</text:p>
+      <text:p/>
+      <text:p text:style-name="P1">1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st.</text:p>
+      <text:p/>
+      <text:p text:style-name="P1">1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st pg_2 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st s:</text:p>
+      <text:p/>
+      <text:p/>
+      <text:p>1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st</text:p>
+      <text:p>1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st</text:p>
+      <text:p/>
+      <text:p>1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st</text:p>
+      <text:p>1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st</text:p>
+      <text:p>1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st pg_3 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 
1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st 1_st</text:p>
+     </table:table-cell>
+    </table:table-row>
+    <table:table-row table:style-name="Table1.1">
+     <table:table-cell table:style-name="Table1.A1">
+      <text:p>2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 
2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 
2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 
2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 
2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd 2_nd</text:p>
+      <text:p/>
+     </table:table-cell>
+    </table:table-row>
+   </table:table>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 8830891fa632..7f62a3a9d6b8 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -3595,6 +3595,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf163230)
     assertXPath(pExportDump, "//page", 3);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf163285)
+{
+    createSwDoc("tdf163285.fodt");
+    auto pDump = parseLayoutDump();
+    // The first row must split across three pages, despite its "do not break" 
attribute, because it
+    // doesn't fit on the whole page.
+    // A1 text is created such that its "pg_1", "pg_2" and "pg_3" must start 
the respective pages.
+    assertXPath(pDump, "//page", 3);
+    OUString topText1 = getXPathContent(pDump, 
"//page[1]/body/tab/row[1]/cell[1]/txt[1]");
+    CPPUNIT_ASSERT(topText1.startsWith("pg_1"));
+    OUString topText2 = getXPathContent(pDump, 
"//page[2]/body/tab/row[1]/cell[1]/txt[1]");
+    CPPUNIT_ASSERT(topText2.startsWith("pg_2"));
+    OUString topText3 = getXPathContent(pDump, 
"//page[3]/body/tab/row[1]/cell[1]/txt[1]");
+    // Without the fix, this failed:
+    CPPUNIT_ASSERT(topText3.startsWith("pg_3"));
+}
+
 } // end of anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 2c8de7dd5578..bedda6f8895a 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -19,6 +19,7 @@
 
 #include <config_wasm_strip.h>
 
+#include <bodyfrm.hxx>
 #include <pagefrm.hxx>
 #include <rootfrm.hxx>
 #include <IDocumentFieldsAccess.hxx>
@@ -1129,7 +1130,13 @@ bool SwTabFrame::Split(const SwTwips nCutPos, bool 
bTryToSplit,
     {
         // A row larger than the entire page ought to be allowed to split 
regardless of setting,
         // otherwise it has hidden content and that makes no sense
-        if ( pRow->getFrameArea().Height() > 
FindPageFrame()->getFramePrintArea().Height() )
+        tools::Long nMaxHeight = FindPageFrame()->getFramePrintArea().Height();
+        for (auto pBody = FindBodyFrame(); pBody; pBody = 
pBody->GetUpper()->FindBodyFrame())
+        {
+            if (pBody->IsPageBodyFrame())
+                nMaxHeight = pBody->getFramePrintArea().Height();
+        }
+        if (pRow->getFrameArea().Height() > nMaxHeight)
             pRow->SetForceRowSplitAllowed( true );
         else
             bSplitRowAllowed = false;

Reply via email to