sw/source/core/text/redlnitr.cxx | 52 +++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-)
New commits: commit 4fccc66345dcedff735a2e918858b12fb1044c01 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Nov 3 16:40:45 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Nov 17 22:18:35 2020 +0100 sw_fieldmarkhide: SwRedlineItr assumption that Show means no MergedPara ... in SwRedlineItr::CheckLine() and also SwRedlineItr::Seek() Change-Id: I711ec37bd345cbf5f5f5339b8d792bcb56c425c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105980 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 3286661251af..6727751c3576 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -463,7 +463,9 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode, } // TODO this is true initially but after delete ops it may be false... need to delete m_pMerged somewhere? // assert(SwRedlineTable::npos != nRedlPos); - assert(SwRedlineTable::npos != nRedlPos || m_pMergedPara->extents.size() <= 1); + // false now with fieldmarks + assert(pRootFrame->GetFieldmarkMode() != sw::FieldmarkMode::ShowBoth + || SwRedlineTable::npos != nRedlPos || m_pMergedPara->extents.size() <= 1); } if (!(pExtInp || m_pMergedPara || SwRedlineTable::npos != nRedlPos)) return; @@ -476,7 +478,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode, } m_pRedline.reset(new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos, - m_pMergedPara + (pRootFrame && pRootFrame->IsHideRedlines()) ? SwRedlineItr::Mode::Hide : bShow ? SwRedlineItr::Mode::Show @@ -539,7 +541,6 @@ short SwRedlineItr::Seek(SwFont& rFnt, if( ExtOn() ) return 0; // Abbreviation: if we're within an ExtendTextInputs // there can't be other changes of attributes (not even by redlining) - assert(m_eMode == Mode::Hide || m_nNdIdx == nNode); if (m_eMode == Mode::Show) { if (m_bOn) @@ -570,7 +571,7 @@ short SwRedlineItr::Seek(SwFont& rFnt, for ( ; m_nAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size() ; ++m_nAct) { - m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ]->CalcStartEnd(m_nNdIdx, m_nStart, m_nEnd); + m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ]->CalcStartEnd(nNode, m_nStart, m_nEnd); if (nNew < m_nEnd) { @@ -811,7 +812,6 @@ bool SwRedlineItr::CheckLine( // case, but surely that was a bug? if (m_nFirst == SwRedlineTable::npos || m_eMode != Mode::Show) return false; - assert(nStartNode == nEndNode); (void) nStartNode; (void) nEndNode; if( nChkEnd == nChkStart ) // empty lines look one char further ++nChkEnd; sal_Int32 nOldStart = m_nStart; @@ -820,28 +820,44 @@ bool SwRedlineItr::CheckLine( bool bRet = bRedlineEnd = false; eRedlineEnd = RedlineType::None; + SwPosition const start(*m_rDoc.GetNodes()[nStartNode]->GetContentNode(), nChkStart); + SwPosition const end(*m_rDoc.GetNodes()[nEndNode]->GetContentNode(), nChkEnd); for (m_nAct = m_nFirst; m_nAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++m_nAct) { SwRangeRedline const*const pRedline( m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ] ); - pRedline->CalcStartEnd( m_nNdIdx, m_nStart, m_nEnd ); - if (nChkEnd < m_nStart) - break; - if (nChkStart <= m_nEnd && (nChkEnd >= m_nStart || COMPLETE_STRING == m_nEnd)) + bool isBreak(false); + switch (ComparePosition(*pRedline->Start(), *pRedline->End(), start, end)) { - bRet = true; - if ( rRedlineText.isEmpty() && pRedline->GetType() == RedlineType::Delete ) - rRedlineText = const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true); - // store redlining at paragraph break - if ( COMPLETE_STRING == m_nEnd ) - { + case SwComparePosition::Behind: + isBreak = true; + break; + case SwComparePosition::OverlapBehind: + case SwComparePosition::CollideStart: + case SwComparePosition::Outside: + case SwComparePosition::Equal: + // store redlining at line end (for line break formatting) eRedlineEnd = pRedline->GetType(); bRedlineEnd = true; + isBreak = true; + [[fallthrough]]; + case SwComparePosition::OverlapBefore: + case SwComparePosition::CollideEnd: + case SwComparePosition::Inside: + { + bRet = true; + if (rRedlineText.isEmpty() && pRedline->GetType() == RedlineType::Delete) + { + rRedlineText = const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true); + } break; } - // store redlining at line end (for line break formatting) - else if ( nChkEnd <= m_nEnd ) - eRedlineEnd = pRedline->GetType(); + case SwComparePosition::Before: + break; // -Werror=switch + } + if (isBreak) + { + break; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits