You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/10/23 15:46:30 UTC

svn commit: r1401294 [1/4] - in /incubator/ooo/trunk/main: canvas/source/vcl/ cppcanvas/source/mtfrenderer/ drawinglayer/source/primitive2d/ filter/source/graphicfilter/eps/ sd/source/ui/slidesorter/view/ svx/source/sdr/overlay/ svx/source/sdr/properti...

Author: alg
Date: Tue Oct 23 13:46:28 2012
New Revision: 1401294

URL: http://svn.apache.org/viewvc?rev=1401294&view=rev
Log:
#121237# Rework/Cleanup of Region code due to missing complete support for B2DPolygon class

Added:
    incubator/ooo/trunk/main/vcl/inc/regionband.hxx   (with props)
    incubator/ooo/trunk/main/vcl/source/gdi/regionband.cxx   (with props)
Removed:
    incubator/ooo/trunk/main/vcl/inc/region.h
Modified:
    incubator/ooo/trunk/main/canvas/source/vcl/canvashelper.cxx
    incubator/ooo/trunk/main/cppcanvas/source/mtfrenderer/implrenderer.cxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
    incubator/ooo/trunk/main/filter/source/graphicfilter/eps/eps.cxx
    incubator/ooo/trunk/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx
    incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
    incubator/ooo/trunk/main/svx/source/sdr/properties/itemsettools.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/sdrpaintwindow.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx
    incubator/ooo/trunk/main/sw/source/core/view/viewsh.cxx
    incubator/ooo/trunk/main/toolkit/source/awt/vclxregion.cxx
    incubator/ooo/trunk/main/vcl/Library_vcl.mk
    incubator/ooo/trunk/main/vcl/aqua/source/gdi/salgdi.cxx
    incubator/ooo/trunk/main/vcl/inc/unx/gtk/gtkgdi.hxx
    incubator/ooo/trunk/main/vcl/inc/vcl/regband.hxx
    incubator/ooo/trunk/main/vcl/inc/vcl/region.hxx
    incubator/ooo/trunk/main/vcl/os2/source/gdi/salgdi.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/bitmap.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/bmpacc3.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/gdimtf.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/outdev2.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/outmap.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/pdfwriter_impl2.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/regband.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/region.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/salgdilayout.cxx
    incubator/ooo/trunk/main/vcl/source/window/window.cxx
    incubator/ooo/trunk/main/vcl/unx/generic/gdi/pspgraphics.cxx
    incubator/ooo/trunk/main/vcl/unx/generic/gdi/salgdi.cxx
    incubator/ooo/trunk/main/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
    incubator/ooo/trunk/main/vcl/unx/headless/svpgdi.cxx
    incubator/ooo/trunk/main/vcl/unx/headless/svppspgraphics.cxx
    incubator/ooo/trunk/main/vcl/win/source/gdi/salgdi.cxx

Modified: incubator/ooo/trunk/main/canvas/source/vcl/canvashelper.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/canvas/source/vcl/canvashelper.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/canvas/source/vcl/canvashelper.cxx (original)
+++ incubator/ooo/trunk/main/canvas/source/vcl/canvashelper.cxx Tue Oct 23 13:46:28 2012
@@ -1230,7 +1230,7 @@ namespace vclcanvas
         // accumulate non-empty clips into one region
         // ==========================================
 
-        Region aClipRegion( REGION_NULL );
+        Region aClipRegion(true);
 
         if( viewState.Clip.is() )
         {

Modified: incubator/ooo/trunk/main/cppcanvas/source/mtfrenderer/implrenderer.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/cppcanvas/source/mtfrenderer/implrenderer.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/cppcanvas/source/mtfrenderer/implrenderer.cxx (original)
+++ incubator/ooo/trunk/main/cppcanvas/source/mtfrenderer/implrenderer.cxx Tue Oct 23 13:46:28 2012
@@ -1396,7 +1396,7 @@ namespace cppcanvas
                         }
                         else
                         {
-                            if( !pClipAction->GetRegion().HasPolyPolygon() )
+                            if( !pClipAction->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
                             {
                                 VERBOSE_TRACE( "ImplRenderer::createActions(): non-polygonal clip "
                                                "region encountered, falling back to bounding box!" );
@@ -1418,9 +1418,11 @@ namespace cppcanvas
                                 // with old one, just set it)
 
                                 // #121806# explicitely kept integer
+                                basegfx::B2DPolyPolygon aPolyPolygon(pClipAction->GetRegion().GetAsB2DPolyPolygon());
+
+                                aPolyPolygon.transform(rVDev.GetViewTransformation());
                                 updateClipping(
-                                    rVDev.LogicToPixel(
-                                        pClipAction->GetRegion().GetPolyPolygon() ).getB2DPolyPolygon(),
+                                    aPolyPolygon,
                                     rFactoryParms,
                                     false );
                             }
@@ -1450,7 +1452,7 @@ namespace cppcanvas
                     {
                         MetaISectRegionClipRegionAction* pClipAction = static_cast<MetaISectRegionClipRegionAction*>(pCurrAct);
 
-                        if( !pClipAction->GetRegion().HasPolyPolygon() )
+                        if( !pClipAction->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
                         {
                             VERBOSE_TRACE( "ImplRenderer::createActions(): non-polygonal clip "
                                            "region encountered, falling back to bounding box!" );
@@ -1470,9 +1472,11 @@ namespace cppcanvas
                             // intersect current clip with given clip polygon
 
                             // #121806# explicitely kept integer
+                            basegfx::B2DPolyPolygon aPolyPolygon(pClipAction->GetRegion().GetAsB2DPolyPolygon());
+
+                            aPolyPolygon.transform(rVDev.GetViewTransformation());
                             updateClipping(
-                                rVDev.LogicToPixel(
-                                    pClipAction->GetRegion().GetPolyPolygon() ).getB2DPolyPolygon(),
+                                aPolyPolygon,
                                 rFactoryParms,
                                 true );
                         }

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx Tue Oct 23 13:46:28 2012
@@ -387,26 +387,8 @@ namespace
         if(!rRegion.IsEmpty())
         {
             Region aRegion(rRegion);
-            aRetval = aRegion.GetB2DPolyPolygon();
 
-            if(!aRetval.count())
-            {
-		        RegionHandle aRegionHandle(aRegion.BeginEnumRects());
-		        Rectangle aRegionRectangle;
-
-                while(aRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
-		        {
-                    if(!aRegionRectangle.IsEmpty())
-                    {
-					    const basegfx::B2DRange aRegionRange(
-                            aRegionRectangle.Left(), aRegionRectangle.Top(),
-                            aRegionRectangle.Right(), aRegionRectangle.Bottom());
-                        aRetval.append(basegfx::tools::createPolygonFromRect(aRegionRange));
-                    }
-                }
-
-                aRegion.EndEnumRects(aRegionHandle);
-            }
+            aRetval = aRegion.GetAsB2DPolyPolygon();
         }
 
         return aRetval;

Modified: incubator/ooo/trunk/main/filter/source/graphicfilter/eps/eps.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/graphicfilter/eps/eps.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/graphicfilter/eps/eps.cxx (original)
+++ incubator/ooo/trunk/main/filter/source/graphicfilter/eps/eps.cxx Tue Oct 23 13:46:28 2012
@@ -1637,32 +1637,59 @@ void PSWriter::ImplSetClipRegion( Region
 {
 	if ( !rClipRegion.IsEmpty() )
 	{
-		Rectangle		aRect;
-		RegionHandle	hRegionHandle = rClipRegion.BeginEnumRects();
+        RectangleVector aRectangles;
+        rClipRegion.GetRegionRectangles(aRectangles);
 
-		while ( rClipRegion.GetNextEnumRect( hRegionHandle, aRect ) )
-		{
-			double nX1 = aRect.Left();
-			double nY1 = aRect.Top();
-			double nX2 = aRect.Right();
-			double nY2 = aRect.Bottom();
-			ImplWriteDouble( nX1 );
-			ImplWriteDouble( nY1 );
-			ImplWriteByte( 'm' );
-			ImplWriteDouble( nX2 );
-			ImplWriteDouble( nY1 );
-			ImplWriteByte( 'l' );
-			ImplWriteDouble( nX2 );
-			ImplWriteDouble( nY2 );
-			ImplWriteByte( 'l' );
-			ImplWriteDouble( nX1 );
-			ImplWriteDouble( nY2 );
-			ImplWriteByte( 'l' );
-			ImplWriteDouble( nX1 );
-			ImplWriteDouble( nY1 );
-			ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
-		};
-		rClipRegion.EndEnumRects( hRegionHandle );
+        for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+        {
+            double nX1(aRectIter->Left());
+            double nY1(aRectIter->Top());
+            double nX2(aRectIter->Right());
+            double nY2(aRectIter->Bottom());
+
+            ImplWriteDouble( nX1 );
+            ImplWriteDouble( nY1 );
+            ImplWriteByte( 'm' );
+            ImplWriteDouble( nX2 );
+            ImplWriteDouble( nY1 );
+            ImplWriteByte( 'l' );
+            ImplWriteDouble( nX2 );
+            ImplWriteDouble( nY2 );
+            ImplWriteByte( 'l' );
+            ImplWriteDouble( nX1 );
+            ImplWriteDouble( nY2 );
+            ImplWriteByte( 'l' );
+            ImplWriteDouble( nX1 );
+            ImplWriteDouble( nY1 );
+            ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
+        }
+
+		//Rectangle		aRect;
+		//RegionHandle	hRegionHandle = rClipRegion.BeginEnumRects();
+        //
+		//while ( rClipRegion.GetEnumRects( hRegionHandle, aRect ) )
+		//{
+		//	double nX1 = aRect.Left();
+		//	double nY1 = aRect.Top();
+		//	double nX2 = aRect.Right();
+		//	double nY2 = aRect.Bottom();
+		//	ImplWriteDouble( nX1 );
+		//	ImplWriteDouble( nY1 );
+		//	ImplWriteByte( 'm' );
+		//	ImplWriteDouble( nX2 );
+		//	ImplWriteDouble( nY1 );
+		//	ImplWriteByte( 'l' );
+		//	ImplWriteDouble( nX2 );
+		//	ImplWriteDouble( nY2 );
+		//	ImplWriteByte( 'l' );
+		//	ImplWriteDouble( nX1 );
+		//	ImplWriteDouble( nY2 );
+		//	ImplWriteByte( 'l' );
+		//	ImplWriteDouble( nX1 );
+		//	ImplWriteDouble( nY1 );
+		//	ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
+		//};
+		//rClipRegion.EndEnumRects( hRegionHandle );
 		ImplWriteLine( "eoclip newpath" );
 	}
 }
@@ -1711,12 +1738,18 @@ void PSWriter::ImplBmp( Bitmap* pBitmap,
 				aRect = Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( (long)nWidth, (long)nHeight ) );
 				aRegion = Region( pMaskBitmap->CreateRegion( COL_BLACK, aRect ) );
 
-				if ( ( mnLevel == 1 ) && ( aRegion.GetRectCount() * 5 > 1000 ) )
+				if( mnLevel == 1 )
 				{
-					nHeight >>= 1;
-					if ( nHeight < 2 )
-						return;
-					continue;
+                    RectangleVector aRectangleVector;
+                    aRegion.GetRegionRectangles(aRectangleVector);
+
+                    if ( aRectangleVector.size() * 5 > 1000 )
+				    {
+					    nHeight >>= 1;
+					    if ( nHeight < 2 )
+						    return;
+                        continue;
+                    }
 				}
 				break;
 			}
@@ -1731,26 +1764,50 @@ void PSWriter::ImplBmp( Bitmap* pBitmap,
 			ImplWriteLine( "gs\npum" );
 			ImplTranslate( aSourcePos.X(), aSourcePos.Y() );
 			ImplScale( nXWidth / nWidth,  nYHeight / nHeight );
-			RegionHandle	hRegionHandle = aRegion.BeginEnumRects();
 
-			while ( aRegion.GetNextEnumRect( hRegionHandle, aRect ) )
-			{
-				aRect.Move( 0, - ( nHeightOrg - nHeightLeft ) );
-				ImplWriteLong( aRect.Left() );
-				ImplWriteLong( aRect.Top() );
-				ImplWriteByte( 'm' );
-				ImplWriteLong( aRect.Right() + 1 );
-				ImplWriteLong( aRect.Top() );
-				ImplWriteByte( 'l' );
-				ImplWriteLong( aRect.Right() + 1 );
-				ImplWriteLong( aRect.Bottom() + 1 );
-				ImplWriteByte( 'l' );
-				ImplWriteLong( aRect.Left() );
-				ImplWriteLong( aRect.Bottom() + 1 );
-				ImplWriteByte( 'l' );
-				ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
-			};
-			aRegion.EndEnumRects( hRegionHandle );
+            RectangleVector aRectangles;
+            aRegion.GetRegionRectangles(aRectangles);
+            const long nMoveVertical(nHeightLeft - nHeightOrg);
+
+            for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
+                aRectIter->Move(0, nMoveVertical);
+                
+                ImplWriteLong( aRectIter->Left() );
+                ImplWriteLong( aRectIter->Top() );
+                ImplWriteByte( 'm' );
+                ImplWriteLong( aRectIter->Right() + 1 );
+                ImplWriteLong( aRectIter->Top() );
+                ImplWriteByte( 'l' );
+                ImplWriteLong( aRectIter->Right() + 1 );
+                ImplWriteLong( aRectIter->Bottom() + 1 );
+                ImplWriteByte( 'l' );
+                ImplWriteLong( aRectIter->Left() );
+                ImplWriteLong( aRectIter->Bottom() + 1 );
+                ImplWriteByte( 'l' );
+                ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
+            }
+
+            //RegionHandle	hRegionHandle = aRegion.BeginEnumRects();
+            //
+			//while ( aRegion.GetEnumRects( hRegionHandle, aRect ) )
+			//{
+			//	aRect.Move( 0, - ( nHeightOrg - nHeightLeft ) );
+			//	ImplWriteLong( aRect.Left() );
+			//	ImplWriteLong( aRect.Top() );
+			//	ImplWriteByte( 'm' );
+			//	ImplWriteLong( aRect.Right() + 1 );
+			//	ImplWriteLong( aRect.Top() );
+			//	ImplWriteByte( 'l' );
+			//	ImplWriteLong( aRect.Right() + 1 );
+			//	ImplWriteLong( aRect.Bottom() + 1 );
+			//	ImplWriteByte( 'l' );
+			//	ImplWriteLong( aRect.Left() );
+			//	ImplWriteLong( aRect.Bottom() + 1 );
+			//	ImplWriteByte( 'l' );
+			//	ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
+			//};
+			//aRegion.EndEnumRects( hRegionHandle );
 			ImplWriteLine( "eoclip newpath" );
 			ImplWriteLine( "pom" );
 		}

Modified: incubator/ooo/trunk/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx (original)
+++ incubator/ooo/trunk/main/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx Tue Oct 23 13:46:28 2012
@@ -79,19 +79,26 @@ void DeviceCopy (
 void ForAllRectangles (const Region& rRegion, ::boost::function<void(const Rectangle&)> aFunction)
 {
     OSL_ASSERT(aFunction);
+    RectangleVector aRectangles;
+    rRegion.GetRegionRectangles(aRectangles);
 
-    if (rRegion.GetRectCount() <= 1)
+    if(0 == aRectangles.size())
     {
-        aFunction(rRegion.GetBoundRect());
+        aFunction(Rectangle());
     }
     else
     {
-        Region aMutableRegionCopy (rRegion);
-        RegionHandle aHandle(aMutableRegionCopy.BeginEnumRects());
-        Rectangle aBox;
-        while (aMutableRegionCopy.GetNextEnumRect(aHandle, aBox))
-            aFunction(aBox);
-        aMutableRegionCopy.EndEnumRects(aHandle);
+        for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+        {
+            aFunction(*aRectIter);
+        }
+
+        //Region aMutableRegionCopy (rRegion);
+        //RegionHandle aHandle(aMutableRegionCopy.BeginEnumRects());
+        //Rectangle aBox;
+        //while (aMutableRegionCopy.GetEnumRects(aHandle, aBox))
+        //    aFunction(aBox);
+        //aMutableRegionCopy.EndEnumRects(aHandle);
     }
 }
 

Modified: incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaymanagerbuffered.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaymanagerbuffered.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaymanagerbuffered.cxx Tue Oct 23 13:46:28 2012
@@ -116,41 +116,67 @@ namespace sdr
 
 		void OverlayManagerBuffered::ImpRestoreBackground(const Region& rRegionPixel) const
 		{
-			// local region
-			Region aRegionPixel(rRegionPixel);
-			RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
-			Rectangle aRegionRectanglePixel;
-			
 			// MapModes off
 			const bool bMapModeWasEnabledDest(getOutputDevice().IsMapModeEnabled());
 			const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
 			getOutputDevice().EnableMapMode(false);
 			((OverlayManagerBuffered*)this)->maBufferDevice.EnableMapMode(false);
 
-			while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
-			{
+			// local region
+            RectangleVector aRectangles;
+            rRegionPixel.GetRegionRectangles(aRectangles);
+
+            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
 #ifdef DBG_UTIL
-				// #i72754# possible graphical region test only with non-pro
-				static bool bDoPaintForVisualControl(false);
-				if(bDoPaintForVisualControl)
-				{
-					getOutputDevice().SetLineColor(COL_LIGHTGREEN);
-					getOutputDevice().SetFillColor();
-					getOutputDevice().DrawRect(aRegionRectanglePixel);
-				}
+                // #i72754# possible graphical region test only with non-pro
+                static bool bDoPaintForVisualControl(false);
+
+                if(bDoPaintForVisualControl)
+                {
+                    getOutputDevice().SetLineColor(COL_LIGHTGREEN);
+                    getOutputDevice().SetFillColor();
+                    getOutputDevice().DrawRect(*aRectIter);
+                }
 #endif
 
-				// restore the area
-				const Point aTopLeft(aRegionRectanglePixel.TopLeft());
-				const Size aSize(aRegionRectanglePixel.GetSize());
-
-				getOutputDevice().DrawOutDev(
-					aTopLeft, aSize, // destination
-					aTopLeft, aSize, // source
-					maBufferDevice);
-			}
+                // restore the area
+                const Point aTopLeft(aRectIter->TopLeft());
+                const Size aSize(aRectIter->GetSize());
+
+                getOutputDevice().DrawOutDev(
+                    aTopLeft, aSize, // destination
+                    aTopLeft, aSize, // source
+                    maBufferDevice);
+            }
 
-			aRegionPixel.EndEnumRects(aRegionHandle);
+			//Region aRegionPixel(rRegionPixel);
+			//RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
+			//Rectangle aRegionRectanglePixel;
+			//
+			//while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+			//{
+#ifdef DBG_U//TIL
+			//	// #i72754# possible graphical region test only with non-pro
+			//	static bool bDoPaintForVisualControl(false);
+			//	if(bDoPaintForVisualControl)
+			//	{
+			//		getOutputDevice().SetLineColor(COL_LIGHTGREEN);
+			//		getOutputDevice().SetFillColor();
+			//		getOutputDevice().DrawRect(aRegionRectanglePixel);
+			//	}
+#endif      //
+			//	// restore the area
+			//	const Point aTopLeft(aRegionRectanglePixel.TopLeft());
+			//	const Size aSize(aRegionRectanglePixel.GetSize());
+            //
+			//	getOutputDevice().DrawOutDev(
+			//		aTopLeft, aSize, // destination
+			//		aTopLeft, aSize, // source
+			//		maBufferDevice);
+			//}
+            //
+			//aRegionPixel.EndEnumRects(aRegionHandle);
 
 			// restore MapModes
 			getOutputDevice().EnableMapMode(bMapModeWasEnabledDest);
@@ -182,54 +208,94 @@ namespace sdr
 			}
 
 			// also limit to buffer size
-			const Rectangle aBufferDeviceRectanglePixel = Rectangle(Point(), maBufferDevice.GetOutputSizePixel());
+			const Rectangle aBufferDeviceRectanglePixel(Point(), maBufferDevice.GetOutputSizePixel());
 			aRegion.Intersect(aBufferDeviceRectanglePixel);
 
-			// prepare to iterate over the rectangles from the region in pixels
-			RegionHandle aRegionHandle(aRegion.BeginEnumRects());
-			Rectangle aRegionRectanglePixel;
-
 			// MapModes off
 			const bool bMapModeWasEnabledDest(rSource.IsMapModeEnabled());
 			const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
 			rSource.EnableMapMode(false);
 			maBufferDevice.EnableMapMode(false);
 
-			while(aRegion.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
-			{
-				// for each rectangle, save the area
-				Point aTopLeft(aRegionRectanglePixel.TopLeft());
-				Size aSize(aRegionRectanglePixel.GetSize());
-
-				maBufferDevice.DrawOutDev(
-					aTopLeft, aSize, // destination
-					aTopLeft, aSize, // source
-					rSource);
+			// prepare to iterate over the rectangles from the region in pixels
+            RectangleVector aRectangles;
+            aRegion.GetRegionRectangles(aRectangles);
+
+            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
+                // for each rectangle, save the area
+                const Point aTopLeft(aRectIter->TopLeft());
+                const Size aSize(aRectIter->GetSize());
+
+                maBufferDevice.DrawOutDev(
+                    aTopLeft, aSize, // destination
+                    aTopLeft, aSize, // source
+                    rSource);
 
 #ifdef DBG_UTIL
-				// #i72754# possible graphical region test only with non-pro
-				static bool bDoPaintForVisualControl(false);
-				if(bDoPaintForVisualControl)
-				{
-					const bool bMapModeWasEnabledTest(getOutputDevice().IsMapModeEnabled());
-					getOutputDevice().EnableMapMode(false);
-					getOutputDevice().SetLineColor(COL_LIGHTRED);
-					getOutputDevice().SetFillColor();
-					getOutputDevice().DrawRect(aRegionRectanglePixel);
-					getOutputDevice().EnableMapMode(bMapModeWasEnabledTest);
-				}
+                // #i72754# possible graphical region test only with non-pro
+                static bool bDoPaintForVisualControl(false);
 
-				static bool bDoSaveForVisualControl(false);
-				if(bDoSaveForVisualControl)
-				{
-					const Bitmap aBitmap(maBufferDevice.GetBitmap(aTopLeft, aSize));
-					SvFileStream aNew((const String&)String(ByteString( "c:\\test.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC);
-					aNew << aBitmap;
-				}
+                if(bDoPaintForVisualControl)
+                {
+                    const bool bMapModeWasEnabledTest(getOutputDevice().IsMapModeEnabled());
+                    
+                    getOutputDevice().EnableMapMode(false);
+                    getOutputDevice().SetLineColor(COL_LIGHTRED);
+                    getOutputDevice().SetFillColor();
+                    getOutputDevice().DrawRect(*aRectIter);
+                    getOutputDevice().EnableMapMode(bMapModeWasEnabledTest);
+                }
+
+                static bool bDoSaveForVisualControl(false);
+                
+                if(bDoSaveForVisualControl)
+                {
+                    const Bitmap aBitmap(maBufferDevice.GetBitmap(aTopLeft, aSize));
+                    SvFileStream aNew((const String&)String(ByteString( "c:\\test.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC);
+                    aNew << aBitmap;
+                }
 #endif
-			}
+            }
 
-			aRegion.EndEnumRects(aRegionHandle);
+			//RegionHandle aRegionHandle(aRegion.BeginEnumRects());
+			//Rectangle aRegionRectanglePixel;
+            //
+			//while(aRegion.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+			//{
+			//	// for each rectangle, save the area
+			//	Point aTopLeft(aRegionRectanglePixel.TopLeft());
+			//	Size aSize(aRegionRectanglePixel.GetSize());
+            //
+			//	maBufferDevice.DrawOutDev(
+			//		aTopLeft, aSize, // destination
+			//		aTopLeft, aSize, // source
+			//		rSource);
+            //
+#ifdef DBG_U//TIL
+			//	// #i72754# possible graphical region test only with non-pro
+			//	static bool bDoPaintForVisualControl(false);
+			//	if(bDoPaintForVisualControl)
+			//	{
+			//		const bool bMapModeWasEnabledTest(getOutputDevice().IsMapModeEnabled());
+			//		getOutputDevice().EnableMapMode(false);
+			//		getOutputDevice().SetLineColor(COL_LIGHTRED);
+			//		getOutputDevice().SetFillColor();
+			//		getOutputDevice().DrawRect(aRegionRectanglePixel);
+			//		getOutputDevice().EnableMapMode(bMapModeWasEnabledTest);
+			//	}
+            //
+			//	static bool bDoSaveForVisualControl(false);
+			//	if(bDoSaveForVisualControl)
+			//	{
+			//		const Bitmap aBitmap(maBufferDevice.GetBitmap(aTopLeft, aSize));
+			//		SvFileStream aNew((const String&)String(ByteString( "c:\\test.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC);
+			//		aNew << aBitmap;
+			//	}
+#endif      //
+			//}
+            //
+			//aRegion.EndEnumRects(aRegionHandle);
 
 			// restore MapModes
 			rSource.EnableMapMode(bMapModeWasEnabledDest);

Modified: incubator/ooo/trunk/main/svx/source/sdr/properties/itemsettools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/properties/itemsettools.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/properties/itemsettools.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/properties/itemsettools.cxx Tue Oct 23 13:46:28 2012
@@ -27,10 +27,9 @@
 #include <tools/debug.hxx>
 #include <svl/itemset.hxx>
 #include <svl/whiter.hxx>
-
-#include <vector>
 #include <svx/svdogrp.hxx>
 #include <svx/svditer.hxx>
+#include <vcl/region.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // class to remember broadcast start positions
@@ -39,9 +38,6 @@ namespace sdr
 {
 	namespace properties
 	{
-		// helper vector to remember rectangles
-		typedef ::std::vector< Rectangle > RectangleVector;
-
 		ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj)
 		{
 			if(rObj.ISA(SdrObjGroup))

Modified: incubator/ooo/trunk/main/svx/source/svdraw/sdrpaintwindow.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/sdrpaintwindow.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/sdrpaintwindow.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/sdrpaintwindow.cxx Tue Oct 23 13:46:28 2012
@@ -62,9 +62,9 @@ void SdrPreRenderDevice::PreparePreRende
 void SdrPreRenderDevice::OutputPreRenderDevice(const Region& rExpandedRegion)
 {
 	// region to pixels
-	Region aRegionPixel(mrOutputDevice.LogicToPixel(rExpandedRegion));
-	RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
-	Rectangle aRegionRectanglePixel;
+	const Region aRegionPixel(mrOutputDevice.LogicToPixel(rExpandedRegion));
+	//RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
+	//Rectangle aRegionRectanglePixel;
 
 	// MapModes off
 	sal_Bool bMapModeWasEnabledDest(mrOutputDevice.IsMapModeEnabled());
@@ -72,31 +72,60 @@ void SdrPreRenderDevice::OutputPreRender
 	mrOutputDevice.EnableMapMode(sal_False);
 	maPreRenderDevice.EnableMapMode(sal_False);
 
-	while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
-	{
-		// for each rectangle, copy the area
-		const Point aTopLeft(aRegionRectanglePixel.TopLeft());
-		const Size aSize(aRegionRectanglePixel.GetSize());
-
-		mrOutputDevice.DrawOutDev(
-			aTopLeft, aSize, 
-			aTopLeft, aSize, 
-			maPreRenderDevice);
+    RectangleVector aRectangles;
+    aRegionPixel.GetRegionRectangles(aRectangles);
+
+    for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+    {
+        // for each rectangle, copy the area
+        const Point aTopLeft(aRectIter->TopLeft());
+        const Size aSize(aRectIter->GetSize());
+
+        mrOutputDevice.DrawOutDev(
+            aTopLeft, aSize, 
+            aTopLeft, aSize, 
+            maPreRenderDevice);
 
 #ifdef DBG_UTIL
-		// #i74769#
-		static bool bDoPaintForVisualControlRegion(false);
-		if(bDoPaintForVisualControlRegion)
-		{
-			Color aColor((((((rand()&0x7f)|0x80)<<8L)|((rand()&0x7f)|0x80))<<8L)|((rand()&0x7f)|0x80));
-			mrOutputDevice.SetLineColor(aColor);
-			mrOutputDevice.SetFillColor();
-			mrOutputDevice.DrawRect(aRegionRectanglePixel);
-		}
+        // #i74769#
+        static bool bDoPaintForVisualControlRegion(false);
+
+        if(bDoPaintForVisualControlRegion)
+        {
+            const Color aColor((((((rand()&0x7f)|0x80)<<8L)|((rand()&0x7f)|0x80))<<8L)|((rand()&0x7f)|0x80));
+
+            mrOutputDevice.SetLineColor(aColor);
+            mrOutputDevice.SetFillColor();
+            mrOutputDevice.DrawRect(*aRectIter);
+        }
 #endif
-	}
+    }
 
-	aRegionPixel.EndEnumRects(aRegionHandle);
+//	while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+//	{
+//		// for each rectangle, copy the area
+//		const Point aTopLeft(aRegionRectanglePixel.TopLeft());
+//		const Size aSize(aRegionRectanglePixel.GetSize());
+//
+//		mrOutputDevice.DrawOutDev(
+//			aTopLeft, aSize, 
+//			aTopLeft, aSize, 
+//			maPreRenderDevice);
+//
+//#ifdef DBG_UTIL
+//		// #i74769#
+//		static bool bDoPaintForVisualControlRegion(false);
+//		if(bDoPaintForVisualControlRegion)
+//		{
+//			Color aColor((((((rand()&0x7f)|0x80)<<8L)|((rand()&0x7f)|0x80))<<8L)|((rand()&0x7f)|0x80));
+//			mrOutputDevice.SetLineColor(aColor);
+//			mrOutputDevice.SetFillColor();
+//			mrOutputDevice.DrawRect(aRegionRectanglePixel);
+//		}
+//#endif
+//	}
+//
+//	aRegionPixel.EndEnumRects(aRegionHandle);
 
 	mrOutputDevice.EnableMapMode(bMapModeWasEnabledDest);
 	maPreRenderDevice.EnableMapMode(bMapModeWasEnabledSource);

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx Tue Oct 23 13:46:28 2012
@@ -809,9 +809,7 @@ void ImpSdrGDIMetaFileImport::checkClip(
 {
     if(maVD.IsClipRegion())
     {
-        Region aRegion(maVD.GetClipRegion());
-
-        maClip = aRegion.ConvertToB2DPolyPolygon();
+        maClip = maVD.GetClipRegion().GetAsB2DPolyPolygon();
 
         if(isClip())
         {

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx Tue Oct 23 13:46:28 2012
@@ -806,19 +806,31 @@ void SdrPaintView::CompleteRedraw(Output
 #ifdef DBG_UTIL
 				// #i74769# test-paint repaint region
 				static bool bDoPaintForVisualControl(false);
-				if(bDoPaintForVisualControl)
+
+                if(bDoPaintForVisualControl)
 				{
-					RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
-					Rectangle aRegionRectangle;
-					
-					while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
-					{
-						pWindow->SetLineColor(COL_LIGHTGREEN);
-						pWindow->SetFillColor();
-						pWindow->DrawRect(aRegionRectangle);
-					}
+                    RectangleVector aRectangles;
+                    aOptimizedRepaintRegion.GetRegionRectangles(aRectangles);
 
-					aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
+                    pWindow->SetLineColor(COL_LIGHTGREEN);
+                    pWindow->SetFillColor();
+
+                    for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+                    {
+                        pWindow->DrawRect(*aRectIter);
+                    }
+
+					//RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
+					//Rectangle aRegionRectangle;
+					//
+					//while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
+					//{
+					//	pWindow->SetLineColor(COL_LIGHTGREEN);
+					//	pWindow->SetFillColor();
+					//	pWindow->DrawRect(aRegionRectangle);
+					//}
+                    //
+					//aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
 				}
 #endif
 			}
@@ -988,19 +1000,31 @@ SdrPaintWindow* SdrPaintView::BeginDrawL
 #ifdef DBG_UTIL
 						// #i74769# test-paint repaint region
 						static bool bDoPaintForVisualControl(false);
-						if(bDoPaintForVisualControl)
+
+                        if(bDoPaintForVisualControl)
 						{
-							RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
-							Rectangle aRegionRectangle;
-							
-							while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
-							{
-								pWindow->SetLineColor(COL_LIGHTGREEN);
-								pWindow->SetFillColor();
-								pWindow->DrawRect(aRegionRectangle);
-							}
+                            RectangleVector aRectangles;
+                            aOptimizedRepaintRegion.GetRegionRectangles(aRectangles);
+
+                            pWindow->SetLineColor(COL_LIGHTGREEN);
+                            pWindow->SetFillColor();
 
-							aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
+                            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+                            {
+                                pWindow->DrawRect(*aRectIter);
+                            }
+
+							//RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
+							//Rectangle aRegionRectangle;
+							//
+							//while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
+							//{
+							//	pWindow->SetLineColor(COL_LIGHTGREEN);
+							//	pWindow->SetFillColor();
+							//	pWindow->DrawRect(aRegionRectangle);
+							//}
+                            //
+							//aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
 						}
 #endif
 					}

Modified: incubator/ooo/trunk/main/sw/source/core/view/viewsh.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/view/viewsh.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/view/viewsh.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/view/viewsh.cxx Tue Oct 23 13:46:28 2012
@@ -2004,12 +2004,20 @@ void ViewShell::Paint(const Rectangle &r
 
 		if ( bInEndAction && GetWin() )
 		{
-			Region aRegion( GetWin()->GetPaintRegion() );
-			RegionHandle hHdl( aRegion.BeginEnumRects() );
-			Rectangle aRect;
-			while ( aRegion.GetNextEnumRect( hHdl, aRect ) )
-				Imp()->AddPaintRect( aRect );
-			aRegion.EndEnumRects( hHdl );
+			const Region aRegion(GetWin()->GetPaintRegion());
+            RectangleVector aRectangles;
+            aRegion.GetRegionRectangles(aRectangles);
+
+            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
+                Imp()->AddPaintRect(*aRectIter);
+            }
+
+            //RegionHandle hHdl( aRegion.BeginEnumRects() );
+			//Rectangle aRect;
+			//while ( aRegion.GetEnumRects( hHdl, aRect ) )
+			//	Imp()->AddPaintRect( aRect );
+			//aRegion.EndEnumRects( hHdl );
 		}
 		else if ( SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) &&
 				  GetOut() == GetWin() )

Modified: incubator/ooo/trunk/main/toolkit/source/awt/vclxregion.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/toolkit/source/awt/vclxregion.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/toolkit/source/awt/vclxregion.cxx (original)
+++ incubator/ooo/trunk/main/toolkit/source/awt/vclxregion.cxx Tue Oct 23 13:46:28 2012
@@ -150,15 +150,24 @@ void VCLXRegion::xOrRegion( const ::com:
 {
 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
 
-	sal_uLong nRects = maRegion.GetRectCount();
-	::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects( nRects );
+    RectangleVector aRectangles;
+    maRegion.GetRegionRectangles(aRectangles);
 
-	Rectangle aRect;
-	sal_uInt32 nR = 0;
-	RegionHandle h = maRegion.BeginEnumRects();
-	while ( maRegion.GetNextEnumRect( h, aRect ) )
-		aRects.getArray()[nR++] = AWTRectangle( aRect );
-	maRegion.EndEnumRects( h );
+//    sal_uLong nRects = maRegion.GetRectCount();
+	::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects(aRectangles.size());
+    sal_uInt32 a(0);
+
+    for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+    {
+        aRects.getArray()[a++] = AWTRectangle(*aRectIter);
+    }
+
+	//Rectangle aRect;
+	//sal_uInt32 nR = 0;
+	//RegionHandle h = maRegion.BeginEnumRects();
+	//while ( maRegion.GetEnumRects( h, aRect ) )
+	//	aRects.getArray()[nR++] = AWTRectangle( aRect );
+	//maRegion.EndEnumRects( h );
 
 	return aRects;
 }

Modified: incubator/ooo/trunk/main/vcl/Library_vcl.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/Library_vcl.mk?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/Library_vcl.mk (original)
+++ incubator/ooo/trunk/main/vcl/Library_vcl.mk Tue Oct 23 13:46:28 2012
@@ -377,6 +377,7 @@ $(eval $(call gb_Library_add_exception_o
     vcl/source/gdi/print \
     vcl/source/gdi/regband \
     vcl/source/gdi/region \
+    vcl/source/gdi/regionband \
     vcl/source/gdi/salgdilayout \
     vcl/source/gdi/sallayout \
     vcl/source/gdi/salmisc \

Modified: incubator/ooo/trunk/main/vcl/aqua/source/gdi/salgdi.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/aqua/source/gdi/salgdi.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/aqua/source/gdi/salgdi.cxx (original)
+++ incubator/ooo/trunk/main/vcl/aqua/source/gdi/salgdi.cxx Tue Oct 23 13:46:28 2012
@@ -50,7 +50,6 @@
 
 #include "fontsubset.hxx"
 #include "impfont.hxx"
-#include "region.h"
 #include "sallayout.hxx"
 #include "sft.hxx"
 
@@ -572,24 +571,31 @@ bool AquaSalGraphics::setClipRegion( con
     mxClipPath = CGPathCreateMutable();
 
     // set current path, either as polypolgon or sequence of rectangles
-    if( i_rClip.HasPolyPolygon() )
+    if(i_rClip.HasPolyPolygonOrB2DPolyPolygon())
     {
-        basegfx::B2DPolyPolygon aClip( const_cast<Region&>(i_rClip).ConvertToB2DPolyPolygon() );
+        const basegfx::B2DPolyPolygon aClip(i_rClip.GetAsB2DPolyPolygon());
+
         AddPolyPolygonToPath( mxClipPath, aClip, !getAntiAliasB2DDraw(), false );
     }
     else
     {
-        long nX, nY, nW, nH;
-        ImplRegionInfo aInfo;
-        bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
-        while( bRegionRect )
+        RectangleVector aRectangles;
+        i_rClip.GetRegionRectangles(aRectangles);
+
+        for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
         {
-            if( nW && nH )
+            const long nW(aRectIter->Right() - aRectIter->Left() + 1); // uses +1 logic in original
+
+            if(nW)
             {
-                CGRect aRect = {{nX,nY}, {nW,nH}};
-                CGPathAddRect( mxClipPath, NULL, aRect );
+                const long nH(aRectIter->Bottom() - aRectIter->Top() + 1); // uses +1 logic in original
+
+                if(nH)
+                {
+                    CGRect aRect = {{ aRectIter->Left(), aRectIter->Top() }, { nW, nH }};
+                    CGPathAddRect( mxClipPath, NULL, aRect );
+                }
             }
-            bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
         }
     }
     // set the current path as clip region

Added: incubator/ooo/trunk/main/vcl/inc/regionband.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/regionband.hxx?rev=1401294&view=auto
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/regionband.hxx (added)
+++ incubator/ooo/trunk/main/vcl/inc/regionband.hxx Tue Oct 23 13:46:28 2012
@@ -0,0 +1,87 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef _SV_REGIONBAND_HXX
+#define _SV_REGIONBAND_HXX
+
+#include <vcl/regband.hxx>
+#include <vcl/region.hxx>
+
+#ifdef DBG_UTIL
+const char* ImplDbgTestRegionBand(const void*);
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+
+class RegionBand
+{
+private:
+    friend const char* ImplDbgTestRegionBand(const void*);
+
+	ImplRegionBand* 	        mpFirstBand;		// root of the list with y-bands
+	ImplRegionBand* 	        mpLastCheckedBand;
+
+    void implReset();
+
+public:
+    RegionBand();
+    RegionBand(const RegionBand&);
+    RegionBand& operator=(const RegionBand&);
+    RegionBand(const Rectangle&);
+    ~RegionBand();
+
+    bool operator==( const RegionBand& rRegionBand ) const;
+    bool operator!=( const RegionBand& rRegionBand ) const { return !(RegionBand::operator==( rRegionBand )); }
+    
+    void load(SvStream& rIStrm);
+    void save(SvStream& rIStrm) const;
+
+    bool isSingleRectangle() const;
+    ImplRegionBand* ImplGetFirstRegionBand() const { return mpFirstBand; }
+    void ImplAddMissingBands(const long nTop, const long nBottom);
+    void InsertBand(ImplRegionBand* pPreviousBand, ImplRegionBand* pBandToInsert);
+    void processPoints();
+    void CreateBandRange(long nYTop, long nYBottom);
+    bool InsertLine(const Point& rStartPt, const Point& rEndPt, long nLineId);
+    bool InsertPoint(const Point &rPoint, long nLineID, bool bEndPoint, LineType eLineType);
+    bool OptimizeBandList();
+    void Move(long nHorzMove, long nVertMove);
+    void Scale(double fScaleX, double fScaleY);
+    void InsertBands(long nTop, long nBottom);
+    bool InsertSingleBand(ImplRegionBand* pBand, long nYBandPosition);
+    void Union(long nLeft, long nTop, long nRight, long nBottom);
+    void Intersect(long nLeft, long nTop, long nRight, long nBottom);
+    void Union(const RegionBand& rSource);
+    void Exclude(long nLeft, long nTop, long nRight, long nBottom);
+    void XOr(long nLeft, long nTop, long nRight, long nBottom);
+    void Intersect(const RegionBand& rSource);
+    bool Exclude(const RegionBand& rSource);
+    void XOr(const RegionBand& rSource);
+    Rectangle GetBoundRect() const;
+    bool IsInside(const Point& rPoint) const;
+    sal_uInt32 getRectangleCount() const; // only users are Region::Intersect and PSWriter::ImplBmp
+    void GetRegionRectangles(RectangleVector& rTarget) const;
+};
+
+#endif	// _SV_REGIONBAND_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+//eof

Propchange: incubator/ooo/trunk/main/vcl/inc/regionband.hxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/trunk/main/vcl/inc/unx/gtk/gtkgdi.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/unx/gtk/gtkgdi.hxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/unx/gtk/gtkgdi.hxx (original)
+++ incubator/ooo/trunk/main/vcl/inc/unx/gtk/gtkgdi.hxx Tue Oct 23 13:46:28 2012
@@ -40,7 +40,7 @@ class GtkSalGraphics : public X11SalGrap
 public:
                         GtkSalGraphics( GtkWidget *window )
                             : m_pWindow( window ),
-                              m_aClipRegion( REGION_NULL )
+                              m_aClipRegion(true)
                               {}
     virtual             ~GtkSalGraphics();
     

Modified: incubator/ooo/trunk/main/vcl/inc/vcl/regband.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/vcl/regband.hxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/vcl/regband.hxx (original)
+++ incubator/ooo/trunk/main/vcl/inc/vcl/regband.hxx Tue Oct 23 13:46:28 2012
@@ -53,7 +53,7 @@ struct ImplRegionBandSep
 	ImplRegionBandSep*			mpNextSep;
 	long						mnXLeft;
 	long						mnXRight;
-	sal_Bool						mbRemoved;
+	bool						mbRemoved;
 };
 
 enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL };
@@ -64,7 +64,7 @@ struct ImplRegionBandPoint
 	ImplRegionBandPoint*		mpNextBandPoint;
 	long						mnX;
 	long						mnLineId;
-	sal_Bool						mbEndPoint;
+	bool						mbEndPoint;
 	LineType					meLineType;
 };
 
@@ -81,7 +81,9 @@ public:
 	ImplRegionBandPoint*		mpFirstBandPoint;	// root of the list with lines
 	long						mnYTop; 			// actual boundary of the band
 	long						mnYBottom;
-	sal_Bool						mbTouched;
+
+    // bitfield
+	bool                        mbTouched : 1;
 
 								// create y-band with boundaries
 								ImplRegionBand( long nYTop, long nYBottom );
@@ -106,14 +108,14 @@ public:
 	long						GetXRightBoundary() const;
 
 								// combine overlapping bands
-	sal_Bool						OptimizeBand();
+	bool						OptimizeBand();
 
 								// generate separations from lines and process
 								// union with existing separations
 	void						ProcessPoints();
 								// insert point in the list for later processing
-	sal_Bool						InsertPoint( long nX, long nLineID,
-											 sal_Bool bEndPoint, LineType eLineType );
+	bool						InsertPoint( long nX, long nLineID,
+											 bool bEndPoint, LineType eLineType );
 
 	void						Union( long nXLeft, long nXRight );
 	void						Intersect( long nXLeft, long nXRight );
@@ -123,13 +125,13 @@ public:
 	void						MoveX( long nHorzMove );
 	void						ScaleX( double fHorzScale );
 
-	sal_Bool						IsInside( long nX );
-	sal_Bool						IsInside( long nLeft, long nRight );
-	sal_Bool						IsOver( long nLeft, long nRight );
+	bool						IsInside( long nX );
+	bool						IsInside( long nLeft, long nRight );
+	bool						IsOver( long nLeft, long nRight );
 
-	sal_Bool						IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
+	bool						IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
 
-	sal_Bool						operator==( const ImplRegionBand& rRegionBand ) const;
+	bool						operator==( const ImplRegionBand& rRegionBand ) const;
 
     /** Split the called band at the given vertical coordinate.  After the
         split the called band will cover the upper part not including nY.

Modified: incubator/ooo/trunk/main/vcl/inc/vcl/region.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/vcl/region.hxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/vcl/region.hxx (original)
+++ incubator/ooo/trunk/main/vcl/inc/vcl/region.hxx Tue Oct 23 13:46:28 2012
@@ -19,125 +19,102 @@
  * 
  *************************************************************/
 
-
-
 #ifndef _SV_REGION_HXX
 #define _SV_REGION_HXX
 
 #include <tools/gen.hxx>
 #include <vcl/sv.h>
 #include <vcl/dllapi.h>
-
 #include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <boost/shared_ptr.hpp>
 
-class ImplRegion;
 class ImplRegionBand;
+class RegionBand;
 class Polygon;
 class PolyPolygon;
-struct ImplRegionInfo;
 
-// --------------
-// - RegionType -
-// --------------
+//////////////////////////////////////////////////////////////////////////////
 
-enum RegionType { REGION_NULL, REGION_EMPTY, REGION_RECTANGLE, REGION_COMPLEX };
-enum RegionOverlapType { REGION_INSIDE, REGION_OVER, REGION_OUTSIDE };
+typedef boost::shared_ptr< RegionBand > RegionBandPtr;
+typedef boost::shared_ptr< PolyPolygon > PolyPolygonPtr;
+typedef boost::shared_ptr< basegfx::B2DPolyPolygon > B2DPolyPolygonPtr;
+typedef std::vector< Rectangle > RectangleVector;
 
-typedef long RegionHandle;
-
-// ----------
-// - Region -
-// ----------
+//////////////////////////////////////////////////////////////////////////////
 
 class VCL_DLLPUBLIC Region
 {
+private:
 	friend class OutputDevice;
 	friend class Window;
 	friend class Bitmap;
 
-private:
-	ImplRegion* 		mpImplRegion;
-
-	SAL_DLLPRIVATE void				ImplCopyData();
-	SAL_DLLPRIVATE void				ImplCreateRectRegion( const Rectangle& rRect );
-	SAL_DLLPRIVATE void				ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
-	SAL_DLLPRIVATE void				ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& rPolyPoly );
-	SAL_DLLPRIVATE void				ImplPolyPolyRegionToBandRegionFunc();
-	SAL_DLLPRIVATE inline void 		ImplPolyPolyRegionToBandRegion();
-	SAL_DLLPRIVATE const ImplRegion*	ImplGetImplRegion() const { return mpImplRegion; }
-	SAL_DLLPRIVATE ImplRegion* 		ImplGetImplRegion() { return mpImplRegion; }
-	SAL_DLLPRIVATE void				ImplBeginAddRect( );
-	SAL_DLLPRIVATE sal_Bool				ImplAddRect( const Rectangle& rRect );
-	SAL_DLLPRIVATE void				ImplEndAddRect( );
-	SAL_DLLPRIVATE void             ImplIntersectWithPolyPolygon( const Region& );
-	SAL_DLLPRIVATE void             ImplExcludePolyPolygon( const Region& );
-	SAL_DLLPRIVATE void             ImplUnionPolyPolygon( const Region& );
-	SAL_DLLPRIVATE void             ImplXOrPolyPolygon( const Region& );
-
-public: // public within vcl
-	VCL_PLUGIN_PUBLIC bool				ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo,
-										  long& nX, long& nY, long& nWidth, long& nHeight ) const;
-	VCL_PLUGIN_PUBLIC bool				ImplGetNextRect( ImplRegionInfo& rImplRegionInfo,
-										 long& nX, long& nY, long& nWidth, long& nHeight ) const;
-#ifdef DBG_UTIL
-	friend const char*	ImplDbgTestRegion( const void* pObj );
-#endif
+    // possible contents
+    B2DPolyPolygonPtr           mpB2DPolyPolygon;
+    PolyPolygonPtr              mpPolyPolygon;
+    RegionBandPtr               mpRegionBand;
+
+    /// bitfield
+    bool                        mbIsNull : 1;
+
+    // helpers
+    SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
+    SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& rPolyPoly );
+    
+    SAL_DLLPRIVATE PolyPolygon ImplCreatePolyPolygonFromRegionBand() const;
+    SAL_DLLPRIVATE basegfx::B2DPolyPolygon ImplCreateB2DPolyPolygonFromRegionBand() const;
 
 public:
-					Region();
-					Region( RegionType eType );
-					Region( const Rectangle& rRect );
-					Region( const Polygon& rPolygon );
-					Region( const PolyPolygon& rPolyPoly );
-					Region( const basegfx::B2DPolyPolygon& );
-					Region( const Region& rRegion );
-					~Region();
-
-	void			Move( long nHorzMove, long nVertMove );
-	void			Scale( double fScaleX, double fScaleY );
-	sal_Bool			Union( const Rectangle& rRegion );
-	sal_Bool			Intersect( const Rectangle& rRegion );
-	sal_Bool			Exclude( const Rectangle& rRegion );
-	sal_Bool			XOr( const Rectangle& rRegion );
-	sal_Bool			Union( const Region& rRegion );
-	sal_Bool			Intersect( const Region& rRegion );
-	sal_Bool			Exclude( const Region& rRegion );
-	sal_Bool			XOr( const Region& rRegion );
-
-	RegionType		GetType() const;
-	sal_Bool			IsEmpty() const { return GetType() == REGION_EMPTY; };
-	sal_Bool			IsNull() const { return GetType() == REGION_NULL; };
-
-	void			SetEmpty();
-	void			SetNull();
-
-	Rectangle		GetBoundRect() const;
-
-    sal_Bool            HasPolyPolygon() const;
-    PolyPolygon     GetPolyPolygon() const;
-    // returns an empty polypolygon in case HasPolyPolygon is sal_False
-    const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const;
-    // returns a PolyPolygon either copied from the set PolyPolygon region
-    // or created from the constituent rectangles
-    basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon();
-
-	sal_uLong			GetRectCount() const;
-	RegionHandle	BeginEnumRects();
-	sal_Bool			GetEnumRects( RegionHandle hRegionHandle, Rectangle& rRect );
-	sal_Bool			GetNextEnumRect( RegionHandle hRegionHandle, Rectangle& rRect )
-						{ return GetEnumRects( hRegionHandle, rRect ); }
-	void			EndEnumRects( RegionHandle hRegionHandle );
-
-	sal_Bool			IsInside( const Point& rPoint ) const;
-	sal_Bool			IsInside( const Rectangle& rRect ) const;
-	sal_Bool			IsOver( const Rectangle& rRect ) const;
-
-	Region& 		operator=( const Region& rRegion );
-	Region& 		operator=( const Rectangle& rRect );
-
-	sal_Bool			operator==( const Region& rRegion ) const;
-	sal_Bool			operator!=( const Region& rRegion ) const
-						{ return !(Region::operator==( rRegion )); }
+	Region(bool bIsNull = false); // default creates empty region, with true a null region is created
+	Region(const Rectangle& rRect);
+	Region(const Polygon& rPolygon);
+	Region(const PolyPolygon& rPolyPoly);
+	Region(const basegfx::B2DPolyPolygon&);
+	Region(const Region& rRegion);
+	~Region();
+
+    // direct access to contents
+    const basegfx::B2DPolyPolygon* getB2DPolyPolygon() const { return mpB2DPolyPolygon.get(); }
+    const PolyPolygon* getPolyPolygon() const { return mpPolyPolygon.get(); }
+    const RegionBand* getRegionBand() const { return mpRegionBand.get(); }
+
+    // access with converters, the asked data will be created from the most
+    // valuable data, buffered and returned
+    const PolyPolygon GetAsPolyPolygon() const;
+    const basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const;
+    const RegionBand* GetAsRegionBand() const;
+
+    // manipulators
+	void Move( long nHorzMove, long nVertMove );
+	void Scale( double fScaleX, double fScaleY );
+	bool Union( const Rectangle& rRegion );
+	bool Intersect( const Rectangle& rRegion );
+	bool Exclude( const Rectangle& rRegion );
+	bool XOr( const Rectangle& rRegion );
+	bool Union( const Region& rRegion );
+	bool Intersect( const Region& rRegion );
+	bool Exclude( const Region& rRegion );
+	bool XOr( const Region& rRegion );
+
+	bool IsEmpty() const;
+	bool IsNull() const;
+
+	void SetEmpty();
+	void SetNull();
+
+	Rectangle GetBoundRect() const;
+    bool HasPolyPolygonOrB2DPolyPolygon() const { return (getB2DPolyPolygon() || getPolyPolygon()); }
+    void GetRegionRectangles(RectangleVector& rTarget) const;
+
+	bool IsInside( const Point& rPoint ) const;
+	bool IsInside( const Rectangle& rRect ) const;
+	bool IsOver( const Rectangle& rRect ) const;
+
+	Region& operator=( const Region& rRegion );
+	Region& operator=( const Rectangle& rRect );
+
+	bool operator==( const Region& rRegion ) const;
+	bool operator!=( const Region& rRegion ) const { return !(Region::operator==( rRegion )); }
 
 	friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Region& rRegion );
 	friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Region& rRegion );
@@ -155,3 +132,6 @@ public:
 };
 
 #endif	// _SV_REGION_HXX
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Modified: incubator/ooo/trunk/main/vcl/os2/source/gdi/salgdi.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/os2/source/gdi/salgdi.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/os2/source/gdi/salgdi.cxx (original)
+++ incubator/ooo/trunk/main/vcl/os2/source/gdi/salgdi.cxx Tue Oct 23 13:46:28 2012
@@ -35,8 +35,6 @@
 #include <rtl/strbuf.hxx>
 #endif
 
-#include <region.h>
-
 #ifndef __H_FT2LIB
 #include <os2/wingdi.h>
 #include <ft2lib.h>
@@ -217,27 +215,48 @@ void Os2SalGraphics::ResetClipRegion()
 
 bool Os2SalGraphics::setClipRegion( const Region& i_rClip )
 {
-    ULONG nCount = i_rClip.GetRectCount();
-
-	mpClipRectlAry	  = new RECTL[ nCount ];
-	mnClipElementCount = 0;
+    RectangleVector aRectangles;
+    i_rClip.GetRegionRectangles(aRectangles);
+    mnClipElementCount = aRectangles.size();
+    mpClipRectlAry = 0;
 
-    ImplRegionInfo aInfo;
-    long nX, nY, nW, nH;
-    bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
-    while( bRegionRect )
+    if(mnClipElementCount)
     {
-        if ( nW && nH )
+        mpClipRectlAry = new RECTL[mnClipElementCount];
+
+        for(sal_uInt32 a(0); a < mnClipElementCount; a++)
         {
-            RECTL* pClipRect = &mpClipRectlAry[ mnClipElementCount ];
-            pClipRect->xLeft   = nX;
-            pClipRect->yTop    = mnHeight - nY;
-            pClipRect->xRight  = nX + nW;
-            pClipRect->yBottom = mnHeight - (nY + nH);
-            mnClipElementCount++;
+            const Rectangle& rRect = aRectangles[a];
+            RECTL* pClipRect = &mpClipRectlAry[a];
+
+            pClipRect->xLeft = rRect.Left();
+            pClipRect->yTop = mnHeight - rRect.Top();
+            pClipRect->xRight = rRect.Right() + 1; // nX + nW -> L + ((R - L) + 1) -> R + 1
+            pClipRect->yBottom = mnHeight - (rRect.Bottom() + 1); // same for height
         }
-        bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
     }
+
+//    ULONG nCount = i_rClip.GetRectCount();
+//
+//	mpClipRectlAry	  = new RECTL[ nCount ];
+//	mnClipElementCount = 0;
+//
+//    ImplRegionInfo aInfo;
+//    long nX, nY, nW, nH;
+//    bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
+//    while( bRegionRect )
+//    {
+//        if ( nW && nH )
+//        {
+//            RECTL* pClipRect = &mpClipRectlAry[ mnClipElementCount ];
+//            pClipRect->xLeft   = nX;
+//            pClipRect->yTop    = mnHeight - nY;
+//            pClipRect->xRight  = nX + nW;
+//            pClipRect->yBottom = mnHeight - (nY + nH);
+//            mnClipElementCount++;
+//        }
+//        bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
+//    }
 #ifdef SAL_PRINTER_CLIPPATH
 	if ( mbPrinter )
 	{

Modified: incubator/ooo/trunk/main/vcl/source/gdi/bitmap.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/bitmap.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/bitmap.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/bitmap.cxx Tue Oct 23 13:46:28 2012
@@ -1384,38 +1384,92 @@ Region Bitmap::CreateRegion( const Color
 
 	if( pReadAcc )
 	{
-		Rectangle			aSubRect;
+		//Rectangle			aSubRect;
 		const long			nLeft = aRect.Left();
 		const long			nTop = aRect.Top();
 		const long			nRight = aRect.Right();
 		const long			nBottom = aRect.Bottom();
 		const BitmapColor	aMatch( pReadAcc->GetBestMatchingColor( rColor ) );
 
-		aRegion.ImplBeginAddRect();
+        //RectangleVector aRectangles;
+		//aRegion.ImplBeginAddRect();
+        std::vector< long > aLine;
+        long nYStart(nTop);
+        long nY(nTop);
 
-		for( long nY = nTop; nY <= nBottom; nY++ )
+		for( ; nY <= nBottom; nY++ )
 		{
-			aSubRect.Top() = aSubRect.Bottom() = nY;
+			//aSubRect.Top() = aSubRect.Bottom() = nY;
+            std::vector< long > aNewLine;
+            long nX(nLeft);
 
-			for( long nX = nLeft; nX <= nRight; )
+			for( ; nX <= nRight; )
 			{
 				while( ( nX <= nRight ) && ( aMatch != pReadAcc->GetPixel( nY, nX ) ) )
 					nX++;
 
 				if( nX <= nRight )
 				{
-					aSubRect.Left() = nX;
+                    aNewLine.push_back(nX);
+					//aSubRect.Left() = nX;
 
 					while( ( nX <= nRight ) && ( aMatch == pReadAcc->GetPixel( nY, nX ) ) )
 						nX++;
 
-					aSubRect.Right() = nX - 1L;
-					aRegion.ImplAddRect( aSubRect );
+					//aSubRect.Right() = nX - 1L;
+                    aNewLine.push_back(nX - 1);
+
+					//aRegion.ImplAddRect( aSubRect );
+                    //aRectangles.push_back(aSubRect);
+                    //aRegion.Union(aSubRect);
 				}
 			}
+
+            if(aNewLine != aLine)
+            {
+                // need to write aLine, it's different from the next line
+                if(aLine.size())
+                {
+                    Rectangle aSubRect;
+
+                    // enter y values and proceed ystart
+                    aSubRect.Top() = nYStart;
+                    aSubRect.Bottom() = nY ? nY - 1 : 0;
+
+                    for(sal_uInt32 a(0); a < aLine.size();)
+                    {
+                        aSubRect.Left() = aLine[a++];
+                        aSubRect.Right() = aLine[a++];
+                        aRegion.Union(aSubRect);
+                    }
+                }
+
+                // copy line as new line
+                aLine = aNewLine;
+                nYStart = nY;
+            }
 		}
 
-		aRegion.ImplEndAddRect();
+        // write last line if used
+        if(aLine.size())
+        {
+            Rectangle aSubRect;
+
+            // enter y values
+            aSubRect.Top() = nYStart;
+            aSubRect.Bottom() = nY ? nY - 1 : 0;
+
+            for(sal_uInt32 a(0); a < aLine.size();)
+            {
+                aSubRect.Left() = aLine[a++];
+                aSubRect.Right() = aLine[a++];
+                aRegion.Union(aSubRect);
+            }
+        }
+
+		//aRegion.ImplEndAddRect();
+        //aRegion.SetRegionRectangles(aRectangles);
+
 		( (Bitmap*) this )->ReleaseAccess( pReadAcc );
 	}
 	else

Modified: incubator/ooo/trunk/main/vcl/source/gdi/bmpacc3.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/bmpacc3.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/bmpacc3.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/bmpacc3.cxx Tue Oct 23 13:46:28 2012
@@ -317,20 +317,34 @@ void BitmapWriteAccess::FillPolygon( con
 	{
 		const BitmapColor&	rFillColor = *mpFillColor;
 		Region				aRegion( rPoly );
-		Rectangle			aRect;
+//		Rectangle			aRect;
 
 		aRegion.Intersect( Rectangle( Point(), Size( Width(), Height() ) ) );
 
 		if( !aRegion.IsEmpty() )
 		{
-			RegionHandle aRegHandle( aRegion.BeginEnumRects() );
+            RectangleVector aRectangles;
+            aRegion.GetRegionRectangles(aRectangles);
 
-			while( aRegion.GetNextEnumRect( aRegHandle, aRect ) )
-				for( long nY = aRect.Top(), nEndY = aRect.Bottom(); nY <= nEndY; nY++ )
-					for( long nX = aRect.Left(), nEndX = aRect.Right(); nX <= nEndX; nX++ )
-						SetPixel( nY, nX, rFillColor );
-
-			aRegion.EndEnumRects( aRegHandle );
+            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
+                for(long nY = aRectIter->Top(), nEndY = aRectIter->Bottom(); nY <= nEndY; nY++)
+                {
+                    for(long nX = aRectIter->Left(), nEndX = aRectIter->Right(); nX <= nEndX; nX++)
+                    {
+                        SetPixel(nY, nX, rFillColor);
+                    }
+                }
+            }
+
+			//RegionHandle aRegHandle( aRegion.BeginEnumRects() );
+            //
+			//while( aRegion.GetEnumRects( aRegHandle, aRect ) )
+			//	for( long nY = aRect.Top(), nEndY = aRect.Bottom(); nY <= nEndY; nY++ )
+			//		for( long nX = aRect.Left(), nEndX = aRect.Right(); nX <= nEndX; nX++ )
+			//			SetPixel( nY, nX, rFillColor );
+            //
+			//aRegion.EndEnumRects( aRegHandle );
 		}
 	}
 }
@@ -364,20 +378,34 @@ void BitmapWriteAccess::FillPolyPolygon(
 	{
 		const BitmapColor&	rFillColor = *mpFillColor;
 		Region				aRegion( rPolyPoly );
-		Rectangle			aRect;
+		//Rectangle			aRect;
 
 		aRegion.Intersect( Rectangle( Point(), Size( Width(), Height() ) ) );
 
 		if( !aRegion.IsEmpty() )
 		{
-			RegionHandle aRegHandle( aRegion.BeginEnumRects() );
-			
-			while( aRegion.GetNextEnumRect( aRegHandle, aRect ) )
-				for( long nY = aRect.Top(), nEndY = aRect.Bottom(); nY <= nEndY; nY++ )
-					for( long nX = aRect.Left(), nEndX = aRect.Right(); nX <= nEndX; nX++ )
-						SetPixel( nY, nX, rFillColor );
+            RectangleVector aRectangles;
+            aRegion.GetRegionRectangles(aRectangles);
 
-			aRegion.EndEnumRects( aRegHandle );
+            for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+            {
+                for(long nY = aRectIter->Top(), nEndY = aRectIter->Bottom(); nY <= nEndY; nY++)
+                {
+                    for(long nX = aRectIter->Left(), nEndX = aRectIter->Right(); nX <= nEndX; nX++)
+                    {
+                        SetPixel(nY, nX, rFillColor);
+                    }
+                }
+            }
+
+            //RegionHandle aRegHandle( aRegion.BeginEnumRects() );
+			//
+			//while( aRegion.GetEnumRects( aRegHandle, aRect ) )
+			//	for( long nY = aRect.Top(), nEndY = aRect.Bottom(); nY <= nEndY; nY++ )
+			//		for( long nX = aRect.Left(), nEndX = aRect.Right(); nX <= nEndX; nX++ )
+			//			SetPixel( nY, nX, rFillColor );
+            //
+			//aRegion.EndEnumRects( aRegHandle );
 		}
 	}
 }

Modified: incubator/ooo/trunk/main/vcl/source/gdi/gdimtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/gdimtf.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/gdimtf.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/gdimtf.cxx Tue Oct 23 13:46:28 2012
@@ -1384,8 +1384,8 @@ void GDIMetaFile::Rotate( long nAngle10 
                 {
 				    MetaClipRegionAction* pAct = (MetaClipRegionAction*) pAction;
 
-                    if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygon() )
-                        aMtf.AddAction( new MetaClipRegionAction( Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), sal_True ) );
+                    if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
+                        aMtf.AddAction( new MetaClipRegionAction( Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), sal_True ) );
                     else
                     {
 				        pAction->Duplicate();
@@ -1406,8 +1406,8 @@ void GDIMetaFile::Rotate( long nAngle10 
 				    MetaISectRegionClipRegionAction*    pAct = (MetaISectRegionClipRegionAction*) pAction;
                     const Region&                       rRegion = pAct->GetRegion();
 
-                    if( rRegion.HasPolyPolygon() )
-                        aMtf.AddAction( new MetaISectRegionClipRegionAction( Region( ImplGetRotatedPolyPolygon( rRegion.GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) );
+                    if( rRegion.HasPolyPolygonOrB2DPolyPolygon() )
+                        aMtf.AddAction( new MetaISectRegionClipRegionAction( Region( ImplGetRotatedPolyPolygon( rRegion.GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) );
                     else
                     {
 				        pAction->Duplicate();
@@ -2744,12 +2744,12 @@ sal_uLong GDIMetaFile::GetChecksum() con
                 MetaClipRegionAction* pAct = dynamic_cast< MetaClipRegionAction* >(pAction);
                 const Region& rRegion = pAct->GetRegion();
 
-                if(rRegion.HasPolyPolygon())
+                if(rRegion.HasPolyPolygonOrB2DPolyPolygon())
                 {
                     // It has shown that this is a possible bottleneck for checksum calculation.
                     // In worst case a very expensive RegionHandle representation gets created.
                     // In this case it's cheaper to use the PolyPolygon
-                    const basegfx::B2DPolyPolygon aPolyPolygon(rRegion.GetB2DPolyPolygon());
+                    const basegfx::B2DPolyPolygon aPolyPolygon(rRegion.GetAsB2DPolyPolygon());
                     const sal_uInt32 nPolyCount(aPolyPolygon.count());
                     SVBT64 aSVBT64;
 

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=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/outdev.cxx Tue Oct 23 13:46:28 2012
@@ -50,7 +50,6 @@
 #include <svdata.hxx>
 #include <window.h>
 #include <outdev.h>
-#include <region.h>
 #include <outdata.hxx>
 
 #include <basegfx/point/b2dpoint.hxx>
@@ -329,7 +328,7 @@ void OutputDevice::ImplDrawPolyPolygon( 
 // =======================================================================
 
 OutputDevice::OutputDevice() :
-	maRegion( REGION_NULL ),
+	maRegion(true),
 	maFillColor( COL_WHITE ),
 	maTextLineColor( COL_TRANSPARENT ),
 	maSettings( Application::GetSettings() )
@@ -541,23 +540,35 @@ void    OutputDevice::ImplReMirror( Rect
 }
 void    OutputDevice::ImplReMirror( Region &rRegion ) const
 {
-	long				nX;
-	long				nY;
-	long				nWidth;
-	long				nHeight;
-	ImplRegionInfo		aInfo;
-	sal_Bool				bRegionRect;
-    Region              aMirroredRegion;
-
-	bRegionRect = rRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
-	while ( bRegionRect )
-	{
-        Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
-        ImplReMirror( aRect );
-        aMirroredRegion.Union( aRect );
-		bRegionRect = rRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
-	}
+    RectangleVector aRectangles;
+    rRegion.GetRegionRectangles(aRectangles);
+    Region aMirroredRegion;
+
+    for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+    {
+        ImplReMirror(*aRectIter);
+        aMirroredRegion.Union(*aRectIter);
+    }
+
     rRegion = aMirroredRegion;
+
+//	long				nX;
+//	long				nY;
+//	long				nWidth;
+//	long				nHeight;
+//	ImplRegionInfo		aInfo;
+//	sal_Bool				bRegionRect;
+//    Region              aMirroredRegion;
+//
+//	bRegionRect = rRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
+//	while ( bRegionRect )
+//	{
+//        Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
+//        ImplReMirror( aRect );
+//        aMirroredRegion.Union( aRect );
+//		bRegionRect = rRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
+//	}
+//    rRegion = aMirroredRegion;
 }
 
 
@@ -1037,7 +1048,7 @@ void OutputDevice::ImplSetClipRegion( co
 	{
 		if ( mbClipRegion )
 		{
-			maRegion			= Region( REGION_NULL );
+			maRegion			= Region(true);
 			mbClipRegion		= sal_False;
 			mbInitClipRegion	= sal_True;
 		}
@@ -1072,13 +1083,14 @@ void OutputDevice::SetClipRegion( const 
 {
 	DBG_TRACE( "OutputDevice::SetClipRegion( rRegion )" );
 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
-	DBG_CHKOBJ( &rRegion, Region, ImplDbgTestRegion );
 
 	if ( mpMetaFile )
 		mpMetaFile->AddAction( new MetaClipRegionAction( rRegion, sal_True ) );
 
-	if ( rRegion.GetType() == REGION_NULL )
+	if ( rRegion.IsNull() )
+    {
 		ImplSetClipRegion( NULL );
+    }
 	else
 	{
 		Region aRegion = LogicToPixel( rRegion );
@@ -1106,7 +1118,7 @@ Region OutputDevice::GetActiveClipRegion
 
 	if ( GetOutDevType() == OUTDEV_WINDOW )
 	{
-		Region aRegion( REGION_NULL );
+		Region aRegion(true);
 		Window* pWindow = (Window*)this;
 		if ( pWindow->mpWindowImpl->mbInPaint )
 		{
@@ -1167,11 +1179,8 @@ void OutputDevice::IntersectClipRegion( 
 {
 	DBG_TRACE( "OutputDevice::IntersectClipRegion( rRegion )" );
 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
-	DBG_CHKOBJ( &rRegion, Region, ImplDbgTestRegion );
-
-	RegionType eType = rRegion.GetType();
 
-	if ( eType != REGION_NULL )
+	if(!rRegion.IsNull())
 	{
 		if ( mpMetaFile )
 			mpMetaFile->AddAction( new MetaISectRegionClipRegionAction( rRegion ) );

Modified: incubator/ooo/trunk/main/vcl/source/gdi/outdev2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/outdev2.cxx?rev=1401294&r1=1401293&r2=1401294&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/outdev2.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/outdev2.cxx Tue Oct 23 13:46:28 2012
@@ -45,7 +45,6 @@
 #include <image.h>
 #include <outdev.h>
 #include <window.h>
-#include <region.h>
 #include <outdata.hxx>
 
 #define BAND_MAX_SIZE 512000
@@ -2136,7 +2135,7 @@ void OutputDevice::ImplPrintTransparent(
 
 		// do painting
         const long		nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
-		long			nX, nY, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
+		long			nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
 		long*			pMapX = new long[ nSrcWidth + 1 ];
 		long*			pMapY = new long[ nSrcHeight + 1 ];
 		const sal_Bool		bOldMap = mbMap;
@@ -2151,21 +2150,37 @@ void OutputDevice::ImplPrintTransparent(
 			pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight );
     
         // walk through all rectangles of mask
-        Region          aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) );
-		ImplRegionInfo	aInfo;
-		sal_Bool            bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
-
-		while( bRgnRect )
-		{
-			Bitmap          aBandBmp( aPaint );
-            const Rectangle aBandRect( Point( nWorkX, nWorkY ), Size( nWorkWidth, nWorkHeight ) );
-            const Point     aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] );
-            const Size      aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() );
-			
-			aBandBmp.Crop( aBandRect );
-            ImplDrawBitmap( aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION );
-            bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
-		}
+        const Region aWorkRgn(aMask.CreateRegion(COL_BLACK, Rectangle(Point(), aMask.GetSizePixel())));
+        RectangleVector aRectangles;
+        aWorkRgn.GetRegionRectangles(aRectangles);
+
+        for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+        {
+            const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]);
+            const Size aMapSz(
+                pMapX[aRectIter->Right() + 1] - aMapPt.X(),      // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
+                pMapY[aRectIter->Bottom() + 1] - aMapPt.Y());    // same for Y
+            Bitmap aBandBmp(aPaint);
+
+            aBandBmp.Crop(*aRectIter);
+            ImplDrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION);
+        }
+
+        //Region          aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) );
+		//ImplRegionInfo	aInfo;
+		//sal_Bool            bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
+        //
+		//while( bRgnRect )
+		//{
+		//	Bitmap          aBandBmp( aPaint );
+        //    const Rectangle aBandRect( Point( nWorkX, nWorkY ), Size( nWorkWidth, nWorkHeight ) );
+        //    const Point     aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] );
+        //    const Size      aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() );
+		//	
+		//	aBandBmp.Crop( aBandRect );
+        //    ImplDrawBitmap( aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION );
+        //    bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
+		//}
 
         mbMap = bOldMap;
 
@@ -2221,7 +2236,7 @@ void OutputDevice::ImplPrintMask( const 
 
 		// do painting
         const long		nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
-		long			nX, nY, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
+		long			nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
 		long*			pMapX = new long[ nSrcWidth + 1 ];
 		long*			pMapY = new long[ nSrcHeight + 1 ];
         GDIMetaFile*    pOldMetaFile = mpMetaFile;
@@ -2243,18 +2258,32 @@ void OutputDevice::ImplPrintMask( const 
 			pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight );
     
         // walk through all rectangles of mask
-        Region          aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) );
-		ImplRegionInfo	aInfo;
-		sal_Bool            bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
+        const Region aWorkRgn(aMask.CreateRegion(COL_BLACK, Rectangle(Point(), aMask.GetSizePixel())));
+        RectangleVector aRectangles;
+        aWorkRgn.GetRegionRectangles(aRectangles);
 
-		while( bRgnRect )
-		{
-            const Point aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] );
-            const Size  aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() );
+        for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
+        {
+            const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]);
+            const Size aMapSz(
+                pMapX[aRectIter->Right() + 1] - aMapPt.X(),      // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
+                pMapY[aRectIter->Bottom() + 1] - aMapPt.Y());    // same for Y
 
-			DrawRect( Rectangle( aMapPt, aMapSz ) );
-			bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
-		}
+            DrawRect(Rectangle(aMapPt, aMapSz));
+        }
+
+        //Region          aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) );
+		//ImplRegionInfo	aInfo;
+		//sal_Bool            bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
+        //
+		//while( bRgnRect )
+		//{
+        //    const Point aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] );
+        //    const Size  aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() );
+        //
+		//	DrawRect( Rectangle( aMapPt, aMapSz ) );
+		//	bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight );
+		//}
 
 		Pop();
 		delete[] pMapX;