diff options
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/frmedt/tblsel.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/tabfrm.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/layout/findfrm.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/flowfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/layout/sectfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 26 |
8 files changed, 39 insertions, 24 deletions
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 9781ccd87911..33832c265ef4 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1502,7 +1502,7 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, // It's more robust if we calculate the minimum values for the whole Table const SwTabFrame *pTab = pStart->ImplFindTabFrame(); pStart = const_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame const *>(pTab->FirstCell())); - pEnd = const_cast<SwLayoutFrame*>(pTab->FindLastContent()->GetUpper()); + pEnd = const_cast<SwLayoutFrame*>(pTab->FindLastContentOrTable()->GetUpper()); while( !pEnd->IsCellFrame() ) pEnd = pEnd->GetUpper(); ::lcl_CalcColValues( aMins, aTabCols, pStart, pEnd, false, /*bColumnWidth=*/true ); diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 11c516b9b0b6..52b3551b2eb5 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -1689,7 +1689,7 @@ static void lcl_FindStartEndCol( const SwLayoutFrame *&rpStart, nEX = ::lcl_CalcWish( rpEnd, nWish, nPrtWidth ) + aRectFnSet.GetPrtLeft(*pTab); } - const SwContentFrame* pLastContent = pTab->FindLastContent(); + SwFrame const*const pLastContent = pTab->FindLastContentOrTable(); rpEnd = pLastContent ? pLastContent->GetUpper() : nullptr; // --> Made code robust. If pTab does not have a lower, // we would crash here. @@ -1745,7 +1745,7 @@ static void lcl_FindStartEndCol( const SwLayoutFrame *&rpStart, { pTmpTab = static_cast<const SwTabFrame*>(pTmpTab->FindPrev()); OSL_ENSURE( pTmpTab->IsTabFrame(), "Predecessor of Follow not Master."); - rpEnd = pTmpTab->FindLastContent()->GetUpper(); + rpEnd = pTmpTab->FindLastContentOrTable()->GetUpper(); while( !rpEnd->IsCellFrame() ) rpEnd = rpEnd->GetUpper(); while ( aRectFnSet.GetLeft(rpEnd->getFrameArea()) > nEX ) @@ -1921,7 +1921,7 @@ void MakeSelUnions( SwSelUnions& rUnions, const SwLayoutFrame *pStart, pFirst = ::lcl_FindNextCellFrame( pFirst ); } const SwLayoutFrame* pLast = nullptr; - const SwFrame* pLastContent = pTable->FindLastContent(); + SwFrame const*const pLastContent = pTable->FindLastContentOrTable(); if ( pLastContent ) pLast = ::lcl_FindCellFrame( pLastContent->GetUpper() ); diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx index cc57d46d8492..40b9923ba744 100644 --- a/sw/source/core/inc/tabfrm.hxx +++ b/sw/source/core/inc/tabfrm.hxx @@ -136,6 +136,8 @@ public: virtual bool Prepare( const PrepareHint ePrep = PREP_CLEAR, const void *pVoid = nullptr, bool bNotify = true ) override; + SwFrame *FindLastContentOrTable(); + inline const SwFrame *FindLastContentOrTable() const; SwContentFrame *FindLastContent(); inline const SwContentFrame *FindLastContent() const; @@ -228,6 +230,11 @@ public: virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override; }; +inline const SwFrame *SwTabFrame::FindLastContentOrTable() const +{ + return const_cast<SwTabFrame*>(this)->FindLastContentOrTable(); +} + inline const SwContentFrame *SwTabFrame::FindLastContent() const { return const_cast<SwTabFrame*>(this)->FindLastContent(); diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index 786c7627d7c9..4bd1a5dde202 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -782,7 +782,7 @@ SwFrame *SwFrame::FindNext_() if ( static_cast<SwTabFrame*>(this)->GetFollow() ) return static_cast<SwTabFrame*>(this)->GetFollow(); - pThis = static_cast<SwTabFrame*>(this)->FindLastContent(); + pThis = static_cast<SwTabFrame*>(this)->FindLastContentOrTable(); if ( !pThis ) pThis = this; bIgnoreTab = true; @@ -912,7 +912,7 @@ SwContentFrame *SwFrame::FindNextCnt_( const bool _bInSameFootnote ) if( pThis ) return static_cast<SwContentFrame*>(pThis); } - pThis = static_cast<SwTabFrame*>(this)->FindLastContent(); + pThis = static_cast<SwTabFrame*>(this)->FindLastContentOrTable(); if ( !pThis ) return nullptr; } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 20ba1d50420d..b7461e038356 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -916,7 +916,7 @@ SwLayoutFrame *SwFrame::GetNextLeaf( MakePageType eMakePage ) SwLayoutFrame *pLayLeaf = nullptr; if ( IsTabFrame() ) { - SwContentFrame* pTmp = static_cast<SwTabFrame*>(this)->FindLastContent(); + SwFrame *const pTmp = static_cast<SwTabFrame*>(this)->FindLastContentOrTable(); if ( pTmp ) pLayLeaf = pTmp->GetUpper(); } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 416037b25fbd..3a762e6ce885 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3706,11 +3706,15 @@ const SwContentFrame* GetCellContent( const SwLayoutFrame& rCell ) const SwTabFrame* pTmpTab = pContent->FindTabFrame(); if ( pTmpTab != pTab ) { - pContent = pTmpTab->FindLastContent(); - if ( pContent ) - - pContent = pContent->FindNextCnt(); - + SwFrame const*const pTmp = pTmpTab->FindLastContentOrTable(); + if (pTmp) + { + pContent = pTmp->FindNextCnt(); + } + else + { + pContent = nullptr; + } } else break; diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 58d0c7d4d5ad..d10d90aeee65 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -1667,7 +1667,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage ) pLayLeaf = nullptr; else if( IsTabFrame() ) { - SwContentFrame* pTmpCnt = static_cast<SwTabFrame*>(this)->FindLastContent(); + SwFrame *const pTmpCnt = static_cast<SwTabFrame*>(this)->FindLastContentOrTable(); pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : nullptr; } else if (pCellLeaf && CanContainSplitSection(this)) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 76a064017ad8..960bb9462007 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3336,7 +3336,7 @@ bool SwTabFrame::GetInfo( SfxPoolItem &rHint ) const return true; } -SwContentFrame *SwTabFrame::FindLastContent() +SwFrame *SwTabFrame::FindLastContentOrTable() { SwFrame *pRet = m_pLower; @@ -3398,19 +3398,23 @@ SwContentFrame *SwTabFrame::FindLastContent() while ( pRet->GetNext() ) pRet = pRet->GetNext(); - while (pRet && pRet->IsTabFrame()) // possibly there's only tables here! - { // tdf#126138 skip table, don't look inside - // TODO this is actually not ideal, e.g. SwFrame::FindNext_() might - // -if there's a table at the end- return a lower frame inside that - // table instead of the "next" one... probably this function should - // really return SwFrame* to be able to return a SwTabFrame? - pRet = pRet->GetPrev(); - } - - if (pRet && pRet->IsSctFrame()) + if (pRet->IsSctFrame()) pRet = static_cast<SwSectionFrame*>(pRet)->FindLastContent(); } + assert(pRet == nullptr || dynamic_cast<SwContentFrame*>(pRet) || dynamic_cast<SwTabFrame*>(pRet)); + return pRet; +} + +SwContentFrame *SwTabFrame::FindLastContent() +{ + SwFrame * pRet(FindLastContentOrTable()); + + while (pRet && pRet->IsTabFrame()) // possibly there's only tables here! + { // tdf#126138 skip table, don't look inside + pRet = pRet->GetPrev(); + } + assert(pRet == nullptr || dynamic_cast<SwContentFrame*>(pRet)); return static_cast<SwContentFrame*>(pRet); } |