diff options
author | Mark Hung <marklh9@gmail.com> | 2016-08-03 07:25:50 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2016-09-18 08:43:54 +0000 |
commit | eb8217e17e09613ab1af43a89b52f04e7cb781e8 (patch) | |
tree | c7f5187285d6af45ed73555f6dc99ca7aeb79e6f | |
parent | 3287bc2f91438085b7604773d5e0346fc3c3f452 (diff) |
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@libreoffice.org>
Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r-- | sw/source/core/inc/swfont.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/text/itrpaint.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index dd9e79ea54e6..857719bf9863 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 637f44c2f34d..be1b63a5e34c 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 222fe8ccddbe..89d444e4ede8 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 ) { }; |