diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-01-28 17:21:44 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-01-28 17:21:44 +0100 |
commit | e8b81cd40140a1a5f79f9eb24470ad4891564ef8 (patch) | |
tree | 3d9963243d0e9623a4287457a7a7c48d667c580d /drawinglayer | |
parent | ffe5c97056ab181367e49691d487eb6f6f375200 (diff) |
aw079: #i99147# corrected diverse aspects of invisible object visualisation and interaction
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/hittestprocessor2d.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index e699f1ae8ea4..9be5b5633d1f 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -50,6 +50,7 @@ #include <basegfx/matrix/b3dhommatrix.hxx> #include <drawinglayer/processor3d/cutfindprocessor3d.hxx> #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx> +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -487,6 +488,49 @@ namespace drawinglayer break; } case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + { + if(!getHitTextOnly()) + { + // The recently added BitmapEx::GetTransparency() makes it easy to extend + // the BitmapPrimitive2D HitTest to take the contained BotmapEx and it's + // transparency into account + const basegfx::B2DRange aRange(rCandidate.getB2DRange(getViewInformation2D())); + + if(!aRange.isEmpty()) + { + const primitive2d::BitmapPrimitive2D& rBitmapCandidate(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); + const BitmapEx& rBitmapEx = rBitmapCandidate.getBitmapEx(); + const Size& rSizePixel(rBitmapEx.GetSizePixel()); + + if(rSizePixel.Width() && rSizePixel.Height()) + { + basegfx::B2DHomMatrix aBackTransform( + getViewInformation2D().getObjectToViewTransformation() * + rBitmapCandidate.getTransform()); + aBackTransform.invert(); + + const basegfx::B2DPoint aRelativePoint(aBackTransform * getDiscreteHitPosition()); + const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0); + + if(aUnitRange.isInside(aRelativePoint)) + { + const sal_Int32 nX(basegfx::fround(aRelativePoint.getX() * rSizePixel.Width())); + const sal_Int32 nY(basegfx::fround(aRelativePoint.getY() * rSizePixel.Height())); + + mbHit = (0xff != rBitmapEx.GetTransparency(nX, nY)); + } + } + else + { + // fallback to standard HitTest + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); + mbHit = checkFillHitWithTolerance(basegfx::B2DPolyPolygon(aOutline), getDiscreteHitTolerance()); + } + } + } + + break; + } case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D : case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D : |