summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-11-02 20:22:55 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-03 07:50:54 +0100
commit72ec44bc294dd814c0ba8657337b6b2646382b02 (patch)
treee8b6a6c0c9a23156fd8ed8c5b16db4d15608dcfd
parent4ed24dd436b77454b64cd22ae0b0ded2f990f1cb (diff)
tdf#105967 sw change tracking: fix line break symbol in empty line
At line break symbol of inserted or deleted empty lines, paint strikeout/underline based on redline color. Keep also the underline and strikeout formattings of the line break symbol in neutral color (NON_PRINTING_CHARACTER_COLOR), if they are not affected by change tracking. Note: in non empty lines, remove also the colored (not NON_PRINTING_CHARACTER_COLOR) underline/strikeout, if it's not based on redlining, fixing the double colored lines on the neutral color line break symbol. Follow-up of db25f1e2e3ae7a078f8f3c080ff3c4802f83b853 (tdf#105967 sw change tracking: fix pilcrow in empty line). Change-Id: I565a10154f5ecbefeb00fe3e17a53f74f2f84e63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105206 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--include/svx/ctredlin.hxx1
-rw-r--r--sw/source/core/text/frmpaint.cxx4
-rw-r--r--sw/source/core/text/itrpaint.cxx18
-rw-r--r--sw/source/core/text/porlay.cxx6
-rw-r--r--sw/source/core/text/porlay.hxx5
-rw-r--r--sw/source/core/text/porrst.cxx48
-rw-r--r--sw/source/core/text/porrst.hxx5
-rw-r--r--sw/source/core/text/redlnitr.cxx8
-rw-r--r--sw/source/core/text/redlnitr.hxx2
9 files changed, 67 insertions, 30 deletions
diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx
index 1b4dac85319b..4dd80bafd709 100644
--- a/include/svx/ctredlin.hxx
+++ b/include/svx/ctredlin.hxx
@@ -59,6 +59,7 @@ enum class RedlineType : sal_uInt16
TableRowDelete = 0x7,// Table row has been deleted.
TableCellInsert = 0x8,// Table cell has been inserted.
TableCellDelete = 0x9,// Table cell has been deleted.
+ None = USHRT_MAX - 1, // special value to indicate missing redlining in some return value
Any = USHRT_MAX // special value to indicate any redline type in some method calls
};
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index d664b07c5d50..d64cd59eda59 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -502,7 +502,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
else if( pSh->GetWin() )
{
std::unique_ptr<SwFont> pFnt;
- RedlineType eRedline = RedlineType::Any;
+ RedlineType eRedline = RedlineType::None;
const SwTextNode& rTextNode = *GetTextNodeForParaProps();
if ( rTextNode.HasSwAttrSet() )
{
@@ -605,7 +605,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
// show redline color and settings drawing a background pilcrow,
// but keep also other formattings (with neutral pilcrow color)
- if ( eRedline != RedlineType::Any )
+ if ( eRedline != RedlineType::None )
{
pFnt->DrawText_( aDrawInf );
if ( eRedline == RedlineType::Delete )
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index d714f5c68b4c..866eaf929979 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -299,6 +299,14 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
pEndTempl = pPor;
}
+ // set redlining for line break symbol
+ if ( pPor->IsBreakPortion() && GetInfo().GetOpt().IsParagraph() && GetRedln() )
+ {
+ SeekAndChg( GetInfo() );
+ if ( m_pCurr->GetRedlineEndType() != RedlineType::None )
+ static_cast<SwBreakPortion&>(*pPor).SetRedline( m_pCurr->GetRedlineEndType() );
+ }
+
// A special case are GluePortions which output blanks.
// 6168: Avoid that the rest of a FieldPortion gets the attributes of the
@@ -326,12 +334,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
// Paragraph symbols should have the same font as the paragraph in front of them,
// except for the case that there's redlining in the paragraph
if( GetRedln() )
- {
SeekAndChg( GetInfo() );
- // paint redlining
- if ( m_pCurr->HasRedline() )
- static_cast<SwBreakPortion&>(*pPor).PaintRedline( GetInfo() );
- }
else
SeekAndChgBefore( GetInfo() );
}
@@ -433,6 +436,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
GetInfo().GetIdx() >= TextFrameIndex(GetInfo().GetText().getLength()))
{
bool bHasRedlineEnd( GetRedln() && m_pCurr->HasRedlineEnd() );
+ RedlineType eRedlineEnd = bHasRedlineEnd ? m_pCurr->GetRedlineEndType() : RedlineType::None;
if( bHasRedlineEnd )
{
TextFrameIndex nOffset = GetInfo().GetIdx();
@@ -442,8 +446,8 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
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 && eRedlineEnd != RedlineType::Delete ? m_pFont->GetUnderline() : LINESTYLE_NONE,
+ bHasRedlineEnd && eRedlineEnd == RedlineType::Delete ? m_pFont->GetStrikeout() : STRIKEOUT_NONE,
bHasRedlineEnd ? m_pFont->GetColor() : COL_AUTO );
GetFnt()->ChgPhysFnt( GetInfo().GetVsh(), *pOut );
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 148d909f6449..7a72d65b12f4 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -606,13 +606,16 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
{
OUString sRedlineText;
bool bHasRedlineEnd;
+ enum RedlineType eRedlineEnd;
bHasRedline = rLine.GetRedln()->CheckLine(start.first->GetIndex(), start.second,
- end.first->GetIndex(), end.second, sRedlineText, bHasRedlineEnd);
+ end.first->GetIndex(), end.second, sRedlineText, bHasRedlineEnd, eRedlineEnd);
if( bHasRedline )
{
SetRedlineText( sRedlineText );
if( bHasRedlineEnd )
SetRedlineEnd( bHasRedlineEnd );
+ if( eRedlineEnd != RedlineType::None )
+ SetRedlineEndType( eRedlineEnd );
}
}
SetRedline( bHasRedline );
@@ -676,6 +679,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_bForcedLeftMargin = m_bHanging = false;
+ m_eRedlineEnd = RedlineType::None;
}
SwLineLayout::SwLineLayout()
diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx
index 5126460b5424..811f1b19331b 100644
--- a/sw/source/core/text/porlay.hxx
+++ b/sw/source/core/text/porlay.hxx
@@ -24,6 +24,7 @@
#include <swrect.hxx>
#include <swtypes.hxx>
#include "portxt.hxx"
+#include <svx/ctredlin.hxx>
#include <vector>
#include <deque>
@@ -98,6 +99,8 @@ private:
bool m_bHanging : 1; // Contains a hanging portion in the margin
bool m_bUnderscore : 1;
+ enum RedlineType m_eRedlineEnd; // redline type of pilcrow and line break symbols
+
OUString m_sRedlineText; // shortened text of (first) tracked deletion shown in margin
SwTwips GetHangingMargin_() const;
@@ -133,6 +136,8 @@ public:
bool HasRedline() const { return m_bRedline; }
void SetRedlineEnd( const bool bNew ) { m_bRedlineEnd = bNew; }
bool HasRedlineEnd() const { return m_bRedlineEnd; }
+ void SetRedlineEndType( const enum RedlineType eNew ) { m_eRedlineEnd = eNew; }
+ RedlineType GetRedlineEndType() const { return m_eRedlineEnd; }
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 a82ee74c1a94..f31c597eac57 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -72,8 +72,7 @@ void SwTmpEndPortion::Paint( const SwTextPaintInfo &rInf ) const
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.SetUnderline( eUnderline );
aFont.SetStrikeout( eStrikeout );
const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont);
@@ -98,6 +97,7 @@ SwBreakPortion::SwBreakPortion( const SwLinePortion &rPortion )
: SwLinePortion( rPortion )
{
nLineLength = TextFrameIndex(1);
+ m_eRedline = RedlineType::None;
SetWhichPor( PortionType::Break );
}
@@ -115,24 +115,38 @@ SwLinePortion *SwBreakPortion::Compress()
void SwBreakPortion::Paint( const SwTextPaintInfo &rInf ) const
{
if( rInf.OnWin() && rInf.GetOpt().IsLineBreak() )
+ {
rInf.DrawLineBreak( *this );
-}
-void SwBreakPortion::PaintRedline( const SwTextPaintInfo &rInf ) const
-{
- if( rInf.OnWin() && rInf.GetOpt().IsLineBreak() )
- {
- sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width();
- if ( nNoBreakWidth > 0 )
+ // paint redlining
+ if (m_eRedline != RedlineType::None)
{
- // approximate portion size with multiple no-break spaces
- // and draw these spaces (at least a single one) by DrawText
- // painting the requested redline underline/strikeout
- sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth;
- OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE);
- for (sal_Int16 i = 1; i < nSpaces; ++i)
- aBuf.append(S_NOBREAK_FOR_REDLINE);
- rInf.DrawText(aBuf.makeStringAndClear(), *this);
+ sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width();
+ if ( nNoBreakWidth > 0 )
+ {
+ // approximate portion size with multiple no-break spaces
+ // and draw these spaces (at least a single one) by DrawText
+ // painting the requested redline underline/strikeout
+ sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth;
+ OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE);
+ for (sal_Int16 i = 1; i < nSpaces; ++i)
+ aBuf.append(S_NOBREAK_FOR_REDLINE);
+
+ const SwFont* pOldFnt = rInf.GetFont();
+
+ SwFont aFont(*pOldFnt);
+
+ if (m_eRedline == RedlineType::Delete)
+ aFont.SetUnderline( LINESTYLE_NONE );
+ else
+ aFont.SetStrikeout( STRIKEOUT_NONE );
+
+ const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont);
+
+ rInf.DrawText(aBuf.makeStringAndClear(), *this);
+
+ const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt));
+ }
}
}
}
diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx
index 32a94ca32e17..af678bb54fc2 100644
--- a/sw/source/core/text/porrst.hxx
+++ b/sw/source/core/text/porrst.hxx
@@ -24,6 +24,7 @@
#include <TextFrameIndex.hxx>
#include <txttypes.hxx>
#include <txtfrm.hxx>
+#include <svx/ctredlin.hxx>
#include "porlin.hxx"
#include "portxt.hxx"
@@ -55,6 +56,8 @@ public:
class SwBreakPortion : public SwLinePortion
{
+ RedlineType m_eRedline;
+
public:
explicit SwBreakPortion( const SwLinePortion &rPortion );
// Returns 0 if we have no usable data
@@ -68,7 +71,7 @@ public:
virtual void HandlePortion( SwPortionHandler& rPH ) const override;
static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
- void PaintRedline( const SwTextPaintInfo &rInf ) const;
+ void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
};
class SwKernPortion : public SwLinePortion
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 9dafe23aff05..4a6157581810 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& bRedlineEnd, RedlineType& eRedlineEnd)
{
// note: previously this would return true in the (!m_bShow && m_pExt)
// case, but surely that was a bug?
@@ -818,6 +818,7 @@ bool SwRedlineItr::CheckLine(
sal_Int32 nOldEnd = m_nEnd;
SwRedlineTable::size_type const nOldAct = m_nAct;
bool bRet = bRedlineEnd = false;
+ eRedlineEnd = RedlineType::None;
for (m_nAct = m_nFirst; m_nAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++m_nAct)
{
@@ -831,11 +832,16 @@ bool SwRedlineItr::CheckLine(
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 )
{
+ eRedlineEnd = pRedline->GetType();
bRedlineEnd = true;
break;
}
+ // store redlining at line end (for line break formatting)
+ else if ( nChkEnd <= m_nEnd )
+ eRedlineEnd = pRedline->GetType();
}
}
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 0a60b414a9e2..1623a31aacc2 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);
+ sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd, RedlineType& eRedlineEnd);
bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{ return m_pExt->Leave(rFnt, nNode, nNew); }
bool ExtOn() {