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/16 11:44:04 UTC

svn commit: r1398711 [2/4] - in /incubator/ooo/trunk/main: drawinglayer/ drawinglayer/inc/drawinglayer/attribute/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/inc/drawinglayer/primitive3d/ drawinglayer/inc/drawinglayer/processor2d/ drawingla...

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitive2d.cxx Tue Oct 16 09:44:02 2012
@@ -25,187 +25,13 @@
 #include "precompiled_drawinglayer.hxx"
 
 #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
-#include <drawinglayer/animation/animationtiming.hxx>
-#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
-#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
-#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
-#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
 #include <drawinglayer/primitive2d/cropprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
-
-//////////////////////////////////////////////////////////////////////////////
-// helper class for animated graphics
-
-#include <vcl/animate.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/virdev.hxx>
+#include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <vcl/svapp.hxx>
-#include <vcl/metaact.hxx>
-
-//////////////////////////////////////////////////////////////////////////////
-// includes for testing MetafilePrimitive2D::create2DDecomposition
-
-// this switch defines if the test code is included or not
-#undef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-
-#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-#include <vcl/gradient.hxx>
-#include <vcl/pngread.hxx>
-#include <vcl/lineinfo.hxx>
-#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-
-//////////////////////////////////////////////////////////////////////////////
-
-namespace
-{
-	struct animationStep
-	{
-		BitmapEx								maBitmapEx;
-		sal_uInt32								mnTime;
-	};
-
-	class animatedBitmapExPreparator
-	{
-		::Animation								maAnimation;
-		::std::vector< animationStep >			maSteps;
-
-		sal_uInt32 generateStepTime(sal_uInt32 nIndex) const;
-
-	public:
-		animatedBitmapExPreparator(const Graphic& rGraphic);
-
-		sal_uInt32 count() const { return maSteps.size(); }
-		sal_uInt32 loopCount() const { return (sal_uInt32)maAnimation.GetLoopCount(); }
-		sal_uInt32 stepTime(sal_uInt32 a) const { return maSteps[a].mnTime; }
-		const BitmapEx& stepBitmapEx(sal_uInt32 a) const { return maSteps[a].maBitmapEx; }
-	};
-
-	sal_uInt32 animatedBitmapExPreparator::generateStepTime(sal_uInt32 nIndex) const
-	{
-		const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(nIndex));
-		sal_uInt32 nWaitTime(rAnimBitmap.nWait * 10);
-
-		// #115934#
-		// Take care of special value for MultiPage TIFFs. ATM these shall just
-		// show their first page. Later we will offer some switching when object
-		// is selected.
-		if(ANIMATION_TIMEOUT_ON_CLICK == rAnimBitmap.nWait)
-		{
-			// ATM the huge value would block the timer, so
-			// use a long time to show first page (whole day)
-			nWaitTime = 100 * 60 * 60 * 24;
-		}
-
-		// Bad trap: There are animated gifs with no set WaitTime (!).
-		// In that case use a default value.
-		if(0L == nWaitTime)
-		{
-			nWaitTime = 100L;
-		}
-
-		return nWaitTime;
-	}
-
-	animatedBitmapExPreparator::animatedBitmapExPreparator(const Graphic& rGraphic)
-	:	maAnimation(rGraphic.GetAnimation())
-	{
-		OSL_ENSURE(GRAPHIC_BITMAP == rGraphic.GetType() && rGraphic.IsAnimated(), "animatedBitmapExPreparator: graphic is not animated (!)");
-
-		// #128539# secure access to Animation, looks like there exist animated GIFs out there
-		// with a step count of zero
-		if(maAnimation.Count())
-		{
-			VirtualDevice aVirtualDevice(*Application::GetDefaultDevice());
-			VirtualDevice aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L);
-
-			// Prepare VirtualDevices and their states
-			aVirtualDevice.EnableMapMode(sal_False);
-			aVirtualDeviceMask.EnableMapMode(sal_False);
-			aVirtualDevice.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
-			aVirtualDeviceMask.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
-			aVirtualDevice.Erase();
-			aVirtualDeviceMask.Erase();
-
-			for(sal_uInt16 a(0L); a < maAnimation.Count(); a++)
-			{
-				animationStep aNextStep;
-				aNextStep.mnTime = generateStepTime(a);
-	
-				// prepare step
-				const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(a));
-
-				switch(rAnimBitmap.eDisposal)
-				{
-					case DISPOSE_NOT:
-					{
-						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
-						Bitmap aMask = rAnimBitmap.aBmpEx.GetMask();
-
-						if(aMask.IsEmpty())
-						{
-							const Point aEmpty;
-							const Rectangle aRect(aEmpty, aVirtualDeviceMask.GetOutputSizePixel());
-							const Wallpaper aWallpaper(COL_BLACK);
-							aVirtualDeviceMask.DrawWallpaper(aRect, aWallpaper);
-						}
-						else
-						{
-							BitmapEx aExpandVisibilityMask = BitmapEx(aMask, aMask);
-							aVirtualDeviceMask.DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask);
-						}
-
-						break;
-					}
-					case DISPOSE_BACK:
-					{
-						// #i70772# react on no mask, for primitives, too.
-						const Bitmap aMask(rAnimBitmap.aBmpEx.GetMask());
-						const Bitmap aContent(rAnimBitmap.aBmpEx.GetBitmap());
-
-						aVirtualDeviceMask.Erase();
-						aVirtualDevice.DrawBitmap(rAnimBitmap.aPosPix, aContent);
-
-						if(aMask.IsEmpty())
-						{
-							const Rectangle aRect(rAnimBitmap.aPosPix, aContent.GetSizePixel());
-							aVirtualDeviceMask.SetFillColor(COL_BLACK);
-							aVirtualDeviceMask.SetLineColor();
-							aVirtualDeviceMask.DrawRect(aRect);
-						}
-						else
-						{
-							aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, aMask);
-						}
-
-						break;
-					}
-					case DISPOSE_FULL:
-					{
-						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
-						break;
-					}
-					case DISPOSE_PREVIOUS :
-					{
-						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
-						aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask());
-						break;
-					}
-				}
-			
-				// create BitmapEx
-				Bitmap aMainBitmap = aVirtualDevice.GetBitmap(Point(), aVirtualDevice.GetOutputSizePixel());
-				Bitmap aMaskBitmap = aVirtualDeviceMask.GetBitmap(Point(), aVirtualDeviceMask.GetOutputSizePixel());
-				aNextStep.maBitmapEx = BitmapEx(aMainBitmap, aMaskBitmap);
-
-				// add to vector
-				maSteps.push_back(aNextStep);
-			}
-		}
-	}
-} // end of anonymous namespace
+#include <vcl/outdev.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -225,8 +51,6 @@ namespace drawinglayer
 
 			if(255L != getGraphicAttr().GetTransparency())
 			{
-				Primitive2DReference xPrimitive;
-
                 // do not apply mirroring from GraphicAttr to the Metafile by calling
                 // GetTransformedGraphic, this will try to mirror the Metafile using Scale()
                 // at the Metafile. This again calls Scale at the single MetaFile actions,
@@ -262,556 +86,11 @@ namespace drawinglayer
                 const GraphicObject& rGraphicObject = getGraphicObject();
                 const Graphic aTransformedGraphic(rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr));
 
-                switch(aTransformedGraphic.GetType())
-				{
-					case GRAPHIC_BITMAP :
-					{
-                        if(aTransformedGraphic.IsAnimated())
-						{
-							// prepare animation data
-							animatedBitmapExPreparator aData(aTransformedGraphic);
-
-							if(aData.count())
-							{
-								// create sub-primitives for animated bitmap and the needed animation loop
-								animation::AnimationEntryLoop aAnimationLoop(aData.loopCount() ? aData.loopCount() : 0xffff);
-								Primitive2DSequence aBitmapPrimitives(aData.count());
-
-								for(sal_uInt32 a(0L); a < aData.count(); a++)
-								{
-                                    animation::AnimationEntryFixed aTime((double)aData.stepTime(a), (double)a / (double)aData.count());
-									aAnimationLoop.append(aTime);
-									const Primitive2DReference xRef(new BitmapPrimitive2D(aData.stepBitmapEx(a), aTransform));
-									aBitmapPrimitives[a] = xRef;
-								}
-
-								// prepare animation list
-								animation::AnimationEntryList aAnimationList;
-								aAnimationList.append(aAnimationLoop);
-
-								// create and add animated switch primitive
-								xPrimitive = Primitive2DReference(new AnimatedSwitchPrimitive2D(aAnimationList, aBitmapPrimitives, false));
-							}
-						}
-                        else if(aTransformedGraphic.getSvgData().get())
-                        {
-                            // embedded Svg fill, create embed transform
-                            const basegfx::B2DRange& rSvgRange(aTransformedGraphic.getSvgData()->getRange());
-
-                            if(basegfx::fTools::more(rSvgRange.getWidth(), 0.0) && basegfx::fTools::more(rSvgRange.getHeight(), 0.0))
-                            {
-                                // translate back to origin, scale to unit coordinates
-                                basegfx::B2DHomMatrix aEmbedSvg(
-                                    basegfx::tools::createTranslateB2DHomMatrix(
-                                        -rSvgRange.getMinX(),
-                                        -rSvgRange.getMinY()));
-
-                                aEmbedSvg.scale(
-                                    1.0 / rSvgRange.getWidth(),
-                                    1.0 / rSvgRange.getHeight());
-
-                                // apply created object transformation
-                                aEmbedSvg = aTransform * aEmbedSvg;
-
-                                // add Svg primitives embedded
-                                xPrimitive = new TransformPrimitive2D(
-                                    aEmbedSvg,
-                                    aTransformedGraphic.getSvgData()->getPrimitive2DSequence());
-                            }
-                        }
-						else
-						{
-							xPrimitive = Primitive2DReference(new BitmapPrimitive2D(aTransformedGraphic.GetBitmapEx(), aTransform));
-						}
-
-						break;
-					}
-
-					case GRAPHIC_GDIMETAFILE :
-					{
-#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-                        static bool bDoTest(false);
-
-                        if(bDoTest)
-                        {
-							// All this is/was test code for testing MetafilePrimitive2D::create2DDecomposition
-							// extensively. It may be needed again when diverse actions need debugging, so i leave 
-							// it in here, but take it out using USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE.
-							// Use it by compiling with the code, insert any DrawObject, convert to Metafile. The
-							// debugger will then stop here (when breakpoint set, of course). You may enter single 
-							// parts of actions and/or change to true what You want to check.
-                            GDIMetaFile aMtf;
-			                VirtualDevice aOut;
-        		            const basegfx::B2DRange aRange(getB2DRange(rViewInformation));
-                            const Rectangle aRectangle(
-                                basegfx::fround(aRange.getMinX()), basegfx::fround(aRange.getMinY()),
-                                basegfx::fround(aRange.getMaxX()), basegfx::fround(aRange.getMaxY()));
-                            const Point aOrigin(aRectangle.TopLeft());
-                            const Fraction aScaleX(aRectangle.getWidth());
-                            const Fraction aScaleY(aRectangle.getHeight());
-                            MapMode aMapMode(MAP_100TH_MM, aOrigin, aScaleX, aScaleY);
-
-                            Size aDummySize(2, 2);
-                            aOut.SetOutputSizePixel(aDummySize);
-			                aOut.EnableOutput(FALSE);
-			                aOut.SetMapMode(aMapMode);
-
-                            aMtf.Clear();
-			                aMtf.Record(&aOut);
-
-			                const Fraction aNeutralFraction(1, 1);
-			                const MapMode aRelativeMapMode(
-                                MAP_RELATIVE, 
-                                Point(-aRectangle.Left(), -aRectangle.Top()), 
-                                aNeutralFraction, aNeutralFraction);
-			                aOut.SetMapMode(aRelativeMapMode);
-
-                            if(false)
-                            {
-                                const sal_Int32 nHor(aRectangle.getWidth() / 4);
-                                const sal_Int32 nVer(aRectangle.getHeight() / 4);
-                                const Rectangle aCenteredRectangle(
-                                    aRectangle.Left() + nHor, aRectangle.Top() + nVer,
-                                    aRectangle.Right() - nHor, aRectangle.Bottom() - nVer);
-                                aOut.SetClipRegion(aCenteredRectangle);
-                            }
-
-                            if(false)
-                            {
-                                const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight());
-                                aOut.IntersectClipRegion(aRightRectangle);
-                            }
-
-                            if(false)
-                            {
-                                const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight());
-                                const Rectangle aBottomRectangle(aRectangle.LeftCenter(), aRectangle.BottomRight());
-                                Region aRegion(aRightRectangle);
-                                aRegion.Intersect(aBottomRectangle);
-                                aOut.IntersectClipRegion(aRegion);
-                            }
-
-                            if(false)
-                            {
-                                const sal_Int32 nHor(aRectangle.getWidth() / 10);
-                                const sal_Int32 nVer(aRectangle.getHeight() / 10);
-                                aOut.MoveClipRegion(nHor, nVer);
-                            }
-
-                            if(false)
-                            {
-                                Wallpaper aWallpaper(Color(COL_BLACK));
-                                aOut.DrawWallpaper(aRectangle, aWallpaper);
-                            }
+                aRetval = create2DDecompositionOfGraphic(
+                    aTransformedGraphic,
+                    aTransform);
 
-                            if(false)
-                            {
-                                Wallpaper aWallpaper(Gradient(GRADIENT_LINEAR, Color(COL_RED), Color(COL_GREEN)));
-                                aOut.DrawWallpaper(aRectangle, aWallpaper);
-                            }
-
-                            if(false)
-                            {
-            					SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
-                                vcl::PNGReader aPNGReader(aRead);
-		                        BitmapEx aBitmapEx(aPNGReader.Read());
-                                Wallpaper aWallpaper(aBitmapEx);
-                                aOut.DrawWallpaper(aRectangle, aWallpaper);
-                            }
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-								Color aColor(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0));
-
-								for(sal_uInt32 a(0); a < 5000; a++)
-								{
-									const Point aPoint(
-										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-
-									if(!(a % 3))
-									{
-										aColor = Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0));
-									}
-
-									aOut.DrawPixel(aPoint, aColor);
-								}
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor();
-
-								for(sal_uInt32 a(0); a < 5000; a++)
-								{
-									const Point aPoint(
-										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-									aOut.DrawPixel(aPoint);
-								}
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor();
-								
-								Point aStart(
-									aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-									aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-								Point aStop(
-									aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-									aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-		
-								LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0));
-								bool bUseLineInfo(false);
-
-								for(sal_uInt32 a(0); a < 20; a++)
-								{
-									if(!(a%6))
-									{
-										bUseLineInfo = !bUseLineInfo;
-									}
-
-									if(!(a%4))
-									{
-										aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-									}
-
-									if(a%3)
-									{
-										aStart = aStop;
-										aStop = Point(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-									}
-									else
-									{
-										aStart = Point(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-										aStop = Point(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-									}
-
-									if(bUseLineInfo)
-									{
-										aOut.DrawLine(aStart, aStop, aLineInfo);
-									}
-									else
-									{
-										aOut.DrawLine(aStart, aStop);
-									}
-								}
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawRect(aRectangle);
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-                                const sal_uInt32 nHor(aRectangle.getWidth() / 10);
-                                const sal_uInt32 nVer(aRectangle.getHeight() / 10);
-								aOut.DrawRect(aRectangle, nHor, nVer);
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawEllipse(aRectangle);
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawArc(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawPie(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
-							}
-
-                            if(false)
-                            {
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawChord(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-
-								for(sal_uInt32 b(0); b < 5; b++)
-								{
-									const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0)));
-									const bool bClose(basegfx::fround(rand() / 32767.0));
-									Polygon aPolygon(nCount + (bClose ? 1 : 0));
-
-									for(sal_uInt32 a(0); a < nCount; a++)
-									{
-										const Point aPoint(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-										aPolygon[a] = aPoint;
-									}
-
-									if(bClose)
-									{
-										aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
-									}
-
-									aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-									aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-
-									if(!(b%2))
-									{
-										const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0));
-										aOut.DrawPolyLine(aPolygon, aLineInfo);
-									}
-									else
-									{
-										aOut.DrawPolyLine(aPolygon);
-									}
-								}
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-
-								for(sal_uInt32 b(0); b < 5; b++)
-								{
-									const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0)));
-									const bool bClose(basegfx::fround(rand() / 32767.0));
-									Polygon aPolygon(nCount + (bClose ? 1 : 0));
-
-									for(sal_uInt32 a(0); a < nCount; a++)
-									{
-										const Point aPoint(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-										aPolygon[a] = aPoint;
-									}
-
-									if(bClose)
-									{
-										aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
-									}
-
-									aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-									aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-									aOut.DrawPolygon(aPolygon);
-								}
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-								PolyPolygon aPolyPolygon;
-
-								for(sal_uInt32 b(0); b < 3; b++)
-								{
-									const sal_uInt32 nCount(basegfx::fround(rand() * (6 / 32767.0)));
-									const bool bClose(basegfx::fround(rand() / 32767.0));
-									Polygon aPolygon(nCount + (bClose ? 1 : 0));
-
-									for(sal_uInt32 a(0); a < nCount; a++)
-									{
-										const Point aPoint(
-											aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
-											aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
-										aPolygon[a] = aPoint;
-									}
-
-									if(bClose)
-									{
-										aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
-									}
-
-									aPolyPolygon.Insert(aPolygon);
-								}
-								
-								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
-								aOut.DrawPolyPolygon(aPolyPolygon);
-							}
-
-                            if(false)
-                            {
-            					SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
-                                vcl::PNGReader aPNGReader(aRead);
-		                        BitmapEx aBitmapEx(aPNGReader.Read());
-								aOut.DrawBitmapEx(aRectangle.TopLeft(), aBitmapEx);
-							}
-
-                            if(false)
-                            {
-            					SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
-                                vcl::PNGReader aPNGReader(aRead);
-		                        BitmapEx aBitmapEx(aPNGReader.Read());
-								aOut.DrawBitmapEx(aRectangle.TopLeft(), aRectangle.GetSize(), aBitmapEx);
-							}
-
-                            if(false)
-                            {
-            					SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
-                                vcl::PNGReader aPNGReader(aRead);
-		                        BitmapEx aBitmapEx(aPNGReader.Read());
-								const Size aSizePixel(aBitmapEx.GetSizePixel());
-								aOut.DrawBitmapEx(
-									aRectangle.TopLeft(), 
-									aRectangle.GetSize(), 
-									Point(0, 0),
-									Size(aSizePixel.Width() /2, aSizePixel.Height() / 2),
-									aBitmapEx);
-							}
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-								const Point aPointA(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.3));
-								const Point aPointB(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.5));
-								const Point aPointC(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.7));
-                                const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8);
-                                
-                                const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8);
-                                Font aFont(aFontName, Size(0, 1000));
-                                aFont.SetAlign(ALIGN_BASELINE);
-                                aFont.SetColor(COL_RED);
-                                //sal_Int32* pDXArray = new sal_Int32[aText.Len()];
-
-                                aFont.SetOutline(true);
-                                aOut.SetFont(aFont);
-                                aOut.DrawText(aPointA, aText, 0, aText.Len());
-
-                                aFont.SetShadow(true);
-                                aOut.SetFont(aFont);
-                                aOut.DrawText(aPointB, aText, 0, aText.Len());
-
-                                aFont.SetRelief(RELIEF_EMBOSSED);
-                                aOut.SetFont(aFont);
-                                aOut.DrawText(aPointC, aText, 0, aText.Len());
-
-                                //delete pDXArray;
-                            }
-
-                            if(false)
-                            {
-                                const double fHor(aRectangle.getWidth());
-                                const double fVer(aRectangle.getHeight());
-								const Point aPointA(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.3));
-								const Point aPointB(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.5));
-								const Point aPointC(
-									aRectangle.Left() + basegfx::fround(fHor * 0.2), 
-									aRectangle.Top() + basegfx::fround(fVer * 0.7));
-                                const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8);
-                                
-                                const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8);
-                                Font aFont(aFontName, Size(0, 1000));
-                                aFont.SetAlign(ALIGN_BASELINE);
-                                aFont.SetColor(COL_RED);
-
-                                aOut.SetFont(aFont);
-								const sal_Int32 nWidth(aOut.GetTextWidth(aText, 0, aText.Len()));
-                                aOut.DrawText(aPointA, aText, 0, aText.Len());
-                                aOut.DrawTextLine(aPointA, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
-                                aOut.DrawTextLine(aPointB, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
-                                aOut.DrawTextLine(aPointC, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
-                            }
-
-                            aMtf.Stop();
-			                aMtf.WindStart();
-		                    aMtf.SetPrefMapMode(MapMode(MAP_100TH_MM));
-			                aMtf.SetPrefSize(Size(aRectangle.getWidth(), aRectangle.getHeight()));
-                            
-                            xPrimitive = Primitive2DReference(
-                                new MetafilePrimitive2D(
-                                    aTransform, 
-                                    aMtf));
-                        }
-                        else
-                        {
-#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-                            // create MetafilePrimitive2D
-                            const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile();
-      
-                            xPrimitive = Primitive2DReference(
-                                new MetafilePrimitive2D(
-                                    aTransform,
-                                    rMetafile));
-
-                            // #i100357# find out if clipping is needed for this primitive. Unfortunately,
-                            // there exist Metafiles who's content is bigger than the proposed PrefSize set
-                            // at them. This is an error, but we need to work around this
-                            const Size aMetaFilePrefSize(rMetafile.GetPrefSize());
-                            const Size aMetaFileRealSize(
-                                const_cast< GDIMetaFile& >(rMetafile).GetBoundRect(
-                                    *Application::GetDefaultDevice()).GetSize());
-
-                            if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth()
-                                || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight())
-                            {
-                                // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon
-                                const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1);
-                                basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon());
-                                aMaskPolygon.transform(aTransform);
-
-                                xPrimitive = Primitive2DReference(
-                                    new MaskPrimitive2D(
-                                        basegfx::B2DPolyPolygon(aMaskPolygon),
-                                        aChildContent));
-                            }
-#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-                        }
-#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
-
-						break;
-					}
-
-					default:
-					{
-						// nothing to create
-						break;
-					}
-				}
-
-                if(xPrimitive.is())
+                if(aRetval.getLength())
                 {
                     // check for cropping
                     if(getGraphicAttr().IsCropped())
@@ -851,17 +130,17 @@ namespace drawinglayer
                         }
 
                         // embed content in cropPrimitive
-                        xPrimitive = new CropPrimitive2D(
-                            Primitive2DSequence(&xPrimitive, 1),
-                            aTransform,
-                            getGraphicAttr().GetLeftCrop() * fFactorX,
-                            getGraphicAttr().GetTopCrop() * fFactorY,
-                            getGraphicAttr().GetRightCrop() * fFactorX,
-                            getGraphicAttr().GetBottomCrop() * fFactorY);
-                    }
+                        Primitive2DReference xPrimitive(
+                            new CropPrimitive2D(
+                                aRetval,
+                                aTransform,
+                                getGraphicAttr().GetLeftCrop() * fFactorX,
+                                getGraphicAttr().GetTopCrop() * fFactorY,
+                                getGraphicAttr().GetRightCrop() * fFactorX,
+                                getGraphicAttr().GetBottomCrop() * fFactorY));
 
-                    // add to decomposition
-                    appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xPrimitive);
+                        aRetval = Primitive2DSequence(&xPrimitive, 1);
+                    }
                 }
 			}
 

Added: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx?rev=1398711&view=auto
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx (added)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx Tue Oct 16 09:44:02 2012
@@ -0,0 +1,782 @@
+/**************************************************************
+ * 
+ * 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.
+ * 
+ *************************************************************/
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_drawinglayer.hxx"
+
+#include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// helper class for animated graphics
+
+#include <vcl/animate.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/metaact.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// includes for testing MetafilePrimitive2D::create2DDecomposition
+
+// this switch defines if the test code is included or not
+#undef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+
+#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+#include <vcl/gradient.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/lineinfo.hxx>
+#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+	struct animationStep
+	{
+		BitmapEx								maBitmapEx;
+		sal_uInt32								mnTime;
+	};
+
+	class animatedBitmapExPreparator
+	{
+		::Animation								maAnimation;
+		::std::vector< animationStep >			maSteps;
+
+		sal_uInt32 generateStepTime(sal_uInt32 nIndex) const;
+
+	public:
+		animatedBitmapExPreparator(const Graphic& rGraphic);
+
+		sal_uInt32 count() const { return maSteps.size(); }
+		sal_uInt32 loopCount() const { return (sal_uInt32)maAnimation.GetLoopCount(); }
+		sal_uInt32 stepTime(sal_uInt32 a) const { return maSteps[a].mnTime; }
+		const BitmapEx& stepBitmapEx(sal_uInt32 a) const { return maSteps[a].maBitmapEx; }
+	};
+
+	sal_uInt32 animatedBitmapExPreparator::generateStepTime(sal_uInt32 nIndex) const
+	{
+		const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(nIndex));
+		sal_uInt32 nWaitTime(rAnimBitmap.nWait * 10);
+
+		// #115934#
+		// Take care of special value for MultiPage TIFFs. ATM these shall just
+		// show their first page. Later we will offer some switching when object
+		// is selected.
+		if(ANIMATION_TIMEOUT_ON_CLICK == rAnimBitmap.nWait)
+		{
+			// ATM the huge value would block the timer, so
+			// use a long time to show first page (whole day)
+			nWaitTime = 100 * 60 * 60 * 24;
+		}
+
+		// Bad trap: There are animated gifs with no set WaitTime (!).
+		// In that case use a default value.
+		if(0L == nWaitTime)
+		{
+			nWaitTime = 100L;
+		}
+
+		return nWaitTime;
+	}
+
+	animatedBitmapExPreparator::animatedBitmapExPreparator(const Graphic& rGraphic)
+	:	maAnimation(rGraphic.GetAnimation())
+	{
+		OSL_ENSURE(GRAPHIC_BITMAP == rGraphic.GetType() && rGraphic.IsAnimated(), "animatedBitmapExPreparator: graphic is not animated (!)");
+
+		// #128539# secure access to Animation, looks like there exist animated GIFs out there
+		// with a step count of zero
+		if(maAnimation.Count())
+		{
+			VirtualDevice aVirtualDevice(*Application::GetDefaultDevice());
+			VirtualDevice aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L);
+
+			// Prepare VirtualDevices and their states
+			aVirtualDevice.EnableMapMode(sal_False);
+			aVirtualDeviceMask.EnableMapMode(sal_False);
+			aVirtualDevice.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
+			aVirtualDeviceMask.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
+			aVirtualDevice.Erase();
+			aVirtualDeviceMask.Erase();
+
+			for(sal_uInt16 a(0L); a < maAnimation.Count(); a++)
+			{
+				animationStep aNextStep;
+				aNextStep.mnTime = generateStepTime(a);
+	
+				// prepare step
+				const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(a));
+
+				switch(rAnimBitmap.eDisposal)
+				{
+					case DISPOSE_NOT:
+					{
+						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+						Bitmap aMask = rAnimBitmap.aBmpEx.GetMask();
+
+						if(aMask.IsEmpty())
+						{
+							const Point aEmpty;
+							const Rectangle aRect(aEmpty, aVirtualDeviceMask.GetOutputSizePixel());
+							const Wallpaper aWallpaper(COL_BLACK);
+							aVirtualDeviceMask.DrawWallpaper(aRect, aWallpaper);
+						}
+						else
+						{
+							BitmapEx aExpandVisibilityMask = BitmapEx(aMask, aMask);
+							aVirtualDeviceMask.DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask);
+						}
+
+						break;
+					}
+					case DISPOSE_BACK:
+					{
+						// #i70772# react on no mask, for primitives, too.
+						const Bitmap aMask(rAnimBitmap.aBmpEx.GetMask());
+						const Bitmap aContent(rAnimBitmap.aBmpEx.GetBitmap());
+
+						aVirtualDeviceMask.Erase();
+						aVirtualDevice.DrawBitmap(rAnimBitmap.aPosPix, aContent);
+
+						if(aMask.IsEmpty())
+						{
+							const Rectangle aRect(rAnimBitmap.aPosPix, aContent.GetSizePixel());
+							aVirtualDeviceMask.SetFillColor(COL_BLACK);
+							aVirtualDeviceMask.SetLineColor();
+							aVirtualDeviceMask.DrawRect(aRect);
+						}
+						else
+						{
+							aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, aMask);
+						}
+
+						break;
+					}
+					case DISPOSE_FULL:
+					{
+						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+						break;
+					}
+					case DISPOSE_PREVIOUS :
+					{
+						aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
+						aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask());
+						break;
+					}
+				}
+			
+				// create BitmapEx
+				Bitmap aMainBitmap = aVirtualDevice.GetBitmap(Point(), aVirtualDevice.GetOutputSizePixel());
+				Bitmap aMaskBitmap = aVirtualDeviceMask.GetBitmap(Point(), aVirtualDeviceMask.GetOutputSizePixel());
+				aNextStep.maBitmapEx = BitmapEx(aMainBitmap, aMaskBitmap);
+
+				// add to vector
+				maSteps.push_back(aNextStep);
+			}
+		}
+	}
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+	namespace primitive2d
+	{
+		Primitive2DSequence create2DDecompositionOfGraphic(
+            const Graphic& rGraphic,
+            const basegfx::B2DHomMatrix& rTransform)
+		{
+			Primitive2DSequence aRetval;
+
+            switch(rGraphic.GetType())
+			{
+				case GRAPHIC_BITMAP :
+				{
+                    if(rGraphic.IsAnimated())
+					{
+						// prepare animation data
+						animatedBitmapExPreparator aData(rGraphic);
+
+						if(aData.count())
+						{
+							// create sub-primitives for animated bitmap and the needed animation loop
+							animation::AnimationEntryLoop aAnimationLoop(aData.loopCount() ? aData.loopCount() : 0xffff);
+							Primitive2DSequence aBitmapPrimitives(aData.count());
+
+							for(sal_uInt32 a(0); a < aData.count(); a++)
+							{
+                                animation::AnimationEntryFixed aTime((double)aData.stepTime(a), (double)a / (double)aData.count());
+								aAnimationLoop.append(aTime);
+								aBitmapPrimitives[a] = new BitmapPrimitive2D(
+                                    aData.stepBitmapEx(a), 
+                                    rTransform);
+							}
+
+							// prepare animation list
+							animation::AnimationEntryList aAnimationList;
+							aAnimationList.append(aAnimationLoop);
+
+							// create and add animated switch primitive
+                            aRetval.realloc(1);
+							aRetval[0] = new AnimatedSwitchPrimitive2D(
+                                aAnimationList, 
+                                aBitmapPrimitives, 
+                                false);
+						}
+					}
+                    else if(rGraphic.getSvgData().get())
+                    {
+                        // embedded Svg fill, create embed transform
+                        const basegfx::B2DRange& rSvgRange(rGraphic.getSvgData()->getRange());
+
+                        if(basegfx::fTools::more(rSvgRange.getWidth(), 0.0) && basegfx::fTools::more(rSvgRange.getHeight(), 0.0))
+                        {
+                            // translate back to origin, scale to unit coordinates
+                            basegfx::B2DHomMatrix aEmbedSvg(
+                                basegfx::tools::createTranslateB2DHomMatrix(
+                                    -rSvgRange.getMinX(),
+                                    -rSvgRange.getMinY()));
+
+                            aEmbedSvg.scale(
+                                1.0 / rSvgRange.getWidth(),
+                                1.0 / rSvgRange.getHeight());
+
+                            // apply created object transformation
+                            aEmbedSvg = rTransform * aEmbedSvg;
+
+                            // add Svg primitives embedded
+                            aRetval.realloc(1);
+                            aRetval[0] = new TransformPrimitive2D(
+                                aEmbedSvg,
+                                rGraphic.getSvgData()->getPrimitive2DSequence());
+                        }
+                    }
+					else
+					{
+                        aRetval.realloc(1);
+						aRetval[0] = new BitmapPrimitive2D(
+                            rGraphic.GetBitmapEx(), 
+                            rTransform);
+					}
+
+					break;
+				}
+
+				case GRAPHIC_GDIMETAFILE :
+				{
+#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+                    static bool bDoTest(false);
+
+                    if(bDoTest)
+                    {
+						// All this is/was test code for testing MetafilePrimitive2D::create2DDecomposition
+						// extensively. It may be needed again when diverse actions need debugging, so i leave 
+						// it in here, but take it out using USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE.
+						// Use it by compiling with the code, insert any DrawObject, convert to Metafile. The
+						// debugger will then stop here (when breakpoint set, of course). You may enter single 
+						// parts of actions and/or change to true what You want to check.
+                        GDIMetaFile aMtf;
+			            VirtualDevice aOut;
+        		        const basegfx::B2DRange aRange(getB2DRange(rViewInformation));
+                        const Rectangle aRectangle(
+                            basegfx::fround(aRange.getMinX()), basegfx::fround(aRange.getMinY()),
+                            basegfx::fround(aRange.getMaxX()), basegfx::fround(aRange.getMaxY()));
+                        const Point aOrigin(aRectangle.TopLeft());
+                        const Fraction aScaleX(aRectangle.getWidth());
+                        const Fraction aScaleY(aRectangle.getHeight());
+                        MapMode aMapMode(MAP_100TH_MM, aOrigin, aScaleX, aScaleY);
+
+                        Size aDummySize(2, 2);
+                        aOut.SetOutputSizePixel(aDummySize);
+			            aOut.EnableOutput(FALSE);
+			            aOut.SetMapMode(aMapMode);
+
+                        aMtf.Clear();
+			            aMtf.Record(&aOut);
+
+			            const Fraction aNeutralFraction(1, 1);
+			            const MapMode aRelativeMapMode(
+                            MAP_RELATIVE, 
+                            Point(-aRectangle.Left(), -aRectangle.Top()), 
+                            aNeutralFraction, aNeutralFraction);
+			            aOut.SetMapMode(aRelativeMapMode);
+
+                        if(false)
+                        {
+                            const sal_Int32 nHor(aRectangle.getWidth() / 4);
+                            const sal_Int32 nVer(aRectangle.getHeight() / 4);
+                            const Rectangle aCenteredRectangle(
+                                aRectangle.Left() + nHor, aRectangle.Top() + nVer,
+                                aRectangle.Right() - nHor, aRectangle.Bottom() - nVer);
+                            aOut.SetClipRegion(aCenteredRectangle);
+                        }
+
+                        if(false)
+                        {
+                            const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight());
+                            aOut.IntersectClipRegion(aRightRectangle);
+                        }
+
+                        if(false)
+                        {
+                            const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight());
+                            const Rectangle aBottomRectangle(aRectangle.LeftCenter(), aRectangle.BottomRight());
+                            Region aRegion(aRightRectangle);
+                            aRegion.Intersect(aBottomRectangle);
+                            aOut.IntersectClipRegion(aRegion);
+                        }
+
+                        if(false)
+                        {
+                            const sal_Int32 nHor(aRectangle.getWidth() / 10);
+                            const sal_Int32 nVer(aRectangle.getHeight() / 10);
+                            aOut.MoveClipRegion(nHor, nVer);
+                        }
+
+                        if(false)
+                        {
+                            Wallpaper aWallpaper(Color(COL_BLACK));
+                            aOut.DrawWallpaper(aRectangle, aWallpaper);
+                        }
+
+                        if(false)
+                        {
+                            Wallpaper aWallpaper(Gradient(GRADIENT_LINEAR, Color(COL_RED), Color(COL_GREEN)));
+                            aOut.DrawWallpaper(aRectangle, aWallpaper);
+                        }
+
+                        if(false)
+                        {
+            				SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
+                            vcl::PNGReader aPNGReader(aRead);
+		                    BitmapEx aBitmapEx(aPNGReader.Read());
+                            Wallpaper aWallpaper(aBitmapEx);
+                            aOut.DrawWallpaper(aRectangle, aWallpaper);
+                        }
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+							Color aColor(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0));
+
+							for(sal_uInt32 a(0); a < 5000; a++)
+							{
+								const Point aPoint(
+									aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+									aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+
+								if(!(a % 3))
+								{
+									aColor = Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0));
+								}
+
+								aOut.DrawPixel(aPoint, aColor);
+							}
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor();
+
+							for(sal_uInt32 a(0); a < 5000; a++)
+							{
+								const Point aPoint(
+									aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+									aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+								aOut.DrawPixel(aPoint);
+							}
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor();
+								
+							Point aStart(
+								aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+								aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+							Point aStop(
+								aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+								aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+		
+							LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0));
+							bool bUseLineInfo(false);
+
+							for(sal_uInt32 a(0); a < 20; a++)
+							{
+								if(!(a%6))
+								{
+									bUseLineInfo = !bUseLineInfo;
+								}
+
+								if(!(a%4))
+								{
+									aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+								}
+
+								if(a%3)
+								{
+									aStart = aStop;
+									aStop = Point(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+								}
+								else
+								{
+									aStart = Point(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+									aStop = Point(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+								}
+
+								if(bUseLineInfo)
+								{
+									aOut.DrawLine(aStart, aStop, aLineInfo);
+								}
+								else
+								{
+									aOut.DrawLine(aStart, aStop);
+								}
+							}
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawRect(aRectangle);
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+                            const sal_uInt32 nHor(aRectangle.getWidth() / 10);
+                            const sal_uInt32 nVer(aRectangle.getHeight() / 10);
+							aOut.DrawRect(aRectangle, nHor, nVer);
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawEllipse(aRectangle);
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawArc(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawPie(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
+						}
+
+                        if(false)
+                        {
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawChord(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter());
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+
+							for(sal_uInt32 b(0); b < 5; b++)
+							{
+								const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0)));
+								const bool bClose(basegfx::fround(rand() / 32767.0));
+								Polygon aPolygon(nCount + (bClose ? 1 : 0));
+
+								for(sal_uInt32 a(0); a < nCount; a++)
+								{
+									const Point aPoint(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+									aPolygon[a] = aPoint;
+								}
+
+								if(bClose)
+								{
+									aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
+								}
+
+								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+
+								if(!(b%2))
+								{
+									const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0));
+									aOut.DrawPolyLine(aPolygon, aLineInfo);
+								}
+								else
+								{
+									aOut.DrawPolyLine(aPolygon);
+								}
+							}
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+
+							for(sal_uInt32 b(0); b < 5; b++)
+							{
+								const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0)));
+								const bool bClose(basegfx::fround(rand() / 32767.0));
+								Polygon aPolygon(nCount + (bClose ? 1 : 0));
+
+								for(sal_uInt32 a(0); a < nCount; a++)
+								{
+									const Point aPoint(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+									aPolygon[a] = aPoint;
+								}
+
+								if(bClose)
+								{
+									aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
+								}
+
+								aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+								aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+								aOut.DrawPolygon(aPolygon);
+							}
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+							PolyPolygon aPolyPolygon;
+
+							for(sal_uInt32 b(0); b < 3; b++)
+							{
+								const sal_uInt32 nCount(basegfx::fround(rand() * (6 / 32767.0)));
+								const bool bClose(basegfx::fround(rand() / 32767.0));
+								Polygon aPolygon(nCount + (bClose ? 1 : 0));
+
+								for(sal_uInt32 a(0); a < nCount; a++)
+								{
+									const Point aPoint(
+										aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), 
+										aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0)));
+									aPolygon[a] = aPoint;
+								}
+
+								if(bClose)
+								{
+									aPolygon[aPolygon.GetSize() - 1] = aPolygon[0];
+								}
+
+								aPolyPolygon.Insert(aPolygon);
+							}
+								
+							aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)));
+							aOut.DrawPolyPolygon(aPolyPolygon);
+						}
+
+                        if(false)
+                        {
+            				SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
+                            vcl::PNGReader aPNGReader(aRead);
+		                    BitmapEx aBitmapEx(aPNGReader.Read());
+							aOut.DrawBitmapEx(aRectangle.TopLeft(), aBitmapEx);
+						}
+
+                        if(false)
+                        {
+            				SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
+                            vcl::PNGReader aPNGReader(aRead);
+		                    BitmapEx aBitmapEx(aPNGReader.Read());
+							aOut.DrawBitmapEx(aRectangle.TopLeft(), aRectangle.GetSize(), aBitmapEx);
+						}
+
+                        if(false)
+                        {
+            				SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ);
+                            vcl::PNGReader aPNGReader(aRead);
+		                    BitmapEx aBitmapEx(aPNGReader.Read());
+							const Size aSizePixel(aBitmapEx.GetSizePixel());
+							aOut.DrawBitmapEx(
+								aRectangle.TopLeft(), 
+								aRectangle.GetSize(), 
+								Point(0, 0),
+								Size(aSizePixel.Width() /2, aSizePixel.Height() / 2),
+								aBitmapEx);
+						}
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+							const Point aPointA(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.3));
+							const Point aPointB(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.5));
+							const Point aPointC(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.7));
+                            const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8);
+                                
+                            const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8);
+                            Font aFont(aFontName, Size(0, 1000));
+                            aFont.SetAlign(ALIGN_BASELINE);
+                            aFont.SetColor(COL_RED);
+                            //sal_Int32* pDXArray = new sal_Int32[aText.Len()];
+
+                            aFont.SetOutline(true);
+                            aOut.SetFont(aFont);
+                            aOut.DrawText(aPointA, aText, 0, aText.Len());
+
+                            aFont.SetShadow(true);
+                            aOut.SetFont(aFont);
+                            aOut.DrawText(aPointB, aText, 0, aText.Len());
+
+                            aFont.SetRelief(RELIEF_EMBOSSED);
+                            aOut.SetFont(aFont);
+                            aOut.DrawText(aPointC, aText, 0, aText.Len());
+
+                            //delete pDXArray;
+                        }
+
+                        if(false)
+                        {
+                            const double fHor(aRectangle.getWidth());
+                            const double fVer(aRectangle.getHeight());
+							const Point aPointA(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.3));
+							const Point aPointB(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.5));
+							const Point aPointC(
+								aRectangle.Left() + basegfx::fround(fHor * 0.2), 
+								aRectangle.Top() + basegfx::fround(fVer * 0.7));
+                            const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8);
+                                
+                            const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8);
+                            Font aFont(aFontName, Size(0, 1000));
+                            aFont.SetAlign(ALIGN_BASELINE);
+                            aFont.SetColor(COL_RED);
+
+                            aOut.SetFont(aFont);
+							const sal_Int32 nWidth(aOut.GetTextWidth(aText, 0, aText.Len()));
+                            aOut.DrawText(aPointA, aText, 0, aText.Len());
+                            aOut.DrawTextLine(aPointA, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
+                            aOut.DrawTextLine(aPointB, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
+                            aOut.DrawTextLine(aPointC, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE);
+                        }
+
+                        aMtf.Stop();
+			            aMtf.WindStart();
+		                aMtf.SetPrefMapMode(MapMode(MAP_100TH_MM));
+			            aMtf.SetPrefSize(Size(aRectangle.getWidth(), aRectangle.getHeight()));
+                            
+                        aRetval.realloc(1);
+                        aRetval[0] = new MetafilePrimitive2D(
+                            rTransform, 
+                            aMtf);
+                    }
+                    else
+                    {
+#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+                        // create MetafilePrimitive2D
+                        const GDIMetaFile& rMetafile = rGraphic.GetGDIMetaFile();
+
+                        aRetval.realloc(1);
+                        aRetval[0] = new MetafilePrimitive2D(
+                            rTransform,
+                            rMetafile);
+
+                        // #i100357# find out if clipping is needed for this primitive. Unfortunately,
+                        // there exist Metafiles who's content is bigger than the proposed PrefSize set
+                        // at them. This is an error, but we need to work around this
+                        const Size aMetaFilePrefSize(rMetafile.GetPrefSize());
+                        const Size aMetaFileRealSize(
+                            const_cast< GDIMetaFile& >(rMetafile).GetBoundRect(
+                                *Application::GetDefaultDevice()).GetSize());
+
+                        if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth()
+                            || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight())
+                        {
+                            // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon
+                            basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon());
+                            aMaskPolygon.transform(rTransform);
+
+                            aRetval[0] = new MaskPrimitive2D(
+                                basegfx::B2DPolyPolygon(aMaskPolygon),
+                                aRetval);
+                        }
+#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+                    }
+#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE
+
+					break;
+				}
+
+				default:
+				{
+					// nothing to create
+					break;
+				}
+			}
+
+			return aRetval;
+		}
+	} // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

Propchange: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
------------------------------------------------------------------------------
    svn:executable = *

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=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx Tue Oct 16 09:44:02 2012
@@ -50,7 +50,7 @@
 #include <basegfx/polygon/b2dpolygonclipper.hxx>
 #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
-#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
 #include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx>
 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx Tue Oct 16 09:44:02 2012
@@ -57,7 +57,8 @@ namespace drawinglayer
                     {
                         // create tiling matrices
                         ::std::vector< basegfx::B2DHomMatrix > aMatrices;
-                        texture::GeoTexSvxTiled aTiling(getReferenceRange().getMinimum(), getReferenceRange().getRange());
+                        texture::GeoTexSvxTiled aTiling(getReferenceRange());
+                        
                         aTiling.appendTransformations(aMatrices);
 
                         // check if content needs to be clipped

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx Tue Oct 16 09:44:02 2012
@@ -31,9 +31,11 @@
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
-#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <vcl/graph.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -510,56 +512,69 @@ namespace drawinglayer
 {
 	namespace primitive2d
 	{
-		Primitive2DSequence PolyPolygonBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+		Primitive2DSequence PolyPolygonGraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
 		{
-            if(!getFillBitmap().isDefault())
+            if(!getFillGraphic().isDefault())
             {
-			    // create SubSequence with FillBitmapPrimitive2D
-			    const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
-			    basegfx::B2DHomMatrix aNewObjectTransform;
-			    aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
-			    aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
-			    aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
-			    aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
-			    FillBitmapPrimitive2D* pNewBitmap = new FillBitmapPrimitive2D(aNewObjectTransform, getFillBitmap());
-			    const Primitive2DReference xSubRef(pNewBitmap);
-			    const Primitive2DSequence aSubSequence(&xSubRef, 1L);
+                const Graphic& rGraphic = getFillGraphic().getGraphic();
+                const GraphicType aType(rGraphic.GetType());
 
-			    // create mask primitive
-			    MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
-			    const Primitive2DReference xRef(pNewMask);
-			 
-                return Primitive2DSequence(&xRef, 1);
-            }
-            else
-            {
-                return Primitive2DSequence();
+                // is there a bitmap or a metafile (do we have content)?
+                if(GRAPHIC_BITMAP == aType || GRAPHIC_GDIMETAFILE == aType)
+                {
+                    const Size aPrefSize(rGraphic.GetPrefSize());
+
+                    // does content have a size?
+                    if(aPrefSize.Width() && aPrefSize.Height())
+                    {
+                        // create SubSequence with FillGraphicPrimitive2D based on polygon range
+                        const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
+                        const basegfx::B2DHomMatrix aNewObjectTransform(
+                            basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                aPolyPolygonRange.getRange(),
+                                aPolyPolygonRange.getMinimum()));
+                        const Primitive2DReference xSubRef(
+                            new FillGraphicPrimitive2D(
+                                aNewObjectTransform, 
+                                getFillGraphic()));
+
+                        // embed to mask primitive
+                        const Primitive2DReference xRef(
+                            new MaskPrimitive2D(
+                                getB2DPolyPolygon(), 
+                                Primitive2DSequence(&xSubRef, 1)));
+
+                        return Primitive2DSequence(&xRef, 1);
+                    }
+                }
             }
+
+            return Primitive2DSequence();
 		}
 
-		PolyPolygonBitmapPrimitive2D::PolyPolygonBitmapPrimitive2D(
+		PolyPolygonGraphicPrimitive2D::PolyPolygonGraphicPrimitive2D(
 			const basegfx::B2DPolyPolygon& rPolyPolygon, 
-			const attribute::FillBitmapAttribute& rFillBitmap)
+			const attribute::FillGraphicAttribute& rFillGraphic)
 		:	BufferedDecompositionPrimitive2D(),
 			maPolyPolygon(rPolyPolygon),
-			maFillBitmap(rFillBitmap)
+			maFillGraphic(rFillGraphic)
 		{
 		}
 
-		bool PolyPolygonBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+		bool PolyPolygonGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
 		{
 			if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
 			{
-				const PolyPolygonBitmapPrimitive2D& rCompare = (PolyPolygonBitmapPrimitive2D&)rPrimitive;
+				const PolyPolygonGraphicPrimitive2D& rCompare = (PolyPolygonGraphicPrimitive2D&)rPrimitive;
 				
-				return (getFillBitmap() == rCompare.getFillBitmap());
+				return (getFillGraphic() == rCompare.getFillGraphic());
 			}
 
 			return false;
 		}
 
 		// provide unique ID
-		ImplPrimitrive2DIDBlock(PolyPolygonBitmapPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D)
+		ImplPrimitrive2DIDBlock(PolyPolygonGraphicPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D)
 
 	} // end of namespace primitive2d
 } // end of namespace drawinglayer

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx Tue Oct 16 09:44:02 2012
@@ -27,10 +27,12 @@
 #include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx>
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
-#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <vcl/graph.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -182,26 +184,23 @@ namespace drawinglayer
 								aRelativeTopLeft.setY(0.5 - aRelativeSize.getY());
 							}
 
-							// prepare FillBitmapAttribute
-							const attribute::FillBitmapAttribute aFillBitmapAttribute(
-								getBitmapEx(),
-								aRelativeTopLeft,
-								aRelativeSize,
+							// prepare FillGraphicAttribute
+							const attribute::FillGraphicAttribute aFillGraphicAttribute(
+								Graphic(getBitmapEx()),
+								basegfx::B2DRange(aRelativeTopLeft, aRelativeTopLeft+ aRelativeSize),
 								true);
 
 							// create ObjectTransform
-							basegfx::B2DHomMatrix aObjectTransform;
-							
-							aObjectTransform.set(0, 0, getLocalObjectRange().getWidth());
-							aObjectTransform.set(1, 1, getLocalObjectRange().getHeight());
-							aObjectTransform.set(0, 2, getLocalObjectRange().getMinX());
-							aObjectTransform.set(1, 2, getLocalObjectRange().getMinY());
+							const basegfx::B2DHomMatrix aObjectTransform(
+                                basegfx::tools::createScaleTranslateB2DHomMatrix(
+                                    getLocalObjectRange().getRange(),
+                                    getLocalObjectRange().getMinimum()));
 				            
 							// create FillBitmapPrimitive
 							const drawinglayer::primitive2d::Primitive2DReference xFillBitmap(
-								new drawinglayer::primitive2d::FillBitmapPrimitive2D(
+								new drawinglayer::primitive2d::FillGraphicPrimitive2D(
 									aObjectTransform,
-									aFillBitmapAttribute));
+									aFillGraphicAttribute));
 							aRetval = Primitive2DSequence(&xFillBitmap, 1);
 
 							// always embed tiled fill to clipping

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx Tue Oct 16 09:44:02 2012
@@ -32,8 +32,8 @@
 #include <basegfx/polygon/b3dpolypolygon.hxx>
 #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
 #include <vcl/vclenum.hxx>
-#include <drawinglayer/attribute/fillbitmapattribute.hxx>
-#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <drawinglayer/attribute/fillgraphicattribute.hxx>
+#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
 #include <vcl/bmpacc.hxx>
 #include <basegfx/polygon/b3dpolypolygontools.hxx>
 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
@@ -208,7 +208,7 @@ namespace drawinglayer
 				// look for and evtl. build texture sub-group primitive
 				if(!rFill.getGradient().isDefault() 
 					|| !rFill.getHatch().isDefault() 
-					|| !rFill.getBitmap().isDefault())
+					|| !rFill.getFillGraphic().isDefault())
 				{
 					bool bModulate(::com::sun::star::drawing::TextureMode_MODULATE == aSdr3DObjectAttribute.getTextureMode());
 					bool bFilter(aSdr3DObjectAttribute.getTextureFilter());
@@ -234,13 +234,13 @@ namespace drawinglayer
                             bModulate, 
                             bFilter);
 					}
-					else // if(!rFill.getBitmap().isDefault())
+					else // if(!rFill.getFillGraphic().isDefault())
 					{
 						// create bitmapTexture3D with sublist, add to local aRetval
-						basegfx::B2DRange aTexRange(0.0, 0.0, rTextureSize.getX(), rTextureSize.getY());
+						const basegfx::B2DRange aTexRange(0.0, 0.0, rTextureSize.getX(), rTextureSize.getY());
 						
                         pNewTexturePrimitive3D = new BitmapTexturePrimitive3D(
-                            rFill.getBitmap().getFillBitmapAttribute(aTexRange), 
+                            rFill.getFillGraphic().createFillGraphicAttribute(aTexRange), 
                             aRetval, 
                             rTextureSize, 
                             bModulate, 
@@ -313,7 +313,7 @@ namespace drawinglayer
                 basegfx::BColor(),
                 attribute::FillGradientAttribute(),
                 attribute::FillHatchAttribute(), 
-                attribute::SdrFillBitmapAttribute());
+                attribute::SdrFillGraphicAttribute());
 			
             const Primitive3DReference aHidden(
                 new HiddenGeometryPrimitive3D(

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive3d/textureprimitive3d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive3d/textureprimitive3d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive3d/textureprimitive3d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive3d/textureprimitive3d.cxx Tue Oct 16 09:44:02 2012
@@ -167,12 +167,12 @@ namespace drawinglayer
 	namespace primitive3d
 	{
 		BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
-			const attribute::FillBitmapAttribute& rFillBitmapAttribute, 
+			const attribute::FillGraphicAttribute& rFillGraphicAttribute, 
 			const Primitive3DSequence& rChildren, 
 			const basegfx::B2DVector& rTextureSize, 
 			bool bModulate, bool bFilter)
 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
-			maFillBitmapAttribute(rFillBitmapAttribute)
+			maFillGraphicAttribute(rFillGraphicAttribute)
 		{
 		}
 
@@ -182,7 +182,7 @@ namespace drawinglayer
 			{
 				const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive;
 
-				return (getFillBitmapAttribute() == rCompare.getFillBitmapAttribute());
+				return (getFillGraphicAttribute() == rCompare.getFillGraphicAttribute());
 			}
 
 			return false;