[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source

Manfred Blume manfred.blume at cib.de
Thu Dec 21 23:23:04 UTC 2017


 sw/qa/extras/uiwriter/data/fdo114306.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx       |   28 ++++++++++++++++++++++++++++
 sw/source/core/layout/findfrm.cxx        |   27 ++++++++++++++++++++++++++-
 sw/source/core/layout/flowfrm.cxx        |    8 ++++++--
 4 files changed, 60 insertions(+), 3 deletions(-)

New commits:
commit 58074678a9a6608a745acef6e61b81ede09cd180
Author: Manfred Blume <manfred.blume at cib.de>
Date:   Thu Dec 21 21:10:03 2017 +0100

    tdf#114306 fix Unexpected page break in long table
    
    Cherry-picked from 18765b9fa739337d2d891513f6e2fb7c3ce23b50
    
    Change-Id: I9a89bb29a1d745c0bc3c46966a60c2f9a484bdd8

diff --git a/sw/qa/extras/uiwriter/data/fdo114306.odt b/sw/qa/extras/uiwriter/data/fdo114306.odt
new file mode 100755
index 000000000000..5a7d2f9ca864
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo114306.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 766ab7199419..afdd8aee20dc 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -206,6 +206,7 @@ public:
     void testTdf104814();
     void testTdf105417();
     void testTdf112025();
+    void testTdf114306();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -311,6 +312,7 @@ public:
     CPPUNIT_TEST(testTdf104814);
     CPPUNIT_TEST(testTdf105417);
     CPPUNIT_TEST(testTdf112025);
+    CPPUNIT_TEST(testTdf114306);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3784,6 +3786,32 @@ void SwUiWriterTest::testTdf112025()
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle, "IsLandscape"));
 }
 
+void SwUiWriterTest::testTdf114306()
+{
+    load(DATA_DIRECTORY, "fdo114306.odt");
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    xmlXPathObjectPtr pXmlObj;
+    xmlNodeSetPtr pXmlNodes;
+    int numberOfNodes = 0;
+
+    // There are 2 long paragraphs in cell A1.
+    // A part of paragraph 2 should flow over to the second page but *not* the whole paragraph.
+    // There should be 2 paragraphs on page 1 and 1 paragraph on page 2.
+    pXmlObj = getXPathNode(pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt");
+    pXmlNodes = pXmlObj->nodesetval;
+    numberOfNodes = xmlXPathNodeSetGetLength(pXmlNodes);
+    CPPUNIT_ASSERT_EQUAL(2, numberOfNodes);
+    xmlXPathFreeObject(pXmlObj);
+
+    pXmlObj = getXPathNode(pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/txt");
+    pXmlNodes = pXmlObj->nodesetval;
+    numberOfNodes = xmlXPathNodeSetGetLength(pXmlNodes);
+    CPPUNIT_ASSERT_EQUAL(1, numberOfNodes);
+    xmlXPathFreeObject(pXmlObj);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index bac984ba36dc..c33571aaf047 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -1298,8 +1298,33 @@ bool SwFrame::IsMoveable( const SwLayoutFrame* _pLayoutFrame ) const
                   _pLayoutFrame->IsInDocBody() ||
                   _pLayoutFrame->IsInFootnote() )
         {
+            /*
+            https://bugs.documentfoundation.org/show_bug.cgi?id=114306
+            This method is mostly used like:
+
+            if (<other conditions> && IsMoveable())
+            {
+                ...
+                SwFlowFrame::MoveFwd()
+            }
+
+            or
+
+            if (<other conditions> && IsMoveable())
+            {
+                ...
+                SwFlowFrame::MoveBwd()
+            }
+
+            If IsMovable() is called before a MoveFwd() the method may return false if there is no NextCellLeaf.
+            If IsMovable() is called before a MoveBwd() the method may return false if there is no PrevCellLeaf.
+
+            The patch should make IsMoveable() more symmetric.
+            */
             if ( _pLayoutFrame->IsInTab() && !IsTabFrame() &&
-                 ( !IsContentFrame() || !const_cast<SwFrame*>(this)->GetNextCellLeaf( MAKEPAGE_NONE ) ) )
+                 ( !IsContentFrame() || (!const_cast<SwFrame*>(this)->GetNextCellLeaf( MAKEPAGE_NONE )
+                                      && !const_cast<SwFrame*>(this)->GetPrevCellLeaf( MAKEPAGE_NONE )) )
+        )
             {
                 bRetVal = false;
             }
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 02bed5f77dfa..779ec657ccda 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -2006,11 +2006,15 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat )
         const SwLayoutFrame* pUpperFrame = m_rThis.GetUpper();
         while ( pUpperFrame )
         {
-            if ( pUpperFrame->IsTabFrame() )
+            if ( pUpperFrame->IsTabFrame() || pUpperFrame->IsRowFrame() )
             {
                 return false;
             }
-            if ( pUpperFrame->IsColumnFrame() && pUpperFrame->IsInSct() )
+
+            // If the text frame is a follow-in-table, that can move
+            // backward as well.
+            bool bIsFollow = const_cast<SwLayoutFrame*>(pUpperFrame)->GetPrevCellLeaf();
+            if ( ( pUpperFrame->IsColumnFrame() && pUpperFrame->IsInSct() ) || bIsFollow )
             {
                 break;
             }


More information about the Libreoffice-commits mailing list