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

Noel Grandin noel at peralex.com
Mon May 30 06:36:09 UTC 2016


 vcl/source/filter/wmf/enhwmf.cxx |    2 -
 vcl/source/filter/wmf/winmtf.cxx |   49 +++++++++++++++++++--------------------
 vcl/source/filter/wmf/winmtf.hxx |   19 ++++++++-------
 vcl/source/filter/wmf/winwmf.cxx |    7 +++--
 4 files changed, 41 insertions(+), 36 deletions(-)

New commits:
commit 98d09839353325afefea2dad549b1f9adf10aea1
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 27 15:40:53 2016 +0200

    Convert MTF R2 constants to scoped enum
    
    Change-Id: I9c18e5bbbd176cf5276000e43f4c3a993e4e0d87
    Reviewed-on: https://gerrit.libreoffice.org/25545
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index ebb42cf..152bdfc 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -808,7 +808,7 @@ bool EnhWMFReader::ReadEnhWMF()
                 case EMR_SETROP2 :
                 {
                     pWMF->ReadUInt32( nDat32 );
-                    pOut->SetRasterOp( nDat32 );
+                    pOut->SetRasterOp( (WMFRasterOp)nDat32 );
                 }
                 break;
 
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 2228bbc..663267a 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -846,8 +846,9 @@ WinMtfOutput::WinMtfOutput( GDIMetaFile& rGDIMetaFile ) :
     maLatestLineStyle.aLineColor = Color( 0x12, 0x34, 0x56 );
     maLatestFillStyle.aFillColor = Color( 0x12, 0x34, 0x56 );
 
-    mnRop = R2_BLACK + 1;
-    SetRasterOp( R2_BLACK );
+    mnRop = WMFRasterOp::Black;
+    meRasterOp = ROP_OVERPAINT;
+    mpGDIMetaFile->AddAction( new MetaRasterOpAction( ROP_OVERPAINT ) );
 }
 
 WinMtfOutput::~WinMtfOutput()
@@ -917,30 +918,30 @@ void WinMtfOutput::UpdateFillStyle()
     }
 }
 
-sal_uInt32 WinMtfOutput::SetRasterOp( sal_uInt32 nRasterOp )
+WMFRasterOp WinMtfOutput::SetRasterOp( WMFRasterOp nRasterOp )
 {
-    sal_uInt32 nRetROP = mnRop;
+    WMFRasterOp nRetROP = mnRop;
     if ( nRasterOp != mnRop )
     {
         mnRop = nRasterOp;
 
-        if ( mbNopMode && ( nRasterOp != R2_NOP ) )
-        {   // changing modes from R2_NOP so set pen and brush
+        if ( mbNopMode && ( nRasterOp != WMFRasterOp::Nop ) )
+        {   // changing modes from WMFRasterOp::Nop so set pen and brush
             maFillStyle = m_NopFillStyle;
             maLineStyle = m_NopLineStyle;
             mbNopMode = false;
         }
         switch( nRasterOp )
         {
-            case R2_NOT:
+            case WMFRasterOp::Not:
                 meRasterOp = ROP_INVERT;
             break;
 
-            case R2_XORPEN:
+            case WMFRasterOp::XorPen:
                 meRasterOp = ROP_XOR;
             break;
 
-            case R2_NOP:
+            case WMFRasterOp::Nop:
             {
                 meRasterOp = ROP_OVERPAINT;
                 if( !mbNopMode )
@@ -1637,7 +1638,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
 
             if ( (nUsed & 1) && (( nUsed & 2 ) == 0) && nWinRop != PATINVERT )
             {   // patterns aren't well supported yet
-                sal_uInt32 nOldRop = SetRasterOp( ROP_OVERPAINT );  // in this case nRasterOperation is either 0 or 0xff
+                WMFRasterOp nOldRop = SetRasterOp( WMFRasterOp::NONE );  // in this case nRasterOperation is either 0 or 0xff
                 UpdateFillStyle();
                 DrawRect( aRect, false );
                 SetRasterOp( nOldRop );
@@ -1695,7 +1696,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                 if ( !bDrawn )
                 {
                     Push();
-                    sal_uInt32  nOldRop = SetRasterOp( R2_COPYPEN );
+                    WMFRasterOp nOldRop = SetRasterOp( WMFRasterOp::CopyPen );
                     Bitmap      aBitmap( pSave->aBmpEx.GetBitmap() );
                     sal_uInt32  nOperation = ( nRasterOperation & 0xf );
                     switch( nOperation )
@@ -1709,16 +1710,16 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                             }
                             else
                             {
-                                SetRasterOp( R2_XORPEN );
+                                SetRasterOp( WMFRasterOp::XorPen );
                                 ImplDrawBitmap( aPos, aSize, aBitmap );
-                                SetRasterOp( R2_COPYPEN );
+                                SetRasterOp( WMFRasterOp::CopyPen );
                                 Bitmap  aMask( aBitmap );
                                 aMask.Invert();
                                 BitmapEx aBmpEx( aBitmap, aMask );
                                 ImplDrawBitmap( aPos, aSize, aBmpEx );
                                 if ( nOperation == 0x1 )
                                 {
-                                    SetRasterOp( R2_NOT );
+                                    SetRasterOp( WMFRasterOp::Not );
                                     DrawRect( aRect, false );
                                 }
                             }
@@ -1737,7 +1738,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                             ImplDrawBitmap( aPos, aSize, aBmpEx );
                             if ( nOperation == 0x7 )
                             {
-                                SetRasterOp( R2_NOT );
+                                SetRasterOp( WMFRasterOp::Not );
                                 DrawRect( aRect, false );
                             }
                         }
@@ -1746,18 +1747,18 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                         case 0x4 :
                         case 0xb :
                         {
-                            SetRasterOp( R2_NOT );
+                            SetRasterOp( WMFRasterOp::Not );
                             DrawRect( aRect, false );
-                            SetRasterOp( R2_COPYPEN );
+                            SetRasterOp( WMFRasterOp::CopyPen );
                             Bitmap  aMask( aBitmap );
                             aBitmap.Invert();
                             BitmapEx aBmpEx( aBitmap, aMask );
                             ImplDrawBitmap( aPos, aSize, aBmpEx );
-                            SetRasterOp( R2_XORPEN );
+                            SetRasterOp( WMFRasterOp::XorPen );
                             ImplDrawBitmap( aPos, aSize, aBitmap );
                             if ( nOperation == 0xb )
                             {
-                                SetRasterOp( R2_NOT );
+                                SetRasterOp( WMFRasterOp::Not );
                                 DrawRect( aRect, false );
                             }
                         }
@@ -1770,11 +1771,11 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                             aMask.Invert();
                             BitmapEx aBmpEx( aBitmap, aMask );
                             ImplDrawBitmap( aPos, aSize, aBmpEx );
-                            SetRasterOp( R2_XORPEN );
+                            SetRasterOp( WMFRasterOp::XorPen );
                             ImplDrawBitmap( aPos, aSize, aBitmap );
                             if ( nOperation == 0xd )
                             {
-                                SetRasterOp( R2_NOT );
+                                SetRasterOp( WMFRasterOp::Not );
                                 DrawRect( aRect, false );
                             }
                         }
@@ -1782,11 +1783,11 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
                         case 0x6 :
                         case 0x9 :
                         {
-                            SetRasterOp( R2_XORPEN );
+                            SetRasterOp( WMFRasterOp::XorPen );
                             ImplDrawBitmap( aPos, aSize, aBitmap );
                             if ( nOperation == 0x9 )
                             {
-                                SetRasterOp( R2_NOT );
+                                SetRasterOp( WMFRasterOp::Not );
                                 DrawRect( aRect, false );
                             }
                         }
@@ -1812,7 +1813,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
 
                         case 0x5 :  // only destination is used
                         {
-                            SetRasterOp( R2_NOT );
+                            SetRasterOp( WMFRasterOp::Not );
                             DrawRect( aRect, false );
                         }
                         break;
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index cff2763..caf3a88 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -70,12 +70,15 @@ enum class BkMode
 #define ANSI_VAR_FONT           12
 #define SYSTEM_FIXED_FONT       16
 
-#define R2_BLACK                1
-#define R2_MASKNOTPEN           3
-#define R2_NOT                  6
-#define R2_XORPEN               7
-#define R2_NOP                  11
-#define R2_COPYPEN              13
+enum class WMFRasterOp {
+    NONE                 = 0,
+    Black                = 1,
+    MaskNotPen           = 3,
+    Not                  = 6,
+    XorPen               = 7,
+    Nop                  = 11,
+    CopyPen              = 13
+};
 
 /* Mapping modes */
 #define MM_TEXT                 1
@@ -490,7 +493,7 @@ class WinMtfOutput
 
     Point               maActPos;
 
-    sal_uInt32          mnRop;
+    WMFRasterOp         mnRop;
     bool            mbNopMode;
     bool            mbFillStyleSelected;
     bool            mbClipNeedsUpdate;
@@ -558,7 +561,7 @@ public:
     void                Push();
     void                Pop();
 
-    sal_uInt32          SetRasterOp( sal_uInt32 nRasterOp );
+    WMFRasterOp         SetRasterOp( WMFRasterOp nRasterOp );
     void                StrokeAndFillPath( bool bStroke, bool bFill );
 
     void                SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index ae5cc87..d33e24c 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -195,7 +195,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
         {
             sal_uInt16 nROP2 = 0;
             pWMF->ReadUInt16( nROP2 );
-            pOut->SetRasterOp( nROP2 );
+            pOut->SetRasterOp( (WMFRasterOp)nROP2 );
         }
         break;
 
@@ -951,10 +951,11 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
 
         case W_META_PATBLT:
         {
-            sal_uInt32 nROP = 0, nOldROP = 0;
+            sal_uInt32 nROP = 0;
+            WMFRasterOp nOldROP = WMFRasterOp::NONE;
             pWMF->ReadUInt32( nROP );
             Size aSize = ReadYXExt();
-            nOldROP = pOut->SetRasterOp( nROP );
+            nOldROP = pOut->SetRasterOp( (WMFRasterOp)nROP );
             pOut->DrawRect( Rectangle( ReadYX(), aSize ), false );
             pOut->SetRasterOp( nOldROP );
         }


More information about the Libreoffice-commits mailing list