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

Mark Hung marklh9 at gmail.com
Mon Aug 21 14:06:11 UTC 2017


 sw/source/core/text/itrpaint.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit cd65bae41c52c4d2f40589776a645e224ee222cd
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sat Aug 12 23:33:57 2017 +0800

    tdf#111626 switch underline color.
    
    Switch underline font color if it is from the underline color
    of the portion. If the underline color is auto, take the font
    color into consideration.
    
    Change-Id: I81a0e100cd024add603b574f07e10b5e3a785d0b
    Reviewed-on: https://gerrit.libreoffice.org/41090
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index cd76aa2a0b13..7bd3ce8e549e 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -70,6 +70,12 @@ bool IsUnderlineBreak( const SwLinePortion& rPor, const SwFont& rFnt )
            SvxCaseMap::SmallCaps == rFnt.GetCaseMap();
 }
 
+const Color GetUnderColor( const SwFont *pFont )
+{
+    return pFont->GetUnderColor() == Color( COL_AUTO ) ?
+        pFont->GetColor() : pFont->GetUnderColor();
+}
+
 void SwTextPainter::CtorInitTextPainter( SwTextFrame *pNewFrame, SwTextPaintInfo *pNewInf )
 {
     CtorInitTextCursor( pNewFrame, pNewInf );
@@ -486,10 +492,15 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
         GetInfo().SetUnderFnt( nullptr );
         return;
     }
-
     // Reuse calculated underline font as much as possible.
-    if ( GetInfo().GetUnderFnt() && GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + 1)
+    if ( GetInfo().GetUnderFnt() && GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + 1 )
+    {
+        SwFont &rFont = GetInfo().GetUnderFnt()->GetFont();
+        const Color aColor = GetUnderColor( GetInfo().GetFont() );
+        if ( GetUnderColor( &rFont ) != aColor )
+            rFont.SetColor( aColor );
         return;
+    }
 
     // If current underline matches the common underline font, we continue
     // to use the common underline font.
@@ -578,7 +589,6 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
                 break;
 
             aIter.Seek( nTmpIdx );
-
             if ( aIter.GetFnt()->GetEscapement() < 0 || m_pFont->IsWordLineMode() ||
                  SvxCaseMap::SmallCaps == m_pFont->GetCaseMap() )
                 break;


More information about the Libreoffice-commits mailing list