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

Mark Hung marklh9 at gmail.com
Sun Sep 18 08:45:19 UTC 2016


 sw/source/core/inc/swfont.hxx     |    7 +++++--
 sw/source/core/text/itrpaint.cxx  |    6 +++++-
 sw/source/core/txtnode/swfont.cxx |    4 ++--
 3 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit eb8217e17e09613ab1af43a89b52f04e7cb781e8
Author: Mark Hung <marklh9 at gmail.com>
Date:   Wed Aug 3 07:25:50 2016 +0800

    tdf#80724 try to reuse calculated underline font as much as possible.
    
    Underline was broken because for every portion it calculate a
    new underline font based on the following portion so that the
    portions do not have consistent underline fonts. And worse the
    last portion is never be treated as part of continuous underline.
    
    Change-Id: I7a62d89d5b1031a0e7c5e0339f0c591e58dceb12
    Reviewed-on: https://gerrit.libreoffice.org/28267
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index dd9e79e..857719b 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -961,12 +961,14 @@ inline void SwFont::SetHighlightColor( const Color& aNewColor )
 class SwUnderlineFont
 {
     Point m_aPos;
+    sal_Int32 m_nEnd;
     SwFont* m_pFont;
 
 public:
-    // sets the font which should paint the common baseline
+    // sets the font which should paint the common baseline,
+    // index where continuous underline ends,
     // and the starting point of the common baseline
-    SwUnderlineFont( SwFont& rFnt, const Point& rPoint );
+    SwUnderlineFont( SwFont& rFnt ,sal_Int32 m_nEnd , const Point& rPoint );
     ~SwUnderlineFont();
 
     SwFont& GetFont()
@@ -975,6 +977,7 @@ public:
         return *m_pFont;
     }
     const Point& GetPos() const { return m_aPos; }
+    sal_Int32 GetEnd() const { return m_nEnd; }
     // the x coordinate of the starting point has to be set for each portion
     void SetPos( const Point& rPoint ) { m_aPos = rPoint;  }
 };
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 637f44c..be1b63a 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -493,6 +493,10 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
         return;
     }
 
+    // Reuse calculated underline font as much as possible.
+    if ( GetInfo().GetUnderFnt() && GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + 1)
+        return;
+
     // If current underline matches the common underline font, we continue
     // to use the common underline font.
     // Bug 120769:Color of underline display wrongly
@@ -656,7 +660,7 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
         const Color aFillColor( COL_TRANSPARENT );
         pUnderlineFnt->SetFillColor( aFillColor );
 
-        GetInfo().SetUnderFnt( new SwUnderlineFont( *pUnderlineFnt,
+        GetInfo().SetUnderFnt( new SwUnderlineFont( *pUnderlineFnt, nUnderEnd,
                                                      aCommonBaseLine ) );
     }
     else
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 222fe8c..89d444e 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1501,8 +1501,8 @@ void SwDrawTextInfo::Shift( sal_uInt16 nDir )
 /**
  * @note Used for the "continuous underline" feature.
  **/
-SwUnderlineFont::SwUnderlineFont( SwFont& rFnt, const Point& rPoint )
-        : m_aPos( rPoint ), m_pFont( &rFnt )
+SwUnderlineFont::SwUnderlineFont( SwFont& rFnt, sal_Int32 nEnd, const Point& rPoint )
+        : m_aPos( rPoint ), m_nEnd( nEnd ), m_pFont( &rFnt )
 {
 };
 


More information about the Libreoffice-commits mailing list