diff options
author | Armin Le Grand <alg@apache.org> | 2012-01-30 14:42:40 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2012-01-30 14:42:40 +0000 |
commit | 45a5763215a102bd72c464d7b9977e12a78627c2 (patch) | |
tree | ed7016b4a6dd6e731ffcc9c7b0d0ec03eacba82a /vcl | |
parent | 6d83002b6ef24dff960891df2471e18fac9e6c5a (diff) |
#118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/outdev.cxx | 11 | ||||
-rw-r--r-- | vcl/source/gdi/region.cxx | 47 |
2 files changed, 49 insertions, 9 deletions
diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 48f4195cbb54..ca9c0eb6393e 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -998,7 +998,16 @@ void OutputDevice::ImplInitClipRegion() mnOutOffY+GetOutputHeightPixel()-1 ); aRegion.Intersect( aDeviceBounds ); } - ImplSelectClipRegion( aRegion ); + + if ( aRegion.IsEmpty() ) + { + mbOutputClipped = sal_True; + } + else + { + mbOutputClipped = sal_False; + ImplSelectClipRegion( aRegion ); + } } mbClipRegionSet = sal_True; diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index 628c596d839d..a4aee2122c12 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -1461,6 +1461,14 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) // unnecessary banding mpImplRegion->mpPolyPoly->Clip( rRect ); + // The clipping above may lead to empty ClipRegion + if(!mpImplRegion->mpPolyPoly->Count()) + { + // react on empty ClipRegion; ImplRegion already is unique (see above) + delete mpImplRegion; + mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); + } + return sal_True; } else if( mpImplRegion->mpB2DPolyPoly ) @@ -1473,10 +1481,24 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) } *mpImplRegion->mpB2DPolyPoly = - basegfx::tools::clipPolyPolygonOnRange( *mpImplRegion->mpB2DPolyPoly, - basegfx::B2DRange( rRect.Left(), rRect.Top(), - rRect.Right(), rRect.Bottom() ), - true, false ); + basegfx::tools::clipPolyPolygonOnRange( + *mpImplRegion->mpB2DPolyPoly, + basegfx::B2DRange( + rRect.Left(), + rRect.Top(), + rRect.Right() + 1, + rRect.Bottom() + 1), + true, + false); + + // The clipping above may lead to empty ClipRegion + if(!mpImplRegion->mpB2DPolyPoly->count()) + { + // react on empty ClipRegion; ImplRegion already is unique (see above) + delete mpImplRegion; + mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); + } + return sal_True; } else @@ -2083,10 +2105,19 @@ Rectangle Region::GetBoundRect() const return mpImplRegion->mpPolyPoly->GetBoundRect(); if( mpImplRegion->mpB2DPolyPoly ) { - const basegfx::B2DRange aRange = basegfx::tools::getRange( *mpImplRegion->mpB2DPolyPoly ); - aRect.SetPos( Point( (int)aRange.getMinX(), (int)aRange.getMinY() ) ); - aRect.SetSize( Size( (int)aRange.getWidth(), (int)aRange.getHeight() ) ); - return aRect; + const basegfx::B2DRange aRange(basegfx::tools::getRange(*mpImplRegion->mpB2DPolyPoly)); + + if(aRange.isEmpty()) + { + // emulate PolyPolygon::GetBoundRect() when empty polygon + return Rectangle(); + } + else + { + return Rectangle( + static_cast<sal_Int32>(floor(aRange.getMinX())), static_cast<sal_Int32>(floor(aRange.getMinY())), + static_cast<sal_Int32>(ceil(aRange.getMaxX())), static_cast<sal_Int32>(ceil(aRange.getMaxY()))); + } } // no band in the list? -> region is empty! |