sw/source/core/layout/calcmove.cxx | 12 ++++++++++-- sw/source/core/layout/layact.cxx | 18 ++++++++---------- sw/source/core/txtnode/fntcache.cxx | 2 +- sw/source/core/txtnode/txtedt.cxx | 12 ++++++++++-- 4 files changed, 29 insertions(+), 15 deletions(-)
New commits: commit db7f2cbe7d9713ab65e64fd1093b9fae6e334782 Author: Michael Stahl <mst...@redhat.com> Date: Thu Jul 27 21:00:17 2017 +0200 sw: convert to assert Change-Id: I96f91105d32b18c29bd82eedcf2f93c54ad5f229 diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index f0f34c5a15b2..94cf9bc6dcac 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1274,7 +1274,7 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) // flowing back and forth. GetUpper()->ResetCompletePaint(); // The predecessor was invalidated, so this is obsolete as well now. - OSL_ENSURE( pPre, "missing old Prev" ); + assert(pPre); if ((pPre == pMoveBwdPre && isMoveBwdPreValid) && !pPre->IsSctFrame()) ::ValidateSz( pPre ); } commit 5989c5722a9ce424803d8fb7858ad98c10d0601d Author: Michael Stahl <mst...@redhat.com> Date: Thu Jul 27 20:37:54 2017 +0200 sw: assert that index is valid in SwFntObj::DrawText() If nCnt = 0 the only thing that will happen is an infinite loop. Change-Id: I23c5d0ff9d36fbfb3eabc93476fe3ca1c558f91c diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 97f2ad1c8c39..29ddcabedee1 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1531,7 +1531,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) sal_Int32 nCnt = rInf.GetText().getLength(); if ( nCnt < rInf.GetIdx() ) - nCnt = 0; + assert(false); // layout bug, not handled below else nCnt = nCnt - rInf.GetIdx(); nCnt = std::min<sal_Int32>( nCnt, rInf.GetLen() ); commit e488c8d9eb85bd0d8d250f9839e11357418ebc84 Author: Michael Stahl <mst...@redhat.com> Date: Thu Jul 27 20:29:17 2017 +0200 sw: inline pointless RESCHEDULE macro Change-Id: I093c8fbf5bb181d8e530fe33805a16aea94cdd62 diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index db136d963873..9a5ea484770c 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -74,17 +74,12 @@ } \ } -#define RESCHEDULE \ - { \ - if ( IsReschedule() ) \ - { \ - ::RescheduleProgress( m_pImp->GetShell()->GetDoc()->GetDocShell() ); \ - } \ - } - void SwLayAction::CheckWaitCursor() { - RESCHEDULE + if (IsReschedule()) + { + ::RescheduleProgress(m_pImp->GetShell()->GetDoc()->GetDocShell()); + } if ( !m_pWait && IsWaitAllowed() && IsPaint() && ((std::clock() - m_nStartTicks) * 1000 / CLOCKS_PER_SEC >= CLOCKS_PER_SEC/2) ) { @@ -1723,7 +1718,10 @@ bool SwLayAction::FormatContent( const SwPageFrame *pPage ) pContent = bNxtCnt ? pContentNext : pContent->GetNextContentFrame(); } - RESCHEDULE; + if (IsReschedule()) + { + ::RescheduleProgress(m_pImp->GetShell()->GetDoc()->GetDocShell()); + } } else { commit b1ad2ee35647ccd46b0bdb96c5ded09710e307be Author: Michael Stahl <mst...@redhat.com> Date: Thu Jul 27 17:52:59 2017 +0200 tdf#108991 sw: fix crash due to not formatted but "valid" SwTextFrame SwTextNode::EraseText() on the paragraph at the start of the selection notifies the SwTextFrame: 0 in SwFrame::ImplInvalidateSize() (this=0x3088a20) at sw/source/core/layout/wsfrm.cxx:1568 1 in SwFrame::InvalidateSize() (this=0x3088a20) at sw/source/core/inc/frame.hxx:849 2 in SwTextFrame::InvalidateRange_(SwCharRange const&, long) (this=0x3088a20, aRange=..., nD=-62) at sw/source/core/text/txtfrm.cxx:741 3 in SwTextFrame::InvalidateRange(SwCharRange const&, long) (this=0x3088a20, aRange=..., nD=-62) at sw/source/core/text/txtfrm.cxx:708 4 in SwTextFrame::Modify(SfxPoolItem const*, SfxPoolItem const*) (this=0x3088a20, pOld=0x0, pNew=0x7ffc8da38c50) at sw/source/core/text/txtfrm.cxx:1005 5 in SwClient::SwClientNotify(SwModify const&, SfxHint const&) (this=0x3088a20, rHint=...) at sw/source/core/attr/calbck.cxx:67 6 in SwModify::CallSwClientNotify(SfxHint const&) const (this=0x2f05550, rHint=...) at sw/inc/calbck.hxx:355 7 in SwModify::ModifyBroadcast(SfxPoolItem const*, SfxPoolItem const*) (this=0x2f05550, pOldValue=0x0, pNewValue=0x7ffc8da38c50) at sw/inc/calbck.hxx:176 8 in SwModify::NotifyClients(SfxPoolItem const*, SfxPoolItem const*) (this=0x2f05550, pOldValue=0x0, pNewValue=0x7ffc8da38c50) at sw/source/core/attr/calbck.cxx:142 9 in SwTextNode::EraseText(SwIndex const&, int, SwInsertFlags) (this=0x2f05550, rIdx=SwIndex (offset 1), nCount=62, nMode=SwInsertFlags::DEFAULT) at sw/source/core/txtnode/ndtxt.cxx:2355 10 in SwUndoDelete::SaveContent(SwPosition const*, SwPosition const*, SwTextNode*, SwTextNode*) (this=0x3052950, pStt=0x7ffc8da390b8, pEnd=0x7ffc8da39100, pSttTextNd=0x2f05550, pEndTextNd=0x2faefe0) at sw/source/core/undo/undel.cxx:387 However, at this point the first page, which contains this paragraph, is not visible; so the Action that is created in ViewShell::ImplEndAction() will skip over the first page and start at the 2nd page, which is the first visible one. Now it happens that the last paragraph in the document has a page break on it, and formatting it causes it to move forward (a new page to be inserted and the empty 2nd page to be deleted). Unfortunately it then decides to reset the mbValidSize flag on the preceding SwTextFrame, assuming that it was set by its own moving forward, and not already set before. 0 in ValidateSz(SwFrame*) (pFrame=0x3088a20) at sw/source/core/layout/calcmove.cxx:1082 1 in SwContentFrame::MakeAll(OutputDevice*) (this=0x308b4a0) at sw/source/core/layout/calcmove.cxx:1276 2 in SwFrame::PrepareMake(OutputDevice*) (this=0x308b4a0, pRenderContext=0x306f850) at sw/source/core/layout/calcmove.cxx:346 3 in SwFrame::Calc(OutputDevice*) const (this=0x308b4a0, pRenderContext=0x306f850) at sw/source/core/layout/trvlfrm.cxx:1760 4 in SwLayAction::IsShortCut(SwPageFrame*&) (this=0x7ffc8da394a0, prPage=@0x7ffc8da392b8: 0x7491e30) at sw/source/core/layout/layact.cxx:1085 5 in SwLayAction::InternalAction(OutputDevice*) (this=0x7ffc8da394a0, pRenderContext=0x306f850) at sw/source/core/layout/layact.cxx:490 6 in SwLayAction::Action(OutputDevice*) (this=0x7ffc8da394a0, pRenderContext=0x306f850) at sw/source/core/layout/layact.cxx:351 7 in SwViewShell::ImplEndAction(bool) (this=0x30829c0, bIdleEnd=false) at sw/source/core/view/viewsh.cxx:278 8 in SwViewShell::EndAction(bool) (this=0x30829c0, bIdleEnd=false) at sw/inc/viewsh.hxx:605 9 in SwCursorShell::EndAction(bool, bool) (this=0x30829c0, bIdleEnd=false, DoSetPosX=false) at sw/source/core/crsr/crsrsh.cxx:258 10 in SwActContext::~SwActContext() (this=0x7ffc8da396a0, __in_chrg=<optimized out>) at sw/source/core/edit/edws.cxx:159 11 in SwWrtShell::DelRight() (this=0x30829c0) at sw/source/uibase/wrtsh/delete.cxx:260 So at the end of the Action, the first page is still not valid, and the SwTextFrame has mbValidPos = false, but it does have mbValidSize = true. Then when the SwCursorShell::UpdateCursor() calls SwViewShell::MakeVisible(), which creates another Action, the SwTextFrame is not formatted and its SwTextPortions do not match the paragraph text content, which is the cause of the crash. Change-Id: I6e8153c574469a94d190fda8bc3007d17a474c7f diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index a1b14d9b5277..f0f34c5a15b2 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1251,6 +1251,9 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) SwRectFnSet aRectFnSet(this); + SwFrame const* pMoveBwdPre(nullptr); + bool isMoveBwdPreValid(false); + while ( !mbValidPos || !mbValidSize || !mbValidPrtArea ) { // - loop prevention @@ -1272,7 +1275,7 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) GetUpper()->ResetCompletePaint(); // The predecessor was invalidated, so this is obsolete as well now. OSL_ENSURE( pPre, "missing old Prev" ); - if( !pPre->IsSctFrame() ) + if ((pPre == pMoveBwdPre && isMoveBwdPreValid) && !pPre->IsSctFrame()) ::ValidateSz( pPre ); } bMoveable = IsMoveable(); @@ -1405,6 +1408,9 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) // To prevent oscillations/loops, check that this has not just // flowed forwards. bool bDummy; + auto const pTemp(GetIndPrev()); + auto const bTemp(pTemp && pTemp->GetValidSizeFlag() + && pTemp->GetValidPrtAreaFlag()); if ( !lcl_Prev( this ) && !bMovedFwd && ( bMoveable || ( bFly && !bTab ) ) && @@ -1412,6 +1418,8 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) && MoveBwd( bDummy ) ) { aRectFnSet.Refresh(this); + pMoveBwdPre = pTemp; + isMoveBwdPreValid = bTemp; bMovedBwd = true; bFormatted = false; if ( bKeep && bMoveable ) commit af78fa5f0d3d891b9a30e927a3b35c55f03a03a7 Author: Michael Stahl <mst...@redhat.com> Date: Tue Jul 25 21:20:10 2017 +0200 sw: fix string accesses in SwScanner::NextWord() (related: tdf#109081) getWordBoundary() can return bounds that do not include the starting nPos, if there are ZWSP characters at the starting position. This happens in the bugdoc of tdf#109081 where paragraph starts with 3 ZWSP and then 5 dashes, SwScanner is created from 0 to 1 and bounds are 3 to 8. Change-Id: I5fc41b98568a7211fc7d5f29bb87840371a4c005 diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 460736fb0975..fa0724c85047 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -941,8 +941,16 @@ bool SwScanner::NextWord() { aBound.startPos = std::max( aBound.startPos, nStartPos ); aBound.endPos = std::min( aBound.endPos, nEndPos ); - nBegin = aBound.startPos; - nLen = aBound.endPos - nBegin; + if (aBound.endPos < aBound.startPos) + { + nBegin = nEndPos; + nLen = 0; // found word is outside of search interval + } + else + { + nBegin = aBound.startPos; + nLen = aBound.endPos - nBegin; + } } if( ! nLen ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits