[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jul 6 10:42:02 UTC 2017


 sw/qa/extras/uiwriter/data/lines-in-section-in-table.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx                       |   18 +++++++++++++++
 sw/source/core/layout/sectfrm.cxx                        |    6 ++---
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit f8a76d218305a56d15b82b9dac4fafa558872780
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jul 6 11:16:54 2017 +0200

    tdf#108524 sw: split section frames inside table cells, non-split text frames
    
    Commit f991b842addddeada6dc45c4054deeca5aa7f17b (tdf#108524 sw: attempt
    to split section frames inside table cells, 2017-06-19) added initial
    support for multi-page sections inside a table cell, but turns out this
    only worked in case at the split point there was a long enough
    paragraph, so it was split into two (a "master" text frame and a
    "follow" one), and then the follow was moved to the next page by
    SwContentFrame::MakeAll(), with the MoveFwd() call in the "If a Follow
    sits next to its Master and doesn't fit, we know it can be moved right
    now." block.
    
    However, if the section contains lots of one-liner text frames, then all
    of them are masters, so the above code doesn't move them to the next
    page; so the section frame is still not split. Fix the problem by
    allowing the move of frames inside table-in-sections in
    SwSectionFrame::MoveAllowed(), that way SwTextFrame::AdjustFrame() will
    not set the text frame as undersized, so at the end
    SwContentFrame::MakeAll() will call MoveFwd() in the "If a column
    section can't find any space for its first ContentFrame" block.
    
    With this the split of text frames in section-in-table frames is
    consistent regardless if they are of multiple or single lines.
    
    Change-Id: Ief9d62da3fd8a5c707e1f9489a92f7a81e7b38ac
    Reviewed-on: https://gerrit.libreoffice.org/39623
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/data/lines-in-section-in-table.odt b/sw/qa/extras/uiwriter/data/lines-in-section-in-table.odt
new file mode 100644
index 000000000000..4f0abd6e5e88
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/lines-in-section-in-table.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c9b4efda6fad..b85a7e58e5b4 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -256,6 +256,7 @@ public:
     void testTdf107976();
     void testTdf108524();
     void testTableInSection();
+    void testLinesInSectionInTable();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -399,6 +400,7 @@ public:
     CPPUNIT_TEST(testTdf107976);
     CPPUNIT_TEST(testTdf108524);
     CPPUNIT_TEST(testTableInSection);
+    CPPUNIT_TEST(testLinesInSectionInTable);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4962,6 +4964,22 @@ void SwUiWriterTest::testTdf108524()
     assertXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell/section", 1);
 }
 
+void SwUiWriterTest::testLinesInSectionInTable()
+{
+    // This is similar to testTdf108524(), but the page boundary now is not in
+    // the middle of a multi-line paragraph: the section only contains oneliner
+    // paragraphs instead.
+    createDoc("lines-in-section-in-table.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    // In total we expect two cells containing a section.
+    assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/section", 2);
+
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell/section", 1);
+    // This was 0, section wasn't split, instead it was only on the first page
+    // and it was cut off.
+    assertXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell/section", 1);
+}
+
 void SwUiWriterTest::testTableInSection()
 {
     // The document has a section, containing a table that spans over 2 pages.
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 331b4be8fc66..7288251dfd12 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -590,7 +590,7 @@ namespace
     }
 
     /// Checks if pFrame is in a table, which itself is in a section.
-    bool IsInTableInSection(SwFrame* pFrame)
+    bool IsInTableInSection(const SwFrame* pFrame)
     {
         if (!pFrame->IsInTab())
             return false;
@@ -2160,8 +2160,8 @@ bool SwSectionFrame::MoveAllowed( const SwFrame* pFrame) const
         return false;
     // Now it has to be examined whether there is a layout sheet wherein
     // a section Follow can be created
-    if( IsInTab() || ( !IsInDocBody() && FindFooterOrHeader() ) )
-        return false; // It doesn't work in tables/headers/footers
+    if( IsInTableInSection(this) || ( !IsInDocBody() && FindFooterOrHeader() ) )
+        return false; // It doesn't work in table-in-sections/headers/footers
     if( IsInFly() ) // In column based or chained frames
         return nullptr != const_cast<SwFrame*>(static_cast<SwFrame const *>(GetUpper()))->GetNextLeaf( MAKEPAGE_NONE );
     return true;


More information about the Libreoffice-commits mailing list