incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1237725 - in /incubator/ooo/trunk/main/vcl/source/gdi: outdev.cxx region.cxx
Date Mon, 30 Jan 2012 15:42:40 GMT
Author: alg
Date: Mon Jan 30 15:42:40 2012
New Revision: 1237725

URL: http://svn.apache.org/viewvc?rev=1237725&view=rev
Log:
#118855# Corrected handling of possibly created empty clipRegions after PolyPolygon clipping

Modified:
    incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/region.cxx

Modified: incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx?rev=1237725&r1=1237724&r2=1237725&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx Mon Jan 30 15:42:40 2012
@@ -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;

Modified: incubator/ooo/trunk/main/vcl/source/gdi/region.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/region.cxx?rev=1237725&r1=1237724&r2=1237725&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/region.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/region.cxx Mon Jan 30 15:42:40 2012
@@ -1461,6 +1461,14 @@ sal_Bool Region::Intersect( const Rectan
         // 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 Rectan
         }
 
         *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!



Mime
View raw message