[Libreoffice-commits] core.git: sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 30 17:53:04 UTC 2020


 sw/source/core/text/itrpaint.cxx |    2 ++
 sw/source/core/text/porrst.cxx   |   19 +++++++++++++++++++
 sw/source/core/text/porrst.hxx   |    3 +++
 3 files changed, 24 insertions(+)

New commits:
commit 58f64686cd83a349611daa52188db8bca347b3d4
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Fri Oct 30 14:20:07 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Oct 30 18:52:22 2020 +0100

    tdf#105967 sw change tracking: fix line break symbol
    
    Paint strikeout/underline based on redline color
    and settings at the inserted or deleted line breaks.
    
    Follow-up of commit 350dbba44ee7703b1da11cc4732a5090ce5efe3d
    (tdf#105967 sw change tracking: fix pilcrow symbol).
    
    Change-Id: I64e267aef5a8bb1818f7e9d1a2fe5febb0df43a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105068
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 153131a2a3e9..ea0b965914e9 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -329,6 +329,8 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
                 SeekAndChg( GetInfo() );
             else
                 SeekAndChgBefore( GetInfo() );
+            // paint redlining
+            static_cast<SwBreakPortion&>(*pPor).PaintRedline( GetInfo() );
         }
         else
             bSeeked = false;
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index f04960725c54..a82ee74c1a94 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -118,6 +118,25 @@ void SwBreakPortion::Paint( const SwTextPaintInfo &rInf ) const
         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 )
+        {
+            // 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);
+        }
+    }
+}
+
 bool SwBreakPortion::Format( SwTextFormatInfo &rInf )
 {
     const SwLinePortion *pRoot = rInf.GetRoot();
diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx
index a0d47683a5f7..32a94ca32e17 100644
--- a/sw/source/core/text/porrst.hxx
+++ b/sw/source/core/text/porrst.hxx
@@ -66,6 +66,9 @@ public:
 
     // Accessibility: pass information about this portion to the PortionHandler
     virtual void HandlePortion( SwPortionHandler& rPH ) const override;
+
+    static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
+    void PaintRedline( const SwTextPaintInfo &rInf ) const;
 };
 
 class SwKernPortion : public SwLinePortion


More information about the Libreoffice-commits mailing list