[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-text-background-color' - editeng/source include/vcl vcl/source

matteocam matteo.campanelli at gmail.com
Thu May 22 10:56:01 PDT 2014


 editeng/source/editeng/impedit3.cxx |    9 +++++----
 editeng/source/items/svxfont.cxx    |    1 +
 include/vcl/font.hxx                |    5 +++++
 include/vcl/outdev.hxx              |    5 +++--
 vcl/source/outdev/font.cxx          |    1 +
 vcl/source/outdev/outdevstate.cxx   |    7 +++++++
 vcl/source/outdev/text.cxx          |   14 +++++++++++---
 7 files changed, 33 insertions(+), 9 deletions(-)

New commits:
commit 181266201b5e6aaad1dcd9cbc2dd4db44ecf3dc5
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu May 22 13:53:19 2014 -0400

    HasBkg method to Font.HasBkg iff HasSingleUnderline.SetBkgColor in OutputDev
    
    Change-Id: I10e6e1b916df0c78d26596a37944e8b57b2897e7

diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index fee0219..3bf1b26 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -3673,7 +3673,12 @@ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRect, OutputDev
         VirtualDevice* pVDev = GetVirtualDevice( pTarget->GetMapMode(), pTarget->GetDrawMode() );
         pVDev->SetDigitLanguage( GetRefDevice()->GetDigitLanguage() );
 
+        /*
+         * Set the appropriate background color according
+         * to text criteria
+        */
         {
+
             Color aBackgroundColor( pView->GetBackgroundColor() );
             // #i47161# Check if text is visible on background
             SvxFont aTmpFont;
@@ -3699,11 +3704,7 @@ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRect, OutputDev
             if( nColorDiff < 8 )
                 aBackgroundColor = aFontColor.IsDark() ? COL_WHITE : COL_BLACK;
 
-            // XXX: BEGIN my changes
-            aBackgroundColor = COL_GRAY;
             pVDev->SetBackground( aBackgroundColor );
-            // END my changes
-            //pVDev->SetBackground( aBackgroundColor ); // original code
         }
 
         bool bVDevValid = true;
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 7feb70e..895eef6 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -456,6 +456,7 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
     const Point &rPos, const OUString &rTxt,
     const sal_Int32 nIdx, const sal_Int32 nLen, const sal_Int32* pDXArray ) const
 {
+
     // Font has to be selected in OutputDevice...
     if ( !IsCaseMap() && !IsCapital() && !IsKern() && !IsEsc() )
     {
diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx
index d9649ba..7079c8d 100644
--- a/include/vcl/font.hxx
+++ b/include/vcl/font.hxx
@@ -60,6 +60,11 @@ public:
     void                SetAlign( FontAlign );
     FontAlign           GetAlign() const;
 
+    // XXX: now font has background iff it is (single-y) underlined
+    bool                HasBackgroundColor() const {
+                return GetUnderline() == UNDERLINE_SINGLE;
+    }
+
     void                SetName( const OUString& rFamilyName );
     const OUString&     GetName() const;
     void                SetStyleName( const OUString& rStyleName );
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 676cf08..5336df1 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -338,6 +338,7 @@ private:
     mutable bool                    mbKerning : 1;
     mutable bool                    mbNewFont : 1;
     mutable bool                    mbTextLines : 1;
+    mutable bool                    mbTextBackground : 1;
     mutable bool                    mbTextSpecial : 1;
     mutable bool                    mbRefPoint : 1;
     mutable bool                    mbEnableRTL : 1;
@@ -648,7 +649,7 @@ public:
     ///@}
 
 
-    /** @name Rectangle functions
+    /** @name Rectangle functionsf
      */
     ///@{
 
@@ -1043,7 +1044,7 @@ private:
     SAL_DLLPRIVATE void         ImplInitAboveTextLineSize();
 
 
-    SAL_DLLPRIVATE bool         ImplDrawTextDirect( SalLayout&, bool bTextLines, sal_uInt32 flags = 0 );
+    SAL_DLLPRIVATE bool         ImplDrawTextDirect( SalLayout&, bool bTextLines, bool bTextBkg = false, sal_uInt32 flags = 0 );
     SAL_DLLPRIVATE void         ImplDrawSpecialText( SalLayout& );
     SAL_DLLPRIVATE void         ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight );
 
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 541df8ef..72e2d0c 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1624,6 +1624,7 @@ bool OutputDevice::ImplNewFont() const
     mbTextSpecial   = maFont.IsShadow() || maFont.IsOutline() ||
                       (maFont.GetRelief() != RELIEF_NONE);
 
+
     // #95414# fix for OLE objects which use scale factors very creatively
     if( mbMap && !aSize.Width() )
     {
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index 2dcaf11..8787a6e 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -520,6 +520,13 @@ void OutputDevice::SetFont( const Font& rNewFont )
 
         aFont.SetColor( aTextColor );
 
+        mbTextBackground = aFont.HasBackgroundColor();
+        if ( mbTextBackground )
+        {
+            Color aRedColor ( COL_RED );
+            SetBackground(aRedColor);
+        }
+
         bool bTransFill = aFont.IsTransparent();
         if ( !bTransFill )
         {
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index c5030ad..90da4db 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -279,7 +279,10 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
     return true;
 }
 
-bool OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout, bool bTextLines, sal_uInt32 flags )
+bool OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout,
+                                                                    bool bTextLines,
+                                                                    bool bTextBkg,
+                                                                    sal_uInt32 flags )
 {
     if( mpFontEntry->mnOwnOrientation )
         if( ImplDrawRotateText( rSalLayout ) )
@@ -327,6 +330,11 @@ bool OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout, bool bTextLines, s
             maFont.GetStrikeout(), maFont.GetUnderline(), maFont.GetOverline(),
             maFont.IsWordLineMode(), ImplIsUnderlineAbove( maFont ) );
 
+    // draw background
+    if ( bTextBkg ) {
+
+    }
+
     // emphasis marks
     if( maFont.GetEmphasisMark() & EMPHASISMARK_STYLE )
         ImplDrawEmphasisMarks( rSalLayout );
@@ -422,7 +430,7 @@ void OutputDevice::ImplDrawSpecialText( SalLayout& rSalLayout )
 
         if ( maFont.IsOutline() )
         {
-            if(! ImplDrawTextDirect( rSalLayout, mbTextLines, DRAWTEXT_F_OUTLINE))
+            if(! ImplDrawTextDirect( rSalLayout, mbTextLines, false, DRAWTEXT_F_OUTLINE))
             {
                 rSalLayout.DrawBase() = aOrigPos + Point(-1,-1);
                 ImplDrawTextDirect( rSalLayout, mbTextLines );
@@ -473,7 +481,7 @@ void OutputDevice::ImplDrawText( SalLayout& rSalLayout )
     if( mbTextSpecial )
         ImplDrawSpecialText( rSalLayout );
     else
-        ImplDrawTextDirect( rSalLayout, mbTextLines );
+        ImplDrawTextDirect( rSalLayout, mbTextLines, mbTextBackground );
 }
 
 long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,


More information about the Libreoffice-commits mailing list