[Libreoffice-commits] core.git: include/tools svtools/source svx/source sw/source tools/source vcl/source

Noel Grandin noel at peralex.com
Thu Jan 8 23:09:55 PST 2015


 include/tools/poly.hxx              |   22 +++++++++++++++-------
 svtools/source/uno/unoimap.cxx      |    2 +-
 svx/source/dialog/frmsel.cxx        |    4 ++--
 sw/source/core/layout/fly.cxx       |    2 +-
 sw/source/core/unocore/unoframe.cxx |    2 +-
 tools/source/generic/poly.cxx       |   16 ++++++++--------
 tools/source/generic/poly2.cxx      |   12 ++++++------
 vcl/source/gdi/impvect.cxx          |    4 ++--
 vcl/source/gdi/pdfwriter_impl.cxx   |    2 +-
 vcl/source/outdev/hatch.cxx         |    4 ++--
 10 files changed, 39 insertions(+), 31 deletions(-)

New commits:
commit 278b400511a76a9be5e0afc0377a9c69823cc230
Author: Noel Grandin <noel at peralex.com>
Date:   Sun Jan 4 19:34:19 2015 +0200

    fdo#84938: convert POLY_OPTIMIZE_ #defines to 'enum class'
    
    Change-Id: I163bd3f521473c5357c23c3ce4978f984be7b6fe

diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index bfc14ea..af157b2 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -22,17 +22,25 @@
 #include <tools/toolsdllapi.h>
 #include <tools/gen.hxx>
 #include <tools/debug.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 #include <vector>
 
 #define POLY_APPEND             (0xFFFF)
 #define POLYPOLY_APPEND         (0xFFFF)
 
-#define POLY_OPTIMIZE_OPEN      0x00000001UL
-#define POLY_OPTIMIZE_CLOSE     0x00000002UL
-#define POLY_OPTIMIZE_NO_SAME   0x00000004UL
-#define POLY_OPTIMIZE_REDUCE    0x00000008UL
-#define POLY_OPTIMIZE_EDGES     0x00000010UL
+enum class PolyOptimizeFlags {
+    NONE      = 0x0000,
+    OPEN      = 0x0001,
+    CLOSE     = 0x0002,
+    NO_SAME   = 0x0004,
+    REDUCE    = 0x0008,
+    EDGES     = 0x0010,
+};
+namespace o3tl
+{
+    template<> struct typed_flags<PolyOptimizeFlags> : is_typed_flags<PolyOptimizeFlags, 0x001f> {};
+}
 
 enum PolyStyle
 {
@@ -134,7 +142,7 @@ public:
     bool                IsRightOrientated() const;
     double              CalcDistance( sal_uInt16 nPt1, sal_uInt16 nPt2 );
     void                Clip( const Rectangle& rRect, bool bPolygon = true );
-    void                Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* pData = NULL );
+    void                Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData = NULL );
 
     /** Adaptive subdivision of polygons with curves
 
@@ -223,7 +231,7 @@ public:
     sal_uInt16          Count() const;
     Rectangle           GetBoundRect() const;
     void                Clip( const Rectangle& rRect );
-    void                Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* pData = NULL );
+    void                Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData = NULL );
 
     /** Adaptive subdivision of polygons with curves
 
diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx
index b4ece34..ab16d84 100644
--- a/svtools/source/uno/unoimap.cxx
+++ b/svtools/source/uno/unoimap.cxx
@@ -290,7 +290,7 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const
                 aPoly.SetPoint( aPoint, nPoint );
             }
 
-            aPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+            aPoly.Optimize( PolyOptimizeFlags::CLOSE );
             pNewIMapObject = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false );
         }
         break;
diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx
index 86772ce..7de0506 100644
--- a/svx/source/dialog/frmsel.cxx
+++ b/svx/source/dialog/frmsel.cxx
@@ -531,7 +531,7 @@ void FrameSelectorImpl::DrawBackground()
     tools::PolyPolygon aPPoly;
     for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
         (*aIt)->MergeFocusToPolyPolygon( aPPoly );
-    aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+    aPPoly.Optimize( PolyOptimizeFlags::CLOSE );
     maVirDev.SetLineColor( maBackCol );
     maVirDev.SetFillColor( maBackCol );
     maVirDev.DrawPolyPolygon( aPPoly );
@@ -687,7 +687,7 @@ void FrameSelectorImpl::DrawAllTrackingRects()
         // no frame border selected -> draw tracking rectangle around entire control
         aPPoly.Insert( Polygon( Rectangle( maVirDevPos, maVirDev.GetOutputSizePixel() ) ) );
 
-    aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+    aPPoly.Optimize( PolyOptimizeFlags::CLOSE );
     for( sal_uInt16 nIdx = 0, nCount = aPPoly.Count(); nIdx < nCount; ++nIdx )
         mrFrameSel.InvertTracking( aPPoly.GetObject( nIdx ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
 }
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 80773d3..ddec469 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2529,7 +2529,7 @@ bool SwFlyFrm::GetContour( tools::PolyPolygon&   rContour,
             if( !aClip.Height() )
                 aClip.Height( 1 );
             rContour.Clip( aClip.SVRect() );
-            rContour.Optimize(POLY_OPTIMIZE_CLOSE);
+            rContour.Optimize(PolyOptimizeFlags::CLOSE);
             bRet = true;
         }
     }
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 1db4715..123af06 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1450,7 +1450,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
                                 aSet.SetPoint(aPoint, (sal_uInt16)j);
                             }
                             // Close polygon if it isn't closed already.
-                            aSet.Optimize( POLY_OPTIMIZE_CLOSE );
+                            aSet.Optimize( PolyOptimizeFlags::CLOSE );
                             aPoly.Insert( aSet );
                         }
                         pNoTxt->SetContourAPI( &aPoly );
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index eb3859a..e949835 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -697,30 +697,30 @@ double Polygon::CalcDistance( sal_uInt16 nP1, sal_uInt16 nP2 )
     return sqrt( fDx * fDx + fDy * fDy );
 }
 
-void Polygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* pData )
+void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData )
 {
     DBG_ASSERT( !mpImplPolygon->mpFlagAry, "Optimizing could fail with beziers!" );
 
     sal_uInt16 nSize = mpImplPolygon->mnPoints;
 
-    if( nOptimizeFlags && nSize )
+    if( bool(nOptimizeFlags) && nSize )
     {
-        if( nOptimizeFlags & POLY_OPTIMIZE_EDGES )
+        if( nOptimizeFlags & PolyOptimizeFlags::EDGES )
         {
             const Rectangle aBound( GetBoundRect() );
             const double    fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
             const sal_uInt16    nPercent = pData ? pData->GetPercentValue() : 50;
 
-            Optimize( POLY_OPTIMIZE_NO_SAME );
+            Optimize( PolyOptimizeFlags::NO_SAME );
             ImplReduceEdges( *this, fArea, nPercent );
         }
-        else if( nOptimizeFlags & ( POLY_OPTIMIZE_REDUCE | POLY_OPTIMIZE_NO_SAME ) )
+        else if( nOptimizeFlags & ( PolyOptimizeFlags::REDUCE | PolyOptimizeFlags::NO_SAME ) )
         {
             Polygon         aNewPoly;
             const Point&    rFirst = mpImplPolygon->mpPointAry[ 0 ];
             sal_uIntPtr         nReduce;
 
-            if( nOptimizeFlags & ( POLY_OPTIMIZE_REDUCE ) )
+            if( nOptimizeFlags & ( PolyOptimizeFlags::REDUCE ) )
                 nReduce = pData ? pData->GetAbsValue() : 4UL;
             else
                 nReduce = 0UL;
@@ -757,13 +757,13 @@ void Polygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* pDat
 
         if( nSize > 1 )
         {
-            if( ( nOptimizeFlags & POLY_OPTIMIZE_CLOSE ) &&
+            if( ( nOptimizeFlags & PolyOptimizeFlags::CLOSE ) &&
                 ( mpImplPolygon->mpPointAry[ 0 ] != mpImplPolygon->mpPointAry[ nSize - 1 ] ) )
             {
                 SetSize( mpImplPolygon->mnPoints + 1 );
                 mpImplPolygon->mpPointAry[ mpImplPolygon->mnPoints - 1 ] = mpImplPolygon->mpPointAry[ 0 ];
             }
-            else if( ( nOptimizeFlags & POLY_OPTIMIZE_OPEN ) &&
+            else if( ( nOptimizeFlags & PolyOptimizeFlags::OPEN ) &&
                      ( mpImplPolygon->mpPointAry[ 0 ] == mpImplPolygon->mpPointAry[ nSize - 1 ] ) )
             {
                 const Point& rFirst = mpImplPolygon->mpPointAry[ 0 ];
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index eec33a2..9ed24b1 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -223,9 +223,9 @@ void PolyPolygon::Clear()
     }
 }
 
-void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* pData )
+void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData )
 {
-    if(nOptimizeFlags && Count())
+    if(bool(nOptimizeFlags) && Count())
     {
         // #115630# ImplDrawHatch does not work with beziers included in the polypolygon, take care of that
         bool bIsCurve(false);
@@ -250,7 +250,7 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
         else
         {
             double      fArea;
-            const bool  bEdges = ( nOptimizeFlags & POLY_OPTIMIZE_EDGES ) == POLY_OPTIMIZE_EDGES;
+            const bool  bEdges = ( nOptimizeFlags & PolyOptimizeFlags::EDGES ) == PolyOptimizeFlags::EDGES;
             sal_uInt16      nPercent = 0;
 
             if( bEdges )
@@ -259,7 +259,7 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
 
                 fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
                 nPercent = pData ? pData->GetPercentValue() : 50;
-                nOptimizeFlags &= ~POLY_OPTIMIZE_EDGES;
+                nOptimizeFlags &= ~PolyOptimizeFlags::EDGES;
             }
 
             // watch for ref counter
@@ -274,11 +274,11 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
             {
                 if( bEdges )
                 {
-                    mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( POLY_OPTIMIZE_NO_SAME );
+                    mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( PolyOptimizeFlags::NO_SAME );
                     Polygon::ImplReduceEdges( *( mpImplPolyPolygon->mpPolyAry[ i ] ), fArea, nPercent );
                 }
 
-                if( nOptimizeFlags )
+                if( bool(nOptimizeFlags) )
                     mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData );
             }
         }
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index 6b8c06f..e61364d 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -693,7 +693,7 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf,
                     ImplLimitPolyPoly( aPolyPoly );
 
                     if( nFlags & BMP_VECTORIZE_REDUCE_EDGES )
-                        aPolyPoly.Optimize( POLY_OPTIMIZE_EDGES );
+                        aPolyPoly.Optimize( PolyOptimizeFlags::EDGES );
 
                     if( aPolyPoly.Count() )
                     {
@@ -760,7 +760,7 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rMonoBmp,
         ImplLimitPolyPoly( rPolyPoly );
 
         if( nFlags & BMP_VECTORIZE_REDUCE_EDGES )
-            rPolyPoly.Optimize( POLY_OPTIMIZE_EDGES );
+            rPolyPoly.Optimize( PolyOptimizeFlags::EDGES );
 
         // #i14895#:setting the correct direction for polygons
         // that represent holes and non-holes; non-hole polygons
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 5e1f8c2..a8c127d 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -10523,7 +10523,7 @@ void PDFWriterImpl::drawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
     {
         tools::PolyPolygon     aPolyPoly( rPolyPoly );
 
-        aPolyPoly.Optimize( POLY_OPTIMIZE_NO_SAME );
+        aPolyPoly.Optimize( PolyOptimizeFlags::NO_SAME );
         push( PushFlags::LINECOLOR );
         setLineColor( rHatch.GetColor() );
         getReferenceDevice()->DrawHatch( aPolyPoly, rHatch, false );
diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx
index d4777e2..9d337ca2 100644
--- a/vcl/source/outdev/hatch.cxx
+++ b/vcl/source/outdev/hatch.cxx
@@ -97,7 +97,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
         GDIMetaFile*    pOldMetaFile = mpMetaFile;
         bool            bOldMap = mbMap;
 
-        aPolyPoly.Optimize( POLY_OPTIMIZE_NO_SAME );
+        aPolyPoly.Optimize( PolyOptimizeFlags::NO_SAME );
         aHatch.SetDistance( ImplLogicWidthToDevicePixel( aHatch.GetDistance() ) );
 
         mpMetaFile = NULL;
@@ -120,7 +120,7 @@ void OutputDevice::AddHatchActions( const tools::PolyPolygon& rPolyPoly, const H
 {
 
     tools::PolyPolygon aPolyPoly( rPolyPoly );
-    aPolyPoly.Optimize( POLY_OPTIMIZE_NO_SAME | POLY_OPTIMIZE_CLOSE );
+    aPolyPoly.Optimize( PolyOptimizeFlags::NO_SAME | PolyOptimizeFlags::CLOSE );
 
     if( aPolyPoly.Count() )
     {


More information about the Libreoffice-commits mailing list