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

Michael Stahl mstahl at redhat.com
Mon Jun 26 14:04:26 UTC 2017


 sw/qa/extras/uiwriter/uiwriter.cxx |    2 +-
 sw/source/core/inc/frame.hxx       |    8 --------
 sw/source/core/layout/findfrm.cxx  |   12 ------------
 sw/source/core/layout/ftnfrm.cxx   |   12 +++++++-----
 sw/source/core/layout/sectfrm.cxx  |   32 ++++----------------------------
 sw/source/core/layout/trvlfrm.cxx  |    8 ++++----
 6 files changed, 16 insertions(+), 58 deletions(-)

New commits:
commit 272d5a02a3de2350f8af7a93281b651316b24ae5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jun 26 15:01:36 2017 +0200

    Revert "tdf#108524 sw: attempt to split section frames inside table cells"
    
    This reverts commit f991b842addddeada6dc45c4054deeca5aa7f17b.
    
    It doesn't really work and crashes on ooo61225-1.sxw in
    
    1 in SwFrame::FindTabFrame() (this=0x0) at sw/source/core/inc/frame.hxx:913
    2 in SwFrame::GetNextSctLeaf(MakePageType) (this=0x3137130, eMakePage=MAKEPAGE_INSERT) at sw/source/core/layout/sectfrm.cxx:1529
    3 in SwFrame::GetLeaf(MakePageType, bool) (this=0x3137130, eMakePage=MAKEPAGE_INSERT, bFwd=true) at sw/source/core/layout/flowfrm.cxx:805
    4 in SwFlowFrame::MoveFwd(bool, bool, bool) (this=0x31371d8, bMakePage=true, bPageBreak=false, bMoveAlways=false) at sw/source/core/layout/flowfrm.cxx:1861
    
    The code added in GetNextSctLeaf() looks unfinished to me: it assumes that
    something else has added a follow-frame for the SwCellFrame containing
    the SwSectionFrame already, but AFAICT the GetNextSctLeaf() function
    is responsible for creating that SwCellFrame follow.
    
    The caller (in GetLeaf()) specifically checks for this condition and
    avoids calling GetNextCellLeaf().
    
    Change-Id: I51875830771f07f5d2fec293f6063c73fc68d468

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index cbcf944c7521..34974e3f3139 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -397,7 +397,7 @@ public:
     CPPUNIT_TEST(testMsWordCompTrailingBlanks);
     CPPUNIT_TEST(testCreateDocxAnnotation);
     CPPUNIT_TEST(testTdf107976);
-    CPPUNIT_TEST(testTdf108524);
+//    CPPUNIT_TEST(testTdf108524);
     CPPUNIT_TEST(testTableInSection);
     CPPUNIT_TEST_SUITE_END();
 
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 50eac0865054..62ce2de3feae 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -41,7 +41,6 @@ class SwFootnoteFrame;
 class SwFootnoteBossFrame;
 class SwTabFrame;
 class SwRowFrame;
-class SwCellFrame;
 class SwFlowFrame;
 class SwContentFrame;
 class SfxPoolItem;
@@ -223,7 +222,6 @@ class SW_DLLPUBLIC SwFrame: public SwClient, public SfxBroadcaster
     const SwLayoutFrame* ImplGetNextLayoutLeaf( bool bFwd ) const;
 
     SwPageFrame* ImplFindPageFrame();
-    SwCellFrame* ImplFindCellFrame();
 
 protected:
     SwSortedObjs* mpDrawObjs;    // draw objects, can be 0
@@ -761,12 +759,6 @@ public:
     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const;
     void dumpChildrenAsXml(xmlTextWriterPtr writer) const;
     bool IsCollapse() const;
-
-    /// Find the nearest table cell frame that contains us, if any.
-    SwCellFrame* FindCellFrame()
-    {
-        return IsInTab() ? ImplFindCellFrame() : nullptr;
-    }
 };
 
 inline bool SwFrame::IsInDocBody() const
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index df630a270c5c..74942256bef4 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -459,18 +459,6 @@ SwTabFrame* SwFrame::ImplFindTabFrame()
     return static_cast<SwTabFrame*>(pRet);
 }
 
-SwCellFrame* SwFrame::ImplFindCellFrame()
-{
-    SwFrame *pRet = this;
-    while (!pRet->IsCellFrame())
-    {
-        pRet = pRet->GetUpper();
-        if (!pRet)
-            return nullptr;
-    }
-    return static_cast<SwCellFrame*>(pRet);
-}
-
 SwSectionFrame* SwFrame::ImplFindSctFrame()
 {
     SwFrame *pRet = this;
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 06c186c5d4c2..b94ba4582d85 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -22,7 +22,6 @@
 #include <fmtftn.hxx>
 #include <fmtclbl.hxx>
 #include "sectfrm.hxx"
-#include "cellfrm.hxx"
 #include "section.hxx"
 #include <IDocumentSettingAccess.hxx>
 #include "rootfrm.hxx"
@@ -588,16 +587,6 @@ namespace
             return pLayFrame->GetNextLayoutLeaf();
         return pLayFrame;
     }
-
-    /// Checks if pFrame is in a table, which itself is in a section.
-    bool IsInTableInSection(SwFrame* pFrame)
-    {
-        if (!pFrame->IsInTab())
-            return false;
-
-        // The frame is in a table, see if the table is in a section.
-        return pFrame->FindTabFrame()->IsInSct();
-    }
 }
 
 void SwSectionFrame::MoveContentAndDelete( SwSectionFrame* pDel, bool bSave )
@@ -1450,9 +1439,9 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
         return static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(GetUpper()->GetNext())->Lower());
     if( GetUpper()->IsColBodyFrame() && GetUpper()->GetUpper()->GetNext() )
         return static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(GetUpper()->GetUpper()->GetNext())->Lower());
-    // Inside a table-in-section, or sections of headers/footers, there can be only
+    // Inside a section, in tables, or sections of headers/footers, there can be only
     // one column shift be made, one of the above shortcuts should have applied!
-    if( IsInTableInSection(GetUpper()) || FindFooterOrHeader() )
+    if( GetUpper()->IsInTab() || FindFooterOrHeader() )
         return nullptr;
 
     SwSectionFrame *pSect = FindSctFrame();
@@ -1509,9 +1498,6 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
     const bool bBody = IsInDocBody();
     const bool bFootnotePage = FindPageFrame()->IsFootnotePage();
 
-    // The "pLayLeaf is in a table" case is rejected by default, so that it
-    // can't happen that we try to move a table to one of its own cells.
-    bool bLayLeafTableAllowed = false;
     SwLayoutFrame *pLayLeaf;
     // A shortcut for TabFrames such that not all cells need to be visited
     if( bWrongPage )
@@ -1521,16 +1507,6 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
         SwContentFrame* pTmpCnt = static_cast<SwTabFrame*>(this)->FindLastContent();
         pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : nullptr;
     }
-    else if (IsInTab() && !IsInTableInSection(this))
-    {
-        // This frame is in a table-not-in-section, its follow should be
-        // inserted under the follow of the frame's cell.
-        pLayLeaf = FindCellFrame()->GetFollowCell();
-        if (pLayLeaf->FindTabFrame() == FindTabFrame())
-            SAL_WARN("sw.layout", "my table frame and my follow's table frame is the same");
-        // In this case pLayLeaf pointing to an in-table frame is OK.
-        bLayLeafTableAllowed = true;
-    }
     else
     {
         pLayLeaf = GetNextLayoutLeaf();
@@ -1558,10 +1534,10 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
                 pLayLeaf = nullptr;
                 continue;
             }
-            // Once inBody always inBody, don't step into tables-in-sections and not into other sections
+            // Once inBody always inBody, don't step into tables and not into other sections
             if ( (bBody && !pLayLeaf->IsInDocBody()) ||
                  (IsInFootnote() != pLayLeaf->IsInFootnote() ) ||
-                 (pLayLeaf->IsInTab() && !bLayLeafTableAllowed) ||
+                 pLayLeaf->IsInTab() ||
                  ( pLayLeaf->IsInSct() && ( !pSect->HasFollow()
                    || pSect->GetFollow() != pLayLeaf->FindSctFrame() ) ) )
             {
commit ceabd9e3351f1f18f92e1ef302e76eee3ccc714f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jun 26 13:18:47 2017 +0200

    Revert "crashtesting failure on ooo61225-1.sxw"
    
    This reverts commit 55d4cc340068b0f590ab3a2119a2a2a71a3f8e5e.
    
    It's obviously bogus to have mbInfTab set but ImplFindTabFrame return
    null.  Also, just loading the document still crashes with the same
    problem in a different place.

diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index e608ba7ca793..e14b50289733 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -802,11 +802,13 @@ bool SwFrame::IsFootnoteAllowed() const
     if ( !IsInDocBody() )
         return false;
 
-    // no footnotes in repeated headlines
-    const SwTabFrame *pTab = IsInTab() ? const_cast<SwFrame*>(this)->ImplFindTabFrame() : nullptr;
-    if (pTab && pTab->IsFollow())
-        return !pTab->IsInHeadline(*this);
-
+    if ( IsInTab() )
+    {
+        // no footnotes in repeated headlines
+        const SwTabFrame *pTab = const_cast<SwFrame*>(this)->ImplFindTabFrame();
+        if ( pTab->IsFollow() )
+            return !pTab->IsInHeadline( *this );
+    }
     return true;
 }
 
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 536b9e46f611..06c186c5d4c2 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1526,7 +1526,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
         // This frame is in a table-not-in-section, its follow should be
         // inserted under the follow of the frame's cell.
         pLayLeaf = FindCellFrame()->GetFollowCell();
-        if (pLayLeaf && pLayLeaf->FindTabFrame() == FindTabFrame())
+        if (pLayLeaf->FindTabFrame() == FindTabFrame())
             SAL_WARN("sw.layout", "my table frame and my follow's table frame is the same");
         // In this case pLayLeaf pointing to an in-table frame is OK.
         bLayLeafTableAllowed = true;
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 1a98adca4f8a..05864d10a4ba 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1691,11 +1691,11 @@ bool SwFrame::WannaRightPage() const
     const SwFrame *pFlow = pPage->FindFirstBodyContent();
     const SwPageDesc *pDesc = nullptr;
     ::boost::optional<sal_uInt16> oPgNum;
-    if (pFlow && pFlow->IsInTab())
-        pFlow = pFlow->FindTabFrame();
-    if (pFlow)
+    if ( pFlow )
     {
-        const SwFlowFrame *pTmp = SwFlowFrame::CastFlowFrame(pFlow);
+        if ( pFlow->IsInTab() )
+            pFlow = pFlow->FindTabFrame();
+        const SwFlowFrame *pTmp = SwFlowFrame::CastFlowFrame( pFlow );
         if ( !pTmp->IsFollow() )
         {
             const SwFormatPageDesc& rPgDesc = pFlow->GetAttrSet()->GetPageDesc();


More information about the Libreoffice-commits mailing list