[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sw/qa sw/source

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 5 23:00:17 UTC 2019


 sw/qa/extras/uiwriter/data/fdo114306.odt   |binary
 sw/qa/extras/uiwriter/data/fdo114306_2.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx         |   28 ++++++++++++
 sw/source/core/layout/findfrm.cxx          |    8 +++
 sw/source/core/layout/flowfrm.cxx          |    9 +++
 sw/source/core/layout/tabfrm.cxx           |   67 +++++++++++++++++++++--------
 6 files changed, 91 insertions(+), 21 deletions(-)

New commits:
commit 956e80b5af61d2f5a0a294566ff2164b057fe474
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Fri Apr 5 16:18:36 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sat Apr 6 00:59:49 2019 +0200

    Revert "tdf#114306: Revert commits fixing this issue ( 6.1 only )"
    
    This reverts commit f15146021b722dda0cf10cb08de6e0a3c525168a.
    
    Change-Id: Ibf5092630084a0137e5dc13b5b8ef0c654ff83c7
    Reviewed-on: https://gerrit.libreoffice.org/70308
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

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/data/fdo114306_2.odt b/sw/qa/extras/uiwriter/data/fdo114306_2.odt
new file mode 100755
index 000000000000..b4bebc58add5
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo114306_2.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index b9c7231a3d96..ff1e4b1f4b94 100755
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -332,6 +332,8 @@ public:
     void testTdf112448();
     void testTdf113790();
     void testTdf108048();
+    void testTdf114306();
+    void testTdf114306_2();
     void testTdf113481();
     void testTdf115013();
     void testTdf114536();
@@ -526,6 +528,8 @@ public:
     CPPUNIT_TEST(testTdf112448);
     CPPUNIT_TEST(testTdf113790);
     CPPUNIT_TEST(testTdf108048);
+    CPPUNIT_TEST(testTdf114306);
+    CPPUNIT_TEST(testTdf114306_2);
     CPPUNIT_TEST(testTdf113481);
     CPPUNIT_TEST(testTdf115013);
     CPPUNIT_TEST(testTdf114536);
@@ -5482,6 +5486,30 @@ void SwUiWriterTest::testTdf72942()
     CPPUNIT_ASSERT_EQUAL(OUString("Liberation Sans"), getProperty<OUString>(xRun4, "CharFontName"));
 }
 
+void SwUiWriterTest::testTdf114306()
+{
+    load(DATA_DIRECTORY, "fdo114306.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+
+    // 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.
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt", 2);
+    assertXPath(pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/txt", 1);
+}
+
+void SwUiWriterTest::testTdf114306_2()
+{
+    // tdf#114306 fix unexpected page break in row-spanned table
+    // load regression document without writer crash
+    load(DATA_DIRECTORY, "fdo114306_2.odt");
+
+    // correct number of pages
+    CPPUNIT_ASSERT_EQUAL(4, getPages());
+}
+
+
 // During insert of the document with list inside into the main document inside the list
 // we should merge both lists into one, when they have the same list properties
 void SwUiWriterTest::testTdf113877()
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index c327ebfcab2c..b720d9936a45 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -1340,8 +1340,14 @@ bool SwFrame::IsMoveable( const SwLayoutFrame* _pLayoutFrame ) const
                   _pLayoutFrame->IsInDocBody() ||
                   _pLayoutFrame->IsInFootnote() )
         {
+            // 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.
             if ( _pLayoutFrame->IsInTab() && !IsTabFrame() &&
-                 ( !IsContentFrame() || !const_cast<SwFrame*>(this)->GetNextCellLeaf() ) )
+                 ( !IsContentFrame() || (!const_cast<SwFrame*>(this)->GetNextCellLeaf()
+                                      && !const_cast<SwFrame*>(this)->GetPrevCellLeaf()) )
+                )
             {
                 bRetVal = false;
             }
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 34a3258e68b4..4366c98af710 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -2041,14 +2041,19 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat )
         const SwLayoutFrame* pUpperFrame = m_rThis.GetUpper();
         while ( pUpperFrame )
         {
-            if ( pUpperFrame->IsTabFrame() )
+            if ( pUpperFrame->IsTabFrame() || pUpperFrame->IsRowFrame() )
             {
                 return false;
             }
             // If the text frame is a follow-section-in-table, that can move
             // backward as well.
             bool bIsFollowSection = pUpperFrame->IsSctFrame() && static_cast<const SwSectionFrame*>(pUpperFrame)->GetPrecede();
-            if ( ( pUpperFrame->IsColumnFrame() && pUpperFrame->IsInSct() ) || bIsFollowSection )
+
+            // 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() ) || bIsFollowSection || bIsFollow )
             {
                 break;
             }
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index a4a5a7820cf7..e1aea42d8bf9 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -164,7 +164,7 @@ void SwTabFrame::RegistFlys()
 }
 
 void SwInvalidateAll( SwFrame *pFrame, long nBottom );
-static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom );
+static bool lcl_RecalcRow( SwRowFrame* pRow, long nBottom );
 static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, long lYStart, bool bInva );
 // #i26945# - add parameter <_bOnlyRowsAndCells> to control
 // that only row and cell frames are formatted.
@@ -290,7 +290,7 @@ static void lcl_InvalidateLowerObjs( SwLayoutFrame& _rLayoutFrame,
     }
 }
 
-// Local helper function to shrink all lowers of rRow to 0 height
+// Local helper function to shrink all lowers of pRow to 0 height
 static void lcl_ShrinkCellsAndAllContent( SwRowFrame& rRow )
 {
     SwCellFrame* pCurrMasterCell = static_cast<SwCellFrame*>(rRow.Lower());
@@ -682,7 +682,7 @@ static bool lcl_RecalcSplitLine( SwRowFrame& rLastLine, SwRowFrame& rFollowLine,
     rLastLine.SetInSplit();
 
     // Do the recalculation
-    lcl_RecalcRow( rLastLine, LONG_MAX );
+    lcl_RecalcRow( &rLastLine, LONG_MAX );
     // #115759# - force a format of the last line in order to
     // get the correct height.
     rLastLine.InvalidateSize();
@@ -1567,7 +1567,8 @@ static bool lcl_InnerCalcLayout( SwFrame *pFrame,
     return bRet;
 }
 
-static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
+// returns false if pRow is invalid
+static bool lcl_RecalcRow( SwRowFrame* pRow, long nBottom )
 {
     // FME 2007-08-30 #i81146# new loop control
     int nLoopControlRuns_1 = 0;
@@ -1581,14 +1582,14 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
         int nLoopControlRuns_2 = 0;
         sal_uInt16 nLoopControlStage_2 = 0;
 
-        while( lcl_InnerCalcLayout( &rRow, nBottom ) )
+        while( lcl_InnerCalcLayout( pRow, nBottom ) )
         {
             if ( ++nLoopControlRuns_2 > nLoopControlMax )
             {
                 SAL_WARN_IF(nLoopControlStage_2 == 0, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 1!");
                 SAL_WARN_IF(nLoopControlStage_2 == 1, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 2!!");
                 SAL_WARN_IF(nLoopControlStage_2 >= 2, "sw.layout", "LoopControl_2 in lcl_RecalcRow: Stage 3!!!");
-                rRow.ValidateThisAndAllLowers( nLoopControlStage_2++ );
+                pRow->ValidateThisAndAllLowers( nLoopControlStage_2++ );
                 nLoopControlRuns_2 = 0;
                 if( nLoopControlStage_2 > 2 )
                     break;
@@ -1601,14 +1602,39 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
         {
             // #115759# - force another format of the
             // lowers, if at least one of it was invalid.
-            bCheck = SwContentFrame::CalcLowers( &rRow, rRow.GetUpper(), nBottom, true );
+
+            // tdf#114306 writer may crash because pRow points to a deleted SwRowFrame
+            SwRowFrame* pOriginalRow = pRow;
+            OSL_ENSURE(pOriginalRow->GetUpper() && pOriginalRow->GetUpper()->IsTabFrame(), "No table");
+            SwTabFrame* pOriginalTab = static_cast<SwTabFrame*>(pRow->GetUpper());
+
+            bCheck = SwContentFrame::CalcLowers( pRow, pRow->GetUpper(), nBottom, true );
+
+            bool bRowStillExists = false;
+            SwFrame* pTestRow = pOriginalTab->Lower();
+
+            while (pTestRow)
+            {
+                if (pTestRow == pRow)
+                {
+                    bRowStillExists = true;
+                    break;
+                }
+                pTestRow = pTestRow->GetNext();
+            }
+
+            if (!bRowStillExists)
+            {
+                SAL_WARN("sw.layout", "no row anymore at " << pRow);
+                return false;
+            }
 
             // NEW TABLES
             // First we calculate the cells with row span of < 1, afterwards
             // all cells with row span of > 1:
             for ( int i = 0; i < 2; ++i )
             {
-                SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(rRow.Lower());
+                SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(pRow->Lower());
                 while ( pCellFrame )
                 {
                     const bool bCalc = 0 == i ?
@@ -1634,7 +1660,7 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
                     SAL_WARN_IF(nLoopControlStage_1 == 0, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 1!");
                     SAL_WARN_IF(nLoopControlStage_1 == 1, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 2!!");
                     SAL_WARN_IF(nLoopControlStage_1 >= 2, "sw.layout", "LoopControl_1 in lcl_RecalcRow: Stage 3!!!");
-                    rRow.ValidateThisAndAllLowers( nLoopControlStage_1++ );
+                    pRow->ValidateThisAndAllLowers( nLoopControlStage_1++ );
                     nLoopControlRuns_1 = 0;
                     if( nLoopControlStage_1 > 2 )
                         break;
@@ -1644,7 +1670,8 @@ static void lcl_RecalcRow( SwRowFrame& rRow, long nBottom )
             }
         }
         break;
-    } while( true );
+    } while (true);
+    return true;
 }
 
 static void lcl_RecalcTable( SwTabFrame& rTab,
@@ -1659,7 +1686,7 @@ static void lcl_RecalcTable( SwTabFrame& rTab,
             rNotify.SetLowersComplete( true );
         }
         ::SwInvalidatePositions( pFirstRow, LONG_MAX );
-        lcl_RecalcRow( static_cast<SwRowFrame&>(*pFirstRow), LONG_MAX );
+        lcl_RecalcRow( static_cast<SwRowFrame*>(pFirstRow), LONG_MAX );
     }
 }
 
@@ -2125,7 +2152,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
                             {
                                 ::SwInvalidateAll( pLastLine, LONG_MAX );
                                 SetRebuildLastLine( true );
-                                lcl_RecalcRow( static_cast<SwRowFrame&>(*pLastLine), LONG_MAX );
+                                lcl_RecalcRow( static_cast<SwRowFrame*>(pLastLine), LONG_MAX );
                                 SetRebuildLastLine( false );
                             }
 
@@ -2251,7 +2278,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
                 }
                 else if (m_bONECalcLowers)
                 {
-                    lcl_RecalcRow( static_cast<SwRowFrame&>(*Lower()), LONG_MAX );
+                    lcl_RecalcRow( static_cast<SwRowFrame*>(Lower()), LONG_MAX );
                     m_bONECalcLowers = false;
                 }
             }
@@ -2274,7 +2301,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
             }
             else if (m_bONECalcLowers)
             {
-                lcl_RecalcRow( static_cast<SwRowFrame&>(*Lower()), LONG_MAX );
+                lcl_RecalcRow( static_cast<SwRowFrame*>(Lower()), LONG_MAX );
                 m_bONECalcLowers = false;
             }
 
@@ -2331,7 +2358,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
 
             // 1. Try: bTryToSplit = true  => Try to split the row.
             // 2. Try: bTryToSplit = false => Split the table between the rows.
-            if ( pFirstNonHeadlineRow->GetNext() || bTryToSplit )
+            if ((pFirstNonHeadlineRow && pFirstNonHeadlineRow->GetNext()) || bTryToSplit )
             {
                 SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper());
                 if( IsInSct() || GetUpper()->IsInTab() ) // TABLE IN TABLE)
@@ -2340,7 +2367,11 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
 
                 {
                     SetInRecalcLowerRow( true );
-                    ::lcl_RecalcRow( static_cast<SwRowFrame&>(*Lower()), nDeadLine );
+                    SwRowFrame* pRow = static_cast<SwRowFrame*>(Lower());
+                    if (!lcl_RecalcRow(pRow, nDeadLine))
+                    {
+                        pFirstNonHeadlineRow = GetFirstNonHeadlineRow();
+                    }
                     SetInRecalcLowerRow( false );
                 }
                 m_bLowersFormatted = true;
@@ -2440,7 +2471,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
                     // to nDeadLine may not be enough.
                     if ( bSplitError && bTryToSplit ) // no restart if we did not try to split: i72847, i79426
                     {
-                        lcl_RecalcRow( static_cast<SwRowFrame&>(*Lower()), LONG_MAX );
+                        lcl_RecalcRow( static_cast<SwRowFrame*>(Lower()), LONG_MAX );
                         setFrameAreaPositionValid(false);
                         bTryToSplit = false;
                         continue;
@@ -2481,7 +2512,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext)
                             // its content.
                             const bool bOldJoinLock =  GetFollow()->IsJoinLocked();
                             GetFollow()->LockJoin();
-                            ::lcl_RecalcRow( static_cast<SwRowFrame&>(*GetFollow()->Lower()),
+                            ::lcl_RecalcRow( static_cast<SwRowFrame*>(GetFollow()->Lower()),
                                              fnRectX.GetBottom(GetFollow()->GetUpper()->getFrameArea()) );
                             // #i43913#
                             // #i63632# Do not unlock the


More information about the Libreoffice-commits mailing list