sw/source/core/inc/cntfrm.hxx    |    3 ++-
 sw/source/core/layout/tabfrm.cxx |   26 ++++++++++++++------------
 2 files changed, 16 insertions(+), 13 deletions(-)

New commits:
commit 266a1181569b27cf087324807274e290ee17bc04
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Thu Jun 27 13:04:51 2019 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Mon Jul 1 17:35:32 2019 +0200

    sw: avoid deleting the iterated SwRowFrame on tdf104188-4.odt
    
    The change in commit 1e6dec4b4313212a3bdc6bb06155fd65e795368b
    was not enough to fix this problem.
    
    SwContentFrame::CalcLowers() may move a SwTextFrame to the previous
    page; in that case Calc() on the upper is a bad idea because it may then
    call RemoveFollowFlowLine() and delete the SwRowFrame that is being
    iterated.
    
    There is one other (unknown) bugdoc with this problem, let's hope it's
    fixed as well...
    
    (regression from commit 18765b9fa739337d2d891513f6e2fb7c3ce23b50)
    
    Reviewed-on: https://gerrit.libreoffice.org/74793
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    (cherry picked from commit 1cb7e4899b5ada902e99a0c964ee047950c07044)
    Reviewed-on: https://gerrit.libreoffice.org/74835
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    (cherry picked from commit c5e8780391acb1f9fd72f8956438a79dfa64ca53)
    
    Change-Id: I3c55a0d7ef0350a482fb150d3e96c3b34853400d
    Reviewed-on: https://gerrit.libreoffice.org/74953
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    Tested-by: Michael Stahl <michael.st...@cib.de>

diff --git a/sw/source/core/inc/cntfrm.hxx b/sw/source/core/inc/cntfrm.hxx
index aa28f580f3ad..998cf2ed1a1e 100644
--- a/sw/source/core/inc/cntfrm.hxx
+++ b/sw/source/core/inc/cntfrm.hxx
@@ -92,7 +92,8 @@ public:
 
     inline  SwContentFrame* GetNextContentFrame() const;
     inline  SwContentFrame* GetPrevContentFrame() const;
-    static bool CalcLowers( SwLayoutFrame* pLay, const SwLayoutFrame* 
pDontLeave, long nBottom, bool bSkipRowSpanCells );
+    static bool CalcLowers(SwLayoutFrame & rLay, SwLayoutFrame const& 
rDontLeave,
+            long nBottom, bool bSkipRowSpanCells);
 };
 
 inline SwContentFrame* SwContentFrame::GetNextContentFrame() const
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index ab32ccdc3fc9..800e6c18fd64 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1462,25 +1462,22 @@ static void lcl_InvalidateAllLowersPrt( SwLayoutFrame* 
pLayFrame )
     }
 }
 
-bool SwContentFrame::CalcLowers( SwLayoutFrame* pLay, const SwLayoutFrame* 
pDontLeave,
+bool SwContentFrame::CalcLowers(SwLayoutFrame & rLay, SwLayoutFrame const& 
rDontLeave,
                                  long nBottom, bool bSkipRowSpanCells )
 {
-    if ( !pLay )
-        return true;
-
-    vcl::RenderContext* pRenderContext = 
pLay->getRootFrame()->GetCurrShell()->GetOut();
+    vcl::RenderContext* pRenderContext = 
rLay.getRootFrame()->GetCurrShell()->GetOut();
     // LONG_MAX == nBottom means we have to calculate all
     bool bAll = LONG_MAX == nBottom;
     bool bRet = false;
-    SwContentFrame *pCnt = pLay->ContainsContent();
-    SwRectFnSet aRectFnSet(pLay);
+    SwContentFrame *pCnt = rLay.ContainsContent();
+    SwRectFnSet aRectFnSet(&rLay);
 
     // FME 2007-08-30 #i81146# new loop control
     int nLoopControlRuns = 0;
     const int nLoopControlMax = 10;
     const SwModify* pLoopControlCond = nullptr;
 
-    while ( pCnt && pDontLeave->IsAnLower( pCnt ) )
+    while (pCnt && rDontLeave.IsAnLower(pCnt))
     {
         // #115759# - check, if a format of content frame is
         // possible. Thus, 'copy' conditions, found at the beginning of
@@ -1536,7 +1533,7 @@ bool SwContentFrame::CalcLowers( SwLayoutFrame* pLay, 
const SwLayoutFrame* pDont
                     if ( nLoopControlRuns < nLoopControlMax )
                     {
                         // restart format with first content
-                        pCnt = pLay->ContainsContent();
+                        pCnt = rLay.ContainsContent();
                         continue;
                     }
 
@@ -1545,6 +1542,11 @@ bool SwContentFrame::CalcLowers( SwLayoutFrame* pLay, 
const SwLayoutFrame* pDont
 #endif
                 }
             }
+            if (!rDontLeave.IsAnLower(pCnt)) // moved backward?
+            {
+                pCnt = rLay.ContainsContent();
+                continue; // avoid formatting new upper on different page
+            }
             pCnt->GetUpper()->Calc(pRenderContext);
         }
         if( ! bAll && 
aRectFnSet.YDiff(aRectFnSet.GetTop(pCnt->getFrameArea()), nBottom) > 0 )
@@ -1600,7 +1602,7 @@ static bool lcl_InnerCalcLayout( SwFrame *pFrame,
     return bRet;
 }
 
-static void lcl_RecalcRow( SwRowFrame* pRow, long nBottom )
+static void lcl_RecalcRow(SwRowFrame *const pRow, long const nBottom)
 {
     // FME 2007-08-30 #i81146# new loop control
     int nLoopControlRuns_1 = 0;
@@ -1640,7 +1642,7 @@ static void lcl_RecalcRow( SwRowFrame* pRow, long nBottom 
)
             OSL_ENSURE(pOriginalRow->GetUpper() && 
pOriginalRow->GetUpper()->IsTabFrame(), "No table");
             SwTabFrame* pOriginalTab = 
static_cast<SwTabFrame*>(pRow->GetUpper());
 
-            bCheck = SwContentFrame::CalcLowers( pRow, pRow->GetUpper(), 
nBottom, true );
+            bCheck = SwContentFrame::CalcLowers(*pRow, *pRow->GetUpper(), 
nBottom, true);
 
             bool bRowStillExists = false;
             SwFrame* pTestRow = pOriginalTab->Lower();
@@ -1678,7 +1680,7 @@ static void lcl_RecalcRow( SwRowFrame* pRow, long nBottom 
)
                         SwCellFrame& rToRecalc = 0 == i ?
                                                
const_cast<SwCellFrame&>(pCellFrame->FindStartEndOfRowSpanCell( true )) :
                                                *pCellFrame;
-                        bCheck  |= SwContentFrame::CalcLowers( &rToRecalc, 
&rToRecalc, nBottom, false );
+                        bCheck |= SwContentFrame::CalcLowers(rToRecalc, 
rToRecalc, nBottom, false);
                     }
 
                     pCellFrame = 
static_cast<SwCellFrame*>(pCellFrame->GetNext());
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to