diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-06-04 22:19:30 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-06-07 12:58:48 +0200 |
commit | 87e8d5ec6bb2fa332d2c374040d39ca18462cb6f (patch) | |
tree | bd1c4a2175eb4b1f80c6c562105de3973abc8265 /canvas/workben | |
parent | e9a824dd6c1c33777461874d9892343d193c867d (diff) |
Simplify Sequences initializations (canvas)
Change-Id: I651858d71e378341205d6a785bd97f294664a439
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116737
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'canvas/workben')
-rw-r--r-- | canvas/workben/canvasdemo.cxx | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx index 9d48b84132d6..85791072d860 100644 --- a/canvas/workben/canvasdemo.cxx +++ b/canvas/workben/canvasdemo.cxx @@ -38,6 +38,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/random.hxx> #include <cppuhelper/bootstrap.hxx> +#include <o3tl/safeint.hxx> #include <vcl/canvastools.hxx> #include <vcl/svapp.hxx> #include <vcl/vclmain.hxx> @@ -155,17 +156,16 @@ class DemoRenderer void drawRect( tools::Rectangle rRect, const uno::Sequence< double > &aColor, int /*nWidth*/ ) { - uno::Sequence< geometry::RealPoint2D > aPoints(4); - uno::Reference< rendering::XLinePolyPolygon2D > xPoly; - - aPoints[0] = geometry::RealPoint2D( rRect.Left(), rRect.Top() ); - aPoints[1] = geometry::RealPoint2D( rRect.Left(), rRect.Bottom() ); - aPoints[2] = geometry::RealPoint2D( rRect.Right(), rRect.Bottom() ); - aPoints[3] = geometry::RealPoint2D( rRect.Right(), rRect.Top() ); - - uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1); - aPolys[0] = aPoints; - xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys ); + uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys + { + { + { o3tl::narrowing<double>(rRect.Left()), o3tl::narrowing<double>(rRect.Top()) }, + { o3tl::narrowing<double>(rRect.Left()), o3tl::narrowing<double>(rRect.Bottom()) }, + { o3tl::narrowing<double>(rRect.Right()), o3tl::narrowing<double>(rRect.Bottom()) }, + { o3tl::narrowing<double>(rRect.Right()), o3tl::narrowing<double>(rRect.Top()) } + } + }; + auto xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys ); xPoly->setClosed( 0, true ); rendering::RenderState aRenderState( maRenderState ); @@ -241,8 +241,7 @@ class DemoRenderer } } - uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1); - aPolys[0] = aPoints; + uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys { aPoints }; xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys ); xPoly->setClosed( 0, false ); @@ -399,8 +398,7 @@ class DemoRenderer r * 2 * sin((i*2*M_PI + 2*M_PI)/num_curves), //C1y r * 2 * cos((i*2*M_PI + 2*M_PI)/num_curves), //C2x r * 2 * sin((i*2*M_PI + 2*M_PI)/num_curves)); //C2y - uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > aPolys(1); - aPolys[0] = aBeziers; + uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > aPolys { aBeziers }; xPoly = mxDevice->createCompatibleBezierPolyPolygon(aPolys); xPoly->setClosed( 0, true ); //uno::Reference< rendering::XBezierPolyPolygon2D> xPP( xPoly, uno::UNO_QUERY ); @@ -490,8 +488,7 @@ class DemoRenderer aPoints[i]= geometry::RealPoint2D( centerx + r * cos(i*2 * M_PI/sides), centery + r * sin(i*2 * M_PI/sides)); } - uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys(1); - aPolys[0] = aPoints; + uno::Sequence< uno::Sequence< geometry::RealPoint2D > > aPolys { aPoints }; xPoly = mxDevice->createCompatibleLinePolyPolygon( aPolys ); xPoly->setClosed( 0, true ); rendering::RenderState aRenderState( maRenderState ); |