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

Noel Grandin noel.grandin at collabora.co.uk
Wed Nov 30 06:38:37 UTC 2016


 vcl/source/gdi/pdfwriter_impl.cxx |   44 +++++++++++++--------------
 vcl/source/gdi/pdfwriter_impl.hxx |   61 +++++++++++++++++++++-----------------
 2 files changed, 56 insertions(+), 49 deletions(-)

New commits:
commit 4c5224a29fc11125bc845624a0ffe470416b791c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Nov 29 14:37:55 2016 +0200

    convert GraphicsState flags to o3tl::typed_flags
    
    Change-Id: I5b660895c470a904fa5f1bc8123cea901ad8cf9c
    Reviewed-on: https://gerrit.libreoffice.org/31365
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 30daf70..cd391ca 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -11515,9 +11515,9 @@ void PDFWriterImpl::updateGraphicsState(Mode const mode)
     GraphicsState& rNewState = m_aGraphicsStack.front();
     // first set clip region since it might invalidate everything else
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateClipRegion) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::ClipRegion) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateClipRegion;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::ClipRegion;
 
         if( m_aCurrentPDFState.m_bClipRegion != rNewState.m_bClipRegion ||
             ( rNewState.m_bClipRegion && m_aCurrentPDFState.m_aClipRegion != rNewState.m_aClipRegion ) )
@@ -11527,7 +11527,7 @@ void PDFWriterImpl::updateGraphicsState(Mode const mode)
                 aLine.append( "Q " );
                 // invalidate everything but the clip region
                 m_aCurrentPDFState = GraphicsState();
-                rNewState.m_nUpdateFlags = sal::static_int_cast<sal_uInt16>(~GraphicsState::updateClipRegion);
+                rNewState.m_nUpdateFlags = ~GraphicsStateUpdateFlags::ClipRegion;
             }
             if( rNewState.m_bClipRegion )
             {
@@ -11550,34 +11550,34 @@ void PDFWriterImpl::updateGraphicsState(Mode const mode)
         }
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateMapMode) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::MapMode) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateMapMode;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::MapMode;
         getReferenceDevice()->SetMapMode( rNewState.m_aMapMode );
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateFont) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::Font) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateFont;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::Font;
         getReferenceDevice()->SetFont( rNewState.m_aFont );
         getReferenceDevice()->ImplNewFont();
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateLayoutMode) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::LayoutMode) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateLayoutMode;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::LayoutMode;
         getReferenceDevice()->SetLayoutMode( rNewState.m_nLayoutMode );
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateDigitLanguage) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::DigitLanguage) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateDigitLanguage;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::DigitLanguage;
         getReferenceDevice()->SetDigitLanguage( rNewState.m_aDigitLanguage );
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateLineColor) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::LineColor) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateLineColor;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::LineColor;
         if( m_aCurrentPDFState.m_aLineColor != rNewState.m_aLineColor &&
             rNewState.m_aLineColor != Color( COL_TRANSPARENT ) )
         {
@@ -11586,9 +11586,9 @@ void PDFWriterImpl::updateGraphicsState(Mode const mode)
         }
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateFillColor) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::FillColor) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateFillColor;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::FillColor;
         if( m_aCurrentPDFState.m_aFillColor != rNewState.m_aFillColor &&
             rNewState.m_aFillColor != Color( COL_TRANSPARENT ) )
         {
@@ -11597,9 +11597,9 @@ void PDFWriterImpl::updateGraphicsState(Mode const mode)
         }
     }
 
-    if( (rNewState.m_nUpdateFlags & GraphicsState::updateTransparentPercent) )
+    if( (rNewState.m_nUpdateFlags & GraphicsStateUpdateFlags::TransparentPercent) )
     {
-        rNewState.m_nUpdateFlags &= ~GraphicsState::updateTransparentPercent;
+        rNewState.m_nUpdateFlags &= ~GraphicsStateUpdateFlags::TransparentPercent;
         if( m_aContext.Version >= PDFWriter::PDF_1_4 && m_aCurrentPDFState.m_nTransparentPercent != rNewState.m_nTransparentPercent )
         {
             // TODO: switch extended graphicsstate
@@ -11623,7 +11623,7 @@ void PDFWriterImpl::setFont( const vcl::Font& rFont )
         aColor = m_aGraphicsStack.front().m_aFont.GetColor();
     m_aGraphicsStack.front().m_aFont = rFont;
     m_aGraphicsStack.front().m_aFont.SetColor( aColor );
-    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
+    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
 }
 
 void PDFWriterImpl::push( PushFlags nFlags )
@@ -11675,7 +11675,7 @@ void PDFWriterImpl::pop()
         // what ?
     }
     // invalidate graphics state
-    m_aGraphicsStack.front().m_nUpdateFlags = sal::static_int_cast<sal_uInt16>(~0U);
+    m_aGraphicsStack.front().m_nUpdateFlags = GraphicsStateUpdateFlags::All;
 }
 
 void PDFWriterImpl::setMapMode( const MapMode& rMapMode )
@@ -11691,7 +11691,7 @@ void PDFWriterImpl::setClipRegion( const basegfx::B2DPolyPolygon& rRegion )
     aRegion = getReferenceDevice()->PixelToLogic( aRegion, m_aMapMode );
     m_aGraphicsStack.front().m_aClipRegion = aRegion;
     m_aGraphicsStack.front().m_bClipRegion = true;
-    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
+    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
 }
 
 void PDFWriterImpl::moveClipRegion( sal_Int32 nX, sal_Int32 nY )
@@ -11709,7 +11709,7 @@ void PDFWriterImpl::moveClipRegion( sal_Int32 nX, sal_Int32 nY )
         basegfx::B2DHomMatrix aMat;
         aMat.translate( aPoint.X(), aPoint.Y() );
         m_aGraphicsStack.front().m_aClipRegion.transform( aMat );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
     }
 }
 
@@ -11724,7 +11724,7 @@ bool PDFWriterImpl::intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion
 {
     basegfx::B2DPolyPolygon aRegion( getReferenceDevice()->LogicToPixel( rRegion, m_aGraphicsStack.front().m_aMapMode ) );
     aRegion = getReferenceDevice()->PixelToLogic( aRegion, m_aMapMode );
-    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
+    m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
     if( m_aGraphicsStack.front().m_bClipRegion )
     {
         basegfx::B2DPolyPolygon aOld( basegfx::tools::prepareForPolygonOperation( m_aGraphicsStack.front().m_aClipRegion ) );
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 8cad2f9..9abe5b5 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -38,6 +38,7 @@
 #include <vcl/outdev.hxx>
 #include <vcl/pdfwriter.hxx>
 #include <vcl/wall.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 #include "sallayout.hxx"
 #include "outdata.hxx"
@@ -64,6 +65,24 @@ class SvMemoryStream;
 // PDF spec ver. 1.4: see there for details
 #define MAXIMUM_RC4_KEY_LENGTH (SECUR_128BIT_KEY+3+2)
 
+enum class GraphicsStateUpdateFlags {
+    Font                  = 0x0001,
+    MapMode               = 0x0002,
+    LineColor             = 0x0004,
+    FillColor             = 0x0008,
+    TextLineColor         = 0x0010,
+    OverlineColor         = 0x0020,
+    ClipRegion            = 0x0040,
+    AntiAlias             = 0x0080,
+    LayoutMode            = 0x0100,
+    TransparentPercent    = 0x0200,
+    DigitLanguage         = 0x0400,
+    All                   = 0x07ff
+};
+namespace o3tl {
+    template<> struct typed_flags<GraphicsStateUpdateFlags> : is_typed_flags<GraphicsStateUpdateFlags, 0x07ff> {};
+}
+
 namespace vcl
 {
 
@@ -676,19 +695,7 @@ private:
         LanguageType                     m_aDigitLanguage;
         sal_Int32                        m_nTransparentPercent;
         PushFlags                        m_nFlags;
-        sal_uInt16                       m_nUpdateFlags;
-
-        static const sal_uInt16 updateFont                  = 0x0001;
-        static const sal_uInt16 updateMapMode               = 0x0002;
-        static const sal_uInt16 updateLineColor             = 0x0004;
-        static const sal_uInt16 updateFillColor             = 0x0008;
-        static const sal_uInt16 updateTextLineColor         = 0x0010;
-        static const sal_uInt16 updateOverlineColor         = 0x0020;
-        static const sal_uInt16 updateClipRegion            = 0x0040;
-        static const sal_uInt16 updateAntiAlias             = 0x0080;
-        static const sal_uInt16 updateLayoutMode            = 0x0100;
-        static const sal_uInt16 updateTransparentPercent    = 0x0200;
-        static const sal_uInt16 updateDigitLanguage         = 0x0400;
+        GraphicsStateUpdateFlags         m_nUpdateFlags;
 
         GraphicsState() :
                 m_aLineColor( COL_TRANSPARENT ),
@@ -700,7 +707,7 @@ private:
                 m_aDigitLanguage( 0 ),
                 m_nTransparentPercent( 0 ),
                 m_nFlags( PushFlags::ALL ),
-                m_nUpdateFlags( 0xffff )
+                m_nUpdateFlags( GraphicsStateUpdateFlags::All )
         {}
     };
     std::list< GraphicsState >              m_aGraphicsStack;
@@ -1037,62 +1044,62 @@ public:
     void setLineColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aLineColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLineColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LineColor;
     }
 
     void setFillColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aFillColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFillColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::FillColor;
     }
 
     void setTextLineColor()
     {
         m_aGraphicsStack.front().m_aTextLineColor = Color( COL_TRANSPARENT );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::TextLineColor;
     }
 
     void setTextLineColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aTextLineColor = rColor;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::TextLineColor;
     }
 
     void setOverlineColor()
     {
         m_aGraphicsStack.front().m_aOverlineColor = Color( COL_TRANSPARENT );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateOverlineColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::OverlineColor;
     }
 
     void setOverlineColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aOverlineColor = rColor;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateOverlineColor;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::OverlineColor;
     }
 
     void setTextFillColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
         m_aGraphicsStack.front().m_aFont.SetTransparent( ImplIsColorTransparent( rColor ) );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
     }
     void setTextFillColor()
     {
         m_aGraphicsStack.front().m_aFont.SetFillColor( Color( COL_TRANSPARENT ) );
         m_aGraphicsStack.front().m_aFont.SetTransparent( true );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
     }
     void setTextColor( const Color& rColor )
     {
         m_aGraphicsStack.front().m_aFont.SetColor( rColor );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
     }
 
     void clearClipRegion()
     {
         m_aGraphicsStack.front().m_aClipRegion.clear();
         m_aGraphicsStack.front().m_bClipRegion = false;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
     }
 
     void setClipRegion( const basegfx::B2DPolyPolygon& rRegion );
@@ -1106,19 +1113,19 @@ public:
     void setLayoutMode( ComplexTextLayoutFlags nLayoutMode )
     {
         m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLayoutMode;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LayoutMode;
     }
 
     void setDigitLanguage( LanguageType eLang )
     {
         m_aGraphicsStack.front().m_aDigitLanguage = eLang;
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateDigitLanguage;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::DigitLanguage;
     }
 
     void setTextAlign( TextAlign eAlign )
     {
         m_aGraphicsStack.front().m_aFont.SetAlignment( eAlign );
-        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
+        m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
     }
 
     /* actual drawing functions */


More information about the Libreoffice-commits mailing list