sw/source/core/text/itrpaint.cxx | 15 +++++++++++++-- sw/source/core/text/porlay.cxx | 11 +++-------- sw/source/core/text/porlay.hxx | 3 --- sw/source/core/text/porrst.cxx | 30 +++++++++++++++++++++++++----- sw/source/core/text/porrst.hxx | 11 ++++++++--- sw/source/core/text/redlnitr.cxx | 13 ++++++------- sw/source/core/text/redlnitr.hxx | 2 +- 7 files changed, 56 insertions(+), 29 deletions(-)
New commits: commit 37d85df2d2fd53ee436f24484b48aafc91d501b1 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Oct 29 13:37:21 2020 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Oct 29 23:19:09 2020 +0100 tdf#105967 sw change tracking: fix pilcrow color Paint strikeout/underline based on redline color and settings at the inserted or deleted paragraph break. Follow-up of commit 350dbba44ee7703b1da11cc4732a5090ce5efe3d (tdf#105967 sw change tracking: fix pilcrow symbol). Note: because the pilcrow symbol is painted by the temporary text portion SwTmpEndPortion, see sw/qa/extras/layout/data/tdf42748.fodt for testing. Change-Id: I4c9c6bb7ce445aa30224fabe7162a19df0df08b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105007 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index b00507c907c8..153131a2a3e9 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -427,8 +427,19 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, GetInfo().GetOpt().IsParagraph() && !GetTextFrame()->GetFollow() && GetInfo().GetIdx() >= TextFrameIndex(GetInfo().GetText().getLength())) { - const SwTmpEndPortion aEnd( *pEndTempl, m_pCurr->HasRedlineEnd(), - m_pCurr->HasRedlineEndDel() ); + bool bHasRedlineEnd( GetRedln() && m_pCurr->HasRedlineEnd() ); + if( bHasRedlineEnd ) + { + TextFrameIndex nOffset = GetInfo().GetIdx(); + SeekStartAndChg( GetInfo(), true ); + std::pair<SwTextNode const*, sal_Int32> const pos( + GetTextFrame()->MapViewToModel(nOffset)); + GetRedln()->Seek(*m_pFont, pos.first->GetIndex(), pos.second, 0); + } + const SwTmpEndPortion aEnd( *pEndTempl, + bHasRedlineEnd ? m_pFont->GetUnderline() : LINESTYLE_NONE, + bHasRedlineEnd ? m_pFont->GetStrikeout() : STRIKEOUT_NONE, + bHasRedlineEnd ? m_pFont->GetColor() : COL_AUTO ); GetFnt()->ChgPhysFnt( GetInfo().GetVsh(), *pOut ); if ( bAdjustBaseLine ) diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 69a7c39b5dc2..148d909f6449 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -605,18 +605,14 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) if( bHasRedline ) { OUString sRedlineText; - bool bHasRedlineEnd, bHasRedlineEndDel; + bool bHasRedlineEnd; bHasRedline = rLine.GetRedln()->CheckLine(start.first->GetIndex(), start.second, - end.first->GetIndex(), end.second, sRedlineText, bHasRedlineEnd, bHasRedlineEndDel ); + end.first->GetIndex(), end.second, sRedlineText, bHasRedlineEnd); if( bHasRedline ) { SetRedlineText( sRedlineText ); if( bHasRedlineEnd ) - { SetRedlineEnd( bHasRedlineEnd ); - if( bHasRedlineEndDel ) - SetRedlineEndDel( bHasRedlineEndDel ); - } } } SetRedline( bHasRedline ); @@ -679,8 +675,7 @@ void SwLineLayout::ResetFlags() { m_bFormatAdj = m_bDummy = m_bEndHyph = m_bMidHyph = m_bFly = m_bRest = m_bBlinking = m_bClipping = m_bContent = m_bRedline - = m_bRedlineEnd = m_bRedlineEndDel - = m_bForcedLeftMargin = m_bHanging = false; + = m_bRedlineEnd = m_bForcedLeftMargin = m_bHanging = false; } SwLineLayout::SwLineLayout() diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index 39e50d28ba94..5126460b5424 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -94,7 +94,6 @@ private: bool m_bContent : 1; // Text for line numbering bool m_bRedline : 1; // The Redlining bool m_bRedlineEnd: 1; // Redlining for paragraph mark: tracked change at the end - bool m_bRedlineEndDel : 1; // Redlining for paragraph mark: tracked deletion at the end bool m_bForcedLeftMargin : 1; // Left adjustment moved by the Fly bool m_bHanging : 1; // Contains a hanging portion in the margin bool m_bUnderscore : 1; @@ -134,8 +133,6 @@ public: bool HasRedline() const { return m_bRedline; } void SetRedlineEnd( const bool bNew ) { m_bRedlineEnd = bNew; } bool HasRedlineEnd() const { return m_bRedlineEnd; } - void SetRedlineEndDel( const bool bNew ) { m_bRedlineEndDel = bNew; } - bool HasRedlineEndDel() const { return m_bRedlineEndDel; } void SetRedlineText ( const OUString& sText ) { m_sRedlineText = sText; } const OUString* GetRedlineText() const { return &m_sRedlineText; } void SetForcedLeftMargin() { m_bForcedLeftMargin = true; } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 58cf0cf3f3e3..f04960725c54 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -47,8 +47,10 @@ #include <crsrsh.hxx> SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion, - const bool bCh, const bool bDel ) : - bChanged( bCh ), bDeleted( bDel ) + const FontLineStyle eUL, + const FontStrikeout eStrkout, + const Color& rCol ) : + eUnderline( eUL ), eStrikeout( eStrkout ), aColor( rCol ) { Height( rPortion.Height() ); SetAscent( rPortion.GetAscent() ); @@ -63,9 +65,27 @@ void SwTmpEndPortion::Paint( const SwTextPaintInfo &rInf ) const const SwFont* pOldFnt = rInf.GetFont(); SwFont aFont(*pOldFnt); - aFont.SetColor(NON_PRINTING_CHARACTER_COLOR); - aFont.SetStrikeout( bDeleted ? STRIKEOUT_SINGLE : STRIKEOUT_NONE ); - aFont.SetUnderline( (bChanged && !bDeleted) ? LINESTYLE_SINGLE : LINESTYLE_NONE ); + + // Paint strikeout/underline based on redline color and settings + // (with an extra pilcrow in the background, because there is + // no SetStrikeoutColor(), also SetUnderColor() doesn't work()). + if ( eUnderline != LINESTYLE_NONE || eStrikeout != STRIKEOUT_NONE ) + { + aFont.SetColor( aColor ); + // don't show underline with strikeout + aFont.SetUnderline( eStrikeout == STRIKEOUT_NONE ? eUnderline : LINESTYLE_NONE ); + aFont.SetStrikeout( eStrikeout ); + + const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); + + // draw the pilcrow with strikeout/underline in redline color + rInf.DrawText(CH_PAR, *this); + + } + + aFont.SetColor( NON_PRINTING_CHARACTER_COLOR ); + aFont.SetStrikeout( STRIKEOUT_NONE ); + aFont.SetUnderline( LINESTYLE_NONE ); const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); // draw the pilcrow diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx index 8e05750c8e2d..a0d47683a5f7 100644 --- a/sw/source/core/text/porrst.hxx +++ b/sw/source/core/text/porrst.hxx @@ -23,6 +23,7 @@ #include <TextFrameIndex.hxx> #include <txttypes.hxx> +#include <txtfrm.hxx> #include "porlin.hxx" #include "portxt.hxx" @@ -40,11 +41,15 @@ class SwTextFormatInfo; class SwTmpEndPortion : public SwLinePortion { - bool bChanged; - bool bDeleted; + const FontLineStyle eUnderline; + const FontStrikeout eStrikeout; + Color aColor; public: - explicit SwTmpEndPortion( const SwLinePortion &rPortion, const bool bChanged, const bool bDel ); + explicit SwTmpEndPortion( const SwLinePortion &rPortion, + const FontLineStyle eUnderline, + const FontStrikeout eStrikeout, + const Color& rColor ); virtual void Paint( const SwTextPaintInfo &rInf ) const override; }; diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index b05df68a90a8..9dafe23aff05 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -805,7 +805,7 @@ bool SwRedlineItr::ChkSpecialUnderline_() const bool SwRedlineItr::CheckLine( sal_uLong const nStartNode, sal_Int32 const nChkStart, sal_uLong const nEndNode, sal_Int32 nChkEnd, OUString& rRedlineText, - bool& bRedlineEnd, bool& bRedlineEndDel) + bool& bRedlineEnd) { // note: previously this would return true in the (!m_bShow && m_pExt) // case, but surely that was a bug? @@ -817,7 +817,7 @@ bool SwRedlineItr::CheckLine( sal_Int32 nOldStart = m_nStart; sal_Int32 nOldEnd = m_nEnd; SwRedlineTable::size_type const nOldAct = m_nAct; - bool bRet = bRedlineEnd = bRedlineEndDel = false; + bool bRet = bRedlineEnd = false; for (m_nAct = m_nFirst; m_nAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++m_nAct) { @@ -829,13 +829,12 @@ bool SwRedlineItr::CheckLine( if (nChkStart <= m_nEnd && (nChkEnd > m_nStart || COMPLETE_STRING == m_nEnd)) { bRet = true; + if ( rRedlineText.isEmpty() && pRedline->GetType() == RedlineType::Delete ) + rRedlineText = const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true); if ( COMPLETE_STRING == m_nEnd ) - bRedlineEnd = true; - if ( pRedline->GetType() == RedlineType::Delete ) { - rRedlineText = const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true); - if ( COMPLETE_STRING == m_nEnd ) - bRedlineEndDel = true; + bRedlineEnd = true; + break; } } } diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx index ab242b245d08..0a60b414a9e2 100644 --- a/sw/source/core/text/redlnitr.hxx +++ b/sw/source/core/text/redlnitr.hxx @@ -119,7 +119,7 @@ public: bool ChkSpecialUnderline() const { return IsOn() && ChkSpecialUnderline_(); } bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode, - sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd, bool& bRedlineEndDel); + sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd); bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew) { return m_pExt->Leave(rFnt, nNode, nNew); } bool ExtOn() { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits