diff options
author | Armin Le Grand <alg@apache.org> | 2013-05-17 16:29:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-17 15:39:48 +0100 |
commit | 3a8dbb63197c5b9298015cbd5b15e607ec9a3705 (patch) | |
tree | d7edd0ed73a7d7ebafd449c924bd54ea0aad9065 /drawinglayer | |
parent | 997cc4804d947fdd751e457fda47f95ecf3ac909 (diff) |
Resolves: #i74211# Correct crop of bitmap data when...
logical size and MapMode do not match real pixel size
(cherry picked from commit a24965371f7e881671182bc51432c08cbf667b56)
Conflicts:
svtools/inc/svtools/grfmgr.hxx
svtools/source/graphic/grfmgr.cxx
svx/inc/svx/svdhdl.hxx
svx/inc/svx/svdograf.hxx
svx/source/svdraw/svdhdl.cxx
Change-Id: Icfb9091b55e50081e8daf697c9f00f5b5a10531a
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/cropprimitive2d.cxx | 2 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/graphicprimitive2d.cxx | 48 |
2 files changed, 14 insertions, 36 deletions
diff --git a/drawinglayer/source/primitive2d/cropprimitive2d.cxx b/drawinglayer/source/primitive2d/cropprimitive2d.cxx index 8ce933afffe2..042710c516e3 100644 --- a/drawinglayer/source/primitive2d/cropprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/cropprimitive2d.cxx @@ -85,7 +85,7 @@ namespace drawinglayer // with getSmallValue here, the original which uses rtl::math::approxEqual // is too correct here. Maybe this changes with enhanced precision in aw080 // to the better so that this can be reduced to the more precise call again - if(basegfx::fTools::equal(fRotate, F_PI, 0.000000001)) + if(basegfx::fTools::equal(fabs(fRotate), F_PI, 0.000000001)) { aScale.setX(aScale.getX() * -1.0); aScale.setY(aScale.getY() * -1.0); diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index 778245ff12bc..df69a36cdd94 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -85,47 +85,25 @@ namespace drawinglayer { // calculate scalings between real image size and logic object size. This // is necessary since the crop values are relative to original bitmap size - double fFactorX(1.0); - double fFactorY(1.0); - - { - const MapMode aMapMode100thmm(MAP_100TH_MM); - Size aBitmapSize(rGraphicObject.GetPrefSize()); - - // #i95968# better support PrefMapMode; special for MAP_PIXEL was missing - if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit()) - { - aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm); - } - else - { - aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm); - } - - const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop()); - const double fDivY(aBitmapSize.Height() - getGraphicAttr().GetTopCrop() - getGraphicAttr().GetBottomCrop()); - const basegfx::B2DVector aScale(aTransform * basegfx::B2DVector(1.0, 1.0)); - - if(!basegfx::fTools::equalZero(fDivX)) - { - fFactorX = fabs(aScale.getX()) / fDivX; - } - - if(!basegfx::fTools::equalZero(fDivY)) - { - fFactorY = fabs(aScale.getY()) / fDivY; - } - } + const basegfx::B2DVector aObjectScale(aTransform * basegfx::B2DVector(1.0, 1.0)); + const basegfx::B2DVector aCropScaleFactor( + rGraphicObject.calculateCropScaling( + aObjectScale.getX(), + aObjectScale.getY(), + getGraphicAttr().GetLeftCrop(), + getGraphicAttr().GetTopCrop(), + getGraphicAttr().GetRightCrop(), + getGraphicAttr().GetBottomCrop())); // embed content in cropPrimitive Primitive2DReference xPrimitive( new CropPrimitive2D( aRetval, aTransform, - getGraphicAttr().GetLeftCrop() * fFactorX, - getGraphicAttr().GetTopCrop() * fFactorY, - getGraphicAttr().GetRightCrop() * fFactorX, - getGraphicAttr().GetBottomCrop() * fFactorY)); + getGraphicAttr().GetLeftCrop() * aCropScaleFactor.getX(), + getGraphicAttr().GetTopCrop() * aCropScaleFactor.getY(), + getGraphicAttr().GetRightCrop() * aCropScaleFactor.getX(), + getGraphicAttr().GetBottomCrop() * aCropScaleFactor.getY())); aRetval = Primitive2DSequence(&xPrimitive, 1); } |