xref: /aoo41x/main/svx/source/svdraw/svdfmtf.cxx (revision 47a7c0c1)
1f6e50924SAndrew Rist /**************************************************************
2f6e50924SAndrew Rist  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "svdfmtf.hxx"
28cdf0e10cSrcweir #include <editeng/editdata.hxx>
29cdf0e10cSrcweir #include <math.h>
30cdf0e10cSrcweir #include <svx/xpoly.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
34cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
35cdf0e10cSrcweir #include <editeng/postitem.hxx>
36cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
37cdf0e10cSrcweir #include <editeng/crsditem.hxx>
38cdf0e10cSrcweir #include <editeng/shdditem.hxx>
39cdf0e10cSrcweir #include <svx/xlnclit.hxx>
405aaf853bSArmin Le Grand #include <svx/xlncapit.hxx>
41cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
42cdf0e10cSrcweir #include <svx/xflclit.hxx>
43cdf0e10cSrcweir #include <svx/xgrad.hxx>
44cdf0e10cSrcweir #include <svx/xflgrit.hxx>
45cdf0e10cSrcweir #include <editeng/fontitem.hxx>
46cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
47cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
48cdf0e10cSrcweir #include <editeng/cntritem.hxx>
49cdf0e10cSrcweir #include <editeng/colritem.hxx>
50cdf0e10cSrcweir #include <vcl/metric.hxx>
51cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
52cdf0e10cSrcweir #include <svx/xflhtit.hxx>
53cdf0e10cSrcweir #include <svx/svdattr.hxx>
54cdf0e10cSrcweir #include <svx/svdmodel.hxx>
55cdf0e10cSrcweir #include <svx/svdpage.hxx>
56cdf0e10cSrcweir #include <svx/svdobj.hxx>
57cdf0e10cSrcweir #include "svx/svditext.hxx"
58cdf0e10cSrcweir #include <svx/svdotext.hxx>
59cdf0e10cSrcweir #include <svx/svdorect.hxx>
60cdf0e10cSrcweir #include <svx/svdocirc.hxx>
61cdf0e10cSrcweir #include <svx/svdograf.hxx>
62cdf0e10cSrcweir #include <svx/svdopath.hxx>
63cdf0e10cSrcweir #include <svx/svdetc.hxx>
64cdf0e10cSrcweir #include <svl/itemset.hxx>
65cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
66cdf0e10cSrcweir #include <vcl/salbtype.hxx>		// FRound
67cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
68cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
69cdf0e10cSrcweir #include <svx/xlinjoit.hxx>
70cdf0e10cSrcweir #include <svx/xlndsit.hxx>
71*47a7c0c1SArmin Le Grand #include <basegfx/polygon/b2dpolygonclipper.hxx>
72*47a7c0c1SArmin Le Grand #include <svx/xbtmpit.hxx>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
75cdf0e10cSrcweir 
76cdf0e10cSrcweir ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(SdrModel& rModel):
77cdf0e10cSrcweir 	nMapScalingOfs(0),
78cdf0e10cSrcweir 	pLineAttr(NULL),pFillAttr(NULL),pTextAttr(NULL),
79cdf0e10cSrcweir 	pPage(NULL),pModel(NULL),nLayer(0),
80cdf0e10cSrcweir 	nLineWidth(0),
81cdf0e10cSrcweir 	maLineJoin(basegfx::B2DLINEJOIN_NONE),
825aaf853bSArmin Le Grand 	maLineCap(com::sun::star::drawing::LineCap_BUTT),
83cdf0e10cSrcweir 	maDash(XDASH_RECT, 0, 0, 0, 0, 0),
84cdf0e10cSrcweir 	bFntDirty(sal_True),
85*47a7c0c1SArmin Le Grand 	bLastObjWasPolyWithoutLine(sal_False),
86*47a7c0c1SArmin Le Grand     bNoLine(sal_False),
87*47a7c0c1SArmin Le Grand     bNoFill(sal_False),
88*47a7c0c1SArmin Le Grand     bLastObjWasLine(sal_False),
89*47a7c0c1SArmin Le Grand     maClip()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	aVD.EnableOutput(sal_False);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // #i111954# init to no fill and no line initially
94cdf0e10cSrcweir     aVD.SetLineColor();
95cdf0e10cSrcweir     aVD.SetFillColor();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	aOldLineColor.SetRed( aVD.GetLineColor().GetRed() + 1 ); // invalidate old line color
98cdf0e10cSrcweir 	pLineAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_LINE_FIRST,XATTR_LINE_LAST);
99cdf0e10cSrcweir 	pFillAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
100cdf0e10cSrcweir 	pTextAttr=new SfxItemSet(rModel.GetItemPool(),EE_ITEMS_START,EE_ITEMS_END);
101cdf0e10cSrcweir 	pModel=&rModel;
102*47a7c0c1SArmin Le Grand     checkClip();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	delete pLineAttr;
108cdf0e10cSrcweir 	delete pFillAttr;
109cdf0e10cSrcweir 	delete pTextAttr;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
113cdf0e10cSrcweir 	SdrObjList& rOL,
114cdf0e10cSrcweir 	sal_uIntPtr nInsPos,
115cdf0e10cSrcweir 	SvdProgressInfo *pProgrInfo)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	pPage = rOL.GetPage();
118cdf0e10cSrcweir 	GDIMetaFile* pTmpMtf=NULL;
119cdf0e10cSrcweir 	GDIMetaFile* pMtf = (GDIMetaFile*) &rMtf;
120cdf0e10cSrcweir 	sal_uIntPtr nActionAnz=pMtf->GetActionCount();
121cdf0e10cSrcweir 	sal_Bool bError = sal_False;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	// setup some global scale parameter
125cdf0e10cSrcweir 	// fScaleX, fScaleY, aScaleX, aScaleY, bMov, bSize
126cdf0e10cSrcweir     fScaleX = fScaleY = 1.0;
127cdf0e10cSrcweir 	Size  aMtfSize( pMtf->GetPrefSize() );
128cdf0e10cSrcweir 	if ( aMtfSize.Width() & aMtfSize.Height() && ( aScaleRect.IsEmpty() == sal_False ) )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir 		aOfs = aScaleRect.TopLeft();
131cdf0e10cSrcweir         if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
132cdf0e10cSrcweir             fScaleX = (double)( aScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
133cdf0e10cSrcweir         if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
134cdf0e10cSrcweir             fScaleY = (double)( aScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	bMov = aOfs.X()!=0 || aOfs.Y()!=0;
138cdf0e10cSrcweir     bSize = sal_False;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	aScaleX = Fraction( 1, 1 );
141cdf0e10cSrcweir 	aScaleY = Fraction( 1, 1 );
142cdf0e10cSrcweir     if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir         aScaleX = Fraction( aScaleRect.GetWidth() - 1, aMtfSize.Width() );
145cdf0e10cSrcweir         bSize = sal_True;
146cdf0e10cSrcweir     }
147cdf0e10cSrcweir     if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
148cdf0e10cSrcweir     {
149cdf0e10cSrcweir         aScaleY = Fraction( aScaleRect.GetHeight() - 1, aMtfSize.Height() );
150cdf0e10cSrcweir         bSize = sal_True;
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	if(65000 < nActionAnz)
154cdf0e10cSrcweir 	{
155cdf0e10cSrcweir 		nActionAnz = 65000;
156cdf0e10cSrcweir 		bError = sal_True;
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	if(pProgrInfo)
160cdf0e10cSrcweir 		pProgrInfo->SetActionCount(nActionAnz);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	sal_uIntPtr nActionsToReport = 0;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	for( MetaAction* pAct = pMtf->FirstAction(); pAct; pAct = pMtf->NextAction() )
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		switch (pAct->GetType())
167cdf0e10cSrcweir 		{
168cdf0e10cSrcweir 			case META_PIXEL_ACTION          : DoAction((MetaPixelAction          &)*pAct); break;
169cdf0e10cSrcweir 			case META_POINT_ACTION          : DoAction((MetaPointAction          &)*pAct); break;
170cdf0e10cSrcweir 			case META_LINE_ACTION           : DoAction((MetaLineAction           &)*pAct); break;
171cdf0e10cSrcweir 			case META_RECT_ACTION           : DoAction((MetaRectAction           &)*pAct); break;
172cdf0e10cSrcweir 			case META_ROUNDRECT_ACTION      : DoAction((MetaRoundRectAction      &)*pAct); break;
173cdf0e10cSrcweir 			case META_ELLIPSE_ACTION        : DoAction((MetaEllipseAction        &)*pAct); break;
174cdf0e10cSrcweir 			case META_ARC_ACTION            : DoAction((MetaArcAction            &)*pAct); break;
175cdf0e10cSrcweir 			case META_PIE_ACTION            : DoAction((MetaPieAction            &)*pAct); break;
176cdf0e10cSrcweir 			case META_CHORD_ACTION          : DoAction((MetaChordAction          &)*pAct); break;
177cdf0e10cSrcweir 			case META_POLYLINE_ACTION	    : DoAction((MetaPolyLineAction		 &)*pAct); break;
178cdf0e10cSrcweir 			case META_POLYGON_ACTION        : DoAction((MetaPolygonAction        &)*pAct); break;
179cdf0e10cSrcweir 			case META_POLYPOLYGON_ACTION    : DoAction((MetaPolyPolygonAction    &)*pAct); break;
180cdf0e10cSrcweir 			case META_TEXT_ACTION           : DoAction((MetaTextAction           &)*pAct); break;
181cdf0e10cSrcweir 			case META_TEXTARRAY_ACTION      : DoAction((MetaTextArrayAction      &)*pAct); break;
182cdf0e10cSrcweir 			case META_STRETCHTEXT_ACTION    : DoAction((MetaStretchTextAction    &)*pAct); break;
183cdf0e10cSrcweir 			case META_BMP_ACTION			: DoAction((MetaBmpAction			 &)*pAct); break;
184cdf0e10cSrcweir 			case META_BMPSCALE_ACTION		: DoAction((MetaBmpScaleAction		 &)*pAct); break;
185cdf0e10cSrcweir 			case META_BMPEX_ACTION			: DoAction((MetaBmpExAction			 &)*pAct); break;
186cdf0e10cSrcweir 			case META_BMPEXSCALE_ACTION		: DoAction((MetaBmpExScaleAction	 &)*pAct); break;
187cdf0e10cSrcweir 			case META_LINECOLOR_ACTION      : DoAction((MetaLineColorAction      &)*pAct); break;
188cdf0e10cSrcweir 			case META_FILLCOLOR_ACTION      : DoAction((MetaFillColorAction      &)*pAct); break;
189cdf0e10cSrcweir 			case META_TEXTCOLOR_ACTION      : DoAction((MetaTextColorAction      &)*pAct); break;
190cdf0e10cSrcweir 			case META_TEXTFILLCOLOR_ACTION  : DoAction((MetaTextFillColorAction  &)*pAct); break;
191cdf0e10cSrcweir 			case META_FONT_ACTION           : DoAction((MetaFontAction           &)*pAct); break;
192cdf0e10cSrcweir 			case META_TEXTALIGN_ACTION		: DoAction((MetaTextAlignAction		 &)*pAct); break;
193cdf0e10cSrcweir 			case META_MAPMODE_ACTION        : DoAction((MetaMapModeAction        &)*pAct); break;
194cdf0e10cSrcweir 			case META_CLIPREGION_ACTION     : DoAction((MetaClipRegionAction     &)*pAct); break;
195cdf0e10cSrcweir 			case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
196cdf0e10cSrcweir 			case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
197cdf0e10cSrcweir 			case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
198cdf0e10cSrcweir 			case META_RASTEROP_ACTION       : DoAction((MetaRasterOpAction       &)*pAct); break;
199cdf0e10cSrcweir 			case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
200cdf0e10cSrcweir 			case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
201cdf0e10cSrcweir 			case META_HATCH_ACTION			: DoAction((MetaHatchAction          &)*pAct); break;
202cdf0e10cSrcweir 			case META_COMMENT_ACTION		: DoAction((MetaCommentAction        &)*pAct, pMtf); break;
203cdf0e10cSrcweir 		}
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 		if(pProgrInfo != NULL)
206cdf0e10cSrcweir 		{
207cdf0e10cSrcweir 		  nActionsToReport++;
208cdf0e10cSrcweir 		  if(nActionsToReport >= 16) // Alle 16 Action updaten
209cdf0e10cSrcweir 		  {
210cdf0e10cSrcweir 			if(!pProgrInfo->ReportActions(nActionsToReport))
211cdf0e10cSrcweir 			  break;
212cdf0e10cSrcweir 			nActionsToReport = 0;
213cdf0e10cSrcweir 		  }
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	if(pProgrInfo != NULL)
218cdf0e10cSrcweir 	{
219cdf0e10cSrcweir 		pProgrInfo->ReportActions(nActionsToReport);
220cdf0e10cSrcweir 		nActionsToReport = 0;
221cdf0e10cSrcweir 	}
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	// MapMode-Scaling  vornehmen
224cdf0e10cSrcweir 	MapScaling();
225cdf0e10cSrcweir 	// Objekte in vorgegebenes Rechteck hineinskalieren
226cdf0e10cSrcweir 	sal_uIntPtr nAnz=aTmpList.GetObjCount();
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	// Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
229cdf0e10cSrcweir 	// Da in aTmpList allerdings weniger eintraege als GetActionCount()
230cdf0e10cSrcweir 	// existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
231cdf0e10cSrcweir 	// hinzugefuegt werden.
232cdf0e10cSrcweir 	nActionsToReport = (pMtf->GetActionCount() - nAnz)*2;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	// Alle noch nicht gemeldeten Rescales melden
236cdf0e10cSrcweir 	if(pProgrInfo)
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir 		pProgrInfo->ReportRescales(nActionsToReport);
239cdf0e10cSrcweir 		pProgrInfo->SetInsertCount(nAnz);
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir 	nActionsToReport = 0;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	// alle in aTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
244cdf0e10cSrcweir 	if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
245cdf0e10cSrcweir 	SdrInsertReason aReason(SDRREASON_VIEWCALL);
246cdf0e10cSrcweir 	for (sal_uIntPtr i=0; i<nAnz; i++)
247cdf0e10cSrcweir 	{
248cdf0e10cSrcweir 		 SdrObject* pObj=aTmpList.GetObj(i);
249cdf0e10cSrcweir 		 rOL.NbcInsertObject(pObj,nInsPos,&aReason);
250cdf0e10cSrcweir 		 nInsPos++;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		if(pProgrInfo != NULL)
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			nActionsToReport++;
255cdf0e10cSrcweir 			if(nActionsToReport >= 32) // Alle 32 Action updaten
256cdf0e10cSrcweir 			{
257cdf0e10cSrcweir 				pProgrInfo->ReportInserts(nActionsToReport);
258cdf0e10cSrcweir 				nActionsToReport = 0;
259cdf0e10cSrcweir 			}
260cdf0e10cSrcweir 		}
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 	if (pTmpMtf!=NULL) delete pTmpMtf;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	// ein letztesmal alle verbliebennen Inserts reporten
265cdf0e10cSrcweir 	if(pProgrInfo != NULL)
266cdf0e10cSrcweir 	{
267cdf0e10cSrcweir 		pProgrInfo->ReportInserts(nActionsToReport);
268cdf0e10cSrcweir 		if(bError)
269cdf0e10cSrcweir 			pProgrInfo->ReportError();
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	return aTmpList.GetObjCount();
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	bNoLine = sal_False; bNoFill = sal_False;
278cdf0e10cSrcweir 	FASTBOOL bLine=sal_True && !bForceTextAttr;
279cdf0e10cSrcweir 	FASTBOOL bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr );
280cdf0e10cSrcweir 	FASTBOOL bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL);
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	if ( bLine )
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		if ( nLineWidth )
285cdf0e10cSrcweir 			pLineAttr->Put( XLineWidthItem( nLineWidth ) );
286cdf0e10cSrcweir         else
287cdf0e10cSrcweir 			pLineAttr->Put( XLineWidthItem( 0 ) );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 		aOldLineColor = aVD.GetLineColor();
290cdf0e10cSrcweir 		if( aVD.IsLineColor() )
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			pLineAttr->Put(XLineStyleItem(XLINE_SOLID));
293cdf0e10cSrcweir 			pLineAttr->Put(XLineColorItem(String(), aVD.GetLineColor()));
294cdf0e10cSrcweir 		}
295cdf0e10cSrcweir 		else
296cdf0e10cSrcweir 			pLineAttr->Put(XLineStyleItem(XLINE_NONE));
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 		switch(maLineJoin)
299cdf0e10cSrcweir 		{
300cdf0e10cSrcweir 			default : // basegfx::B2DLINEJOIN_NONE
301cdf0e10cSrcweir 				pLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
302cdf0e10cSrcweir 				break;
303cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MIDDLE:
304cdf0e10cSrcweir 				pLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
305cdf0e10cSrcweir 				break;
306cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_BEVEL:
307cdf0e10cSrcweir 				pLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
308cdf0e10cSrcweir 				break;
309cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MITER:
310cdf0e10cSrcweir 				pLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
311cdf0e10cSrcweir 				break;
312cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_ROUND:
313cdf0e10cSrcweir 				pLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
314cdf0e10cSrcweir 				break;
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 
3175aaf853bSArmin Le Grand         // Add LineCap support
3185aaf853bSArmin Le Grand         pLineAttr->Put(XLineCapItem(maLineCap));
3195aaf853bSArmin Le Grand 
320cdf0e10cSrcweir 		if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
321cdf0e10cSrcweir 		{
322cdf0e10cSrcweir 			pLineAttr->Put(XLineDashItem(String(), maDash));
323cdf0e10cSrcweir 		}
324cdf0e10cSrcweir         else
325cdf0e10cSrcweir         {
326cdf0e10cSrcweir 			pLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
327cdf0e10cSrcweir         }
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 	else
330cdf0e10cSrcweir 		bNoLine = sal_True;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	if ( bFill )
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		if( aVD.IsFillColor() )
335cdf0e10cSrcweir 		{
336cdf0e10cSrcweir 			pFillAttr->Put(XFillStyleItem(XFILL_SOLID));
337cdf0e10cSrcweir 			pFillAttr->Put(XFillColorItem(String(), aVD.GetFillColor()));
338cdf0e10cSrcweir 		}
339cdf0e10cSrcweir 		else
340cdf0e10cSrcweir 			pFillAttr->Put(XFillStyleItem(XFILL_NONE));
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 	else
343cdf0e10cSrcweir 		bNoFill = sal_True;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	if ( bText && bFntDirty )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir 		Font aFnt(aVD.GetFont());
348cdf0e10cSrcweir 		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
349cdf0e10cSrcweir 							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
350cdf0e10cSrcweir 		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
351cdf0e10cSrcweir 							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
352cdf0e10cSrcweir 		pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
353cdf0e10cSrcweir 							aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
354cdf0e10cSrcweir         pTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
355cdf0e10cSrcweir         pTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
356cdf0e10cSrcweir 		sal_uInt32 nHeight = FRound(aFnt.GetSize().Height() * fScaleY);
357cdf0e10cSrcweir 		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
358cdf0e10cSrcweir 		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
359cdf0e10cSrcweir 		pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
360cdf0e10cSrcweir         pTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
361cdf0e10cSrcweir         pTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
362cdf0e10cSrcweir         pTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
363cdf0e10cSrcweir         pTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
364cdf0e10cSrcweir         pTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
365a5258243SPedro Giffuni 
366a5258243SPedro Giffuni         // #i118485# Setting this item leads to problems (written #i118498# for this)
367a5258243SPedro Giffuni         // pTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
368a5258243SPedro Giffuni 
369cdf0e10cSrcweir         pTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
370cdf0e10cSrcweir         pTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
3712ef01c2fSArmin Le Grand         pTextAttr->Put(SvxColorItem(aVD.GetTextColor(), EE_CHAR_COLOR));
372cdf0e10cSrcweir 		//... svxfont textitem svditext
373cdf0e10cSrcweir 		bFntDirty=sal_False;
374cdf0e10cSrcweir 	}
375cdf0e10cSrcweir 	if (pObj!=NULL)
376cdf0e10cSrcweir 	{
377cdf0e10cSrcweir 		pObj->SetLayer(nLayer);
378cdf0e10cSrcweir 		if (bLine) pObj->SetMergedItemSet(*pLineAttr);
379cdf0e10cSrcweir 		if (bFill) pObj->SetMergedItemSet(*pFillAttr);
380cdf0e10cSrcweir 		if (bText)
381cdf0e10cSrcweir 		{
382cdf0e10cSrcweir 			pObj->SetMergedItemSet(*pTextAttr);
383cdf0e10cSrcweir 			pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_LEFT ) );
384cdf0e10cSrcweir 		}
385cdf0e10cSrcweir 	}
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
388*47a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, sal_Bool bScale)
389cdf0e10cSrcweir {
390*47a7c0c1SArmin Le Grand     if ( bScale && !aScaleRect.IsEmpty() )
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir 		if ( bSize )
393cdf0e10cSrcweir 			pObj->NbcResize( Point(), aScaleX, aScaleY );
394cdf0e10cSrcweir 		if ( bMov )
395cdf0e10cSrcweir 			pObj->NbcMove( Size( aOfs.X(), aOfs.Y() ) );
396cdf0e10cSrcweir 	}
397cdf0e10cSrcweir 
398*47a7c0c1SArmin Le Grand     if(isClip())
399cdf0e10cSrcweir     {
400*47a7c0c1SArmin Le Grand         const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
401*47a7c0c1SArmin Le Grand         const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
402*47a7c0c1SArmin Le Grand     	const SdrLayerID aOldLayer(pObj->GetLayer());
403*47a7c0c1SArmin Le Grand     	const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
404*47a7c0c1SArmin Le Grand         const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
405*47a7c0c1SArmin Le Grand         BitmapEx aBitmapEx;
406*47a7c0c1SArmin Le Grand 
407*47a7c0c1SArmin Le Grand         if(pSdrGrafObj)
408*47a7c0c1SArmin Le Grand         {
409*47a7c0c1SArmin Le Grand         	aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
410*47a7c0c1SArmin Le Grand         }
411cdf0e10cSrcweir 
412*47a7c0c1SArmin Le Grand         SdrObject::Free(pObj);
413*47a7c0c1SArmin Le Grand 
414*47a7c0c1SArmin Le Grand         if(!aOldRange.isEmpty())
415*47a7c0c1SArmin Le Grand         {
416*47a7c0c1SArmin Le Grand             // clip against ClipRegion
417*47a7c0c1SArmin Le Grand             const basegfx::B2DPolyPolygon aNewPoly(
418*47a7c0c1SArmin Le Grand                 basegfx::tools::clipPolyPolygonOnPolyPolygon(
419*47a7c0c1SArmin Le Grand                     aPoly,
420*47a7c0c1SArmin Le Grand                     maClip,
421*47a7c0c1SArmin Le Grand                     true,
422*47a7c0c1SArmin Le Grand                     aPoly.isClosed() ? false : true));
423*47a7c0c1SArmin Le Grand             const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
424*47a7c0c1SArmin Le Grand 
425*47a7c0c1SArmin Le Grand             if(!aNewRange.isEmpty())
426*47a7c0c1SArmin Le Grand             {
427*47a7c0c1SArmin Le Grand                 pObj = new SdrPathObj(
428*47a7c0c1SArmin Le Grand                     aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
429*47a7c0c1SArmin Le Grand                     aNewPoly);
430*47a7c0c1SArmin Le Grand 
431*47a7c0c1SArmin Le Grand 		        pObj->SetLayer(aOldLayer);
432*47a7c0c1SArmin Le Grand 		        pObj->SetMergedItemSet(aOldItemSet);
433*47a7c0c1SArmin Le Grand 
434*47a7c0c1SArmin Le Grand                 if(!!aBitmapEx)
435*47a7c0c1SArmin Le Grand                 {
436*47a7c0c1SArmin Le Grand                     // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
437*47a7c0c1SArmin Le Grand                     const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
438*47a7c0c1SArmin Le Grand                     const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
439*47a7c0c1SArmin Le Grand                     basegfx::B2DRange aPixel(aNewRange);
440*47a7c0c1SArmin Le Grand                     basegfx::B2DHomMatrix aTrans;
441*47a7c0c1SArmin Le Grand 
442*47a7c0c1SArmin Le Grand                     aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
443*47a7c0c1SArmin Le Grand                     aTrans.scale(fScaleX, fScaleY);
444*47a7c0c1SArmin Le Grand                     aPixel.transform(aTrans);
445*47a7c0c1SArmin Le Grand 
446*47a7c0c1SArmin Le Grand                     const BitmapEx aClippedBitmap(
447*47a7c0c1SArmin Le Grand                         aBitmapEx,
448*47a7c0c1SArmin Le Grand                         Point(floor(std::max(0.0, aPixel.getMinX())), floor(std::max(0.0, aPixel.getMinY()))),
449*47a7c0c1SArmin Le Grand                         Size(ceil(aPixel.getWidth()), ceil(aPixel.getHeight())));
450*47a7c0c1SArmin Le Grand 
451*47a7c0c1SArmin Le Grand                     pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
452*47a7c0c1SArmin Le Grand                     pObj->SetMergedItem(XFillBitmapItem(String(), aClippedBitmap.GetBitmap()));
453*47a7c0c1SArmin Le Grand                 }
454*47a7c0c1SArmin Le Grand             }
455*47a7c0c1SArmin Le Grand         }
456cdf0e10cSrcweir     }
457cdf0e10cSrcweir 
458*47a7c0c1SArmin Le Grand     if(pObj)
459cdf0e10cSrcweir     {
460*47a7c0c1SArmin Le Grand         // #i111954# check object for visibility
461*47a7c0c1SArmin Le Grand         // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
462*47a7c0c1SArmin Le Grand         bool bVisible(false);
463cdf0e10cSrcweir 
464*47a7c0c1SArmin Le Grand         if(pObj->HasLineStyle())
465cdf0e10cSrcweir         {
466cdf0e10cSrcweir             bVisible = true;
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir 
469*47a7c0c1SArmin Le Grand         if(!bVisible && pObj->HasFillStyle())
470cdf0e10cSrcweir         {
471cdf0e10cSrcweir             bVisible = true;
472cdf0e10cSrcweir         }
473cdf0e10cSrcweir 
474*47a7c0c1SArmin Le Grand         if(!bVisible)
475*47a7c0c1SArmin Le Grand         {
476*47a7c0c1SArmin Le Grand             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
477*47a7c0c1SArmin Le Grand 
478*47a7c0c1SArmin Le Grand             if(pTextObj && pTextObj->HasText())
479*47a7c0c1SArmin Le Grand             {
480*47a7c0c1SArmin Le Grand                 bVisible = true;
481*47a7c0c1SArmin Le Grand             }
482*47a7c0c1SArmin Le Grand         }
483*47a7c0c1SArmin Le Grand 
484*47a7c0c1SArmin Le Grand         if(!bVisible)
485*47a7c0c1SArmin Le Grand         {
486*47a7c0c1SArmin Le Grand             SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
487*47a7c0c1SArmin Le Grand 
488*47a7c0c1SArmin Le Grand             if(pGrafObj)
489*47a7c0c1SArmin Le Grand             {
490*47a7c0c1SArmin Le Grand                 // this may be refined to check if the graphic really is visible. It
491*47a7c0c1SArmin Le Grand                 // is here to ensure that graphic objects without fill, line and text
492*47a7c0c1SArmin Le Grand                 // get created
493*47a7c0c1SArmin Le Grand                 bVisible = true;
494*47a7c0c1SArmin Le Grand             }
495*47a7c0c1SArmin Le Grand         }
496*47a7c0c1SArmin Le Grand 
497*47a7c0c1SArmin Le Grand         if(!bVisible)
498*47a7c0c1SArmin Le Grand         {
499*47a7c0c1SArmin Le Grand             SdrObject::Free(pObj);
500*47a7c0c1SArmin Le Grand         }
501*47a7c0c1SArmin Le Grand         else
502*47a7c0c1SArmin Le Grand         {
503*47a7c0c1SArmin Le Grand 	        aTmpList.InsertObject( pObj );
504*47a7c0c1SArmin Le Grand 	        if ( HAS_BASE( SdrPathObj, pObj ) )
505*47a7c0c1SArmin Le Grand 	        {
506*47a7c0c1SArmin Le Grand 		        FASTBOOL bClosed=pObj->IsClosedObj();
507*47a7c0c1SArmin Le Grand 		        bLastObjWasPolyWithoutLine=bNoLine && bClosed;
508*47a7c0c1SArmin Le Grand 		        bLastObjWasLine=!bClosed;
509*47a7c0c1SArmin Le Grand 	        }
510*47a7c0c1SArmin Le Grand 	        else
511*47a7c0c1SArmin Le Grand 	        {
512*47a7c0c1SArmin Le Grand 		        bLastObjWasPolyWithoutLine = sal_False;
513*47a7c0c1SArmin Le Grand 		        bLastObjWasLine = sal_False;
514*47a7c0c1SArmin Le Grand 	        }
515*47a7c0c1SArmin Le Grand         }
516cdf0e10cSrcweir     }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir 
519cdf0e10cSrcweir /**************************************************************************************************/
520cdf0e10cSrcweir 
521cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
522cdf0e10cSrcweir {
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
526cdf0e10cSrcweir {
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
530cdf0e10cSrcweir {
531cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
532cdf0e10cSrcweir 	const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
533cdf0e10cSrcweir 	const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	if(!aStart.equal(aEnd))
536cdf0e10cSrcweir 	{
537cdf0e10cSrcweir 		basegfx::B2DPolygon aLine;
538cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 		aLine.append(aStart);
541cdf0e10cSrcweir 		aLine.append(aEnd);
542cdf0e10cSrcweir 		aLine.transform(aTransform);
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 		const LineInfo& rLineInfo = rAct.GetLineInfo();
545cdf0e10cSrcweir 		const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
546cdf0e10cSrcweir 		bool bCreateLineObject(true);
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 		if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aLine))
549cdf0e10cSrcweir 		{
550cdf0e10cSrcweir 			bCreateLineObject = false;
551cdf0e10cSrcweir 		}
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 		if(bCreateLineObject)
554cdf0e10cSrcweir 		{
555cdf0e10cSrcweir 			SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
556cdf0e10cSrcweir 			nLineWidth = nNewLineWidth;
557cdf0e10cSrcweir 			maLineJoin = rLineInfo.GetLineJoin();
5585aaf853bSArmin Le Grand             maLineCap = rLineInfo.GetLineCap();
559cdf0e10cSrcweir 			maDash = XDash(XDASH_RECT,
560cdf0e10cSrcweir 				rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
561cdf0e10cSrcweir 				rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
562cdf0e10cSrcweir 				rLineInfo.GetDistance());
563cdf0e10cSrcweir 			SetAttributes(pPath);
564cdf0e10cSrcweir 			nLineWidth = 0;
565cdf0e10cSrcweir 			maLineJoin = basegfx::B2DLINEJOIN_NONE;
566cdf0e10cSrcweir 			maDash = XDash();
567cdf0e10cSrcweir 			InsertObj(pPath, false);
568cdf0e10cSrcweir 		}
569cdf0e10cSrcweir 	}
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
572cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
573cdf0e10cSrcweir {
574*47a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
575cdf0e10cSrcweir 	SetAttributes(pRect);
576cdf0e10cSrcweir 	InsertObj(pRect);
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
580cdf0e10cSrcweir {
581*47a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
582cdf0e10cSrcweir 	SetAttributes(pRect);
583cdf0e10cSrcweir 	long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
584cdf0e10cSrcweir 	if (nRad!=0) {
585cdf0e10cSrcweir 		SfxItemSet aSet(*pLineAttr->GetPool(),SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS);
586cdf0e10cSrcweir 		aSet.Put(SdrEckenradiusItem(nRad));
587cdf0e10cSrcweir 		pRect->SetMergedItemSet(aSet);
588cdf0e10cSrcweir 	}
589cdf0e10cSrcweir 	InsertObj(pRect);
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir /**************************************************************************************************/
593cdf0e10cSrcweir 
594cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
595cdf0e10cSrcweir {
596*47a7c0c1SArmin Le Grand     SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
597cdf0e10cSrcweir 	SetAttributes(pCirc);
598cdf0e10cSrcweir 	InsertObj(pCirc);
599cdf0e10cSrcweir }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
602cdf0e10cSrcweir {
603*47a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
604cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
605cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
606cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
607cdf0e10cSrcweir 	SetAttributes(pCirc);
608cdf0e10cSrcweir 	InsertObj(pCirc);
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
611cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
612cdf0e10cSrcweir {
613*47a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
614cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
615cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
616cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
617cdf0e10cSrcweir 	SetAttributes(pCirc);
618cdf0e10cSrcweir 	InsertObj(pCirc);
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
622cdf0e10cSrcweir {
623*47a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
624cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
625cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
626cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
627cdf0e10cSrcweir 	SetAttributes(pCirc);
628cdf0e10cSrcweir 	InsertObj(pCirc);
629cdf0e10cSrcweir }
630cdf0e10cSrcweir 
631cdf0e10cSrcweir /**************************************************************************************************/
632cdf0e10cSrcweir 
633cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
634cdf0e10cSrcweir {
635cdf0e10cSrcweir 	// #i102706# Do not merge closed polygons
636cdf0e10cSrcweir 	if(rSrcPoly.isClosed())
637cdf0e10cSrcweir 	{
638cdf0e10cSrcweir 		return false;
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
642cdf0e10cSrcweir 	if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count())
643cdf0e10cSrcweir 	{
644cdf0e10cSrcweir 		SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
645cdf0e10cSrcweir 		SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 		if(pLastPoly)
648cdf0e10cSrcweir 		{
649cdf0e10cSrcweir 			if(1L == pLastPoly->GetPathPoly().count())
650cdf0e10cSrcweir 			{
651cdf0e10cSrcweir 				bool bOk(false);
652cdf0e10cSrcweir 				basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 				// #i102706# Do not merge closed polygons
655cdf0e10cSrcweir 				if(aDstPoly.isClosed())
656cdf0e10cSrcweir 				{
657cdf0e10cSrcweir 					return false;
658cdf0e10cSrcweir 				}
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 				if(aDstPoly.count())
661cdf0e10cSrcweir 				{
662cdf0e10cSrcweir 					const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
663cdf0e10cSrcweir 					const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 					if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
666cdf0e10cSrcweir 					{
667cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
668cdf0e10cSrcweir 						bOk = true;
669cdf0e10cSrcweir 					}
670cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
671cdf0e10cSrcweir 					{
672cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
673cdf0e10cSrcweir 						aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
674cdf0e10cSrcweir 						aDstPoly = aNew;
675cdf0e10cSrcweir 						bOk = true;
676cdf0e10cSrcweir 					}
677cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
678cdf0e10cSrcweir 					{
679cdf0e10cSrcweir 						aDstPoly.flip();
680cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
681cdf0e10cSrcweir 						bOk = true;
682cdf0e10cSrcweir 					}
683cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
684cdf0e10cSrcweir 					{
685cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
686cdf0e10cSrcweir 						aNew.flip();
687cdf0e10cSrcweir 						aDstPoly.append(aNew, 1L, aNew.count() - 1L);
688cdf0e10cSrcweir 						bOk = true;
689cdf0e10cSrcweir 					}
690cdf0e10cSrcweir 				}
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 				if(bOk)
693cdf0e10cSrcweir 				{
694cdf0e10cSrcweir 					pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
695cdf0e10cSrcweir 				}
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 				return bOk;
698cdf0e10cSrcweir 			}
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir 	}
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 	return false;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
705cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
706cdf0e10cSrcweir {
707cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
708cdf0e10cSrcweir 	if(bLastObjWasPolyWithoutLine)
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
711cdf0e10cSrcweir 		SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 		if(pLastPoly)
714cdf0e10cSrcweir 		{
715cdf0e10cSrcweir 			if(pLastPoly->GetPathPoly() == rPolyPolygon)
716cdf0e10cSrcweir 			{
717cdf0e10cSrcweir 				SetAttributes(NULL);
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 				if(!bNoLine && bNoFill)
720cdf0e10cSrcweir 				{
721cdf0e10cSrcweir 					pLastPoly->SetMergedItemSet(*pLineAttr);
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 					return true;
724cdf0e10cSrcweir 				}
725cdf0e10cSrcweir 			}
726cdf0e10cSrcweir 		}
727cdf0e10cSrcweir 	}
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 	return false;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732*47a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::checkClip()
733*47a7c0c1SArmin Le Grand {
734*47a7c0c1SArmin Le Grand     if(aVD.IsClipRegion())
735*47a7c0c1SArmin Le Grand     {
736*47a7c0c1SArmin Le Grand         Region aRegion(aVD.GetClipRegion());
737*47a7c0c1SArmin Le Grand 
738*47a7c0c1SArmin Le Grand         maClip = aRegion.ConvertToB2DPolyPolygon();
739*47a7c0c1SArmin Le Grand 
740*47a7c0c1SArmin Le Grand         if(isClip())
741*47a7c0c1SArmin Le Grand         {
742*47a7c0c1SArmin Le Grand     		const basegfx::B2DHomMatrix aTransform(
743*47a7c0c1SArmin Le Grand                 basegfx::tools::createScaleTranslateB2DHomMatrix(
744*47a7c0c1SArmin Le Grand                     fScaleX,
745*47a7c0c1SArmin Le Grand                     fScaleY,
746*47a7c0c1SArmin Le Grand                     aOfs.X(),
747*47a7c0c1SArmin Le Grand                     aOfs.Y()));
748*47a7c0c1SArmin Le Grand 
749*47a7c0c1SArmin Le Grand             maClip.transform(aTransform);
750*47a7c0c1SArmin Le Grand         }
751*47a7c0c1SArmin Le Grand     }
752*47a7c0c1SArmin Le Grand }
753*47a7c0c1SArmin Le Grand 
754*47a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const
755*47a7c0c1SArmin Le Grand {
756*47a7c0c1SArmin Le Grand     return !maClip.getB2DRange().isEmpty();
757*47a7c0c1SArmin Le Grand }
758cdf0e10cSrcweir 
759cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
762cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 	if(aSource.count())
765cdf0e10cSrcweir 	{
766cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
767cdf0e10cSrcweir 		aSource.transform(aTransform);
768cdf0e10cSrcweir 	}
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	const LineInfo& rLineInfo = rAct.GetLineInfo();
771cdf0e10cSrcweir 	const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
772cdf0e10cSrcweir 	bool bCreateLineObject(true);
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aSource))
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		bCreateLineObject = false;
777cdf0e10cSrcweir 	}
778cdf0e10cSrcweir 	else if(bLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
779cdf0e10cSrcweir 	{
780cdf0e10cSrcweir 		bCreateLineObject = false;
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 	if(bCreateLineObject)
784cdf0e10cSrcweir 	{
785*47a7c0c1SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(
786cdf0e10cSrcweir 			aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
787cdf0e10cSrcweir 			basegfx::B2DPolyPolygon(aSource));
788cdf0e10cSrcweir 		nLineWidth = nNewLineWidth;
789cdf0e10cSrcweir 		maLineJoin = rLineInfo.GetLineJoin();
7905aaf853bSArmin Le Grand         maLineCap = rLineInfo.GetLineCap();
791cdf0e10cSrcweir 		maDash = XDash(XDASH_RECT,
792cdf0e10cSrcweir 			rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
793cdf0e10cSrcweir 			rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
794cdf0e10cSrcweir 			rLineInfo.GetDistance());
795cdf0e10cSrcweir 		SetAttributes(pPath);
796cdf0e10cSrcweir 		nLineWidth = 0;
797cdf0e10cSrcweir 		maLineJoin = basegfx::B2DLINEJOIN_NONE;
798cdf0e10cSrcweir 		maDash = XDash();
799cdf0e10cSrcweir 		InsertObj(pPath, false);
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
806cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 	if(aSource.count())
809cdf0e10cSrcweir 	{
810cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
811cdf0e10cSrcweir 		aSource.transform(aTransform);
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
814cdf0e10cSrcweir 		{
815cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
816cdf0e10cSrcweir 			aSource.setClosed(true);
817*47a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
818cdf0e10cSrcweir 			SetAttributes(pPath);
819cdf0e10cSrcweir 			InsertObj(pPath, false);
820cdf0e10cSrcweir 		}
821cdf0e10cSrcweir 	}
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
825cdf0e10cSrcweir {
826cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
827cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 	if(aSource.count())
830cdf0e10cSrcweir 	{
831cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
832cdf0e10cSrcweir 		aSource.transform(aTransform);
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
835cdf0e10cSrcweir 		{
836cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
837cdf0e10cSrcweir 			aSource.setClosed(true);
838*47a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
839cdf0e10cSrcweir 			SetAttributes(pPath);
840cdf0e10cSrcweir 			InsertObj(pPath, false);
841cdf0e10cSrcweir 		}
842cdf0e10cSrcweir 	}
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir /**************************************************************************************************/
846cdf0e10cSrcweir 
847cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir 	// calc text box size, add 5% to make it fit safely
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 	FontMetric aFontMetric( aVD.GetFontMetric() );
852cdf0e10cSrcweir 	Font aFnt( aVD.GetFont() );
853cdf0e10cSrcweir 	FontAlign eAlg( aFnt.GetAlign() );
854cdf0e10cSrcweir 
855cdf0e10cSrcweir     sal_Int32 nTextWidth = (sal_Int32)( aVD.GetTextWidth( rStr ) * fScaleX );
856cdf0e10cSrcweir     sal_Int32 nTextHeight = (sal_Int32)( aVD.GetTextHeight() * fScaleY );
857cdf0e10cSrcweir 	//sal_Int32 nDxWidth = 0;
858cdf0e10cSrcweir 	//sal_Int32 nLen = rStr.Len();
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 	Point aPos( FRound(rPos.X() * fScaleX + aOfs.X()), FRound(rPos.Y() * fScaleY + aOfs.Y()) );
861cdf0e10cSrcweir     Size aSize( nTextWidth, nTextHeight );
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 	if ( eAlg == ALIGN_BASELINE )
864cdf0e10cSrcweir 		aPos.Y() -= FRound(aFontMetric.GetAscent() * fScaleY);
865cdf0e10cSrcweir 	else if ( eAlg == ALIGN_BOTTOM )
866cdf0e10cSrcweir 		aPos.Y() -= nTextHeight;
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 	Rectangle aTextRect( aPos, aSize );
869cdf0e10cSrcweir 	SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 	if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
872cdf0e10cSrcweir 	{
873cdf0e10cSrcweir 		pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
874cdf0e10cSrcweir 		pText->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
875cdf0e10cSrcweir 		// don't let the margins eat the space needed for the text
876cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextUpperDistItem (0));
877cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextLowerDistItem (0));
878cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextRightDistItem (0));
879cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextLeftDistItem (0));
880cdf0e10cSrcweir 		pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
881cdf0e10cSrcweir 	}
882cdf0e10cSrcweir 	else
883cdf0e10cSrcweir 		pText->SetMergedItem( SdrTextAutoGrowWidthItem( sal_True ) );
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 	pText->SetModel( pModel );
886cdf0e10cSrcweir 	pText->SetLayer( nLayer );
887cdf0e10cSrcweir 	pText->NbcSetText( rStr );
888cdf0e10cSrcweir 	SetAttributes( pText, sal_True );
889cdf0e10cSrcweir 	pText->SetSnapRect( aTextRect );
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 	if (!aFnt.IsTransparent())
892cdf0e10cSrcweir 	{
893cdf0e10cSrcweir 		SfxItemSet aAttr(*pFillAttr->GetPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
894cdf0e10cSrcweir 		aAttr.Put(XFillStyleItem(XFILL_SOLID));
895cdf0e10cSrcweir 		aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
896cdf0e10cSrcweir 		pText->SetMergedItemSet(aAttr);
897cdf0e10cSrcweir 	}
898cdf0e10cSrcweir 	sal_uInt32 nWink = aFnt.GetOrientation();
899cdf0e10cSrcweir 	if ( nWink )
900cdf0e10cSrcweir 	{
901cdf0e10cSrcweir 		nWink*=10;
902cdf0e10cSrcweir 		double a=nWink*nPi180;
903cdf0e10cSrcweir 		double nSin=sin(a);
904cdf0e10cSrcweir 		double nCos=cos(a);
905cdf0e10cSrcweir 		pText->NbcRotate(aPos,nWink,nSin,nCos);
906cdf0e10cSrcweir 	}
907cdf0e10cSrcweir 	InsertObj( pText, sal_False );
908cdf0e10cSrcweir }
909cdf0e10cSrcweir 
910cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
913cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
914cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
915cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
919cdf0e10cSrcweir {
920cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
921cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
922cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
923cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
924cdf0e10cSrcweir }
925cdf0e10cSrcweir 
926cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
927cdf0e10cSrcweir {
928cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
929cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
930cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
931cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
935cdf0e10cSrcweir {
936cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
937cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
938*47a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
939cdf0e10cSrcweir 	InsertObj(pGraf);
940cdf0e10cSrcweir }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
943cdf0e10cSrcweir {
944cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
945cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
946*47a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
947cdf0e10cSrcweir 	InsertObj(pGraf);
948cdf0e10cSrcweir }
949cdf0e10cSrcweir 
950cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
951cdf0e10cSrcweir {
952cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
953cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
954*47a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
955cdf0e10cSrcweir 	InsertObj(pGraf);
956cdf0e10cSrcweir }
957cdf0e10cSrcweir 
958cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
959cdf0e10cSrcweir {
960cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
961cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
962*47a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
963cdf0e10cSrcweir 	InsertObj(pGraf);
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
967cdf0e10cSrcweir 
968cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
971cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	if(aSource.count())
974cdf0e10cSrcweir 	{
975cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
976cdf0e10cSrcweir 		aSource.transform(aTransform);
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 		if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
979cdf0e10cSrcweir 		{
980cdf0e10cSrcweir 			const Hatch& rHatch = rAct.GetHatch();
981*47a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
982cdf0e10cSrcweir 			SfxItemSet aHatchAttr(pModel->GetItemPool(),
983cdf0e10cSrcweir 				XATTR_FILLSTYLE, XATTR_FILLSTYLE,
984cdf0e10cSrcweir 				XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0 );
985cdf0e10cSrcweir 			XHatchStyle eStyle;
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 			switch(rHatch.GetStyle())
988cdf0e10cSrcweir 			{
989cdf0e10cSrcweir 				case(HATCH_TRIPLE) :
990cdf0e10cSrcweir 				{
991cdf0e10cSrcweir 					eStyle = XHATCH_TRIPLE;
992cdf0e10cSrcweir 					break;
993cdf0e10cSrcweir 				}
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 				case(HATCH_DOUBLE) :
996cdf0e10cSrcweir 				{
997cdf0e10cSrcweir 					eStyle = XHATCH_DOUBLE;
998cdf0e10cSrcweir 					break;
999cdf0e10cSrcweir 				}
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 				default:
1002cdf0e10cSrcweir 				{
1003cdf0e10cSrcweir 					eStyle = XHATCH_SINGLE;
1004cdf0e10cSrcweir 					break;
1005cdf0e10cSrcweir 				}
1006cdf0e10cSrcweir 			}
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 			SetAttributes(pPath);
1009cdf0e10cSrcweir 			aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
1010cdf0e10cSrcweir 			aHatchAttr.Put(XFillHatchItem(&pModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
1011cdf0e10cSrcweir 			pPath->SetMergedItemSet(aHatchAttr);
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 			InsertObj(pPath, false);
1014cdf0e10cSrcweir 		}
1015cdf0e10cSrcweir 	}
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir 	rAct.Execute(&aVD);
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir 	MapScaling();
1028cdf0e10cSrcweir 	rAct.Execute(&aVD);
1029cdf0e10cSrcweir 	bLastObjWasPolyWithoutLine=sal_False;
1030cdf0e10cSrcweir 	bLastObjWasLine=sal_False;
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling()
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir 	sal_uInt32 i, nAnz = aTmpList.GetObjCount();
1036cdf0e10cSrcweir 	const MapMode& rMap = aVD.GetMapMode();
1037cdf0e10cSrcweir 	Point aMapOrg( rMap.GetOrigin() );
1038cdf0e10cSrcweir 	sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
1039cdf0e10cSrcweir 	if ( bMov2 )
1040cdf0e10cSrcweir     {
1041cdf0e10cSrcweir 		for ( i = nMapScalingOfs; i < nAnz; i++ )
1042cdf0e10cSrcweir         {
1043cdf0e10cSrcweir 			SdrObject* pObj = aTmpList.GetObj(i);
1044cdf0e10cSrcweir 			if ( bMov2 )
1045cdf0e10cSrcweir 				pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) );
1046cdf0e10cSrcweir 		}
1047cdf0e10cSrcweir 	}
1048cdf0e10cSrcweir 	nMapScalingOfs = nAnz;
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	ByteString aSkipComment;
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1058cdf0e10cSrcweir 	{
1059cdf0e10cSrcweir 		MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 		if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
1062cdf0e10cSrcweir 		{
1063cdf0e10cSrcweir 			// #i73407# reformulation to use new B2DPolygon classes
1064cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 			if(aSource.count())
1067cdf0e10cSrcweir 			{
1068cdf0e10cSrcweir 				if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1069cdf0e10cSrcweir 				{
1070cdf0e10cSrcweir 					const Gradient&	rGrad = pAct->GetGradient();
1071*47a7c0c1SArmin Le Grand                     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1072cdf0e10cSrcweir 					SfxItemSet aGradAttr(pModel->GetItemPool(),
1073cdf0e10cSrcweir 					   XATTR_FILLSTYLE, XATTR_FILLSTYLE,
1074cdf0e10cSrcweir 					   XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0 );
1075cdf0e10cSrcweir 					XGradient aXGradient;
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 					aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
1078cdf0e10cSrcweir 					aXGradient.SetStartColor(rGrad.GetStartColor());
1079cdf0e10cSrcweir 					aXGradient.SetEndColor(rGrad.GetEndColor());
1080cdf0e10cSrcweir 					aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
1081cdf0e10cSrcweir 					aXGradient.SetBorder(rGrad.GetBorder());
1082cdf0e10cSrcweir 					aXGradient.SetXOffset(rGrad.GetOfsX());
1083cdf0e10cSrcweir 					aXGradient.SetYOffset(rGrad.GetOfsY());
1084cdf0e10cSrcweir 					aXGradient.SetStartIntens(rGrad.GetStartIntensity());
1085cdf0e10cSrcweir 					aXGradient.SetEndIntens(rGrad.GetEndIntensity());
1086cdf0e10cSrcweir 					aXGradient.SetSteps(rGrad.GetSteps());
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir             		if(aVD.IsLineColor())
1089cdf0e10cSrcweir                     {
1090cdf0e10cSrcweir                         // switch line off; when there was one there will be a
1091cdf0e10cSrcweir                         // META_POLYLINE_ACTION following creating another object
1092cdf0e10cSrcweir     		            const Color aLineColor(aVD.GetLineColor());
1093cdf0e10cSrcweir     		            aVD.SetLineColor();
1094cdf0e10cSrcweir                         SetAttributes(pPath);
1095cdf0e10cSrcweir     		            aVD.SetLineColor(aLineColor);
1096cdf0e10cSrcweir                     }
1097cdf0e10cSrcweir                     else
1098cdf0e10cSrcweir                     {
1099cdf0e10cSrcweir                         SetAttributes(pPath);
1100cdf0e10cSrcweir                     }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 					aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
1103cdf0e10cSrcweir 					aGradAttr.Put(XFillGradientItem(&pModel->GetItemPool(), aXGradient));
1104cdf0e10cSrcweir 					pPath->SetMergedItemSet(aGradAttr);
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 					InsertObj(pPath);
1107cdf0e10cSrcweir 				}
1108cdf0e10cSrcweir 			}
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir 			aSkipComment = "XGRAD_SEQ_END";
1111cdf0e10cSrcweir 		}
1112cdf0e10cSrcweir 	}
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir 	if(aSkipComment.Len())
1115cdf0e10cSrcweir 	{
1116cdf0e10cSrcweir 		MetaAction* pSkipAct = pMtf->NextAction();
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 		while( pSkipAct
1119cdf0e10cSrcweir 			&& ((pSkipAct->GetType() != META_COMMENT_ACTION )
1120cdf0e10cSrcweir 				|| (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
1121cdf0e10cSrcweir 		{
1122cdf0e10cSrcweir 			pSkipAct = pMtf->NextAction();
1123cdf0e10cSrcweir 		}
1124cdf0e10cSrcweir 	}
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1128cdf0e10cSrcweir // eof
1129