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 | |
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')
-rw-r--r-- | canvas/qa/cppunit/canvastest.cxx | 7 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper.cxx | 26 | ||||
-rw-r--r-- | canvas/source/directx/dx_impltools.cxx | 15 | ||||
-rw-r--r-- | canvas/workben/canvasdemo.cxx | 31 |
4 files changed, 37 insertions, 42 deletions
diff --git a/canvas/qa/cppunit/canvastest.cxx b/canvas/qa/cppunit/canvastest.cxx index 993983377d08..5414a757d3c3 100644 --- a/canvas/qa/cppunit/canvastest.cxx +++ b/canvas/qa/cppunit/canvastest.cxx @@ -114,11 +114,8 @@ public: mRenderState.AffineTransform = geometry::AffineMatrix2D(2, 0, 0, 0, 2, 0); mViewState.AffineTransform = geometry::AffineMatrix2D(5, 0, 0, 0, 5, 0); - uno::Sequence<geometry::RealPoint2D> points(2); - points[0] = geometry::RealPoint2D(10, 5); - points[1] = geometry::RealPoint2D(88, 5); - uno::Sequence<uno::Sequence<geometry::RealPoint2D>> polygonPoints(1); - polygonPoints[0] = points; + uno::Sequence<uno::Sequence<geometry::RealPoint2D>> polygonPoints{ { { 10, 5 }, + { 88, 5 } } }; uno::Reference<rendering::XLinePolyPolygon2D> polygon = mDevice->createCompatibleLinePolyPolygon(polygonPoints); polygon->setClosed(0, false); diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 2711634e9948..f9e197d3447a 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -404,23 +404,25 @@ namespace cairocanvas { if( rLeft.getLength() == 3 ) { - uno::Sequence<double> aRes(3); - aRes[0] = basegfx::utils::lerp(rLeft[0],rRight[0],fAlpha); - aRes[1] = basegfx::utils::lerp(rLeft[1],rRight[1],fAlpha); - aRes[2] = basegfx::utils::lerp(rLeft[2],rRight[2],fAlpha); - return aRes; + return + { + basegfx::utils::lerp(rLeft[0],rRight[0],fAlpha), + basegfx::utils::lerp(rLeft[1],rRight[1],fAlpha), + basegfx::utils::lerp(rLeft[2],rRight[2],fAlpha) + }; } else if( rLeft.getLength() == 4 ) { - uno::Sequence<double> aRes(4); - aRes[0] = basegfx::utils::lerp(rLeft[0],rRight[0],fAlpha); - aRes[1] = basegfx::utils::lerp(rLeft[1],rRight[1],fAlpha); - aRes[2] = basegfx::utils::lerp(rLeft[2],rRight[2],fAlpha); - aRes[3] = basegfx::utils::lerp(rLeft[3],rRight[3],fAlpha); - return aRes; + return + { + basegfx::utils::lerp(rLeft[0],rRight[0],fAlpha), + basegfx::utils::lerp(rLeft[1],rRight[1],fAlpha), + basegfx::utils::lerp(rLeft[2],rRight[2],fAlpha), + basegfx::utils::lerp(rLeft[3],rRight[3],fAlpha) + }; } - return uno::Sequence<double>(); + return {}; } static cairo_pattern_t* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon const & rPolygon ) diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx index 27b98364bad1..7f464a8515b9 100644 --- a/canvas/source/directx/dx_impltools.cxx +++ b/canvas/source/directx/dx_impltools.cxx @@ -349,14 +349,13 @@ namespace dxcanvas::tools uno::Sequence< sal_Int8 > argbToIntSequence( Gdiplus::ARGB rColor ) { // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice - uno::Sequence< sal_Int8 > aRet(4); - - aRet[0] = static_cast<sal_Int8>((rColor >> 16) & 0xFF); // red - aRet[1] = static_cast<sal_Int8>((rColor >> 8) & 0xFF); // green - aRet[2] = static_cast<sal_Int8>(rColor & 0xFF); // blue - aRet[3] = static_cast<sal_Int8>((rColor >> 24) & 0xFF); // alpha - - return aRet; + return + { + static_cast<sal_Int8>((rColor >> 16) & 0xFF), // red + static_cast<sal_Int8>((rColor >> 8) & 0xFF), // green + static_cast<sal_Int8>(rColor & 0xFF), // blue + static_cast<sal_Int8>((rColor >> 24) & 0xFF) // alpha + }; } Gdiplus::ARGB sequenceToArgb( const uno::Sequence< sal_Int8 >& rColor ) 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 ); |