summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-05-06 11:33:41 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-05-08 12:42:53 +0200
commitd0119ff7f2c68aa05286bd303128f3a69c6bbd6a (patch)
tree80fc2e52ceb8446997348eda9186cbdfcd247298 /cppcanvas
parent5218ca22b472a80969a715e38d7cb8d052be4b6a (diff)
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 <rb.henschel@t-online.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/source/mtfrenderer/implrenderer.cxx47
-rw-r--r--cppcanvas/source/mtfrenderer/mtftools.cxx7
2 files changed, 24 insertions, 30 deletions
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 <basegfx/range/b2drectangle.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <canvas/canvastools.hxx>
+#include <vcl/canvastools.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/metaact.hxx>
#include <vcl/virdev.hxx>
@@ -169,11 +170,7 @@ namespace cppcanvas
// then transform that
::basegfx::B2DPolygon aLocalClip(
::basegfx::utils::createPolygonFromRect(
- ::basegfx::B2DRectangle(
- static_cast<double>(aLocalClipRect.Left()),
- static_cast<double>(aLocalClipRect.Top()),
- static_cast<double>(aLocalClipRect.Right()),
- static_cast<double>(aLocalClipRect.Bottom()) ) ) );
+ vcl::unotools::b2DRectangleFromRectangle(aLocalClipRect) ) );
::basegfx::B2DHomMatrix aTransform;
if( bOffsetting )