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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 20:57:40 UTC 2018


 sw/qa/extras/layout/data/forcepoint75-1.rtf |binary
 sw/qa/extras/layout/layout.cxx              |   16 +++++++++++++++-
 sw/source/core/inc/flowfrm.hxx              |    2 ++
 sw/source/core/layout/flowfrm.cxx           |    8 ++++++--
 sw/source/core/layout/sectfrm.cxx           |   14 ++++++++------
 sw/source/core/layout/tabfrm.cxx            |   17 ++++++++++++++---
 sw/source/core/layout/wsfrm.cxx             |    4 ++--
 7 files changed, 47 insertions(+), 14 deletions(-)

New commits:
commit faac30002b5a2af6050d440456e09dccedb15fee
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Dec 5 11:58:41 2018 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Dec 18 21:57:14 2018 +0100

    forcepoint#75 avoid move of table in footnote
    
    Change-Id: I3426df04b938487844e471c4cd34bcd72a1b3dfc
    Reviewed-on: https://gerrit.libreoffice.org/64617
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/layout/data/forcepoint75-1.rtf b/sw/qa/extras/layout/data/forcepoint75-1.rtf
new file mode 100644
index 000000000000..01a52963757d
Binary files /dev/null and b/sw/qa/extras/layout/data/forcepoint75-1.rtf differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index f1c167f2b2e2..e2b3006c1b4e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -55,6 +55,7 @@ public:
     void testUserFieldTypeLanguage();
     void testTdf109137();
     void testForcepoint72();
+    void testForcepoint75();
     void testForcepoint76();
     void testTdf118058();
     void testTdf117188();
@@ -92,6 +93,7 @@ public:
     CPPUNIT_TEST(testUserFieldTypeLanguage);
     CPPUNIT_TEST(testTdf109137);
     CPPUNIT_TEST(testForcepoint72);
+    CPPUNIT_TEST(testForcepoint75);
     CPPUNIT_TEST(testForcepoint76);
     CPPUNIT_TEST(testTdf118058);
     CPPUNIT_TEST(testTdf117188);
@@ -2547,10 +2549,22 @@ void SwLayoutWriter::testTdf109137()
                 /*nNumberOfNodes=*/1);
 }
 
-//just care it doesn't crash
+//just care it doesn't crash/assert
 void SwLayoutWriter::testForcepoint72() { createDoc("forcepoint72-1.rtf"); }
 
 //just care it doesn't crash/assert
+void SwLayoutWriter::testForcepoint75()
+{
+    try
+    {
+        createDoc("forcepoint75-1.rtf");
+    }
+    catch (...)
+    {
+    }
+}
+
+//just care it doesn't crash/assert
 void SwLayoutWriter::testForcepoint76() { createDoc("forcepoint76-1.rtf"); }
 
 void SwLayoutWriter::testTdf118058()
diff --git a/sw/source/core/inc/flowfrm.hxx b/sw/source/core/inc/flowfrm.hxx
index 6f08a70bd39f..ba5930b4c145 100644
--- a/sw/source/core/inc/flowfrm.hxx
+++ b/sw/source/core/inc/flowfrm.hxx
@@ -229,6 +229,8 @@ public:
     void SetFlyLock( bool bNew ){ m_bFlyLock = bNew; }
     bool IsFlyLock() const {    return m_bFlyLock; }
 
+    bool ForbiddenForFootnoteCntFwd() const;
+
     // Casting of a Frame into a FlowFrame (if it is one, otherwise 0)
     // These methods need to be customized in subclasses!
     static       SwFlowFrame *CastFlowFrame( SwFrame *pFrame );
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index e79318a065f3..5e3db880b044 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1822,6 +1822,11 @@ bool SwFlowFrame::CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bIgnoreMyOwnK
     return bMovedFwd;
 }
 
+bool SwFlowFrame::ForbiddenForFootnoteCntFwd() const
+{
+    return m_rThis.IsTabFrame() || m_rThis.IsInTab();
+}
+
 /// Return value tells us whether the Frame has changed the page.
 bool SwFlowFrame::MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways )
 {
@@ -1829,8 +1834,7 @@ bool SwFlowFrame::MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways )
     SwFootnoteBossFrame *pOldBoss = m_rThis.FindFootnoteBossFrame();
     if (m_rThis.IsInFootnote())
     {
-        assert(!m_rThis.IsTabFrame()); // prevented by IsMoveable()
-        assert(!m_rThis.IsInTab());
+        assert(!ForbiddenForFootnoteCntFwd()); // prevented by IsMoveable()
         if (!m_rThis.IsContentFrame() || !pOldBoss)
         {
             SAL_WARN("sw.core", "Tables in footnotes are not truly supported");
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 0596f5076418..5c1b39e242e4 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -93,11 +93,9 @@ SwSectionFrame::SwSectionFrame( SwSectionFrame &rSect, bool bMaster ) :
 
     if( bMaster )
     {
-        if( rSect.IsFollow() )
-        {
-            SwSectionFrame* pMaster = rSect.FindMaster();
+        SwSectionFrame* pMaster = rSect.IsFollow() ? rSect.FindMaster() : nullptr;
+        if (pMaster)
             pMaster->SetFollow( this );
-        }
         SetFollow( &rSect );
     }
     else
@@ -2157,8 +2155,12 @@ SwTwips SwSectionFrame::Grow_( SwTwips nDist, bool bTst )
 
         bool bInCalcContent = GetUpper() && IsInFly() && FindFlyFrame()->IsLocked();
         // OD 2004-03-15 #116561# - allow grow in online layout
-        bool bGrow = !Lower() || !Lower()->IsColumnFrame() || !Lower()->GetNext() ||
-             GetSection()->GetFormat()->GetBalancedColumns().GetValue();
+        bool bGrow = !Lower() || !Lower()->IsColumnFrame() || !Lower()->GetNext();
+        if (!bGrow)
+        {
+            SwSection* pSection = GetSection();
+            bGrow = pSection && pSection->GetFormat()->GetBalancedColumns().GetValue();
+        }
         if( !bGrow )
         {
              const SwViewShell *pSh = getRootFrame()->GetCurrShell();
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 16c2664b177c..b201bbbe648d 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1935,7 +1935,11 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
         SwFrame *pPre = GetPrev();
         if ( pPre && pPre->IsTabFrame() && static_cast<SwTabFrame*>(pPre)->GetFollow() == this)
         {
-            if ( !MoveFwd( bMakePage, false ) )
+            // don't make the effort to move fwd if its known
+            // conditions that are known not to work
+            if (IsInFootnote() && ForbiddenForFootnoteCntFwd())
+                bMakePage = false;
+            else if (!MoveFwd(bMakePage, false))
                 bMakePage = false;
             bMovedFwd = true;
         }
@@ -2560,8 +2564,15 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
         const SwFrame* pOldUpper = GetUpper();
 
         //Let's see if we find some place anywhere...
-        if ( !bMovedFwd && !MoveFwd( bMakePage, false ) )
-            bMakePage = false;
+        if (!bMovedFwd)
+        {
+            // don't make the effort to move fwd if its known
+            // conditions that are known not to work
+            if (IsInFootnote() && ForbiddenForFootnoteCntFwd())
+                bMakePage = false;
+            else if (!MoveFwd(bMakePage, false))
+                bMakePage = false;
+        }
 
         // #i29771# Reset bSplitError flag on change of upper
         if ( GetUpper() != pOldUpper )
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 7ecc6e95e650..f721eeaf649e 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -979,10 +979,10 @@ void SwFrame::RemoveFromLayout()
 {
     OSL_ENSURE( mpUpper, "Remove without upper?" );
 
-    if( mpPrev )
+    if (mpPrev)
         // one out of the middle is removed
         mpPrev->mpNext = mpNext;
-    else
+    else if (mpUpper)
     {   // the first in a list is removed //TODO
         OSL_ENSURE( mpUpper->m_pLower == this, "Layout is inconsistent." );
         mpUpper->m_pLower = mpNext;


More information about the Libreoffice-commits mailing list