incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1339213 [9/11] - in /incubator/ooo/branches/alg/aw080: ./ ext_sources/ extras/l10n/source/en-GB/ extras/l10n/source/pt-BR/ extras/l10n/source/zh-CN/ extras/l10n/source/zh-TW/ main/ main/apache-commons/java/codec/ main/apache-commons/java/h...
Date Wed, 16 May 2012 15:07:08 GMT
Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.cxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.cxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.cxx Wed May 16 15:07:00 2012
@@ -54,8 +54,7 @@
 #include <svx/svdmodel.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdobj.hxx>
-#include <editeng/editdata.hxx>
-#include <svx/svditext.hxx>
+#include "svx/svditext.hxx"
 #include <svx/svdotext.hxx>
 #include <svx/svdorect.hxx>
 #include <svx/svdocirc.hxx>
@@ -69,97 +68,68 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <svx/xlinjoit.hxx>
 #include <svx/xlndsit.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xfltrit.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/svdpntv.hxx>
 #include <svx/svdlegacy.hxx>
 #include <svx/svdtrans.hxx>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(SdrModel& rModel):
-	nMapScalingOfs(0),
-	pLineAttr(NULL),
-	pFillAttr(NULL),
-	pTextAttr(NULL),
-	pPage(NULL),
-	mrModel(rModel),
-	nLayer(0),
-	nLineWidth(0),
+ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
+    SdrModel& rModel, 
+    SdrLayerID nLay, 
+    const basegfx::B2DHomMatrix& rObjectTransform)
+:   maTmpList(),
+    maVD(),
+    maObjectTransform(rObjectTransform),
+    maMetaToUnit(),
+    maCurrent(),
+	mpLineAttr(0),
+    mpFillAttr(0),
+    mpTextAttr(0),
+    mrModel(rModel),
+    mnLayer(nLay),
+    maOldLineColor(),
+	mnLineWidth(0),
 	maLineJoin(basegfx::B2DLINEJOIN_NONE),
 	maLineCap(com::sun::star::drawing::LineCap_BUTT),
 	maDash(XDASH_RECT, 0, 0, 0, 0, 0),
-	bFntDirty(sal_True),
-	bLastObjWasPolyWithoutLine(sal_False),bNoLine(sal_False),bNoFill(sal_False),bLastObjWasLine(sal_False)
-{
-	aVD.EnableOutput(sal_False);
-
-    // #i111954# init to no fill and no line initially
-    aVD.SetLineColor();
-    aVD.SetFillColor();
-
-	aOldLineColor.SetRed( aVD.GetLineColor().GetRed() + 1 ); // invalidate old line color
-	pLineAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_LINE_FIRST,XATTR_LINE_LAST);
-	pFillAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
-	pTextAttr=new SfxItemSet(rModel.GetItemPool(),EE_ITEMS_START,EE_ITEMS_END);
+    maClip(),
+	mbFntDirty(true),
+	mbLastObjWasPolyWithoutLine(false),
+    mbNoLine(false),
+    mbNoFill(false),
+    mbLastObjWasLine(false)
+{
+	maVD.EnableOutput(false);
+    maVD.SetLineColor();
+    maVD.SetFillColor();
+	maOldLineColor.SetRed(maVD.GetLineColor().GetRed() + 1);
+	mpLineAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_LINE_FIRST, XATTR_LINE_LAST, 0, 0);
+	mpFillAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
+	mpTextAttr = new SfxItemSet(rModel.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END, 0, 0);
+    checkClip();
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
 {
-	delete pLineAttr;
-	delete pFillAttr;
-	delete pTextAttr;
+	delete mpLineAttr;
+	delete mpFillAttr;
+	delete mpTextAttr;
 }
 
-sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
-	SdrObjList& rOL,
-	sal_uInt32 nInsPos,
-	SvdProgressInfo *pProgrInfo)
-{
-	pPage = rOL.getSdrPageFromSdrObjList();
-	GDIMetaFile* pTmpMtf=NULL;
-	GDIMetaFile* pMtf = (GDIMetaFile*) &rMtf;
-	sal_uInt32 nActionAnz=pMtf->GetActionCount();
-	bool bError = false;
-
-	// setup some global scale parameter
-	// fScaleX, fScaleY, aScaleX, aScaleY, bMov, bSize
-    fScaleX = fScaleY = 1.0;
-	Size  aMtfSize( pMtf->GetPrefSize() );
-	if ( aMtfSize.Width() & aMtfSize.Height() && ( aScaleRect.IsEmpty() == false ) )
-    {
-		aOfs = aScaleRect.TopLeft();
-        if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
-            fScaleX = (double)( aScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
-        if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
-            fScaleY = (double)( aScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
-    }
-
-	bMov = aOfs.X()!=0 || aOfs.Y()!=0;
-    bSize = false;
-
-	aScaleX = Fraction( 1, 1 );
-	aScaleY = Fraction( 1, 1 );
-    if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
-    {
-        aScaleX = Fraction( aScaleRect.GetWidth() - 1, aMtfSize.Width() );
-        bSize = true;
-    }
-    if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
-    {
-        aScaleY = Fraction( aScaleRect.GetHeight() - 1, aMtfSize.Height() );
-        bSize = true;
-    }
-
-	if(65000 < nActionAnz)
-	{
-		nActionAnz = 65000;
-		bError = sal_True;
-	}
-
-	if(pProgrInfo)
-		pProgrInfo->SetActionCount(nActionAnz);
-
-	sal_uInt32 nActionsToReport = 0;
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
-	for( MetaAction* pAct = pMtf->FirstAction(); pAct; pAct = pMtf->NextAction() )
+void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
+{
+	for( MetaAction* pAct = rMtf.FirstAction(); pAct; pAct = rMtf.NextAction() )
 	{
 		switch (pAct->GetType())
 		{
@@ -197,357 +167,519 @@ sal_uInt32 ImpSdrGDIMetaFileImport::DoIm
 			case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
 			case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
 			case META_HATCH_ACTION			: DoAction((MetaHatchAction          &)*pAct); break;
-			case META_COMMENT_ACTION		: DoAction((MetaCommentAction        &)*pAct, pMtf); break;
-		}
+			case META_COMMENT_ACTION		: DoAction((MetaCommentAction        &)*pAct, &rMtf); break;
 
-		if(pProgrInfo != NULL)
-		{
-            nActionsToReport++;
-            if(nActionsToReport >= 16) // Alle 16 Action updaten
+            // missing actions added
+            case META_TEXTRECT_ACTION       : DoAction((MetaTextRectAction&)*pAct); break;
+            case META_BMPSCALEPART_ACTION   : DoAction((MetaBmpScalePartAction&)*pAct); break;
+            case META_BMPEXSCALEPART_ACTION : DoAction((MetaBmpExScalePartAction&)*pAct); break;
+            case META_MASK_ACTION           : DoAction((MetaMaskAction&)*pAct); break;
+            case META_MASKSCALE_ACTION      : DoAction((MetaMaskScaleAction&)*pAct); break;
+            case META_MASKSCALEPART_ACTION  : DoAction((MetaMaskScalePartAction&)*pAct); break;
+            case META_GRADIENT_ACTION       : DoAction((MetaGradientAction&)*pAct); break;
+            case META_WALLPAPER_ACTION      : DoAction((MetaWallpaperAction&)*pAct); break;
+            case META_TRANSPARENT_ACTION    : DoAction((MetaTransparentAction&)*pAct); break;
+            case META_EPS_ACTION            : DoAction((MetaEPSAction&)*pAct); break;
+            case META_REFPOINT_ACTION       : DoAction((MetaRefPointAction&)*pAct); break;
+            case META_TEXTLINECOLOR_ACTION  : DoAction((MetaTextLineColorAction&)*pAct); break;
+            case META_TEXTLINE_ACTION       : DoAction((MetaTextLineAction&)*pAct); break;
+            case META_FLOATTRANSPARENT_ACTION : DoAction((MetaFloatTransparentAction&)*pAct); break;
+            case META_GRADIENTEX_ACTION     : DoAction((MetaGradientExAction&)*pAct); break;
+            case META_LAYOUTMODE_ACTION     : DoAction((MetaLayoutModeAction&)*pAct); break;
+            case META_TEXTLANGUAGE_ACTION   : DoAction((MetaTextLanguageAction&)*pAct); break;
+            case META_OVERLINECOLOR_ACTION  : DoAction((MetaOverlineColorAction&)*pAct); break;
+		}
+
+		if(pProgrInfo && pActionsToReport)
+		{
+            (*pActionsToReport)++;
+            
+            if(*pActionsToReport >= 16) // Alle 16 Action updaten
             {
-                if(!pProgrInfo->ReportActions(nActionsToReport))
+                if(!pProgrInfo->ReportActions(*pActionsToReport))
                     break;
-                nActionsToReport = 0;
+
+                *pActionsToReport = 0;
             }
 		}
 	}
+}
 
-	if(pProgrInfo != NULL)
-	{
-		pProgrInfo->ReportActions(nActionsToReport);
-		nActionsToReport = 0;
-	}
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
-	// MapMode-Scaling  vornehmen
-	MapScaling();
-	// Objekte in vorgegebenes Rechteck hineinskalieren
-	sal_uInt32 nAnz=aTmpList.GetObjCount();
+sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(
+    const GDIMetaFile& rMtf,
+	SdrObjList& rOL,
+	sal_uInt32 nInsPos,
+	SvdProgressInfo* pProgrInfo)
+{
+    const sal_uInt32 nActionCount(rMtf.GetActionCount());
 
-	// Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
-	// Da in aTmpList allerdings weniger eintraege als GetActionCount()
-	// existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
-	// hinzugefuegt werden.
-	nActionsToReport = (pMtf->GetActionCount() - nAnz)*2;
+    if(nActionCount)
+    {
+        // create mapping from MetaFile coordinates to unit coordinates
+        maMetaToUnit.identity();
+        maMetaToUnit.translate(-rMtf.GetPrefMapMode().GetOrigin().X(), -rMtf.GetPrefMapMode().GetOrigin().X());
+        maMetaToUnit.scale(
+            rMtf.GetPrefSize().Width() ? 1.0 / rMtf.GetPrefSize().Width() : 1.0, 
+            rMtf.GetPrefSize().Height() ? 1.0 / rMtf.GetPrefSize().Height() : 1.0);
+
+        // create full mapping; first to unit coordinates, then apply object transformation
+        maCurrent = maObjectTransform * maMetaToUnit;
+    
+	    if(pProgrInfo)
+        {
+		    pProgrInfo->SetActionCount(nActionCount);
+        }
 
+	    sal_uInt32 nActionsToReport(0);
 
-	// Alle noch nicht gemeldeten Rescales melden
-	if(pProgrInfo)
-	{
-		pProgrInfo->ReportRescales(nActionsToReport);
-		pProgrInfo->SetInsertCount(nAnz);
-	}
-	nActionsToReport = 0;
+        // execute
+        DoLoopActions(const_cast< GDIMetaFile& >(rMtf), pProgrInfo, &nActionsToReport);
+    
+        if(pProgrInfo)
+	    {
+		    pProgrInfo->ReportActions(nActionsToReport);
+		    nActionsToReport = 0;
+	    }
 
-	// alle in aTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
-	if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
+	    // Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
+	    // Da in maTmpList allerdings weniger eintraege als GetActionCount()
+	    // existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
+	    // hinzugefuegt werden.
+	    nActionsToReport = (rMtf.GetActionCount() - maTmpList.size()) * 2;
 
-	for (sal_uInt32 i=0; i<nAnz; i++)
-	{
-		 SdrObject* pObj=aTmpList.GetObj(i);
-		 rOL.InsertObjectToSdrObjList(*pObj, nInsPos);
-		 nInsPos++;
+	    // Alle noch nicht gemeldeten Rescales melden
+	    if(pProgrInfo)
+	    {
+		    pProgrInfo->ReportRescales(nActionsToReport);
+		    pProgrInfo->SetInsertCount(maTmpList.size());
+	    }
 
-		if(pProgrInfo != NULL)
-		{
-			nActionsToReport++;
-			if(nActionsToReport >= 32) // Alle 32 Action updaten
-			{
-				pProgrInfo->ReportInserts(nActionsToReport);
-				nActionsToReport = 0;
-			}
-		}
-	}
-	if (pTmpMtf!=NULL) delete pTmpMtf;
+        nActionsToReport = 0;
 
-	// ein letztesmal alle verbliebennen Inserts reporten
-	if(pProgrInfo != NULL)
-	{
-		pProgrInfo->ReportInserts(nActionsToReport);
-		if(bError)
-			pProgrInfo->ReportError();
-	}
+	    // alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
+	    if(nInsPos > rOL.GetObjCount()) 
+        {
+            nInsPos = rOL.GetObjCount();
+        }
+
+	    for(sal_uInt32 i(0); i < maTmpList.size(); i++)
+	    {
+		    SdrObject* pObj = maTmpList[i];
+		    rOL.InsertObjectToSdrObjList(*pObj, nInsPos);
+		    nInsPos++;
+
+		    if(pProgrInfo)
+		    {
+			    nActionsToReport++;
+
+                if(nActionsToReport >= 32) // Alle 32 Action updaten
+			    {
+				    pProgrInfo->ReportInserts(nActionsToReport);
+				    nActionsToReport = 0;
+			    }
+		    }
+	    }
 
-	return aTmpList.GetObjCount();
+	    // ein letztesmal alle verbliebennen Inserts reporten
+	    if(pProgrInfo)
+	    {
+		    pProgrInfo->ReportInserts(nActionsToReport);
+	    }
+
+    }
+	return maTmpList.size();
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
 {
-	bNoLine = sal_False; bNoFill = sal_False;
-	bool bLine=sal_True && !bForceTextAttr;
-	bool bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr );
-	bool bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL);
+	mbNoLine = false; 
+    mbNoFill = false;
+	bool bLine(!bForceTextAttr);
+	bool bFill(!pObj || (pObj->IsClosedObj() && !bForceTextAttr));
+	bool bText(bForceTextAttr || (pObj && pObj->GetOutlinerParaObject()));
 
-	if ( bLine )
+	if(bLine)
 	{
-		if ( nLineWidth )
-			pLineAttr->Put( XLineWidthItem( nLineWidth ) );
+		if(mnLineWidth)
+        {
+			mpLineAttr->Put(XLineWidthItem(mnLineWidth));
+        }
         else
-			pLineAttr->Put( XLineWidthItem( 0 ) );
+        {
+			mpLineAttr->Put(XLineWidthItem(0));
+        }
+
+		maOldLineColor = maVD.GetLineColor();
 
-		aOldLineColor = aVD.GetLineColor();
-		if( aVD.IsLineColor() )
+        if(maVD.IsLineColor())
 		{
-			pLineAttr->Put(XLineStyleItem(XLINE_SOLID));
-			pLineAttr->Put(XLineColorItem(String(), aVD.GetLineColor()));
+			mpLineAttr->Put(XLineStyleItem(XLINE_SOLID));
+			mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor()));
 		}
 		else
-			pLineAttr->Put(XLineStyleItem(XLINE_NONE));
+        {
+			mpLineAttr->Put(XLineStyleItem(XLINE_NONE));
+        }
 
 		switch(maLineJoin)
 		{
 			default : // basegfx::B2DLINEJOIN_NONE
-				pLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
+				mpLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
 				break;
 			case basegfx::B2DLINEJOIN_MIDDLE:
-				pLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
+				mpLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
 				break;
 			case basegfx::B2DLINEJOIN_BEVEL:
-				pLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
+				mpLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
 				break;
 			case basegfx::B2DLINEJOIN_MITER:
-				pLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
+				mpLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
 				break;
 			case basegfx::B2DLINEJOIN_ROUND:
-				pLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
+				mpLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
 				break;
 		}
 
         // Add LineCap support
-        pLineAttr->Put(XLineCapItem(maLineCap));
+        mpLineAttr->Put(XLineCapItem(maLineCap));
 
 		if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
 		{
-			pLineAttr->Put(XLineDashItem(String(), maDash));
+			mpLineAttr->Put(XLineDashItem(String(), maDash));
 		}
         else
         {
-			pLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
+			mpLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
         }
 	}
 	else
-		bNoLine = sal_True;
+    {
+		mbNoLine = true;
+    }
 
-	if ( bFill )
+	if(bFill)
 	{
-		if( aVD.IsFillColor() )
+		if(maVD.IsFillColor())
 		{
-			pFillAttr->Put(XFillStyleItem(XFILL_SOLID));
-			pFillAttr->Put(XFillColorItem(String(), aVD.GetFillColor()));
+			mpFillAttr->Put(XFillStyleItem(XFILL_SOLID));
+			mpFillAttr->Put(XFillColorItem(String(), maVD.GetFillColor()));
 		}
 		else
-			pFillAttr->Put(XFillStyleItem(XFILL_NONE));
+        {
+			mpFillAttr->Put(XFillStyleItem(XFILL_NONE));
+        }
 	}
 	else
-		bNoFill = sal_True;
+    {
+		mbNoFill = true;
+    }
 
-	if ( bText && bFntDirty )
+	if(bText && mbFntDirty)
 	{
-		Font aFnt(aVD.GetFont());
-		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
-							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
-		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
-							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
-		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
-							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
-        pTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
-        pTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
-		sal_uInt32 nHeight = FRound(aFnt.GetSize().Height() * fScaleY);
-		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
-		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
-		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
-        pTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
-        pTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
-        pTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
-        pTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
-        pTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
+		Font aFnt(maVD.GetFont());
+        const double fUnitInReal((maCurrent * basegfx::B2DVector(0.0, 1.0)).getLength());
+		const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * fUnitInReal));
+
+        mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
+		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
+		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
+        mpTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
+        mpTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
+		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
+		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+        mpTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
+        mpTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
+        mpTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
+        mpTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
+        mpTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
 
         // #i118485# Setting this item leads to problems (written #i118498# for this)
-        // pTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
+        // mpTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
 
-        pTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
-        pTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
-        pTextAttr->Put(SvxColorItem(aVD.GetTextColor(), EE_CHAR_COLOR));
+        mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
+        mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
+        mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
 		//... svxfont textitem svditext
-		bFntDirty=sal_False;
+		mbFntDirty = false;
 	}
-	if (pObj!=NULL)
+
+    if(pObj)
 	{
-		pObj->SetLayer(nLayer);
-		if (bLine) pObj->SetMergedItemSet(*pLineAttr);
-		if (bFill) pObj->SetMergedItemSet(*pFillAttr);
-		if (bText)
+		pObj->SetLayer(mnLayer);
+
+        if(bLine) 
+        {
+            pObj->SetMergedItemSet(*mpLineAttr);
+        }
+
+		if(bFill) 
+        {
+            pObj->SetMergedItemSet(*mpFillAttr);
+        }
+
+		if(bText)
 		{
-			pObj->SetMergedItemSet(*pTextAttr);
-			pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_LEFT ) );
+			pObj->SetMergedItemSet(*mpTextAttr);
+			pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
 		}
 	}
 }
 
-void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, bool bScale )
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj)
 {
-	if ( bScale && !aScaleRect.IsEmpty() )
+    if(isClip())
     {
-		if ( bSize )
-		{
-			sdr::legacy::ResizeSdrObject(*pObj, Point(), aScaleX, aScaleY );
-		}
-		if ( bMov )
-		{
-			sdr::legacy::MoveSdrObject(*pObj, Size( aOfs.X(), aOfs.Y() ) );
-		}
-	}
+        const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
+        const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
+    	const SdrLayerID aOldLayer(pObj->GetLayer());
+    	const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
+        const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
+        BitmapEx aBitmapEx;
 
-    // #i111954# check object for visibility
-    // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
-    bool bVisible(false);
+        if(pSdrGrafObj)
+        {
+        	aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
+        }
 
-    if(pObj->HasLineStyle())
-    {
-        bVisible = true;
-    }
+        deleteSdrObjectSafeAndClearPointer(pObj);
 
-    if(!bVisible && pObj->HasFillStyle())
-    {
-        bVisible = true;
+        if(!aOldRange.isEmpty())
+        {
+            // clip against ClipRegion
+            const basegfx::B2DPolyPolygon aNewPoly(
+                basegfx::tools::clipPolyPolygonOnPolyPolygon(
+                    aPoly, 
+                    maClip, 
+                    true, 
+                    aPoly.isClosed() ? false : true));
+            const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
+            
+            if(!aNewRange.isEmpty())
+            {
+                pObj = new SdrPathObj(
+                    mrModel,
+                    aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN, 
+                    aNewPoly);
+            
+		        pObj->SetLayer(aOldLayer);
+		        pObj->SetMergedItemSet(aOldItemSet);
+
+                if(!!aBitmapEx)
+                {
+                    // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
+                    const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
+                    const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
+                    basegfx::B2DRange aPixel(aNewRange);
+                    basegfx::B2DHomMatrix aTrans;
+
+                    aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
+                    aTrans.scale(fScaleX, fScaleY);
+                    aPixel.transform(aTrans);
+
+                    const BitmapEx aClippedBitmap(
+                        aBitmapEx, 
+                        Point(floor(std::max(0.0, aPixel.getMinX())), floor(std::max(0.0, aPixel.getMinY()))), 
+                        Size(ceil(aPixel.getWidth()), ceil(aPixel.getHeight())));
+
+                    pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
+                    pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
+                    pObj->SetMergedItem(XFillBmpTileItem(false));
+                    pObj->SetMergedItem(XFillBmpStretchItem(true));
+                }
+            }
+        }
     }
 
-    if(!bVisible)
+    if(pObj)
     {
-        SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+        // #i111954# check object for visibility
+        // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
+        bool bVisible(false);
 
-        if(pTextObj && pTextObj->HasText())
+        if(pObj->HasLineStyle())
         {
             bVisible = true;
         }
-    }
-
-    if(!bVisible)
-    {
-        SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
 
-        if(pGrafObj)
+        if(!bVisible && pObj->HasFillStyle())
         {
-            // this may be refined to check if the graphic really is visible. It
-            // is here to ensure that graphic objects without fill, line and text
-            // get created
             bVisible = true;
         }
-    }
 
-    if(!bVisible)
-    {
-        deleteSdrObjectSafeAndClearPointer(pObj);
-    }
-    else
-    {
-	    aTmpList.InsertObject( pObj );
-	    if ( dynamic_cast<  SdrPathObj* >(pObj ) )
-	    {
-		    bool bClosed=pObj->IsClosedObj();
-		    bLastObjWasPolyWithoutLine=bNoLine && bClosed;
-		    bLastObjWasLine=!bClosed;
-	    }
-	    else
-	    {
-		    bLastObjWasPolyWithoutLine = sal_False;
-		    bLastObjWasLine = sal_False;
-	    }
+        if(!bVisible)
+        {
+            SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+
+            if(pTextObj && pTextObj->HasText())
+            {
+                bVisible = true;
+            }
+        }
+
+        if(!bVisible)
+        {
+            SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
+
+            if(pGrafObj)
+            {
+                // this may be refined to check if the graphic really is visible. It
+                // is here to ensure that graphic objects without fill, line and text
+                // get created
+                bVisible = true;
+            }
+        }
+
+        if(!bVisible)
+        {
+            deleteSdrObjectSafeAndClearPointer(pObj);
+        }
+        else
+        {
+	        maTmpList.push_back(pObj);
+
+            if(dynamic_cast< SdrPathObj* >(pObj))
+	        {
+		        const bool bClosed(pObj->IsClosedObj());
+
+                mbLastObjWasPolyWithoutLine = mbNoLine && bClosed;
+		        mbLastObjWasLine = !bClosed;
+	        }
+	        else
+	        {
+		        mbLastObjWasPolyWithoutLine = false;
+		        mbLastObjWasLine = false;
+	        }
+        }
     }
 }
 
-/**************************************************************************************************/
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
 {
+    OSL_ENSURE(false, "Tried to construct SdrObject from MetaPixelAction: not supported (!)");
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
 {
+    OSL_ENSURE(false, "Tried to construct SdrObject from MetaPointAction: not supported (!)");
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
 {
-	// #i73407# reformulation to use new B2DPolygon classes
 	const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
 	const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
 
 	if(!aStart.equal(aEnd))
 	{
 		basegfx::B2DPolygon aLine;
-		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
 
 		aLine.append(aStart);
 		aLine.append(aEnd);
-		aLine.transform(aTransform);
+		aLine.transform(maCurrent);
 
 		const LineInfo& rLineInfo = rAct.GetLineInfo();
 		const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
 		bool bCreateLineObject(true);
 
-		if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aLine))
+		if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine))
 		{
 			bCreateLineObject = false;
 		}
 
 		if(bCreateLineObject)
 		{
-			SdrPathObj* pPath = new SdrPathObj(mrModel, OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
-			nLineWidth = nNewLineWidth;
+			SdrPathObj* pPath = new SdrPathObj(
+                mrModel,
+                OBJ_LINE, 
+                basegfx::B2DPolyPolygon(aLine));
+
+            mnLineWidth = nNewLineWidth;
 			maLineJoin = rLineInfo.GetLineJoin();
             maLineCap = rLineInfo.GetLineCap();
 			maDash = XDash(XDASH_RECT,
 				rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
 				rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
 				rLineInfo.GetDistance());
-			SetAttributes(pPath);
-			nLineWidth = 0;
+			
+            SetAttributes(pPath);
+			
+            mnLineWidth = 0;
 			maLineJoin = basegfx::B2DLINEJOIN_NONE;
 			maDash = XDash();
-			InsertObj(pPath, false);
+			
+            InsertObj(pPath);
 		}
 	}
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
 {
 	const Rectangle& rRect(rAct.GetRect());
 	SdrRectObj* pRect = new SdrRectObj(
 		mrModel, 
-		basegfx::tools::createScaleTranslateB2DHomMatrix(
+		maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
 			rRect.getWidth(), rRect.getHeight(), 
 			rRect.Left(), rRect.Top()));
-	SetAttributes(pRect);
+	
+    SetAttributes(pRect);
 	InsertObj(pRect);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
 {
 	const Rectangle& rRect(rAct.GetRect());
 	SdrRectObj* pRect = new SdrRectObj(
 		mrModel, 
-		basegfx::tools::createScaleTranslateB2DHomMatrix(
+		maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
 			rRect.getWidth(), rRect.getHeight(), 
 			rRect.Left(), rRect.Top()));
-	SetAttributes(pRect);
-	long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
-	if (nRad!=0) {
-		SfxItemSet aSet(*pLineAttr->GetPool(),SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS);
-		aSet.Put(SdrMetricItem(SDRATTR_ECKENRADIUS, nRad));
-		pRect->SetMergedItemSet(aSet);
+	
+    SetAttributes(pRect);
+	
+    const sal_uInt32 nRad((rAct.GetHorzRound() + rAct.GetVertRound()) / 2);
+
+    if(nRad) 
+    {
+		pRect->SetMergedItem(SdrMetricItem(SDRATTR_ECKENRADIUS, nRad));
 	}
-	InsertObj(pRect);
+	
+    InsertObj(pRect);
 }
 
-/**************************************************************************************************/
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
 {
 	const Rectangle& rRect(rAct.GetRect());
-	SdrCircObj* pCirc = new SdrCircObj(mrModel, OBJ_CIRC, basegfx::tools::createScaleTranslateB2DHomMatrix(rRect.getWidth(), rRect.getHeight(), rRect.Left(), rRect.Top()));
-	SetAttributes(pCirc);
+	SdrCircObj* pCirc = new SdrCircObj(
+        mrModel, 
+        OBJ_CIRC, 
+        maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
+            rRect.getWidth(), rRect.getHeight(), 
+            rRect.Left(), rRect.Top()));
+
+    SetAttributes(pCirc);
 	InsertObj(pCirc);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 namespace
 {
 	void impPrepareAngles(const Point& rCenter, const Point& rStart, const Point& rEnd, double& o_Start, double& o_End)
@@ -568,6 +700,8 @@ namespace
 	}
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
 {
 	double fStart(0.0);
@@ -579,14 +713,18 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 	SdrCircObj* pCirc = new SdrCircObj(
 		mrModel, 
 		OBJ_CIRC, 
-		basegfx::tools::createScaleTranslateB2DHomMatrix(rRect.getWidth(), rRect.getHeight(), rRect.Left(), rRect.Top()),
+		maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
+            rRect.getWidth(), rRect.getHeight(), 
+            rRect.Left(), rRect.Top()),
 		fStart,
 		fEnd);
 
-	SetAttributes(pCirc);
+    SetAttributes(pCirc);
 	InsertObj(pCirc);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
 {
 	double fStart(0.0);
@@ -598,14 +736,18 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 	SdrCircObj* pCirc = new SdrCircObj(
 		mrModel, 
 		OBJ_SECT, 
-		basegfx::tools::createScaleTranslateB2DHomMatrix(rRect.getWidth(), rRect.getHeight(), rRect.Left(), rRect.Top()),
+		maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
+            rRect.getWidth(), rRect.getHeight(), 
+            rRect.Left(), rRect.Top()),
 		fStart,
 		fEnd);
 
-	SetAttributes(pCirc);
+    SetAttributes(pCirc);
 	InsertObj(pCirc);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
 {
 	double fStart(0.0);
@@ -617,15 +759,17 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 	SdrCircObj* pCirc = new SdrCircObj(
 		mrModel,
 		OBJ_CCUT, 
-		basegfx::tools::createScaleTranslateB2DHomMatrix(rRect.getWidth(), rRect.getHeight(), rRect.Left(), rRect.Top()),
+		maCurrent * basegfx::tools::createScaleTranslateB2DHomMatrix(
+            rRect.getWidth(), rRect.getHeight(), 
+            rRect.Left(), rRect.Top()),
 		fStart,
 		fEnd);
 
-	SetAttributes(pCirc);
+    SetAttributes(pCirc);
 	InsertObj(pCirc);
 }
 
-/**************************************************************************************************/
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
 bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
 {
@@ -635,18 +779,17 @@ bool ImpSdrGDIMetaFileImport::CheckLastL
 		return false;
 	}
 
-	// #i73407# reformulation to use new B2DPolygon classes
-	if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count())
+	if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
 	{
-		SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
-		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >( pTmpObj);
+		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
+		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
 
 		if(pLastPoly)
 		{
-			if(1L == pLastPoly->getB2DPolyPolygonInObjectCoordinates().count())
+			if(1 == pLastPoly->getB2DPolyPolygonInObjectCoordinates().count())
 			{
 				bool bOk(false);
-				basegfx::B2DPolygon aDstPoly(pLastPoly->getB2DPolyPolygonInObjectCoordinates().getB2DPolygon(0L));
+				basegfx::B2DPolygon aDstPoly(pLastPoly->getB2DPolyPolygonInObjectCoordinates().getB2DPolygon(0));
 
 				// #i102706# Do not merge closed polygons
 				if(aDstPoly.isClosed())
@@ -699,23 +842,24 @@ bool ImpSdrGDIMetaFileImport::CheckLastL
 	return false;
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
 {
-	// #i73407# reformulation to use new B2DPolygon classes
-	if(bLastObjWasPolyWithoutLine)
+	if(mbLastObjWasPolyWithoutLine)
 	{
-		SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
-		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >( pTmpObj);
+		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
+		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
 
 		if(pLastPoly)
 		{
 			if(pLastPoly->getB2DPolyPolygonInObjectCoordinates() == rPolyPolygon)
 			{
-				SetAttributes(NULL);
+				SetAttributes(0);
 
-				if(!bNoLine && bNoFill)
+				if(!mbNoLine && mbNoFill)
 				{
-					pLastPoly->SetMergedItemSet(*pLineAttr);
+					pLastPoly->SetMergedItemSet(*mpLineAttr);
 
 					return true;
 				}
@@ -726,122 +870,164 @@ bool ImpSdrGDIMetaFileImport::CheckLastP
 	return false;
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::checkClip()
+{
+    if(maVD.IsClipRegion())
+    {
+        Region aRegion(maVD.GetClipRegion());
+
+        maClip = aRegion.ConvertToB2DPolyPolygon();
+
+        if(isClip())
+        {
+            maClip.transform(maCurrent);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool ImpSdrGDIMetaFileImport::isClip() const
+{
+    return !maClip.getB2DRange().isEmpty();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
 {
-	// #i73407# reformulation to use new B2DPolygon classes
 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
 
 	if(aSource.count())
 	{
-		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
-		aSource.transform(aTransform);
-	}
+		aSource.transform(maCurrent);
 
-	const LineInfo& rLineInfo = rAct.GetLineInfo();
-	const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
-	bool bCreateLineObject(true);
+        const LineInfo& rLineInfo = rAct.GetLineInfo();
+	    const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
+	    bool bCreateLineObject(true);
 
-	if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aSource))
-	{
-		bCreateLineObject = false;
-	}
-	else if(bLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
-	{
-		bCreateLineObject = false;
-	}
-
-	if(bCreateLineObject)
-	{
-		SdrPathObj* pPath = new SdrPathObj(
-			mrModel,
-			aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
-			basegfx::B2DPolyPolygon(aSource));
+	    if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource))
+	    {
+		    bCreateLineObject = false;
+	    }
+	    else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
+	    {
+		    bCreateLineObject = false;
+	    }
 
-		nLineWidth = nNewLineWidth;
-		maLineJoin = rLineInfo.GetLineJoin();
-        maLineCap = rLineInfo.GetLineCap();
-		maDash = XDash(XDASH_RECT,
-			rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
-			rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
-			rLineInfo.GetDistance());
-		SetAttributes(pPath);
-		nLineWidth = 0;
-		maLineJoin = basegfx::B2DLINEJOIN_NONE;
-		maDash = XDash();
-		InsertObj(pPath, false);
+	    if(bCreateLineObject)
+	    {
+            SdrPathObj* pPath = new SdrPathObj(
+                mrModel,
+			    aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
+			    basegfx::B2DPolyPolygon(aSource));
+		
+            mnLineWidth = nNewLineWidth;
+		    maLineJoin = rLineInfo.GetLineJoin();
+            maLineCap = rLineInfo.GetLineCap();
+		    maDash = XDash(XDASH_RECT,
+			    rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
+			    rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
+			    rLineInfo.GetDistance());
+		    
+            SetAttributes(pPath);
+		    
+            mnLineWidth = 0;
+		    maLineJoin = basegfx::B2DLINEJOIN_NONE;
+		    maDash = XDash();
+		    
+            InsertObj(pPath);
+	    }
 	}
 }
 
-void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaPolygonAction& rAct)
 {
-	// #i73407# reformulation to use new B2DPolygon classes
 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
 
 	if(aSource.count())
 	{
-		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
-		aSource.transform(aTransform);
+		aSource.transform(maCurrent);
 
-		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
+		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
 		{
 			// #i73407# make sure polygon is closed, it's a filled primitive
 			aSource.setClosed(true);
 
-			SdrPathObj* pPath = new SdrPathObj(mrModel, OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
-			SetAttributes(pPath);
-			InsertObj(pPath, false);
+            SdrPathObj* pPath = new SdrPathObj(
+                mrModel, 
+                OBJ_POLY, 
+                basegfx::B2DPolyPolygon(aSource));
+			
+            SetAttributes(pPath);
+			InsertObj(pPath);
 		}
 	}
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
 {
-	// #i73407# reformulation to use new B2DPolygon classes
 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
 
 	if(aSource.count())
 	{
-		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
-		aSource.transform(aTransform);
+		aSource.transform(maCurrent);
 
-		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
 		{
 			// #i73407# make sure polygon is closed, it's a filled primitive
 			aSource.setClosed(true);
-
-			SdrPathObj* pPath = new SdrPathObj(mrModel, OBJ_POLY, aSource);
-			SetAttributes(pPath);
-			InsertObj(pPath, false);
+			
+            SdrPathObj* pPath = new SdrPathObj(
+                mrModel, 
+                OBJ_POLY, 
+                aSource);
+			
+            SetAttributes(pPath);
+			InsertObj(pPath);
 		}
 	}
 }
 
-/**************************************************************************************************/
+////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
 {
-	// calc text box size, add 5% to make it fit safely
+	// calc text box size
+	const FontMetric aFontMetric(maVD.GetFontMetric());
+	const Font aFnt(maVD.GetFont());
+	const FontAlign eAlg(aFnt.GetAlign());
+    basegfx::B2DVector aTextScale(maVD.GetTextWidth(rStr), maVD.GetTextHeight());
+    basegfx::B2DPoint aTextPos(rPos.X(), rPos.Y());
+	basegfx::B2DHomMatrix aTextMatrix;
 
-	FontMetric aFontMetric( aVD.GetFontMetric() );
-	Font aFnt( aVD.GetFont() );
-	FontAlign eAlg( aFnt.GetAlign() );
-
-    sal_Int32 nTextWidth = (sal_Int32)( aVD.GetTextWidth( rStr ) * fScaleX );
-    sal_Int32 nTextHeight = (sal_Int32)( aVD.GetTextHeight() * fScaleY );
-	//sal_Int32 nDxWidth = 0;
-	//sal_Int32 nLen = rStr.Len();
-
-	Point aPos( FRound(rPos.X() * fScaleX + aOfs.X()), FRound(rPos.Y() * fScaleY + aOfs.Y()) );
-    Size aSize( nTextWidth, nTextHeight );
-
-	if ( eAlg == ALIGN_BASELINE )
-		aPos.Y() -= FRound(aFontMetric.GetAscent() * fScaleY);
-	else if ( eAlg == ALIGN_BOTTOM )
-		aPos.Y() -= nTextHeight;
+	if(ALIGN_BASELINE == eAlg)
+    {
+        aTextPos.setY(aTextPos.getY() - aFontMetric.GetAscent());
+    }
+	else if(ALIGN_BOTTOM == eAlg)
+    {
+        aTextPos.setY(aTextPos.getY() - aTextScale.getY());
+    }
 
-	const basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(aSize.getWidth(), aSize.getHeight(), aPos.X(), aPos.Y()));
-	SdrRectObj* pText = new SdrRectObj(
+    aTextScale = maCurrent * aTextScale;
+    aTextPos = maCurrent * aTextPos;
+    
+    if(aFnt.GetOrientation())
+    {
+        aTextMatrix.rotate(F_PI180 * (aFnt.GetOrientation() * 0.10));
+    }
+
+    aTextMatrix.scale(aTextScale);
+    aTextMatrix.translate(aTextPos);
+
+    SdrRectObj* pText = new SdrRectObj(
 		mrModel, 
 		aTextMatrix,
 		OBJ_TEXT, 
@@ -859,53 +1045,61 @@ void ImpSdrGDIMetaFileImport::ImportText
 		pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
 	}
 	else
+    {
 		pText->SetMergedItem( SdrOnOffItem(SDRATTR_TEXT_AUTOGROWWIDTH, true ) );
+    }
 
-	//pText->SetModel( mrModel );
-	pText->SetLayer( nLayer );
-	pText->SetText( rStr );
-	SetAttributes( pText, true);
-	pText->setSdrObjectTransformation(aTextMatrix);
+	pText->SetLayer(mnLayer);
+	pText->SetText(rStr);
+	SetAttributes(pText, true);
 
 	if (!aFnt.IsTransparent())
 	{
-		SfxItemSet aAttr(*pFillAttr->GetPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
-		aAttr.Put(XFillStyleItem(XFILL_SOLID));
+		SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
+
+        aAttr.Put(XFillStyleItem(XFILL_SOLID));
 		aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
 		pText->SetMergedItemSet(aAttr);
 	}
-	sal_uInt32 nWink = aFnt.GetOrientation();
-	if ( nWink )
-	{
-		sdr::legacy::RotateSdrObject(*pText,aPos,nWink * 10);
-	}
-	InsertObj( pText, false );
+
+    InsertObj(pText);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
 {
 	XubString aStr(rAct.GetText());
 	aStr.Erase(0,rAct.GetIndex());
 	aStr.Erase(rAct.GetLen());
-	ImportText( rAct.GetPoint(), aStr, rAct );
+
+    ImportText( rAct.GetPoint(), aStr, rAct );
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
 {
 	XubString aStr(rAct.GetText());
 	aStr.Erase(0,rAct.GetIndex());
 	aStr.Erase(rAct.GetLen());
-	ImportText( rAct.GetPoint(), aStr, rAct );
+
+    ImportText( rAct.GetPoint(), aStr, rAct );
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
 {
 	XubString aStr(rAct.GetText());
 	aStr.Erase(0,rAct.GetIndex());
 	aStr.Erase(rAct.GetLen());
-	ImportText( rAct.GetPoint(), aStr, rAct );
+
+    ImportText( rAct.GetPoint(), aStr, rAct );
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
 {
 	const Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
@@ -914,10 +1108,16 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 			aRect.getWidth() + 1, aRect.getHeight() + 1,
 			aRect.Left(), aRect.Top()));
 
-	SdrGrafObj* pGraf = new SdrGrafObj(mrModel, Graphic(rAct.GetBitmap()), aGrafMatrix);
-	InsertObj(pGraf);
+	SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel, 
+        Graphic(rAct.GetBitmap()), 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
 {
 	const Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
@@ -926,10 +1126,16 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 			aRect.getWidth() + 1, aRect.getHeight() + 1,
 			aRect.Left(), aRect.Top()));
 
-	SdrGrafObj* pGraf = new SdrGrafObj(mrModel, Graphic(rAct.GetBitmap()), aGrafMatrix);
-	InsertObj(pGraf);
+	SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel, 
+        Graphic(rAct.GetBitmap()), 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
 {
 	const Rectangle aRect(rAct.GetPoint(), rAct.GetBitmapEx().GetSizePixel());
@@ -938,10 +1144,16 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 			aRect.getWidth() + 1, aRect.getHeight() + 1,
 			aRect.Left(), aRect.Top()));
 
-	SdrGrafObj* pGraf = new SdrGrafObj(mrModel, rAct.GetBitmapEx(), aGrafMatrix);
-	InsertObj(pGraf);
+	SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel, 
+        rAct.GetBitmapEx(), 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
 {
 	const Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
@@ -950,26 +1162,31 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 			aRect.getWidth() + 1, aRect.getHeight() + 1,
 			aRect.Left(), aRect.Top()));
 
-	SdrGrafObj* pGraf = new SdrGrafObj(mrModel, rAct.GetBitmapEx(), aGrafMatrix);
-	InsertObj(pGraf);
+	SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel, 
+        rAct.GetBitmapEx(), 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
 {
-	// #i73407# reformulation to use new B2DPolygon classes
 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
 
 	if(aSource.count())
 	{
-		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
-		aSource.transform(aTransform);
+		aSource.transform(maCurrent);
 
-		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
 		{
 			const Hatch& rHatch = rAct.GetHatch();
-			SdrPathObj* pPath = new SdrPathObj(mrModel, OBJ_POLY, aSource);
+			SdrPathObj* pPath = new SdrPathObj(
+                mrModel, 
+                OBJ_POLY, 
+                aSource);
 			SfxItemSet aHatchAttr(pPath->GetObjectItemPool(),
 				XATTR_FILLSTYLE, XATTR_FILLSTYLE,
 				XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0 );
@@ -1001,44 +1218,23 @@ void ImpSdrGDIMetaFileImport::DoAction( 
 			aHatchAttr.Put(XFillHatchItem(&pPath->GetObjectItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
 			pPath->SetMergedItemSet(aHatchAttr);
 
-			InsertObj(pPath, false);
+			InsertObj(pPath);
 		}
 	}
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
-{
-	rAct.Execute(&aVD);
-}
-
 void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
 {
-	MapScaling();
-	rAct.Execute(&aVD);
-	bLastObjWasPolyWithoutLine=sal_False;
-	bLastObjWasLine=sal_False;
-}
+	rAct.Execute(&maVD);
 
-void ImpSdrGDIMetaFileImport::MapScaling()
-{
-	sal_uInt32 i, nAnz = aTmpList.GetObjCount();
-	const MapMode& rMap = aVD.GetMapMode();
-	Point aMapOrg( rMap.GetOrigin() );
-	bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
-	if ( bMov2 )
-    {
-		for ( i = nMapScalingOfs; i < nAnz; i++ )
-        {
-			SdrObject* pObj = aTmpList.GetObj(i);
-			if ( bMov2 )
-			{
-				sdr::legacy::MoveSdrObject(*pObj, Size( aMapOrg.X(), aMapOrg.Y() ) );
-			}
-		}
-	}
-	nMapScalingOfs = nAnz;
+    // create new transformation since this action may set a relative mapping action.
+    // thus, first apply new mapping, then from metafuile to unit, and then object transformation
+    maCurrent = maObjectTransform * maMetaToUnit * maVD.GetViewTransformation();
+
+    mbLastObjWasPolyWithoutLine = false;
+	mbLastObjWasLine = false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1053,15 +1249,19 @@ void ImpSdrGDIMetaFileImport::DoAction( 
 
 		if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
 		{
-			// #i73407# reformulation to use new B2DPolygon classes
 			basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
 
 			if(aSource.count())
 			{
-				if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+                aSource.transform(maCurrent); // TTTT: needed? was missing before
+
+				if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
 				{
 					const Gradient&	rGrad = pAct->GetGradient();
-					SdrPathObj* pPath = new SdrPathObj(mrModel, OBJ_POLY, aSource);
+					SdrPathObj* pPath = new SdrPathObj(
+                        mrModel, 
+                        OBJ_POLY, 
+                        aSource);
 					SfxItemSet aGradAttr(pPath->GetObjectItemPool(),
 					   XATTR_FILLSTYLE, XATTR_FILLSTYLE,
 					   XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0 );
@@ -1078,14 +1278,14 @@ void ImpSdrGDIMetaFileImport::DoAction( 
 					aXGradient.SetEndIntens(rGrad.GetEndIntensity());
 					aXGradient.SetSteps(rGrad.GetSteps());
 
-            		if(aVD.IsLineColor())
+            		if(maVD.IsLineColor())
                     {
                         // switch line off; when there was one there will be a
                         // META_POLYLINE_ACTION following creating another object
-    		            const Color aLineColor(aVD.GetLineColor());
-    		            aVD.SetLineColor();
+    		            const Color aLineColor(maVD.GetLineColor());
+    		            maVD.SetLineColor();
                         SetAttributes(pPath);
-    		            aVD.SetLineColor(aLineColor);
+    		            maVD.SetLineColor(aLineColor);
                     }
                     else
                     {
@@ -1118,4 +1318,458 @@ void ImpSdrGDIMetaFileImport::DoAction( 
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
+{
+    GDIMetaFile aTemp;
+
+    // dismantle MetaTextRectActions to own metafile and execute
+    maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
+    DoLoopActions(aTemp, 0, 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
+{
+	const Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
+	const basegfx::B2DHomMatrix aGrafMatrix(
+		basegfx::tools::createScaleTranslateB2DHomMatrix(
+			aRect.getWidth() + 1, aRect.getHeight() + 1,
+			aRect.Left(), aRect.Top()));
+    Bitmap aBitmap(rAct.GetBitmap());
+
+    aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
+
+    SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel, 
+        aBitmap, 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
+{
+	const Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
+	const basegfx::B2DHomMatrix aGrafMatrix(
+		basegfx::tools::createScaleTranslateB2DHomMatrix(
+			aRect.getWidth() + 1, aRect.getHeight() + 1,
+			aRect.Left(), aRect.Top()));
+    BitmapEx aBitmapEx(rAct.GetBitmapEx());
+	
+    aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
+
+    SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel,
+        aBitmapEx, 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
+{
+	const Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
+	const basegfx::B2DHomMatrix aGrafMatrix(
+		basegfx::tools::createScaleTranslateB2DHomMatrix(
+			aRect.getWidth() + 1, aRect.getHeight() + 1,
+			aRect.Left(), aRect.Top()));
+    const BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
+
+    SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel,
+        aBitmapEx, 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
+{
+	const Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
+	const basegfx::B2DHomMatrix aGrafMatrix(
+		basegfx::tools::createScaleTranslateB2DHomMatrix(
+			aRect.getWidth() + 1, aRect.getHeight() + 1,
+			aRect.Left(), aRect.Top()));
+    const BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
+    
+    SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel,
+        aBitmapEx, 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
+{
+	const Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
+	const basegfx::B2DHomMatrix aGrafMatrix(
+		basegfx::tools::createScaleTranslateB2DHomMatrix(
+			aRect.getWidth() + 1, aRect.getHeight() + 1,
+			aRect.Left(), aRect.Top()));
+    BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
+	
+    aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
+
+    SdrGrafObj* pGraf = new SdrGrafObj(
+        mrModel,
+        aBitmapEx, 
+        maCurrent * aGrafMatrix);
+
+    InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
+{
+    basegfx::B2DRange aRange(
+        rAct.GetRect().Left(), 
+        rAct.GetRect().Top(), 
+        rAct.GetRect().Right() + 1, 
+        rAct.GetRect().Bottom() + 1);
+
+	if(!aRange.isEmpty())
+	{
+	    basegfx::B2DHomMatrix aObjectTransform(
+		    basegfx::tools::createScaleTranslateB2DHomMatrix(
+                aRange.getRange(),
+                aRange.getMinimum()));
+        SdrRectObj* pRect = new SdrRectObj(
+            mrModel,
+            maCurrent * aObjectTransform);
+
+        SfxItemSet aGradientAttr(mrModel.GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
+        XGradientStyle aXGradientStyle(XGRAD_LINEAR);
+        const Gradient& rGradient = rAct.GetGradient();
+
+        switch(rGradient.GetStyle())
+        {
+            case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
+            case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
+            case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
+            case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
+            case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
+            case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
+        }
+            
+        const XFillGradientItem aXFillGradientItem(
+            &mrModel.GetItemPool(), 
+            XGradient(
+                rGradient.GetStartColor(),
+                rGradient.GetEndColor(),
+                aXGradientStyle,
+                rGradient.GetAngle(),
+                rGradient.GetOfsX(),
+                rGradient.GetOfsY(),
+                rGradient.GetBorder(),
+                rGradient.GetStartIntensity(),
+                rGradient.GetEndIntensity(),
+                rGradient.GetSteps()));
+
+		SetAttributes(pRect);
+		aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
+		aGradientAttr.Put(aXFillGradientItem);
+		pRect->SetMergedItemSet(aGradientAttr);
+
+		InsertObj(pRect);
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& rAct)
+{
+    OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct)
+{
+	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
+
+	if(aSource.count())
+	{
+		aSource.transform(maCurrent);
+    	aSource.setClosed(true);
+
+        SdrPathObj* pPath = new SdrPathObj(
+            mrModel,
+            OBJ_POLY, 
+            aSource);
+
+        SetAttributes(pPath);
+        pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
+		InsertObj(pPath);
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& rAct)
+{
+    OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& rAct)
+{
+    OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
+{
+	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
+
+	if(aSource.count())
+	{
+		aSource.transform(maCurrent);
+
+		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+		{
+        	const Gradient& rGradient = rAct.GetGradient();
+            SdrPathObj* pPath = new SdrPathObj(
+                mrModel,
+                OBJ_POLY, 
+                aSource);
+			SfxItemSet aGradientAttr(mrModel.GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
+            XGradientStyle aXGradientStyle(XGRAD_LINEAR);
+
+            switch(rGradient.GetStyle())
+            {
+                case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
+                case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
+                case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
+                case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
+                case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
+                case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
+            }
+            
+            const XFillGradientItem aXFillGradientItem(
+                &mrModel.GetItemPool(), 
+                XGradient(
+                    rGradient.GetStartColor(),
+                    rGradient.GetEndColor(),
+                    aXGradientStyle,
+                    rGradient.GetAngle(),
+                    rGradient.GetOfsX(),
+                    rGradient.GetOfsY(),
+                    rGradient.GetBorder(),
+                    rGradient.GetStartIntensity(),
+                    rGradient.GetEndIntensity(),
+                    rGradient.GetSteps()));
+
+			SetAttributes(pPath);
+			aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
+			aGradientAttr.Put(aXFillGradientItem);
+			pPath->SetMergedItemSet(aGradientAttr);
+
+			InsertObj(pPath);
+		}
+	}
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
+{
+	const GDIMetaFile& rMtf = rAct.GetGDIMetaFile();
+
+    if(rMtf.GetActionCount())
+    {
+	    const Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
+        basegfx::B2DRange aRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
+
+        // go to object target coordinates to get a good relative size
+        aRange.transform(maCurrent);
+
+        // convert metafile sub-content to BitmapEx
+        BitmapEx aBitmapEx(
+            convertMetafileToBitmapEx(
+                rMtf,
+                aRange,
+                125000));
+
+        // handle colors
+        const Gradient& rGradient = rAct.GetGradient();
+	    basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
+	    basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
+	    
+        if(100 != rGradient.GetStartIntensity())
+	    {
+            aStart *= (double)rGradient.GetStartIntensity() / 100.0;
+	    }
+
+        if(100 != rGradient.GetEndIntensity())
+	    {
+            aEnd *= (double)rGradient.GetEndIntensity() / 100.0;
+	    }
+
+        const bool bEqualColors(aStart == aEnd);
+        const bool bNoSteps(1 == rGradient.GetSteps());
+        bool bCreateObject(true);
+        bool bHasNewMask(false);
+        AlphaMask aNewMask;
+        double fTransparence(0.0);
+        bool bFixedTransparence(false);
+
+        if(bEqualColors || bNoSteps)
+        {
+            // single transparence
+            const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
+            fTransparence = aMedium.luminance();
+
+            if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
+            {
+                // no transparence needed, all done
+            }
+            else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0))
+            {
+                // all transparent, no object
+                bCreateObject = false;
+            }
+            else
+            {
+                // 0.0 < transparence < 1.0, apply fixed transparence
+                bFixedTransparence = true;
+            }
+        }
+        else
+        {
+            // gradient transparence
+            VirtualDevice aVDev;
+
+            aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
+            aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
+
+            aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
+            bHasNewMask = true;
+        }
+
+        if(bCreateObject)
+        {
+            if(bHasNewMask || bFixedTransparence)
+            {
+                if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
+                {
+                    // no transparence yet, apply new one
+                    if(bFixedTransparence)
+                    {
+                        sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
+
+                        aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
+                    }
+
+                    aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
+                }
+                else
+                {
+                    // mix existing and new alpha mask
+                    AlphaMask aOldMask;
+
+                    if(aBitmapEx.IsAlpha())
+                    {
+                        aOldMask = aBitmapEx.GetAlpha();
+                    }
+                    else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType())
+                    {
+                        aOldMask = aBitmapEx.GetMask();
+                    }
+                    else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType())
+                    {
+                        aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
+                    }
+
+                    BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
+
+                    if(pOld)
+                    {
+                        const double fFactor(1.0 / 255.0);
+                        
+                        if(bFixedTransparence)
+                        {
+                            const double fOpNew(1.0 - fTransparence);
+                            
+                            for(sal_uInt32 y(0); y < pOld->Height(); y++)
+                            {
+                                for(sal_uInt32 x(0); x < pOld->Width(); x++)
+                                {
+                                    const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
+                                    const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
+
+                                    pOld->SetPixel(y, x, BitmapColor(aCol));
+                                }
+                            }
+                        }
+                        else
+                        {
+                            BitmapReadAccess* pNew = aNewMask.AcquireReadAccess();
+
+                            if(pNew)
+                            {
+                                if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height())
+                                {
+                                    for(sal_uInt32 y(0); y < pOld->Height(); y++)
+                                    {
+                                        for(sal_uInt32 x(0); x < pOld->Width(); x++)
+                                        {
+                                            const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
+                                            const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor));
+                                            const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
+
+                                            pOld->SetPixel(y, x, BitmapColor(aCol));
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    OSL_ENSURE(false, "Alpha masks have different sizes (!)");
+                                }
+        
+                                aNewMask.ReleaseAccess(pNew);
+                            }
+                            else
+                            {
+                                OSL_ENSURE(false, "Got no access to new alpha mask (!)");
+                            }
+                        }
+
+                        aOldMask.ReleaseAccess(pOld);
+                    }
+                    else
+                    {
+                        OSL_ENSURE(false, "Got no access to old alpha mask (!)");
+                    }
+
+                    // apply combined bitmap as mask
+                    aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
+                }
+            }
+
+            // create and add object
+            SdrGrafObj* pGraf = new SdrGrafObj(
+                mrModel,
+                aBitmapEx, 
+                basegfx::tools::createScaleTranslateB2DHomMatrix(
+                    aRange.getRange(),
+                    aRange.getMinimum()));
+
+            InsertObj(pGraf);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
 // eof

Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.hxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.hxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdfmtf.hxx Wed May 16 15:07:00 2012
@@ -40,68 +40,48 @@ class SdrObject;
 class SvdProgressInfo;
 
 //************************************************************
-//   Hilfsklasse SdrObjRefList
-//************************************************************
-
-class SdrObjRefList
-{
-	Container					aList;
-public:
-
-	SdrObjRefList()
-	:	aList(1024,64,64)
-	{}
-
-	void Clear() { aList.Clear(); }
-	sal_uInt32 GetObjCount() const { return aList.Count(); }
-	SdrObject* GetObj(sal_uInt32 nNum) const { return (SdrObject*)aList.GetObject(nNum); }
-	SdrObject* operator[](sal_uInt32 nNum) const { return (SdrObject*)aList.GetObject(nNum); }
-	void InsertObject(SdrObject* pObj, sal_uInt32 nPos=CONTAINER_APPEND) { aList.Insert(pObj,nPos); }
-	void RemoveObject(sal_uInt32 nPos) { aList.Remove(nPos); }
-};
-
-//************************************************************
 //   Hilfsklasse ImpSdrGDIMetaFileImport
 //************************************************************
 
 class ImpSdrGDIMetaFileImport
 {
 protected:
-	SdrObjRefList				aTmpList;
-	VirtualDevice				aVD;
-	Rectangle					aScaleRect;
-	sal_uInt32					nMapScalingOfs; // ab hier nocht nicht mit MapScaling bearbeitet
-	SfxItemSet*					pLineAttr;
-	SfxItemSet*					pFillAttr;
-	SfxItemSet*					pTextAttr;
-	SdrPage*					pPage;
+    ::std::vector< SdrObject* > maTmpList;
+	VirtualDevice				maVD;
+    const basegfx::B2DHomMatrix maObjectTransform;  // transform from the original object
+    basegfx::B2DHomMatrix       maMetaToUnit;       // transform from meta coordinates to unit coodinates
+    basegfx::B2DHomMatrix       maCurrent;          // current transform from meta to new object
+	SfxItemSet*					mpLineAttr;
+	SfxItemSet*					mpFillAttr;
+	SfxItemSet*					mpTextAttr;
 	SdrModel&					mrModel;
-	SdrLayerID					nLayer;
-	Color						aOldLineColor;
-	sal_Int32					nLineWidth;
+	SdrLayerID					mnLayer;
+	Color						maOldLineColor;
+	sal_Int32					mnLineWidth;
 	basegfx::B2DLineJoin		maLineJoin;
 	com::sun::star::drawing::LineCap    maLineCap;
 	XDash						maDash;
 
-	bool						bMov;
-	bool						bSize;
-	Point						aOfs;
-    double                      fScaleX;
-    double                      fScaleY;
-	Fraction					aScaleX;
-	Fraction					aScaleY;
+    // clipregion
+    basegfx::B2DPolyPolygon     maClip;
 
-	bool	                    bFntDirty;
+    /// bitfield
+	bool                        mbFntDirty : 1;
 
 	// fuer Optimierung von (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> aus 2 mach ein
-	bool			            bLastObjWasPolyWithoutLine;
-	bool		                bNoLine;
-	bool	                    bNoFill;
+	bool                        mbLastObjWasPolyWithoutLine : 1;
+	bool                        mbNoLine : 1;
+	bool                        mbNoFill : 1;
 
 	// fuer Optimierung mehrerer Linien zu einer Polyline
-	bool	                    bLastObjWasLine;
+	bool                        mbLastObjWasLine : 1;
 
 protected:
+    // ckeck for clip and evtl. fill maClip
+    void checkClip();
+    bool isClip() const;
+
+    // actions
 	void DoAction(MetaPixelAction			& rAct);
 	void DoAction(MetaPointAction			& rAct);
 	void DoAction(MetaLineAction			& rAct);
@@ -122,39 +102,64 @@ protected:
 	void DoAction(MetaBmpExAction			& rAct);
 	void DoAction(MetaBmpExScaleAction		& rAct);
 	void DoAction(MetaHatchAction			& rAct);
-	void DoAction(MetaLineColorAction		& rAct);
+	void DoAction(MetaLineColorAction		& rAct) { rAct.Execute(&maVD); }
 	void DoAction(MetaMapModeAction			& rAct);
-	void DoAction(MetaFillColorAction		& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaTextColorAction		& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaTextFillColorAction	& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaFontAction			& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
-	void DoAction(MetaTextAlignAction		& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
-	void DoAction(MetaClipRegionAction		& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaRasterOpAction		& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaPushAction			& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaPopAction				& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
-	void DoAction(MetaMoveClipRegionAction	& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); }
-	void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); }
+	void DoAction(MetaFillColorAction		& rAct) { rAct.Execute(&maVD); }
+	void DoAction(MetaTextColorAction		& rAct) { rAct.Execute(&maVD); }
+	void DoAction(MetaTextFillColorAction	& rAct) { rAct.Execute(&maVD); }
+	void DoAction(MetaFontAction			& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
+	void DoAction(MetaTextAlignAction		& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
+	void DoAction(MetaClipRegionAction		& rAct) { rAct.Execute(&maVD); checkClip(); }
+	void DoAction(MetaRasterOpAction		& rAct) { rAct.Execute(&maVD); }
+	void DoAction(MetaPushAction			& rAct) { rAct.Execute(&maVD); checkClip(); }
+	void DoAction(MetaPopAction				& rAct) { rAct.Execute(&maVD); mbFntDirty = true; checkClip(); }
+	void DoAction(MetaMoveClipRegionAction	& rAct) { rAct.Execute(&maVD); checkClip(); }
+	void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
+	void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
 	void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
 
-	void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
+    // missing actions added
+    void DoAction(MetaTextRectAction& rAct);
+    void DoAction(MetaBmpScalePartAction& rAct);
+    void DoAction(MetaBmpExScalePartAction& rAct);
+    void DoAction(MetaMaskAction& rAct);
+    void DoAction(MetaMaskScaleAction& rAct);
+    void DoAction(MetaMaskScalePartAction& rAct);
+    void DoAction(MetaGradientAction& rAct);
+    void DoAction(MetaWallpaperAction& rAct);
+    void DoAction(MetaTransparentAction& rAct);
+    void DoAction(MetaEPSAction& rAct);
+    void DoAction(MetaRefPointAction& rAct)  { rAct.Execute(&maVD); }
+    void DoAction(MetaTextLineColorAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
+    void DoAction(MetaTextLineAction& rAct);
+    void DoAction(MetaFloatTransparentAction& rAct);
+    void DoAction(MetaGradientExAction& rAct);
+    void DoAction(MetaLayoutModeAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
+    void DoAction(MetaTextLanguageAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
+    void DoAction(MetaOverlineColorAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
+
+	void ImportText(const Point& rPos, const XubString& rStr, const MetaAction& rAct);
 	void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
-	void InsertObj( SdrObject* pObj, bool bScale = true );
-	void MapScaling();
+	void InsertObj(SdrObject* pObj);
 
 	// #i73407# reformulation to use new B2DPolygon classes
 	bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
 	bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
+    
+    void DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport);
 
 public:
-	ImpSdrGDIMetaFileImport(SdrModel& rModel);
+	ImpSdrGDIMetaFileImport(
+        SdrModel& rModel, 
+        SdrLayerID nLay, 
+        const basegfx::B2DHomMatrix& rObjectTransform);
 	~ImpSdrGDIMetaFileImport();
-	sal_uInt32 DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, sal_uInt32 nInsPos = CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
-	void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
-	SdrLayerID GetLayer() const { return nLayer; }
-	void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
-	const Rectangle& GetScaleRect() const { return aScaleRect; }
+
+    sal_uInt32 DoImport(
+        const GDIMetaFile& rMtf, 
+        SdrObjList& rDestList, 
+        sal_uInt32 nInsPos = CONTAINER_APPEND, 
+        SvdProgressInfo* pProgrInfo = 0);
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////

Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoashp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoashp.cxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoashp.cxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoashp.cxx Wed May 16 15:07:00 2012
@@ -291,15 +291,17 @@ SdrObject* ImpCreateShadowObjectClone(co
 		// bitmap and transparence like shadow
 		if(bBitmapFillUsed)
 		{
-			XOBitmap aFillBitmap(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetBitmapValue());
-			Bitmap aSourceBitmap(aFillBitmap.GetBitmap());
-			BitmapReadAccess* pReadAccess = aSourceBitmap.AcquireReadAccess();
+            GraphicObject aGraphicObject(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetGraphicObject());
+            const BitmapEx aBitmapEx(aGraphicObject.GetGraphic().GetBitmapEx());
+			Bitmap aBitmap(aBitmapEx.GetBitmap());
 
-			if(!aSourceBitmap.IsEmpty())
+			if(!aBitmap.IsEmpty())
 			{
-				if(pReadAccess)
+    			BitmapReadAccess* pReadAccess = aBitmap.AcquireReadAccess();
+
+                if(pReadAccess)
 				{
-					Bitmap aDestBitmap(aSourceBitmap.GetSizePixel(), 24L);
+					Bitmap aDestBitmap(aBitmap.GetSizePixel(), 24L);
 					BitmapWriteAccess* pWriteAccess = aDestBitmap.AcquireWriteAccess();
 
 					if(pWriteAccess)
@@ -318,14 +320,29 @@ SdrObject* ImpCreateShadowObjectClone(co
 						}
 
 						aDestBitmap.ReleaseAccess(pWriteAccess);
-						aFillBitmap.SetBitmap(aDestBitmap);
 					}
 
-					aSourceBitmap.ReleaseAccess(pReadAccess);
+					aBitmap.ReleaseAccess(pReadAccess);
+
+                    if(aBitmapEx.IsTransparent())
+                    {
+                        if(aBitmapEx.IsAlpha())
+                        {
+                            aGraphicObject.SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetAlpha())));
+                        }
+                        else
+                        {
+                            aGraphicObject.SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetMask())));
+                        }
+                    }
+                    else
+                    {
+                        aGraphicObject.SetGraphic(Graphic(aDestBitmap));
+                    }
 				}
 			}
 
-			aTempSet.Put(XFillBitmapItem(aTempSet.GetPool(), aFillBitmap));
+			aTempSet.Put(XFillBitmapItem(aTempSet.GetPool(), aGraphicObject));
 			aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
 		}
 

Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdograf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdograf.cxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdograf.cxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdograf.cxx Wed May 16 15:07:00 2012
@@ -53,7 +53,6 @@
 #include "svtools/filter.hxx"
 #include <svx/svdograf.hxx>
 #include <svx/svdogrp.hxx>
-#include <svx/xbitmap.hxx>
 #include <svx/xbtmpit.hxx>
 #include <svx/xflbmtit.hxx>
 #include <svx/svdundo.hxx>
@@ -68,6 +67,8 @@
 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
 #include <osl/thread.hxx>
 #include <vos/mutex.hxx>
+#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
+#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::io;
@@ -312,6 +313,58 @@ sdr::contact::ViewContact* SdrGrafObj::C
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// check if SVG and if try to get ObjectInfoPrimitive2D and extract info
+
+void SdrGrafObj::onGraphicChanged()
+{
+    String aName;
+    String aTitle;
+    String aDesc;
+
+    if(pGraphic)
+    {
+        const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData();
+
+        if(rSvgDataPtr.get())
+        {
+            const drawinglayer::primitive2d::Primitive2DSequence aSequence(rSvgDataPtr->getPrimitive2DSequence());
+
+            if(aSequence.hasElements())
+            {
+                drawinglayer::geometry::ViewInformation2D aViewInformation2D;
+                drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor(aViewInformation2D);
+
+                aProcessor.process(aSequence);
+
+                const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
+
+                if(pResult)
+                {
+                    aName = pResult->getName();
+			        aTitle = pResult->getTitle();
+			        aDesc = pResult->getDesc();
+                }
+            }
+        }
+    }
+
+    if(aName.Len())
+    {
+        SetName(aName);
+    }
+
+    if(aTitle.Len())
+    {
+    	SetTitle(aTitle);
+    }
+
+    if(aDesc.Len())
+    {
+    	SetDescription(aDesc);
+    }
+}
+
+//////////////////////////////////////////////////////////////////////////////
 
 SdrGrafObj::SdrGrafObj(
 	SdrModel& rSdrModel, 
@@ -326,6 +379,7 @@ SdrGrafObj::SdrGrafObj(
 	pGraphic = new GraphicObject( rGrf );
     mpReplacementGraphic = 0;
 	pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
+    onGraphicChanged();
 	
     // #i118485# Shear allowed and possible now
     bNoShear = false;
@@ -369,6 +423,7 @@ void SdrGrafObj::copyDataFromSdrObject(c
 			}
 
 			ImpSetAttrToGrafInfo();
+            onGraphicChanged();
 		}
 		else
 		{
@@ -412,6 +467,7 @@ void SdrGrafObj::SetGraphicObject( const
 	pGraphic->SetUserData();
 	mbIsPreview = false;
 	SetChanged();
+    onGraphicChanged();
 }
 
 // -----------------------------------------------------------------------------
@@ -451,6 +507,7 @@ void SdrGrafObj::SetGraphic( const Graph
     mpReplacementGraphic = 0;
 	pGraphic->SetUserData();
 	mbIsPreview = false;
+    onGraphicChanged();
 	SetChanged();
 }
 
@@ -1030,15 +1087,8 @@ SdrObject* SdrGrafObj::DoConvertToPolygo
 		case GRAPHIC_GDIMETAFILE:
 		{
 			// NUR die aus dem MetaFile erzeugbaren Objekte in eine Gruppe packen und zurueckliefern
+			ImpSdrGDIMetaFileImport aFilter(getSdrModelFromSdrObject(), GetLayer(), getSdrObjectTransformation());
 			SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
-			ImpSdrGDIMetaFileImport aFilter(getSdrModelFromSdrObject());
-			const Rectangle aCurrRect(sdr::legacy::GetSnapRect(*this));
-			Point aOutPos( aCurrRect.TopLeft() );
-			const Size aOutSiz( aCurrRect.GetSize() );
-
-			aFilter.SetScaleRect(aCurrRect);
-			aFilter.SetLayer(GetLayer());
-
 			const sal_uInt32 nInsAnz(aFilter.DoImport(GetTransformedGraphic().GetGDIMetaFile(), *pGrp, 0));
 
 			if(nInsAnz)
@@ -1119,12 +1169,12 @@ SdrObject* SdrGrafObj::DoConvertToPolygo
 			{
 				// Bitmap als Fuellung holen
 				SfxItemSet aSet(GetObjectItemSet());
+				const BitmapEx aBitmapEx(GetTransformedGraphic().GetBitmapEx());
 
 				aSet.Put(XFillStyleItem(XFILL_BITMAP));
-				Bitmap aBitmap( GetTransformedGraphic().GetBitmap() );
-				XOBitmap aXBmp(aBitmap, XBITMAP_STRETCH);
-				aSet.Put(XFillBitmapItem(String(), aXBmp));
+				aSet.Put(XFillBitmapItem(String(), Graphic(aBitmapEx)));
 				aSet.Put(XFillBmpTileItem(false));
+                aSet.Put(SfxBoolItem(XATTR_FILLBMP_STRETCH, true));
 
 				pRetval->SetMergedItemSet(aSet);
 			}

Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoole2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoole2.cxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoole2.cxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdoole2.cxx Wed May 16 15:07:00 2012
@@ -1420,7 +1420,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjR
 
         // bitmap fill
         pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
-        pClone->SetMergedItem(XFillBitmapItem(String(), GetEmtyOLEReplacementBitmap()));
+        pClone->SetMergedItem(XFillBitmapItem(String(), Graphic(GetEmtyOLEReplacementBitmap())));
         pClone->SetMergedItem(XFillBmpTileItem(false));
         pClone->SetMergedItem(XFillBmpStretchItem(false));
 

Modified: incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx?rev=1339213&r1=1339212&r2=1339213&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx (original)
+++ incubator/ooo/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx Wed May 16 15:07:00 2012
@@ -73,6 +73,8 @@
 #include <svx/sdr/contact/viewcontact.hxx>
 #include <svx/svdlegacy.hxx>
 #include <basegfx/numeric/ftools.hxx>
+#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
 
 using namespace ::rtl;
 using namespace ::com::sun::star;
@@ -190,6 +192,32 @@ public:
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
+BitmapEx convertMetafileToBitmapEx(
+    const GDIMetaFile& rMtf, 
+    const basegfx::B2DRange& rTargetRange,
+    const sal_uInt32 nMaximumQuadraticPixels)
+{
+    BitmapEx aBitmapEx;
+
+    if(rMtf.GetActionCount())
+    {
+		const drawinglayer::primitive2d::Primitive2DReference aMtf(
+			new drawinglayer::primitive2d::MetafilePrimitive2D(
+				basegfx::tools::createScaleTranslateB2DHomMatrix(
+                    rTargetRange.getRange(),
+                    rTargetRange.getMinimum()),
+				rMtf));
+        aBitmapEx = convertPrimitive2DSequenceToBitmapEx(
+    		drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1),
+            rTargetRange,
+            nMaximumQuadraticPixels);
+    }
+
+    return aBitmapEx;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
 {
 	for(SdrPaintWindowVector::const_iterator a = maPaintWindows.begin(); a != maPaintWindows.end(); a++)
@@ -780,7 +808,7 @@ void SdrPaintView::EndCompleteRedraw(Sdr
 			static_cast< SdrView* >(this)->TextEditDrawing(rPaintWindow);
 		}
 
-			// draw Overlay, also to PreRender device if exists
+        // draw Overlay, also to PreRender device if exists
 		rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion());
 
 		// output PreRendering
@@ -867,6 +895,8 @@ void SdrPaintView::EndDrawLayers(SdrPain
 	}
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const
 {
 	if(mpPageView)



Mime
View raw message