sw/source/core/layout/flycnt.cxx | 3 +- sw/source/core/layout/objectformattertxtfrm.cxx | 27 ++++++++++++++---------- sw/source/core/layout/objectformattertxtfrm.hxx | 2 - 3 files changed, 19 insertions(+), 13 deletions(-)
New commits: commit 7eb12f8a09dd67168ba42058b99d8ab58a5c7b0a Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu May 6 18:20:14 2021 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri May 7 17:45:50 2021 +0200 tdf#138518 sw: layout: fix assert on ooo43913-1.doc Assertion `rAnchoredObjPage.GetPhyPageNum() == _nFromPageNum' failed. Because not only the fly's anchor frame moves forward in FormatAnchorFrameForCheckMoveFwd(), but also the fly itself, apparently because it's in a table: 0 SwAnchoredObject::SetPageFrame(SwPageFrame*) (this=0x5a1d3d8, _pNewPageFrame=0x8cfbeb0) at sw/source/core/layout/anchoredobject.cxx:162 1 SwPageFrame::MoveFly(SwFlyFrame*, SwPageFrame*) (this=0x8cbd8c0, pToMove=0x5a1d280, pDest=0x8cfbeb0) at sw/source/core/layout/flylay.cxx:985 2 lcl_ArrangeLowers(SwLayoutFrame*, tools::Long, bool) (pLay=0x8cf80c0, lYStart=179488, bInva=false) at sw/source/core/layout/tabfrm.cxx:5000 3 SwCellFrame::Format(OutputDevice*, SwBorderAttrs const*) (this=0x8cf80c0, pAttrs=0x8ce78c0) at sw/source/core/layout/tabfrm.cxx:5359 4 SwLayoutFrame::MakeAll(OutputDevice*) (this=0x8cf80c0) at sw/source/core/layout/calcmove.cxx:1036 5 SwFrame::PrepareMake(OutputDevice*) (this=0x8cf80c0, pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:375 6 SwFrame::Calc(OutputDevice*) const (this=0x8cf80c0, pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792 7 SwFrame::MakePos() (this=0x8cebdb0) at sw/source/core/layout/calcmove.cxx:627 8 SwTextFrame::MakePos() (this=0x8cebdb0) at sw/source/core/text/frmform.cxx:340 9 SwContentFrame::MakeAll(OutputDevice*) (this=0x8cebdb0) at sw/source/core/layout/calcmove.cxx:1412 10 SwFrame::PrepareMake(OutputDevice*) (this=0x8cebdb0, pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:286 11 SwFrame::Calc(OutputDevice*) const (this=0x8cebdb0, pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792 12 SwTextFrame::CalcFollow(o3tl::strong_int<int, Tag_TextFrameIndex>) (this=0x5ae2c60, nTextOfst=...) at sw/source/core/text/frmform.cxx:279 13 SwTextFrame::AdjustFollow_(SwTextFormatter&, o3tl::strong_int<int, Tag_TextFrameIndex>, o3tl::strong_int<int, Tag_TextFrameIndex>, unsigned char) (this=0x5ae2c60, rLine=..., nOffset=..., nEnd=..., nMode=1 '\001') at sw/source/core/text/frmform.cxx:611 14 SwTextFrame::FormatAdjust(SwTextFormatter&, WidowsAndOrphans&, o3tl::strong_int<int, Tag_TextFrameIndex>, bool) (this=0x5ae2c60, rLine=..., rFrameBreak=..., nStrLen=..., bDummy=false) at sw/source/core/text/frmform.cxx:1166 15 SwTextFrame::Format_(SwTextFormatter&, SwTextFormatInfo&, bool) (this=0x5ae2c60, rLine=..., rInf=..., bAdjust=false) at sw/source/core/text/frmform.cxx:1613 16 SwTextFrame::Format_(OutputDevice*, SwParaPortion*) (this=0x5ae2c60, pRenderContext=0x5b7fcf0, pPara=0x8d07490) at sw/source/core/text/frmform.cxx:1720 17 SwTextFrame::Format(OutputDevice*, SwBorderAttrs const*) (this=0x5ae2c60, pRenderContext=0x5b7fcf0) at sw/source/core/text/frmform.cxx:1910 18 SwContentFrame::MakeAll(OutputDevice*) (this=0x5ae2c60) at sw/source/core/layout/calcmove.cxx:1525 19 SwFrame::PrepareMake(OutputDevice*) (this=0x5ae2f80, pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:321 20 SwFrame::Calc(OutputDevice*) const (this=0x5ae2f80, pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792 21 SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs(SwTextFrame&) (_rAnchorTextFrame=...) at sw/source/core/layout/objectformattertxtfrm.cxx:905 22 SwObjectFormatterTextFrame::FormatAnchorFrameForCheckMoveFwd() (this=0x8ce5720) at sw/source/core/layout/objectformattertxtfrm.cxx:919 23 SwObjectFormatterTextFrame::DoFormatObjs() (this=0x8ce5720) at sw/source/core/layout/objectformattertxtfrm.cxx:368 24 SwObjectFormatter::FormatObjsAtFrame(SwFrame&, SwPageFrame const&, SwLayAction*) (_rAnchorFrame=..., _rPageFrame=..., _pLayAction=0x0) at sw/source/core/layout/objectformatter.cxx:160 25 SwContentFrame::CalcLowers(SwLayoutFrame&, SwLayoutFrame const&, long, bool) (rLay=..., rDontLeave=..., nBottom=192048, bSkipRowSpanCells=true) at sw/source/core/layout/tabfrm.cxx:1534 26 lcl_RecalcRow(SwRowFrame&, tools::Long) (rRow=..., nBottom=192048) at sw/source/core/layout/tabfrm.cxx:1653 27 SwTabFrame::MakeAll(OutputDevice*) (this=0x8cf5f80, pRenderContext=0x5b7fcf0) at sw/source/core/layout/tabfrm.cxx:2425 It looks like the _nFromPageNum is always from the SwObjectFormatter::mrPageFrame anyway because that's a precondition of the mpPgNumAndTypeOfAnchors->Collect() being called, so just rely on that to get the correct page. (regression from c799de145f7e289f31e3669646e5bd12814e6c5e) Change-Id: Ibdffb2121cffbc04320d17a29ab2e160dec4250b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115188 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 533a998e540b0f04068c876dde0e74adc3f79c93) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115201 Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 2656e800fd3f..0da839f099c6 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -429,7 +429,8 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* pRenderContext) bool bDummy( false ); bool bPageHasFlysAnchoredBelowThis(false); if ( SwObjectFormatterTextFrame::CheckMovedFwdCondition( - *this, GetPageFrame()->GetPhyPageNum(), +// TODO: what if this fly moved bc it's in table? does sth prevent that? + *this, *GetPageFrame(), bAnchoredAtMaster, nToPageNum, bDummy, bPageHasFlysAnchoredBelowThis) ) { diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 005f14902079..153a90799d50 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -235,9 +235,12 @@ bool SwObjectFormatterTextFrame::DoFormatObj( SwAnchoredObject& _rAnchoredObj, // #i43913# bool bDummy( false ); bool bPageHasFlysAnchoredBelowThis(false); - // #i58182# - consider new method signature + // see how SwObjectFormatter::FormatObjsAtFrame_() checks + // "pPageFrameOfAnchor == &mrPageFrame" - only caller relevant for + // this subclass + assert(GetPageFrame().GetPhyPageNum() == GetPgNumOfCollected(nIdx)); if ( SwObjectFormatterTextFrame::CheckMovedFwdCondition( *GetCollectedObj( nIdx ), - GetPgNumOfCollected( nIdx ), + GetPageFrame(), IsCollectedAnchoredAtMaster( nIdx ), nToPageNum, bDummy, bPageHasFlysAnchoredBelowThis)) @@ -551,11 +554,14 @@ SwAnchoredObject* SwObjectFormatterTextFrame::GetFirstObjWithMovedFwdAnchor( // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE GetWrapInfluenceOnObjPos( true ) == _nWrapInfluenceOnPosition ) { + // see how SwObjectFormatter::FormatObjsAtFrame_() checks + // "pPageFrameOfAnchor == &mrPageFrame" - only caller relevant for + // this subclass + assert(GetPageFrame().GetPhyPageNum() == GetPgNumOfCollected(i)); // #i26945# - use new method <_CheckMovedFwdCondition(..)> // #i43913# - // #i58182# - consider new method signature if ( SwObjectFormatterTextFrame::CheckMovedFwdCondition( *GetCollectedObj( i ), - GetPgNumOfCollected( i ), + GetPageFrame(), IsCollectedAnchoredAtMaster( i ), _noToPageNum, _boInFollow, o_rbPageHasFlysAnchoredBelowThis) ) @@ -605,12 +611,13 @@ static SwContentFrame const* FindFrameInBody(SwAnchoredObject const& rAnchored) // - replace private method by corresponding static public method bool SwObjectFormatterTextFrame::CheckMovedFwdCondition( SwAnchoredObject& _rAnchoredObj, - const sal_uInt32 _nFromPageNum, + SwPageFrame const& rFromPageFrame, const bool _bAnchoredAtMasterBeforeFormatAnchor, sal_uInt32& _noToPageNum, bool& _boInFollow, bool& o_rbPageHasFlysAnchoredBelowThis) { + const sal_uInt32 _nFromPageNum(rFromPageFrame.GetPhyPageNum()); bool bAnchorIsMovedForward( false ); SwPageFrame* pPageFrameOfAnchor = _rAnchoredObj.FindPageFrameOfAnchor(); @@ -687,21 +694,19 @@ bool SwObjectFormatterTextFrame::CheckMovedFwdCondition( if (bAnchorIsMovedForward) { - // tdf#138518 try to determine if there is a fly on page _nFromPageNum + // tdf#138518 try to determine if there is a fly on page rFromPageFrame // which is anchored in a frame that is "below" the anchor frame // of _rAnchoredObj, such that it should move to the next page before // _rAnchoredObj does - SwPageFrame const& rAnchoredObjPage(*_rAnchoredObj.GetPageFrame()); - assert(rAnchoredObjPage.GetPhyPageNum() == _nFromPageNum); - if (auto * pObjs = rAnchoredObjPage.GetSortedObjs()) + if (auto * pObjs = rFromPageFrame.GetSortedObjs()) { for (SwAnchoredObject *const pObj : *pObjs) { SwPageFrame const*const pObjAnchorPage(pObj->FindPageFrameOfAnchor()); assert(pObjAnchorPage); - if ((pObjAnchorPage == &rAnchoredObjPage + if ((pObjAnchorPage == &rFromPageFrame ? _boInFollow // same-page but will move forward - : rAnchoredObjPage.GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum()) + : rFromPageFrame.GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum()) && pObj->GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { diff --git a/sw/source/core/layout/objectformattertxtfrm.hxx b/sw/source/core/layout/objectformattertxtfrm.hxx index 1fc6160507c6..25a7a7e92b77 100644 --- a/sw/source/core/layout/objectformattertxtfrm.hxx +++ b/sw/source/core/layout/objectformattertxtfrm.hxx @@ -178,7 +178,7 @@ class SwObjectFormatterTextFrame : public SwObjectFormatter indicating, if 'anchor is moved forward' */ static bool CheckMovedFwdCondition( SwAnchoredObject& _rAnchoredObj, - const sal_uInt32 _nFromPageNum, + SwPageFrame const& rFromPageFrame, const bool _bAnchoredAtMasterBeforeFormatAnchor, sal_uInt32& _noToPageNum, bool& _boInFollow, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits