Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

after replacing string data types I looked for duplicated code in vcl with simian. Could someone please review it? It builds successfully but I'm unsure about where to use "const"...

Thank you,
Christina
From 94b9a014e07133fef3f7432d4d6945cd76e66d4d Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Tue, 24 Jan 2012 22:26:45 +0100
Subject: [PATCH] Reduced duplicate code detected by simian

---
 vcl/inc/vcl/outdev.hxx     |    1 +
 vcl/source/gdi/outdev.cxx  |   32 ++++++++++++++++++++------------
 vcl/source/gdi/outdev2.cxx |   35 +----------------------------------
 3 files changed, 22 insertions(+), 46 deletions(-)

diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index ea7787c..1c612b5 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -547,6 +547,7 @@ public:
 
     // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
     SAL_DLLPRIVATE bool ImplIsAntiparallel() const ;
+    SAL_DLLPRIVATE Color ImplDrawModeToColor( Color );
 
     // #i101491#
     // Helper which holds the old line geometry creation and is extended to use AA when
diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx
index fe49527..b55a237 100644
--- a/vcl/source/gdi/outdev.cxx
+++ b/vcl/source/gdi/outdev.cxx
@@ -1238,38 +1238,36 @@ void OutputDevice::SetLineColor()
 
 // -----------------------------------------------------------------------
 
-void OutputDevice::SetLineColor( const Color& rColor )
+Color OutputDevice::ImplDrawModeToColor( const Color rColor )
 {
-    OSL_TRACE( "OutputDevice::SetLineColor( %lx )", rColor.GetColor() );
-    DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
-
     Color aColor( rColor );
+    sal_uLong  nDrawMode = GetDrawMode();
 
-    if( mnDrawMode & ( DRAWMODE_BLACKLINE | DRAWMODE_WHITELINE |
-                       DRAWMODE_GRAYLINE | DRAWMODE_GHOSTEDLINE |
-                       DRAWMODE_SETTINGSLINE ) )
+    if( nDrawMode & ( DRAWMODE_BLACKLINE | DRAWMODE_WHITELINE |
+                      DRAWMODE_GRAYLINE | DRAWMODE_GHOSTEDLINE |
+                      DRAWMODE_SETTINGSLINE ) )
     {
         if( !ImplIsColorTransparent( aColor ) )
         {
-            if( mnDrawMode & DRAWMODE_BLACKLINE )
+            if( nDrawMode & DRAWMODE_BLACKLINE )
             {
                 aColor = Color( COL_BLACK );
             }
-            else if( mnDrawMode & DRAWMODE_WHITELINE )
+            else if( nDrawMode & DRAWMODE_WHITELINE )
             {
                 aColor = Color( COL_WHITE );
             }
-            else if( mnDrawMode & DRAWMODE_GRAYLINE )
+            else if( nDrawMode & DRAWMODE_GRAYLINE )
             {
                 const sal_uInt8 cLum = aColor.GetLuminance();
                 aColor = Color( cLum, cLum, cLum );
             }
-            else if( mnDrawMode & DRAWMODE_SETTINGSLINE )
+            else if( nDrawMode & DRAWMODE_SETTINGSLINE )
             {
                 aColor = GetSettings().GetStyleSettings().GetFontColor();
             }
 
-            if( mnDrawMode & DRAWMODE_GHOSTEDLINE )
+            if( nDrawMode & DRAWMODE_GHOSTEDLINE )
             {
                 aColor = Color( ( aColor.GetRed() >> 1 ) | 0x80,
                                 ( aColor.GetGreen() >> 1 ) | 0x80,
@@ -1277,6 +1275,16 @@ void OutputDevice::SetLineColor( const Color& rColor )
             }
         }
     }
+    return aColor;
+}
+
+
+void OutputDevice::SetLineColor( const Color& rColor )
+{
+    OSL_TRACE( "OutputDevice::SetLineColor( %lx )", rColor.GetColor() );
+    DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
+
+    Color aColor = ImplDrawModeToColor( rColor );
 
     if( mpMetaFile )
         mpMetaFile->AddAction( new MetaLineColorAction( aColor, sal_True ) );
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx
index 2003de8..9b0b4f3 100644
--- a/vcl/source/gdi/outdev2.cxx
+++ b/vcl/source/gdi/outdev2.cxx
@@ -1441,40 +1441,7 @@ void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor )
     OSL_TRACE( "OutputDevice::DrawPixel()" );
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
 
-    Color aColor( rColor );
-
-    if( mnDrawMode & ( DRAWMODE_BLACKLINE | DRAWMODE_WHITELINE |
-                       DRAWMODE_GRAYLINE | DRAWMODE_GHOSTEDLINE |
-                       DRAWMODE_SETTINGSLINE ) )
-    {
-        if( !ImplIsColorTransparent( aColor ) )
-        {
-            if( mnDrawMode & DRAWMODE_BLACKLINE )
-            {
-                aColor = Color( COL_BLACK );
-            }
-            else if( mnDrawMode & DRAWMODE_WHITELINE )
-            {
-                aColor = Color( COL_WHITE );
-            }
-            else if( mnDrawMode & DRAWMODE_GRAYLINE )
-            {
-                const sal_uInt8 cLum = aColor.GetLuminance();
-                aColor = Color( cLum, cLum, cLum );
-            }
-            else if( mnDrawMode & DRAWMODE_SETTINGSLINE )
-            {
-                aColor = GetSettings().GetStyleSettings().GetFontColor();
-            }
-
-            if( mnDrawMode & DRAWMODE_GHOSTEDLINE )
-            {
-                aColor = Color( ( aColor.GetRed() >> 1 ) | 0x80,
-                                ( aColor.GetGreen() >> 1 ) | 0x80,
-                                ( aColor.GetBlue() >> 1 ) | 0x80 );
-            }
-        }
-    }
+    Color aColor = ImplDrawModeToColor( rColor );
 
     if ( mpMetaFile )
         mpMetaFile->AddAction( new MetaPixelAction( rPt, aColor ) );
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.