sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx
 |binary
 sw/qa/extras/layout/layout.cxx                                                 
  |   14 +++++
 sw/source/core/layout/findfrm.cxx                                              
  |   27 +++++++++-
 sw/source/core/layout/wsfrm.cxx                                                
  |    1 
 4 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit 4c31b4ef2083087a822c3ae648fd09acc67d2f88
Author:     Attila Szűcs <szucs.atti...@nisz.hu>
AuthorDate: Wed Sep 8 15:51:16 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Nov 2 16:31:24 2021 +0100

    tdf#139336 sw: fix extra pages of multicolumn sections with footnotes
    
    Adding footnotes to multicolumn sections resulted page-long
    section layout, not regarding to the amount of its text content.
    E.g. a page with n multicolumn sections and footnotes could load
    as n (mostly empty) pages. The problem is related to the footnotes
    showed under columns of sections, which can be ambiguous at different
    column number of the different sections on the same page.
    As a workaround for interoperability, show footnotes per pages to
    remove the extra pages, e.g. allowing to show the separated sections
    on a single page, like MSO does.
    
    Note: a compatibility option will be added to avoid regressions.
    
    Note: This fix doesn't change multicolumn page styles or not evenly
    distributed multicolumn sections or footnotes not collected at the
    end of the sections.
    
    Test: choose Edit Section... in local menu of the sections of the
    unit test document. In Options..., see checkbox "Evenly distribute
    contents to all columns" on page Columns, and Footnotes/"Collect at
    end of text" on page Footnotes/Endnotes. To see the result of the
    new settings, save and reload the document. Note: DOCX format doesn't
    support "Collect at end of text", only OpenDocument.
    
    Note: In MSO, it's possible to set multimulticolumn footnotes
    separately from section column number. It's column number can
    be 1–4, or "auto", which uses the column number of the first
    section of the page.
    
    See also tdf#138508 (Single column footnotes on multi-column pages).
    
    Change-Id: I6a3534ac043971479275a3e8bb0713bd3d8ceaa4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121822
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git 
a/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx
 
b/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx
new file mode 100644
index 000000000000..a44ff4047111
Binary files /dev/null and 
b/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx
 differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 1b7ad51d71c2..9050a00a86cf 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3719,6 +3719,20 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
     CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testTdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage)
+{
+    SwDoc* pDoc
+        = createSwDoc(DATA_DIRECTORY, 
"tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx");
+    CPPUNIT_ASSERT(pDoc);
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    // Without the fix, it would be 5 pages, but with the fix the whole 
document
+    // would fit into 1 page, but it will be 2 pages right now, because
+    // when writer import (from docx) the last section with columns, then it 
does not set
+    // the evenly distributed settings, and this settings is required for the 
fix now, to
+    // avoid some regression.
+    assertXPath(pXmlDoc, "/root/page", 2);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index e90ee98c1fdf..1eae79d9cd60 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -31,6 +31,7 @@
 #include <txtftn.hxx>
 #include <fmtftn.hxx>
 #include <fmtpdsc.hxx>
+#include <fmtclbl.hxx>
 #include <txtfrm.hxx>
 #include <bodyfrm.hxx>
 #include <calbck.hxx>
@@ -39,6 +40,7 @@
 #include <osl/diagnose.h>
 #include <sal/log.hxx>
 
+
 /// Searches the first ContentFrame in BodyText below the page.
 SwLayoutFrame *SwFootnoteBossFrame::FindBodyCont()
 {
@@ -440,7 +442,30 @@ SwFootnoteBossFrame* SwFrame::FindFootnoteBossFrame( bool 
bFootnotes )
     // don't contain footnote texts there
     if( pRet->IsInTab() )
         pRet = pRet->FindTabFrame();
-    while ( pRet && !pRet->IsFootnoteBossFrame() )
+
+    // tdf139336: put the footnotes into the page frame (instead of a column 
frame)
+    // to avoid maximizing the section to the full page.... if:
+    // - it is in a section
+    // - collect footnotes at section end (FootnoteAtEnd) is not set
+    // - columns are evenly distributed (=balanced) is not set
+    // Note 1: at page end, the footnotes have no multi-column-capability,
+    //         so this fix is used only where there is better chance to help
+    // Note 2: If balanced is not set, there is a higher chance that the 1. 
column will reach
+    //         the end of the page... if that happens the section will be 
maximized anyway.
+    // Note 3: The user will be able to easily choose the old layout (with 
multi-column footnotes)
+    //         with this setting.
+    //         similar case can be reached with a page break + FootnoteAtEnd 
setting
+    SwSectionFrame* pSectframe = pRet->FindSctFrame();
+    bool bMoveToPageFrame = false;
+    if (pSectframe)
+    {
+        bool bNoBalance = 
pSectframe->GetSection()->GetFormat()->GetBalancedColumns().GetValue();
+        bool bFAtEnd = pSectframe->IsFootnoteAtEnd();
+        bMoveToPageFrame = !bFAtEnd && !bNoBalance;
+    }
+    while (pRet
+           && ((!bMoveToPageFrame && !pRet->IsFootnoteBossFrame())
+               || (bMoveToPageFrame && !pRet->IsPageFrame())))
     {
         if ( pRet->GetUpper() )
             pRet = pRet->GetUpper();
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 9ea1ac6702ee..dea716d803d6 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4025,6 +4025,7 @@ void SwLayoutFrame::FormatWidthCols( const SwBorderAttrs 
&rAttrs,
     if( IsSctFrame() )
     {
         // OD 14.03.2003 #i11760# - adjust 2nd parameter - sal_True --> true
+        setFrameAreaSizeValid(true);
         ::CalcContent( this, true );
         if( bBackLock )
             static_cast<SwSectionFrame*>(this)->SetFootnoteLock( false );

Reply via email to