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