[Libreoffice-commits] core.git: basegfx/source basegfx/test

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon Jul 25 15:21:28 UTC 2016


 basegfx/source/polygon/b2dpolygontools.cxx |   51 ++++++++++----------
 basegfx/test/basegfx2d.cxx                 |   71 +++++++++++++++--------------
 2 files changed, 63 insertions(+), 59 deletions(-)

New commits:
commit 5b5f66c672849bbdc3b31cea678cdaa83295ce9b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sun Jul 24 21:59:09 2016 +0900

    basegfx: use polygon initializer_list in some places
    
    Change-Id: Ibb83476376e1c46aedf67c9455292405219a45c1
    Reviewed-on: https://gerrit.libreoffice.org/27476
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index 6627e3c..2172fd7 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1590,25 +1590,24 @@ namespace basegfx
 
             if(rtl::math::approxEqual(fZero, fRadiusX) || rtl::math::approxEqual(fZero, fRadiusY))
             {
-                B2DPolygon aRetval;
-
                 // at least in one direction no radius, use rectangle.
                 // Do not use createPolygonFromRect() here since original
                 // creator (historical reasons) still creates a start point at the
                 // bottom center, so do the same here to get the same line patterns.
                 // Due to this the order of points is different, too.
                 const B2DPoint aBottomCenter(rRect.getCenter().getX(), rRect.getMaxY());
-                aRetval.append(aBottomCenter);
-
-                aRetval.append( B2DPoint( rRect.getMinX(), rRect.getMaxY() ) );
-                aRetval.append( B2DPoint( rRect.getMinX(), rRect.getMinY() ) );
-                aRetval.append( B2DPoint( rRect.getMaxX(), rRect.getMinY() ) );
-                aRetval.append( B2DPoint( rRect.getMaxX(), rRect.getMaxY() ) );
+                B2DPolygon aPolygon {
+                    aBottomCenter,
+                    { rRect.getMinX(), rRect.getMaxY() },
+                    { rRect.getMinX(), rRect.getMinY() },
+                    { rRect.getMaxX(), rRect.getMinY() },
+                    { rRect.getMaxX(), rRect.getMaxY() }
+                };
 
                 // close
-                aRetval.setClosed( true );
+                aPolygon.setClosed( true );
 
-                return aRetval;
+                return aPolygon;
             }
             else if(rtl::math::approxEqual(fOne, fRadiusX) && rtl::math::approxEqual(fOne, fRadiusY))
             {
@@ -1684,17 +1683,17 @@ namespace basegfx
 
         B2DPolygon createPolygonFromRect( const B2DRectangle& rRect )
         {
-            B2DPolygon aRetval;
-
-            aRetval.append( B2DPoint( rRect.getMinX(), rRect.getMinY() ) );
-            aRetval.append( B2DPoint( rRect.getMaxX(), rRect.getMinY() ) );
-            aRetval.append( B2DPoint( rRect.getMaxX(), rRect.getMaxY() ) );
-            aRetval.append( B2DPoint( rRect.getMinX(), rRect.getMaxY() ) );
+            B2DPolygon aPolygon {
+                { rRect.getMinX(), rRect.getMinY() },
+                { rRect.getMaxX(), rRect.getMinY() },
+                { rRect.getMaxX(), rRect.getMaxY() },
+                { rRect.getMinX(), rRect.getMaxY() }
+            };
 
             // close
-            aRetval.setClosed( true );
+            aPolygon.setClosed( true );
 
-            return aRetval;
+            return aPolygon;
         }
 
         namespace
@@ -1704,17 +1703,17 @@ namespace basegfx
             {
                 B2DPolygon operator () ()
                 {
-                    B2DPolygon aRetval;
-
-                    aRetval.append( B2DPoint( 0.0, 0.0 ) );
-                    aRetval.append( B2DPoint( 1.0, 0.0 ) );
-                    aRetval.append( B2DPoint( 1.0, 1.0 ) );
-                    aRetval.append( B2DPoint( 0.0, 1.0 ) );
+                    B2DPolygon aPolygon {
+                        { 0.0, 0.0 },
+                        { 1.0, 0.0 },
+                        { 1.0, 1.0 },
+                        { 0.0, 1.0 }
+                    };
 
                     // close
-                    aRetval.setClosed( true );
+                    aPolygon.setClosed( true );
 
-                    return aRetval;
+                    return aPolygon;
                 }
             };
         }
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx
index e215dcc..fbc0930 100644
--- a/basegfx/test/basegfx2d.cxx
+++ b/basegfx/test/basegfx2d.cxx
@@ -778,47 +778,52 @@ public:
             tools::createPolygonFromRect(
                 B2DRange(0,0,1,1) ) );
 
-        B2DPolygon aRect2;
-        aRect2.append( B2DPoint(0,0) );
-        aRect2.append( B2DPoint(1,0) );
-        aRect2.append( B2DPoint(1,.5));
-        aRect2.append( B2DPoint(1,1) );
-        aRect2.append( B2DPoint(0,1) );
+        B2DPolygon aRect2 {
+            {0, 0},
+            {1, 0},
+            {1, 0.5},
+            {1, 1},
+            {0, 1}
+        };
         aRect2.setClosed(true);
 
-        B2DPolygon aNonRect1;
-        aNonRect1.append( B2DPoint(0,0) );
-        aNonRect1.append( B2DPoint(1,0) );
-        aNonRect1.append( B2DPoint(1,1) );
-        aNonRect1.append( B2DPoint(0.5,1) );
-        aNonRect1.append( B2DPoint(0.5,0) );
+        B2DPolygon aNonRect1 {
+            {0, 0},
+            {1, 0},
+            {0.5, 1},
+            {0.5, 0}
+        };
         aNonRect1.setClosed(true);
 
-        B2DPolygon aNonRect2;
-        aNonRect2.append( B2DPoint(0,0) );
-        aNonRect2.append( B2DPoint(1,1) );
-        aNonRect2.append( B2DPoint(1,0) );
-        aNonRect2.append( B2DPoint(0,1) );
+        B2DPolygon aNonRect2 {
+            {0, 0},
+            {1, 1},
+            {1, 0},
+            {0, 1}
+        };
         aNonRect2.setClosed(true);
 
-        B2DPolygon aNonRect3;
-        aNonRect3.append( B2DPoint(0,0) );
-        aNonRect3.append( B2DPoint(1,0) );
-        aNonRect3.append( B2DPoint(1,1) );
+        B2DPolygon aNonRect3 {
+            {0, 0},
+            {1, 0},
+            {1, 1}
+        };
         aNonRect3.setClosed(true);
 
-        B2DPolygon aNonRect4;
-        aNonRect4.append( B2DPoint(0,0) );
-        aNonRect4.append( B2DPoint(1,0) );
-        aNonRect4.append( B2DPoint(1,1) );
-        aNonRect4.append( B2DPoint(0,1) );
-
-        B2DPolygon aNonRect5;
-        aNonRect5.append( B2DPoint(0,0) );
-        aNonRect5.append( B2DPoint(1,0) );
-        aNonRect5.append( B2DPoint(1,1) );
-        aNonRect5.append( B2DPoint(0,1) );
-        aNonRect5.setControlPoints(1,B2DPoint(1,0),B2DPoint(-11,0));
+        B2DPolygon aNonRect4 {
+            {0, 0},
+            {1, 0},
+            {1, 1},
+            {0, 1}
+        };
+
+        B2DPolygon aNonRect5 {
+            {0, 0},
+            {1, 0},
+            {1, 1},
+            {0, 1}
+        };
+        aNonRect5.setControlPoints(1, B2DPoint(1,0), B2DPoint(-11,0));
         aNonRect5.setClosed(true);
 
         CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1",


More information about the Libreoffice-commits mailing list