From d0119ff7f2c68aa05286bd303128f3a69c6bbd6a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 6 May 2019 11:33:41 +0200 Subject: improve tools::Rectangle->basegfx::B2?Rectangle conversion Improve the conversion method to do something reasonable with empty Rectangle. Use the conversion method in more places. Change-Id: I48c13f3d6dae71f39f03f7939101e545c8125503 Reviewed-on: https://gerrit.libreoffice.org/71853 Tested-by: Jenkins Reviewed-by: Regina Henschel Reviewed-by: Thorsten Behrens --- cppcanvas/source/mtfrenderer/implrenderer.cxx | 47 +++++++++++++-------------- cppcanvas/source/mtfrenderer/mtftools.cxx | 7 ++-- 2 files changed, 24 insertions(+), 30 deletions(-) (limited to 'cppcanvas') diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 0b618e3ff365..241443aa39a9 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -1080,15 +1080,15 @@ namespace cppcanvas // convert rect to polygon beforehand, must revert // to general polygon clipping here. + ::tools::Rectangle aRect = rState.clipRect; + // #121100# VCL rectangular clips always + // include one more pixel to the right + // and the bottom + aRect.AdjustRight(1); + aRect.AdjustBottom(1); rState.clip = ::basegfx::B2DPolyPolygon( ::basegfx::utils::createPolygonFromRect( - // #121100# VCL rectangular clips always - // include one more pixel to the right - // and the bottom - ::basegfx::B2DRectangle( rState.clipRect.Left(), - rState.clipRect.Top(), - rState.clipRect.Right()+1, - rState.clipRect.Bottom()+1 ) ) ); + vcl::unotools::b2DRectangleFromRectangle(aRect) ) ); } // AW: Simplified @@ -1108,17 +1108,17 @@ namespace cppcanvas } else { + ::tools::Rectangle aRect = rState.clipRect; + // #121100# VCL rectangular clips + // always include one more pixel to + // the right and the bottom + aRect.AdjustRight(1); + aRect.AdjustBottom(1); rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rParms.mrCanvas->getUNOCanvas()->getDevice(), ::basegfx::B2DPolyPolygon( ::basegfx::utils::createPolygonFromRect( - // #121100# VCL rectangular clips - // always include one more pixel to - // the right and the bottom - ::basegfx::B2DRectangle( rState.clipRect.Left(), - rState.clipRect.Top(), - rState.clipRect.Right()+1, - rState.clipRect.Bottom()+1 ) ) ) ); + vcl::unotools::b2DRectangleFromRectangle(aRect) ) ) ); } } else @@ -1165,10 +1165,7 @@ namespace cppcanvas // to general polygon clipping here. ::basegfx::B2DPolyPolygon aClipPoly( ::basegfx::utils::createPolygonFromRect( - ::basegfx::B2DRectangle( rClipRect.Left(), - rClipRect.Top(), - rClipRect.Right(), - rClipRect.Bottom() ) ) ); + vcl::unotools::b2DRectangleFromRectangle(rClipRect) ) ); rState.clipRect.SetEmpty(); @@ -1185,17 +1182,17 @@ namespace cppcanvas } else { + // #121100# VCL rectangular clips + // always include one more pixel to + // the right and the bottom + ::tools::Rectangle aRect = rState.clipRect; + aRect.AdjustRight(1); + aRect.AdjustBottom(1); rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rParms.mrCanvas->getUNOCanvas()->getDevice(), ::basegfx::B2DPolyPolygon( ::basegfx::utils::createPolygonFromRect( - // #121100# VCL rectangular clips - // always include one more pixel to - // the right and the bottom - ::basegfx::B2DRectangle( rState.clipRect.Left(), - rState.clipRect.Top(), - rState.clipRect.Right()+1, - rState.clipRect.Bottom()+1 ) ) ) ); + vcl::unotools::b2DRectangleFromRectangle(aRect) ) ) ); } } else diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx index bd1fac905f3f..1a561631939d 100644 --- a/cppcanvas/source/mtfrenderer/mtftools.cxx +++ b/cppcanvas/source/mtfrenderer/mtftools.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -169,11 +170,7 @@ namespace cppcanvas // then transform that ::basegfx::B2DPolygon aLocalClip( ::basegfx::utils::createPolygonFromRect( - ::basegfx::B2DRectangle( - static_cast(aLocalClipRect.Left()), - static_cast(aLocalClipRect.Top()), - static_cast(aLocalClipRect.Right()), - static_cast(aLocalClipRect.Bottom()) ) ) ); + vcl::unotools::b2DRectangleFromRectangle(aLocalClipRect) ) ); ::basegfx::B2DHomMatrix aTransform; if( bOffsetting ) -- cgit