[Libreoffice-commits] core.git: include/vcl vcl/headless vcl/opengl vcl/quartz vcl/source vcl/unx vcl/win

Noel Grandin noel at peralex.com
Tue May 10 12:09:26 UTC 2016


 include/vcl/salgtype.hxx        |   15 +++++++++++----
 vcl/headless/svpgdi.cxx         |    4 ++--
 vcl/opengl/gdiimpl.cxx          |    6 +++---
 vcl/quartz/salgdicommon.cxx     |    8 ++++----
 vcl/source/outdev/rect.cxx      |   14 +++++++-------
 vcl/source/window/window2.cxx   |   14 +++++++-------
 vcl/unx/generic/gdi/gdiimpl.cxx |   10 +++++-----
 vcl/win/gdi/gdiimpl.cxx         |   12 ++++++------
 8 files changed, 45 insertions(+), 38 deletions(-)

New commits:
commit 9058b06443bb901d39641c47b6d7806eb9055b41
Author: Noel Grandin <noel at peralex.com>
Date:   Tue May 10 09:55:14 2016 +0200

    Convert SAL_INVERT to scoped enum
    
    Change-Id: If9f725c791f9d01efba098caed8387f21862fa04
    Reviewed-on: https://gerrit.libreoffice.org/24825
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/vcl/salgtype.hxx b/include/vcl/salgtype.hxx
index cae4727..b9eb6ae 100644
--- a/include/vcl/salgtype.hxx
+++ b/include/vcl/salgtype.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_VCL_SALGTYPE_HXX
 
 #include <sal/types.h>
+#include <o3tl/typed_flags_set.hxx>
 
 enum class DeviceFormat {
                             NONE = -1,
@@ -70,10 +71,16 @@ enum class SalROPColor {
     N0, N1, Invert
 };
 
-typedef sal_uInt16 SalInvert;
-#define SAL_INVERT_HIGHLIGHT        ((SalInvert)0x0001)
-#define SAL_INVERT_50               ((SalInvert)0x0002)
-#define SAL_INVERT_TRACKFRAME       ((SalInvert)0x0004)
+enum class SalInvert {
+    NONE       = 0x00,
+    Highlight  = 0x01,
+    N50        = 0x02,
+    TrackFrame = 0x04
+};
+namespace o3tl
+{
+    template<> struct typed_flags<SalInvert> : is_typed_flags<SalInvert, 0x07> {};
+}
 
 #endif // INCLUDED_VCL_SALGTYPE_HXX
 
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 7da5c50..2c2408b 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1168,7 +1168,7 @@ void SvpSalGraphics::invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags)
         SAL_WARN("vcl.gdi", "SvpSalGraphics::invert, archaic cairo");
     }
 
-    if (nFlags & SAL_INVERT_TRACKFRAME)
+    if (nFlags & SalInvert::TrackFrame)
     {
         cairo_set_line_width(cr, 2.0);
         const double dashLengths[2] = { 4.0, 4.0 };
@@ -1184,7 +1184,7 @@ void SvpSalGraphics::invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags)
 
         cairo_clip(cr);
 
-        if (nFlags & SAL_INVERT_50)
+        if (nFlags & SalInvert::N50)
         {
             cairo_pattern_t *pattern = create_stipple();
             cairo_mask(cr, pattern);
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 65650c0..c2b2ae3 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -606,8 +606,8 @@ bool OpenGLSalGraphicsImpl::UseInvert( SalInvert nFlags )
 {
     OpenGLZone aZone;
 
-    if( ( nFlags & SAL_INVERT_50 ) ||
-        ( nFlags & SAL_INVERT_TRACKFRAME ) )
+    if( ( nFlags & SalInvert::N50 ) ||
+        ( nFlags & SalInvert::TrackFrame ) )
     {
         // FIXME: Trackframe really should be 2 pix. on/off stipple.
         if( !UseInvert50() )
@@ -2251,7 +2251,7 @@ void OpenGLSalGraphicsImpl::invert(
 
     if( UseInvert( nFlags ) )
     {
-        if( nFlags & SAL_INVERT_TRACKFRAME )
+        if( nFlags & SalInvert::TrackFrame )
         { // FIXME: could be more efficient.
             DrawRect( nX, nY, nWidth, 1 );
             DrawRect( nX, nY + nHeight, nWidth, 1 );
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 3efe620..7b8fb2f 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -1690,7 +1690,7 @@ void AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalIn
         SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth);
         CGContextSaveGState(mrContext);
 
-        if ( nFlags & SAL_INVERT_TRACKFRAME )
+        if ( nFlags & SalInvert::TrackFrame )
         {
             const CGFloat dashLengths[2]  = { 4.0, 4.0 };     // for drawing dashed line
             CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
@@ -1701,7 +1701,7 @@ void AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalIn
             SAL_INFO( "vcl.cg", "CGContextStrokeRect(" << mrContext << "," << aCGRect << ")" );
             CGContextStrokeRect ( mrContext, aCGRect );
         }
-        else if ( nFlags & SAL_INVERT_50 )
+        else if ( nFlags & SalInvert::N50 )
         {
             //CGContextSetAllowsAntialiasing( mrContext, false );
             CGContextSetBlendMode(mrContext, kCGBlendModeDifference);
@@ -1748,7 +1748,7 @@ void AquaSalGraphics::invert( sal_uInt32 nPoints, const SalPoint*  pPtAry, SalIn
         CGContextSaveGState(mrContext);
         CGPoint* CGpoints = makeCGptArray(nPoints,pPtAry);
         CGContextAddLines ( mrContext, CGpoints, nPoints );
-        if ( nSalFlags & SAL_INVERT_TRACKFRAME )
+        if ( nSalFlags & SalInvert::TrackFrame )
         {
             const CGFloat dashLengths[2]  = { 4.0, 4.0 };     // for drawing dashed line
             CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
@@ -1759,7 +1759,7 @@ void AquaSalGraphics::invert( sal_uInt32 nPoints, const SalPoint*  pPtAry, SalIn
             SAL_INFO( "vcl.cg", "CGContextStrokePath(" << mrContext << ")" );
             CGContextStrokePath ( mrContext );
         }
-        else if ( nSalFlags & SAL_INVERT_50 )
+        else if ( nSalFlags & SalInvert::N50 )
         {
             CGContextSetBlendMode(mrContext, kCGBlendModeDifference);
             Pattern50Fill();
diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx
index 32b23de..c4bf57c 100644
--- a/vcl/source/outdev/rect.cxx
+++ b/vcl/source/outdev/rect.cxx
@@ -154,13 +154,13 @@ void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags )
     if ( mbOutputClipped )
         return;
 
-    SalInvert nSalFlags = 0;
+    SalInvert nSalFlags = SalInvert::NONE;
     if ( nFlags & InvertFlags::Highlight )
-        nSalFlags |= SAL_INVERT_HIGHLIGHT;
+        nSalFlags |= SalInvert::Highlight;
     if ( nFlags & InvertFlags::N50 )
-        nSalFlags |= SAL_INVERT_50;
+        nSalFlags |= SalInvert::N50;
     if ( nFlags == (InvertFlags) 0xffff ) // vcldemo trackframe test
-        nSalFlags = SAL_INVERT_TRACKFRAME;
+        nSalFlags = SalInvert::TrackFrame;
     mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
 }
 
@@ -190,11 +190,11 @@ void OutputDevice::Invert( const tools::Polygon& rPoly, InvertFlags nFlags )
     if ( mbOutputClipped )
         return;
 
-    SalInvert nSalFlags = 0;
+    SalInvert nSalFlags = SalInvert::NONE;
     if ( nFlags & InvertFlags::Highlight )
-        nSalFlags |= SAL_INVERT_HIGHLIGHT;
+        nSalFlags |= SalInvert::Highlight;
     if ( nFlags & InvertFlags::N50 )
-        nSalFlags |= SAL_INVERT_50;
+        nSalFlags |= SalInvert::N50;
     const SalPoint* pPtAry = reinterpret_cast<const SalPoint*>(aPoly.GetConstPointAry());
     mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
 }
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index dfd2754..d38603f 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -211,18 +211,18 @@ void Window::InvertTracking( const Rectangle& rRect, sal_uInt16 nFlags )
 
     sal_uInt16 nStyle = nFlags & SHOWTRACK_STYLE;
     if ( nStyle == SHOWTRACK_OBJECT )
-        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_TRACKFRAME, this );
+        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::TrackFrame, this );
     else if ( nStyle == SHOWTRACK_SPLIT )
-        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_50, this );
+        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::N50, this );
     else
     {
         long nBorder = 1;
         if ( nStyle == SHOWTRACK_BIG )
             nBorder = 5;
-        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
-        pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
-        pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
-        pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
+        pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SalInvert::N50, this );
+        pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SalInvert::N50, this );
+        pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, this );
+        pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, this );
     }
 }
 
@@ -274,7 +274,7 @@ void Window::InvertTracking( const tools::Polygon& rPoly, sal_uInt16 nFlags )
     }
 
     const SalPoint* pPtAry = reinterpret_cast<const SalPoint*>(aPoly.GetConstPointAry());
-    pGraphics->Invert( nPoints, pPtAry, SAL_INVERT_TRACKFRAME, this );
+    pGraphics->Invert( nPoints, pPtAry, SalInvert::TrackFrame, this );
 }
 
 IMPL_LINK_TYPED( Window, ImplTrackTimerHdl, Timer*, pTimer, void )
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 1eda18a..b186d35 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -1419,14 +1419,14 @@ void X11SalGraphicsImpl::invert( long       nX,
                                 SalInvert   nFlags )
 {
     GC pGC;
-    if( SAL_INVERT_50 & nFlags )
+    if( SalInvert::N50 & nFlags )
     {
         pGC = GetInvert50GC();
         XFillRectangle( mrParent.GetXDisplay(), mrParent.GetDrawable(), pGC, nX, nY, nDX, nDY );
     }
     else
     {
-        if ( SAL_INVERT_TRACKFRAME & nFlags )
+        if ( SalInvert::TrackFrame & nFlags )
         {
             pGC = GetTrackingGC();
             XDrawRectangle( mrParent.GetXDisplay(), mrParent.GetDrawable(),  pGC, nX, nY, nDX, nDY );
@@ -1446,15 +1446,15 @@ void X11SalGraphicsImpl::invert( sal_uInt32 nPoints,
     SalPolyLine Points ( nPoints, pPtAry );
 
     GC pGC;
-    if( SAL_INVERT_50 & nFlags )
+    if( SalInvert::N50 & nFlags )
         pGC = GetInvert50GC();
     else
-        if ( SAL_INVERT_TRACKFRAME & nFlags )
+        if ( SalInvert::TrackFrame & nFlags )
             pGC = GetTrackingGC();
         else
             pGC = GetInvertGC();
 
-    if( SAL_INVERT_TRACKFRAME & nFlags )
+    if( SalInvert::TrackFrame & nFlags )
         DrawLines ( nPoints, Points, pGC, true );
     else
         XFillPolygon( mrParent.GetXDisplay(),
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 6eebc7a9..87ff4e1 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -906,7 +906,7 @@ SalColor WinSalGraphicsImpl::getPixel( long nX, long nY )
 
 void WinSalGraphicsImpl::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags )
 {
-    if ( nFlags & SAL_INVERT_TRACKFRAME )
+    if ( nFlags & SalInvert::TrackFrame )
     {
         HPEN    hDotPen = CreatePen( PS_DOT, 0, 0 );
         HPEN    hOldPen = SelectPen( mrParent.getHDC(), hDotPen );
@@ -920,7 +920,7 @@ void WinSalGraphicsImpl::invert( long nX, long nY, long nWidth, long nHeight, Sa
         SelectBrush( mrParent.getHDC(), hOldBrush );
         DeletePen( hDotPen );
     }
-    else if ( nFlags & SAL_INVERT_50 )
+    else if ( nFlags & SalInvert::N50 )
     {
         SalData* pSalData = GetSalData();
         if ( !pSalData->mh50Brush )
@@ -956,12 +956,12 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, Sal
     COLORREF    nOldTextColor RGB(0,0,0);
     int         nOldROP = SetROP2( mrParent.getHDC(), R2_NOT );
 
-    if ( nSalFlags & SAL_INVERT_TRACKFRAME )
+    if ( nSalFlags & SalInvert::TrackFrame )
         hPen = CreatePen( PS_DOT, 0, 0 );
     else
     {
 
-        if ( nSalFlags & SAL_INVERT_50 )
+        if ( nSalFlags & SalInvert::N50 )
         {
             SalData* pSalData = GetSalData();
             if ( !pSalData->mh50Brush )
@@ -988,7 +988,7 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, Sal
 
     pWinPtAry = (POINT*)pPtAry;
     // for Windows 95 and its maximum number of points
-    if ( nSalFlags & SAL_INVERT_TRACKFRAME )
+    if ( nSalFlags & SalInvert::TrackFrame )
     {
         if ( !Polyline( mrParent.getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) )
             Polyline( mrParent.getHDC(), pWinPtAry, MAX_64KSALPOINTS );
@@ -1002,7 +1002,7 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, Sal
     SetROP2( mrParent.getHDC(), nOldROP );
     SelectPen( mrParent.getHDC(), hOldPen );
 
-    if ( nSalFlags & SAL_INVERT_TRACKFRAME )
+    if ( nSalFlags & SalInvert::TrackFrame )
         DeletePen( hPen );
     else
     {


More information about the Libreoffice-commits mailing list