xref: /aoo41x/main/svx/source/svdraw/svdfmtf.cxx (revision 8718d260)
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>
7147a7c0c1SArmin Le Grand #include <basegfx/polygon/b2dpolygonclipper.hxx>
7247a7c0c1SArmin Le Grand #include <svx/xbtmpit.hxx>
73*8718d260SArmin Le Grand #include <svx/xfltrit.hxx>
74*8718d260SArmin Le Grand #include <vcl/bmpacc.hxx>
75*8718d260SArmin Le Grand #include <vcl/svgdata.hxx>
76*8718d260SArmin Le Grand #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
77cdf0e10cSrcweir 
78cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
79cdf0e10cSrcweir 
80*8718d260SArmin Le Grand ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
81*8718d260SArmin Le Grand     SdrModel& rModel,
82*8718d260SArmin Le Grand     SdrLayerID nLay,
83*8718d260SArmin Le Grand     const Rectangle& rRect)
84*8718d260SArmin Le Grand :   maTmpList(),
85*8718d260SArmin Le Grand     maVD(),
86*8718d260SArmin Le Grand     maScaleRect(rRect),
87*8718d260SArmin Le Grand     mnMapScalingOfs(0),
88*8718d260SArmin Le Grand 	mpLineAttr(0),
89*8718d260SArmin Le Grand     mpFillAttr(0),
90*8718d260SArmin Le Grand     mpTextAttr(0),
91*8718d260SArmin Le Grand     mpModel(&rModel),
92*8718d260SArmin Le Grand     mnLayer(nLay),
93*8718d260SArmin Le Grand     maOldLineColor(),
94*8718d260SArmin Le Grand 	mnLineWidth(0),
95cdf0e10cSrcweir 	maLineJoin(basegfx::B2DLINEJOIN_NONE),
965aaf853bSArmin Le Grand 	maLineCap(com::sun::star::drawing::LineCap_BUTT),
97cdf0e10cSrcweir 	maDash(XDASH_RECT, 0, 0, 0, 0, 0),
98*8718d260SArmin Le Grand     mbMov(false),
99*8718d260SArmin Le Grand     mbSize(false),
100*8718d260SArmin Le Grand     maOfs(0, 0),
101*8718d260SArmin Le Grand     mfScaleX(1.0),
102*8718d260SArmin Le Grand     mfScaleY(1.0),
103*8718d260SArmin Le Grand     maScaleX(1.0),
104*8718d260SArmin Le Grand     maScaleY(1.0),
105*8718d260SArmin Le Grand 	mbFntDirty(true),
106*8718d260SArmin Le Grand 	mbLastObjWasPolyWithoutLine(false),
107*8718d260SArmin Le Grand     mbNoLine(false),
108*8718d260SArmin Le Grand     mbNoFill(false),
109*8718d260SArmin Le Grand     mbLastObjWasLine(false),
11047a7c0c1SArmin Le Grand     maClip()
111cdf0e10cSrcweir {
112*8718d260SArmin Le Grand 	maVD.EnableOutput(false);
113*8718d260SArmin Le Grand     maVD.SetLineColor();
114*8718d260SArmin Le Grand     maVD.SetFillColor();
115*8718d260SArmin Le Grand 	maOldLineColor.SetRed( maVD.GetLineColor().GetRed() + 1 );
116*8718d260SArmin Le Grand 	mpLineAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_LINE_FIRST, XATTR_LINE_LAST, 0, 0);
117*8718d260SArmin Le Grand 	mpFillAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
118*8718d260SArmin Le Grand 	mpTextAttr = new SfxItemSet(rModel.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END, 0, 0);
11947a7c0c1SArmin Le Grand     checkClip();
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
123cdf0e10cSrcweir {
124*8718d260SArmin Le Grand 	delete mpLineAttr;
125*8718d260SArmin Le Grand 	delete mpFillAttr;
126*8718d260SArmin Le Grand 	delete mpTextAttr;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
130cdf0e10cSrcweir {
131*8718d260SArmin Le Grand 	for( MetaAction* pAct = rMtf.FirstAction(); pAct; pAct = rMtf.NextAction() )
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		switch (pAct->GetType())
134cdf0e10cSrcweir 		{
135cdf0e10cSrcweir 			case META_PIXEL_ACTION          : DoAction((MetaPixelAction          &)*pAct); break;
136cdf0e10cSrcweir 			case META_POINT_ACTION          : DoAction((MetaPointAction          &)*pAct); break;
137cdf0e10cSrcweir 			case META_LINE_ACTION           : DoAction((MetaLineAction           &)*pAct); break;
138cdf0e10cSrcweir 			case META_RECT_ACTION           : DoAction((MetaRectAction           &)*pAct); break;
139cdf0e10cSrcweir 			case META_ROUNDRECT_ACTION      : DoAction((MetaRoundRectAction      &)*pAct); break;
140cdf0e10cSrcweir 			case META_ELLIPSE_ACTION        : DoAction((MetaEllipseAction        &)*pAct); break;
141cdf0e10cSrcweir 			case META_ARC_ACTION            : DoAction((MetaArcAction            &)*pAct); break;
142cdf0e10cSrcweir 			case META_PIE_ACTION            : DoAction((MetaPieAction            &)*pAct); break;
143cdf0e10cSrcweir 			case META_CHORD_ACTION          : DoAction((MetaChordAction          &)*pAct); break;
144cdf0e10cSrcweir 			case META_POLYLINE_ACTION	    : DoAction((MetaPolyLineAction		 &)*pAct); break;
145cdf0e10cSrcweir 			case META_POLYGON_ACTION        : DoAction((MetaPolygonAction        &)*pAct); break;
146cdf0e10cSrcweir 			case META_POLYPOLYGON_ACTION    : DoAction((MetaPolyPolygonAction    &)*pAct); break;
147cdf0e10cSrcweir 			case META_TEXT_ACTION           : DoAction((MetaTextAction           &)*pAct); break;
148cdf0e10cSrcweir 			case META_TEXTARRAY_ACTION      : DoAction((MetaTextArrayAction      &)*pAct); break;
149cdf0e10cSrcweir 			case META_STRETCHTEXT_ACTION    : DoAction((MetaStretchTextAction    &)*pAct); break;
150cdf0e10cSrcweir 			case META_BMP_ACTION			: DoAction((MetaBmpAction			 &)*pAct); break;
151cdf0e10cSrcweir 			case META_BMPSCALE_ACTION		: DoAction((MetaBmpScaleAction		 &)*pAct); break;
152cdf0e10cSrcweir 			case META_BMPEX_ACTION			: DoAction((MetaBmpExAction			 &)*pAct); break;
153cdf0e10cSrcweir 			case META_BMPEXSCALE_ACTION		: DoAction((MetaBmpExScaleAction	 &)*pAct); break;
154cdf0e10cSrcweir 			case META_LINECOLOR_ACTION      : DoAction((MetaLineColorAction      &)*pAct); break;
155cdf0e10cSrcweir 			case META_FILLCOLOR_ACTION      : DoAction((MetaFillColorAction      &)*pAct); break;
156cdf0e10cSrcweir 			case META_TEXTCOLOR_ACTION      : DoAction((MetaTextColorAction      &)*pAct); break;
157cdf0e10cSrcweir 			case META_TEXTFILLCOLOR_ACTION  : DoAction((MetaTextFillColorAction  &)*pAct); break;
158cdf0e10cSrcweir 			case META_FONT_ACTION           : DoAction((MetaFontAction           &)*pAct); break;
159cdf0e10cSrcweir 			case META_TEXTALIGN_ACTION		: DoAction((MetaTextAlignAction		 &)*pAct); break;
160cdf0e10cSrcweir 			case META_MAPMODE_ACTION        : DoAction((MetaMapModeAction        &)*pAct); break;
161cdf0e10cSrcweir 			case META_CLIPREGION_ACTION     : DoAction((MetaClipRegionAction     &)*pAct); break;
162cdf0e10cSrcweir 			case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
163cdf0e10cSrcweir 			case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
164cdf0e10cSrcweir 			case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
165cdf0e10cSrcweir 			case META_RASTEROP_ACTION       : DoAction((MetaRasterOpAction       &)*pAct); break;
166cdf0e10cSrcweir 			case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
167cdf0e10cSrcweir 			case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
168cdf0e10cSrcweir 			case META_HATCH_ACTION			: DoAction((MetaHatchAction          &)*pAct); break;
169*8718d260SArmin Le Grand 			case META_COMMENT_ACTION		: DoAction((MetaCommentAction        &)*pAct, &rMtf); break;
170*8718d260SArmin Le Grand 
171*8718d260SArmin Le Grand             // missing actions added
172*8718d260SArmin Le Grand             case META_TEXTRECT_ACTION       : DoAction((MetaTextRectAction&)*pAct); break;
173*8718d260SArmin Le Grand             case META_BMPSCALEPART_ACTION   : DoAction((MetaBmpScalePartAction&)*pAct); break;
174*8718d260SArmin Le Grand             case META_BMPEXSCALEPART_ACTION : DoAction((MetaBmpExScalePartAction&)*pAct); break;
175*8718d260SArmin Le Grand             case META_MASK_ACTION           : DoAction((MetaMaskAction&)*pAct); break;
176*8718d260SArmin Le Grand             case META_MASKSCALE_ACTION      : DoAction((MetaMaskScaleAction&)*pAct); break;
177*8718d260SArmin Le Grand             case META_MASKSCALEPART_ACTION  : DoAction((MetaMaskScalePartAction&)*pAct); break;
178*8718d260SArmin Le Grand             case META_GRADIENT_ACTION       : DoAction((MetaGradientAction&)*pAct); break;
179*8718d260SArmin Le Grand             case META_WALLPAPER_ACTION      : DoAction((MetaWallpaperAction&)*pAct); break;
180*8718d260SArmin Le Grand             case META_TRANSPARENT_ACTION    : DoAction((MetaTransparentAction&)*pAct); break;
181*8718d260SArmin Le Grand             case META_EPS_ACTION            : DoAction((MetaEPSAction&)*pAct); break;
182*8718d260SArmin Le Grand             case META_REFPOINT_ACTION       : DoAction((MetaRefPointAction&)*pAct); break;
183*8718d260SArmin Le Grand             case META_TEXTLINECOLOR_ACTION  : DoAction((MetaTextLineColorAction&)*pAct); break;
184*8718d260SArmin Le Grand             case META_TEXTLINE_ACTION       : DoAction((MetaTextLineAction&)*pAct); break;
185*8718d260SArmin Le Grand             case META_FLOATTRANSPARENT_ACTION : DoAction((MetaFloatTransparentAction&)*pAct); break;
186*8718d260SArmin Le Grand             case META_GRADIENTEX_ACTION     : DoAction((MetaGradientExAction&)*pAct); break;
187*8718d260SArmin Le Grand             case META_LAYOUTMODE_ACTION     : DoAction((MetaLayoutModeAction&)*pAct); break;
188*8718d260SArmin Le Grand             case META_TEXTLANGUAGE_ACTION   : DoAction((MetaTextLanguageAction&)*pAct); break;
189*8718d260SArmin Le Grand             case META_OVERLINECOLOR_ACTION  : DoAction((MetaOverlineColorAction&)*pAct); break;
190cdf0e10cSrcweir 		}
191cdf0e10cSrcweir 
192*8718d260SArmin Le Grand 		if(pProgrInfo && pActionsToReport)
193cdf0e10cSrcweir 		{
194*8718d260SArmin Le Grand             (*pActionsToReport)++;
195*8718d260SArmin Le Grand 
196*8718d260SArmin Le Grand             if(*pActionsToReport >= 16) // Alle 16 Action updaten
197*8718d260SArmin Le Grand             {
198*8718d260SArmin Le Grand                 if(!pProgrInfo->ReportActions(*pActionsToReport))
199*8718d260SArmin Le Grand                     break;
200*8718d260SArmin Le Grand 
201*8718d260SArmin Le Grand                 *pActionsToReport = 0;
202*8718d260SArmin Le Grand             }
203cdf0e10cSrcweir 		}
204cdf0e10cSrcweir 	}
205*8718d260SArmin Le Grand }
206cdf0e10cSrcweir 
207*8718d260SArmin Le Grand sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(
208*8718d260SArmin Le Grand     const GDIMetaFile& rMtf,
209*8718d260SArmin Le Grand 	SdrObjList& rOL,
210*8718d260SArmin Le Grand 	sal_uInt32 nInsPos,
211*8718d260SArmin Le Grand 	SvdProgressInfo* pProgrInfo)
212*8718d260SArmin Le Grand {
213*8718d260SArmin Le Grand 	// setup some global scale parameter
214*8718d260SArmin Le Grand 	// mfScaleX, mfScaleY, maScaleX, maScaleY, mbMov, mbSize
215*8718d260SArmin Le Grand     mfScaleX = mfScaleY = 1.0;
216*8718d260SArmin Le Grand 	const Size aMtfSize(rMtf.GetPrefSize());
217*8718d260SArmin Le Grand 
218*8718d260SArmin Le Grand     if(aMtfSize.Width() & aMtfSize.Height() && (!maScaleRect.IsEmpty()))
219*8718d260SArmin Le Grand     {
220*8718d260SArmin Le Grand 		maOfs = maScaleRect.TopLeft();
221*8718d260SArmin Le Grand 
222*8718d260SArmin Le Grand         if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
223*8718d260SArmin Le Grand         {
224*8718d260SArmin Le Grand             mfScaleX = (double)( maScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
225*8718d260SArmin Le Grand         }
226*8718d260SArmin Le Grand 
227*8718d260SArmin Le Grand         if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
228*8718d260SArmin Le Grand         {
229*8718d260SArmin Le Grand             mfScaleY = (double)( maScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
230*8718d260SArmin Le Grand         }
231*8718d260SArmin Le Grand     }
232*8718d260SArmin Le Grand 
233*8718d260SArmin Le Grand 	mbMov = maOfs.X()!=0 || maOfs.Y()!=0;
234*8718d260SArmin Le Grand     mbSize = false;
235*8718d260SArmin Le Grand 	maScaleX = Fraction( 1, 1 );
236*8718d260SArmin Le Grand 	maScaleY = Fraction( 1, 1 );
237*8718d260SArmin Le Grand 
238*8718d260SArmin Le Grand     if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
239*8718d260SArmin Le Grand     {
240*8718d260SArmin Le Grand         maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width());
241*8718d260SArmin Le Grand         mbSize = true;
242*8718d260SArmin Le Grand     }
243*8718d260SArmin Le Grand 
244*8718d260SArmin Le Grand     if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
245*8718d260SArmin Le Grand     {
246*8718d260SArmin Le Grand         maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height());
247*8718d260SArmin Le Grand         mbSize = true;
248*8718d260SArmin Le Grand     }
249*8718d260SArmin Le Grand 
250*8718d260SArmin Le Grand 	if(pProgrInfo)
251*8718d260SArmin Le Grand     {
252*8718d260SArmin Le Grand 		pProgrInfo->SetActionCount(rMtf.GetActionCount());
253*8718d260SArmin Le Grand     }
254*8718d260SArmin Le Grand 
255*8718d260SArmin Le Grand 	sal_uInt32 nActionsToReport(0);
256*8718d260SArmin Le Grand 
257*8718d260SArmin Le Grand     // execute
258*8718d260SArmin Le Grand     DoLoopActions(const_cast< GDIMetaFile& >(rMtf), pProgrInfo, &nActionsToReport);
259*8718d260SArmin Le Grand 
260*8718d260SArmin Le Grand     if(pProgrInfo)
261cdf0e10cSrcweir 	{
262cdf0e10cSrcweir 		pProgrInfo->ReportActions(nActionsToReport);
263cdf0e10cSrcweir 		nActionsToReport = 0;
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	// MapMode-Scaling  vornehmen
267cdf0e10cSrcweir 	MapScaling();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	// Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
270*8718d260SArmin Le Grand 	// Da in maTmpList allerdings weniger eintraege als GetActionCount()
271cdf0e10cSrcweir 	// existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
272cdf0e10cSrcweir 	// hinzugefuegt werden.
273*8718d260SArmin Le Grand 	nActionsToReport = (rMtf.GetActionCount() - maTmpList.size()) * 2;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	// Alle noch nicht gemeldeten Rescales melden
276cdf0e10cSrcweir 	if(pProgrInfo)
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		pProgrInfo->ReportRescales(nActionsToReport);
279*8718d260SArmin Le Grand 		pProgrInfo->SetInsertCount(maTmpList.size());
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282*8718d260SArmin Le Grand     nActionsToReport = 0;
283*8718d260SArmin Le Grand 
284*8718d260SArmin Le Grand 	// alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
285*8718d260SArmin Le Grand 	if(nInsPos > rOL.GetObjCount())
286*8718d260SArmin Le Grand     {
287*8718d260SArmin Le Grand         nInsPos = rOL.GetObjCount();
288*8718d260SArmin Le Grand     }
289*8718d260SArmin Le Grand 
290cdf0e10cSrcweir 	SdrInsertReason aReason(SDRREASON_VIEWCALL);
291*8718d260SArmin Le Grand 
292*8718d260SArmin Le Grand 	for(sal_uInt32 i(0); i < maTmpList.size(); i++)
293cdf0e10cSrcweir 	{
294*8718d260SArmin Le Grand 		SdrObject* pObj = maTmpList[i];
295*8718d260SArmin Le Grand 		rOL.NbcInsertObject(pObj, nInsPos, &aReason);
296*8718d260SArmin Le Grand 		nInsPos++;
297cdf0e10cSrcweir 
298*8718d260SArmin Le Grand 		if(pProgrInfo)
299cdf0e10cSrcweir 		{
300cdf0e10cSrcweir 			nActionsToReport++;
301*8718d260SArmin Le Grand 
302*8718d260SArmin Le Grand             if(nActionsToReport >= 32) // Alle 32 Action updaten
303cdf0e10cSrcweir 			{
304cdf0e10cSrcweir 				pProgrInfo->ReportInserts(nActionsToReport);
305cdf0e10cSrcweir 				nActionsToReport = 0;
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 		}
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	// ein letztesmal alle verbliebennen Inserts reporten
311*8718d260SArmin Le Grand 	if(pProgrInfo)
312cdf0e10cSrcweir 	{
313cdf0e10cSrcweir 		pProgrInfo->ReportInserts(nActionsToReport);
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 
316*8718d260SArmin Le Grand 	return maTmpList.size();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
320cdf0e10cSrcweir {
321*8718d260SArmin Le Grand 	mbNoLine = false;
322*8718d260SArmin Le Grand     mbNoFill = false;
323*8718d260SArmin Le Grand 	bool bLine(!bForceTextAttr);
324*8718d260SArmin Le Grand 	bool bFill(!pObj || (pObj->IsClosedObj() && !bForceTextAttr));
325*8718d260SArmin Le Grand 	bool bText(bForceTextAttr || (pObj && pObj->GetOutlinerParaObject()));
326cdf0e10cSrcweir 
327*8718d260SArmin Le Grand 	if(bLine)
328cdf0e10cSrcweir 	{
329*8718d260SArmin Le Grand 		if(mnLineWidth)
330*8718d260SArmin Le Grand         {
331*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineWidthItem(mnLineWidth));
332*8718d260SArmin Le Grand         }
333cdf0e10cSrcweir         else
334*8718d260SArmin Le Grand         {
335*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineWidthItem(0));
336*8718d260SArmin Le Grand         }
337*8718d260SArmin Le Grand 
338*8718d260SArmin Le Grand 		maOldLineColor = maVD.GetLineColor();
339cdf0e10cSrcweir 
340*8718d260SArmin Le Grand         if(maVD.IsLineColor())
341cdf0e10cSrcweir 		{
342*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineStyleItem(XLINE_SOLID));
343*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor()));
344cdf0e10cSrcweir 		}
345cdf0e10cSrcweir 		else
346*8718d260SArmin Le Grand         {
347*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineStyleItem(XLINE_NONE));
348*8718d260SArmin Le Grand         }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 		switch(maLineJoin)
351cdf0e10cSrcweir 		{
352cdf0e10cSrcweir 			default : // basegfx::B2DLINEJOIN_NONE
353*8718d260SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
354cdf0e10cSrcweir 				break;
355cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MIDDLE:
356*8718d260SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
357cdf0e10cSrcweir 				break;
358cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_BEVEL:
359*8718d260SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
360cdf0e10cSrcweir 				break;
361cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MITER:
362*8718d260SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
363cdf0e10cSrcweir 				break;
364cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_ROUND:
365*8718d260SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
366cdf0e10cSrcweir 				break;
367cdf0e10cSrcweir 		}
368cdf0e10cSrcweir 
3695aaf853bSArmin Le Grand         // Add LineCap support
370*8718d260SArmin Le Grand         mpLineAttr->Put(XLineCapItem(maLineCap));
3715aaf853bSArmin Le Grand 
372cdf0e10cSrcweir 		if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
373cdf0e10cSrcweir 		{
374*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineDashItem(String(), maDash));
375cdf0e10cSrcweir 		}
376cdf0e10cSrcweir         else
377cdf0e10cSrcweir         {
378*8718d260SArmin Le Grand 			mpLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
379cdf0e10cSrcweir         }
380cdf0e10cSrcweir 	}
381cdf0e10cSrcweir 	else
382*8718d260SArmin Le Grand     {
383*8718d260SArmin Le Grand 		mbNoLine = true;
384*8718d260SArmin Le Grand     }
385cdf0e10cSrcweir 
386*8718d260SArmin Le Grand 	if(bFill)
387cdf0e10cSrcweir 	{
388*8718d260SArmin Le Grand 		if(maVD.IsFillColor())
389cdf0e10cSrcweir 		{
390*8718d260SArmin Le Grand 			mpFillAttr->Put(XFillStyleItem(XFILL_SOLID));
391*8718d260SArmin Le Grand 			mpFillAttr->Put(XFillColorItem(String(), maVD.GetFillColor()));
392cdf0e10cSrcweir 		}
393cdf0e10cSrcweir 		else
394*8718d260SArmin Le Grand         {
395*8718d260SArmin Le Grand 			mpFillAttr->Put(XFillStyleItem(XFILL_NONE));
396*8718d260SArmin Le Grand         }
397cdf0e10cSrcweir 	}
398cdf0e10cSrcweir 	else
399*8718d260SArmin Le Grand     {
400*8718d260SArmin Le Grand 		mbNoFill = true;
401*8718d260SArmin Le Grand     }
402cdf0e10cSrcweir 
403*8718d260SArmin Le Grand 	if(bText && mbFntDirty)
404cdf0e10cSrcweir 	{
405*8718d260SArmin Le Grand 		Font aFnt(maVD.GetFont());
406*8718d260SArmin Le Grand 		const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * mfScaleY));
407*8718d260SArmin Le Grand 
408*8718d260SArmin Le Grand         mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
409*8718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
410*8718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
411*8718d260SArmin Le Grand         mpTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
412*8718d260SArmin Le Grand         mpTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
413*8718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
414*8718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
415*8718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
416*8718d260SArmin Le Grand         mpTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
417*8718d260SArmin Le Grand         mpTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
418*8718d260SArmin Le Grand         mpTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
419*8718d260SArmin Le Grand         mpTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
420*8718d260SArmin Le Grand         mpTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
421a5258243SPedro Giffuni 
422a5258243SPedro Giffuni         // #i118485# Setting this item leads to problems (written #i118498# for this)
423*8718d260SArmin Le Grand         // mpTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
424a5258243SPedro Giffuni 
425*8718d260SArmin Le Grand         mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
426*8718d260SArmin Le Grand         mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
427*8718d260SArmin Le Grand         mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
428cdf0e10cSrcweir 		//... svxfont textitem svditext
429*8718d260SArmin Le Grand 		mbFntDirty = false;
430cdf0e10cSrcweir 	}
431*8718d260SArmin Le Grand 
432*8718d260SArmin Le Grand     if(pObj)
433cdf0e10cSrcweir 	{
434*8718d260SArmin Le Grand 		pObj->SetLayer(mnLayer);
435*8718d260SArmin Le Grand 
436*8718d260SArmin Le Grand         if(bLine)
437*8718d260SArmin Le Grand         {
438*8718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpLineAttr);
439*8718d260SArmin Le Grand         }
440*8718d260SArmin Le Grand 
441*8718d260SArmin Le Grand 		if(bFill)
442*8718d260SArmin Le Grand         {
443*8718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpFillAttr);
444*8718d260SArmin Le Grand         }
445*8718d260SArmin Le Grand 
446*8718d260SArmin Le Grand 		if(bText)
447cdf0e10cSrcweir 		{
448*8718d260SArmin Le Grand 			pObj->SetMergedItemSet(*mpTextAttr);
449*8718d260SArmin Le Grand 			pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 	}
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
455cdf0e10cSrcweir {
456*8718d260SArmin Le Grand     if(bScale && !maScaleRect.IsEmpty())
457cdf0e10cSrcweir     {
458*8718d260SArmin Le Grand 		if(mbSize)
459*8718d260SArmin Le Grand         {
460*8718d260SArmin Le Grand 			pObj->NbcResize(Point(), maScaleX, maScaleY);
461*8718d260SArmin Le Grand         }
462*8718d260SArmin Le Grand 
463*8718d260SArmin Le Grand         if(mbMov)
464*8718d260SArmin Le Grand         {
465*8718d260SArmin Le Grand 			pObj->NbcMove(Size(maOfs.X(), maOfs.Y()));
466*8718d260SArmin Le Grand         }
467cdf0e10cSrcweir 	}
468cdf0e10cSrcweir 
46947a7c0c1SArmin Le Grand     if(isClip())
470cdf0e10cSrcweir     {
47147a7c0c1SArmin Le Grand         const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
47247a7c0c1SArmin Le Grand         const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
47347a7c0c1SArmin Le Grand     	const SdrLayerID aOldLayer(pObj->GetLayer());
47447a7c0c1SArmin Le Grand     	const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
47547a7c0c1SArmin Le Grand         const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
47647a7c0c1SArmin Le Grand         BitmapEx aBitmapEx;
47747a7c0c1SArmin Le Grand 
47847a7c0c1SArmin Le Grand         if(pSdrGrafObj)
47947a7c0c1SArmin Le Grand         {
48047a7c0c1SArmin Le Grand         	aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
48147a7c0c1SArmin Le Grand         }
482cdf0e10cSrcweir 
48347a7c0c1SArmin Le Grand         SdrObject::Free(pObj);
48447a7c0c1SArmin Le Grand 
48547a7c0c1SArmin Le Grand         if(!aOldRange.isEmpty())
48647a7c0c1SArmin Le Grand         {
48747a7c0c1SArmin Le Grand             // clip against ClipRegion
48847a7c0c1SArmin Le Grand             const basegfx::B2DPolyPolygon aNewPoly(
48947a7c0c1SArmin Le Grand                 basegfx::tools::clipPolyPolygonOnPolyPolygon(
49047a7c0c1SArmin Le Grand                     aPoly,
49147a7c0c1SArmin Le Grand                     maClip,
49247a7c0c1SArmin Le Grand                     true,
49347a7c0c1SArmin Le Grand                     aPoly.isClosed() ? false : true));
49447a7c0c1SArmin Le Grand             const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
49547a7c0c1SArmin Le Grand 
49647a7c0c1SArmin Le Grand             if(!aNewRange.isEmpty())
49747a7c0c1SArmin Le Grand             {
49847a7c0c1SArmin Le Grand                 pObj = new SdrPathObj(
49947a7c0c1SArmin Le Grand                     aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
50047a7c0c1SArmin Le Grand                     aNewPoly);
50147a7c0c1SArmin Le Grand 
50247a7c0c1SArmin Le Grand 		        pObj->SetLayer(aOldLayer);
50347a7c0c1SArmin Le Grand 		        pObj->SetMergedItemSet(aOldItemSet);
50447a7c0c1SArmin Le Grand 
50547a7c0c1SArmin Le Grand                 if(!!aBitmapEx)
50647a7c0c1SArmin Le Grand                 {
50747a7c0c1SArmin Le Grand                     // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
50847a7c0c1SArmin Le Grand                     const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
50947a7c0c1SArmin Le Grand                     const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
51047a7c0c1SArmin Le Grand                     basegfx::B2DRange aPixel(aNewRange);
51147a7c0c1SArmin Le Grand                     basegfx::B2DHomMatrix aTrans;
51247a7c0c1SArmin Le Grand 
51347a7c0c1SArmin Le Grand                     aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
51447a7c0c1SArmin Le Grand                     aTrans.scale(fScaleX, fScaleY);
51547a7c0c1SArmin Le Grand                     aPixel.transform(aTrans);
51647a7c0c1SArmin Le Grand 
51747a7c0c1SArmin Le Grand                     const BitmapEx aClippedBitmap(
51847a7c0c1SArmin Le Grand                         aBitmapEx,
51947a7c0c1SArmin Le Grand                         Point(floor(std::max(0.0, aPixel.getMinX())), floor(std::max(0.0, aPixel.getMinY()))),
52047a7c0c1SArmin Le Grand                         Size(ceil(aPixel.getWidth()), ceil(aPixel.getHeight())));
52147a7c0c1SArmin Le Grand 
52247a7c0c1SArmin Le Grand                     pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
52370d3707aSArmin Le Grand                     pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
52447a7c0c1SArmin Le Grand                 }
52547a7c0c1SArmin Le Grand             }
52647a7c0c1SArmin Le Grand         }
527cdf0e10cSrcweir     }
528cdf0e10cSrcweir 
52947a7c0c1SArmin Le Grand     if(pObj)
530cdf0e10cSrcweir     {
53147a7c0c1SArmin Le Grand         // #i111954# check object for visibility
53247a7c0c1SArmin Le Grand         // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
53347a7c0c1SArmin Le Grand         bool bVisible(false);
534cdf0e10cSrcweir 
53547a7c0c1SArmin Le Grand         if(pObj->HasLineStyle())
536cdf0e10cSrcweir         {
537cdf0e10cSrcweir             bVisible = true;
538cdf0e10cSrcweir         }
539cdf0e10cSrcweir 
54047a7c0c1SArmin Le Grand         if(!bVisible && pObj->HasFillStyle())
541cdf0e10cSrcweir         {
542cdf0e10cSrcweir             bVisible = true;
543cdf0e10cSrcweir         }
544cdf0e10cSrcweir 
54547a7c0c1SArmin Le Grand         if(!bVisible)
54647a7c0c1SArmin Le Grand         {
54747a7c0c1SArmin Le Grand             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
54847a7c0c1SArmin Le Grand 
54947a7c0c1SArmin Le Grand             if(pTextObj && pTextObj->HasText())
55047a7c0c1SArmin Le Grand             {
55147a7c0c1SArmin Le Grand                 bVisible = true;
55247a7c0c1SArmin Le Grand             }
55347a7c0c1SArmin Le Grand         }
55447a7c0c1SArmin Le Grand 
55547a7c0c1SArmin Le Grand         if(!bVisible)
55647a7c0c1SArmin Le Grand         {
55747a7c0c1SArmin Le Grand             SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
55847a7c0c1SArmin Le Grand 
55947a7c0c1SArmin Le Grand             if(pGrafObj)
56047a7c0c1SArmin Le Grand             {
56147a7c0c1SArmin Le Grand                 // this may be refined to check if the graphic really is visible. It
56247a7c0c1SArmin Le Grand                 // is here to ensure that graphic objects without fill, line and text
56347a7c0c1SArmin Le Grand                 // get created
56447a7c0c1SArmin Le Grand                 bVisible = true;
56547a7c0c1SArmin Le Grand             }
56647a7c0c1SArmin Le Grand         }
56747a7c0c1SArmin Le Grand 
56847a7c0c1SArmin Le Grand         if(!bVisible)
56947a7c0c1SArmin Le Grand         {
57047a7c0c1SArmin Le Grand             SdrObject::Free(pObj);
57147a7c0c1SArmin Le Grand         }
57247a7c0c1SArmin Le Grand         else
57347a7c0c1SArmin Le Grand         {
574*8718d260SArmin Le Grand 	        maTmpList.push_back(pObj);
575*8718d260SArmin Le Grand 
576*8718d260SArmin Le Grand             if(dynamic_cast< SdrPathObj* >(pObj))
57747a7c0c1SArmin Le Grand 	        {
578*8718d260SArmin Le Grand 		        const bool bClosed(pObj->IsClosedObj());
579*8718d260SArmin Le Grand 
580*8718d260SArmin Le Grand                 mbLastObjWasPolyWithoutLine = mbNoLine && bClosed;
581*8718d260SArmin Le Grand 		        mbLastObjWasLine = !bClosed;
58247a7c0c1SArmin Le Grand 	        }
58347a7c0c1SArmin Le Grand 	        else
58447a7c0c1SArmin Le Grand 	        {
585*8718d260SArmin Le Grand 		        mbLastObjWasPolyWithoutLine = false;
586*8718d260SArmin Le Grand 		        mbLastObjWasLine = false;
58747a7c0c1SArmin Le Grand 	        }
58847a7c0c1SArmin Le Grand         }
589cdf0e10cSrcweir     }
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir /**************************************************************************************************/
593cdf0e10cSrcweir 
594cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir }
601cdf0e10cSrcweir 
602cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
605cdf0e10cSrcweir 	const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
606cdf0e10cSrcweir 	const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 	if(!aStart.equal(aEnd))
609cdf0e10cSrcweir 	{
610cdf0e10cSrcweir 		basegfx::B2DPolygon aLine;
611*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 		aLine.append(aStart);
614cdf0e10cSrcweir 		aLine.append(aEnd);
615cdf0e10cSrcweir 		aLine.transform(aTransform);
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 		const LineInfo& rLineInfo = rAct.GetLineInfo();
618cdf0e10cSrcweir 		const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
619cdf0e10cSrcweir 		bool bCreateLineObject(true);
620cdf0e10cSrcweir 
621*8718d260SArmin Le Grand 		if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine))
622cdf0e10cSrcweir 		{
623cdf0e10cSrcweir 			bCreateLineObject = false;
624cdf0e10cSrcweir 		}
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 		if(bCreateLineObject)
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
629*8718d260SArmin Le Grand 			mnLineWidth = nNewLineWidth;
630cdf0e10cSrcweir 			maLineJoin = rLineInfo.GetLineJoin();
6315aaf853bSArmin Le Grand             maLineCap = rLineInfo.GetLineCap();
632cdf0e10cSrcweir 			maDash = XDash(XDASH_RECT,
633cdf0e10cSrcweir 				rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
634cdf0e10cSrcweir 				rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
635cdf0e10cSrcweir 				rLineInfo.GetDistance());
636cdf0e10cSrcweir 			SetAttributes(pPath);
637*8718d260SArmin Le Grand 			mnLineWidth = 0;
638cdf0e10cSrcweir 			maLineJoin = basegfx::B2DLINEJOIN_NONE;
639cdf0e10cSrcweir 			maDash = XDash();
640cdf0e10cSrcweir 			InsertObj(pPath, false);
641cdf0e10cSrcweir 		}
642cdf0e10cSrcweir 	}
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
646cdf0e10cSrcweir {
64747a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
648cdf0e10cSrcweir 	SetAttributes(pRect);
649cdf0e10cSrcweir 	InsertObj(pRect);
650cdf0e10cSrcweir }
651cdf0e10cSrcweir 
652cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
653cdf0e10cSrcweir {
65447a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
655cdf0e10cSrcweir 	SetAttributes(pRect);
656cdf0e10cSrcweir 	long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
657cdf0e10cSrcweir 	if (nRad!=0) {
658*8718d260SArmin Le Grand 		SfxItemSet aSet(*mpLineAttr->GetPool(), SDRATTR_ECKENRADIUS, SDRATTR_ECKENRADIUS, 0, 0);
659cdf0e10cSrcweir 		aSet.Put(SdrEckenradiusItem(nRad));
660cdf0e10cSrcweir 		pRect->SetMergedItemSet(aSet);
661cdf0e10cSrcweir 	}
662cdf0e10cSrcweir 	InsertObj(pRect);
663cdf0e10cSrcweir }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir /**************************************************************************************************/
666cdf0e10cSrcweir 
667cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
668cdf0e10cSrcweir {
66947a7c0c1SArmin Le Grand     SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
670cdf0e10cSrcweir 	SetAttributes(pCirc);
671cdf0e10cSrcweir 	InsertObj(pCirc);
672cdf0e10cSrcweir }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
675cdf0e10cSrcweir {
67647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
677cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
678cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
679cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
680cdf0e10cSrcweir 	SetAttributes(pCirc);
681cdf0e10cSrcweir 	InsertObj(pCirc);
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
685cdf0e10cSrcweir {
68647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
687cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
688cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
689cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
690cdf0e10cSrcweir 	SetAttributes(pCirc);
691cdf0e10cSrcweir 	InsertObj(pCirc);
692cdf0e10cSrcweir }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
695cdf0e10cSrcweir {
69647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
697cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
698cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
699cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
700cdf0e10cSrcweir 	SetAttributes(pCirc);
701cdf0e10cSrcweir 	InsertObj(pCirc);
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir /**************************************************************************************************/
705cdf0e10cSrcweir 
706cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
707cdf0e10cSrcweir {
708cdf0e10cSrcweir 	// #i102706# Do not merge closed polygons
709cdf0e10cSrcweir 	if(rSrcPoly.isClosed())
710cdf0e10cSrcweir 	{
711cdf0e10cSrcweir 		return false;
712cdf0e10cSrcweir 	}
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
715*8718d260SArmin Le Grand 	if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
716cdf0e10cSrcweir 	{
717*8718d260SArmin Le Grand 		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
718*8718d260SArmin Le Grand 		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 		if(pLastPoly)
721cdf0e10cSrcweir 		{
722cdf0e10cSrcweir 			if(1L == pLastPoly->GetPathPoly().count())
723cdf0e10cSrcweir 			{
724cdf0e10cSrcweir 				bool bOk(false);
725cdf0e10cSrcweir 				basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 				// #i102706# Do not merge closed polygons
728cdf0e10cSrcweir 				if(aDstPoly.isClosed())
729cdf0e10cSrcweir 				{
730cdf0e10cSrcweir 					return false;
731cdf0e10cSrcweir 				}
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 				if(aDstPoly.count())
734cdf0e10cSrcweir 				{
735cdf0e10cSrcweir 					const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
736cdf0e10cSrcweir 					const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 					if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
739cdf0e10cSrcweir 					{
740cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
741cdf0e10cSrcweir 						bOk = true;
742cdf0e10cSrcweir 					}
743cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
744cdf0e10cSrcweir 					{
745cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
746cdf0e10cSrcweir 						aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
747cdf0e10cSrcweir 						aDstPoly = aNew;
748cdf0e10cSrcweir 						bOk = true;
749cdf0e10cSrcweir 					}
750cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
751cdf0e10cSrcweir 					{
752cdf0e10cSrcweir 						aDstPoly.flip();
753cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
754cdf0e10cSrcweir 						bOk = true;
755cdf0e10cSrcweir 					}
756cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
757cdf0e10cSrcweir 					{
758cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
759cdf0e10cSrcweir 						aNew.flip();
760cdf0e10cSrcweir 						aDstPoly.append(aNew, 1L, aNew.count() - 1L);
761cdf0e10cSrcweir 						bOk = true;
762cdf0e10cSrcweir 					}
763cdf0e10cSrcweir 				}
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 				if(bOk)
766cdf0e10cSrcweir 				{
767cdf0e10cSrcweir 					pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
768cdf0e10cSrcweir 				}
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 				return bOk;
771cdf0e10cSrcweir 			}
772cdf0e10cSrcweir 		}
773cdf0e10cSrcweir 	}
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	return false;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
779cdf0e10cSrcweir {
780cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
781*8718d260SArmin Le Grand 	if(mbLastObjWasPolyWithoutLine)
782cdf0e10cSrcweir 	{
783*8718d260SArmin Le Grand 		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
784*8718d260SArmin Le Grand 		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 		if(pLastPoly)
787cdf0e10cSrcweir 		{
788cdf0e10cSrcweir 			if(pLastPoly->GetPathPoly() == rPolyPolygon)
789cdf0e10cSrcweir 			{
790cdf0e10cSrcweir 				SetAttributes(NULL);
791cdf0e10cSrcweir 
792*8718d260SArmin Le Grand 				if(!mbNoLine && mbNoFill)
793cdf0e10cSrcweir 				{
794*8718d260SArmin Le Grand 					pLastPoly->SetMergedItemSet(*mpLineAttr);
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 					return true;
797cdf0e10cSrcweir 				}
798cdf0e10cSrcweir 			}
799cdf0e10cSrcweir 		}
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	return false;
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
80547a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::checkClip()
80647a7c0c1SArmin Le Grand {
807*8718d260SArmin Le Grand     if(maVD.IsClipRegion())
80847a7c0c1SArmin Le Grand     {
809*8718d260SArmin Le Grand         Region aRegion(maVD.GetClipRegion());
81047a7c0c1SArmin Le Grand 
81147a7c0c1SArmin Le Grand         maClip = aRegion.ConvertToB2DPolyPolygon();
81247a7c0c1SArmin Le Grand 
81347a7c0c1SArmin Le Grand         if(isClip())
81447a7c0c1SArmin Le Grand         {
81547a7c0c1SArmin Le Grand     		const basegfx::B2DHomMatrix aTransform(
81647a7c0c1SArmin Le Grand                 basegfx::tools::createScaleTranslateB2DHomMatrix(
817*8718d260SArmin Le Grand                     mfScaleX,
818*8718d260SArmin Le Grand                     mfScaleY,
819*8718d260SArmin Le Grand                     maOfs.X(),
820*8718d260SArmin Le Grand                     maOfs.Y()));
82147a7c0c1SArmin Le Grand 
82247a7c0c1SArmin Le Grand             maClip.transform(aTransform);
82347a7c0c1SArmin Le Grand         }
82447a7c0c1SArmin Le Grand     }
82547a7c0c1SArmin Le Grand }
82647a7c0c1SArmin Le Grand 
82747a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const
82847a7c0c1SArmin Le Grand {
82947a7c0c1SArmin Le Grand     return !maClip.getB2DRange().isEmpty();
83047a7c0c1SArmin Le Grand }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
835cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 	if(aSource.count())
838cdf0e10cSrcweir 	{
839*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
840cdf0e10cSrcweir 		aSource.transform(aTransform);
841cdf0e10cSrcweir 	}
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	const LineInfo& rLineInfo = rAct.GetLineInfo();
844cdf0e10cSrcweir 	const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
845cdf0e10cSrcweir 	bool bCreateLineObject(true);
846cdf0e10cSrcweir 
847*8718d260SArmin Le Grand 	if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource))
848cdf0e10cSrcweir 	{
849cdf0e10cSrcweir 		bCreateLineObject = false;
850cdf0e10cSrcweir 	}
851*8718d260SArmin Le Grand 	else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
852cdf0e10cSrcweir 	{
853cdf0e10cSrcweir 		bCreateLineObject = false;
854cdf0e10cSrcweir 	}
855cdf0e10cSrcweir 
856cdf0e10cSrcweir 	if(bCreateLineObject)
857cdf0e10cSrcweir 	{
85847a7c0c1SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(
859cdf0e10cSrcweir 			aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
860cdf0e10cSrcweir 			basegfx::B2DPolyPolygon(aSource));
861*8718d260SArmin Le Grand 		mnLineWidth = nNewLineWidth;
862cdf0e10cSrcweir 		maLineJoin = rLineInfo.GetLineJoin();
8635aaf853bSArmin Le Grand         maLineCap = rLineInfo.GetLineCap();
864cdf0e10cSrcweir 		maDash = XDash(XDASH_RECT,
865cdf0e10cSrcweir 			rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
866cdf0e10cSrcweir 			rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
867cdf0e10cSrcweir 			rLineInfo.GetDistance());
868cdf0e10cSrcweir 		SetAttributes(pPath);
869*8718d260SArmin Le Grand 		mnLineWidth = 0;
870cdf0e10cSrcweir 		maLineJoin = basegfx::B2DLINEJOIN_NONE;
871cdf0e10cSrcweir 		maDash = XDash();
872cdf0e10cSrcweir 		InsertObj(pPath, false);
873cdf0e10cSrcweir 	}
874cdf0e10cSrcweir }
875cdf0e10cSrcweir 
876cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
879cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 	if(aSource.count())
882cdf0e10cSrcweir 	{
883*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
884cdf0e10cSrcweir 		aSource.transform(aTransform);
885cdf0e10cSrcweir 
886*8718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
887cdf0e10cSrcweir 		{
888cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
889cdf0e10cSrcweir 			aSource.setClosed(true);
89047a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
891cdf0e10cSrcweir 			SetAttributes(pPath);
892cdf0e10cSrcweir 			InsertObj(pPath, false);
893cdf0e10cSrcweir 		}
894cdf0e10cSrcweir 	}
895cdf0e10cSrcweir }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
898cdf0e10cSrcweir {
899cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
900cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
901cdf0e10cSrcweir 
902cdf0e10cSrcweir 	if(aSource.count())
903cdf0e10cSrcweir 	{
904*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
905cdf0e10cSrcweir 		aSource.transform(aTransform);
906cdf0e10cSrcweir 
907*8718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
908cdf0e10cSrcweir 		{
909cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
910cdf0e10cSrcweir 			aSource.setClosed(true);
91147a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
912cdf0e10cSrcweir 			SetAttributes(pPath);
913cdf0e10cSrcweir 			InsertObj(pPath, false);
914cdf0e10cSrcweir 		}
915cdf0e10cSrcweir 	}
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir /**************************************************************************************************/
919cdf0e10cSrcweir 
920cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir 	// calc text box size, add 5% to make it fit safely
923cdf0e10cSrcweir 
924*8718d260SArmin Le Grand 	FontMetric aFontMetric( maVD.GetFontMetric() );
925*8718d260SArmin Le Grand 	Font aFnt( maVD.GetFont() );
926cdf0e10cSrcweir 	FontAlign eAlg( aFnt.GetAlign() );
927cdf0e10cSrcweir 
928*8718d260SArmin Le Grand     sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX );
929*8718d260SArmin Le Grand     sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY );
930cdf0e10cSrcweir 	//sal_Int32 nDxWidth = 0;
931cdf0e10cSrcweir 	//sal_Int32 nLen = rStr.Len();
932cdf0e10cSrcweir 
933*8718d260SArmin Le Grand 	Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) );
934cdf0e10cSrcweir     Size aSize( nTextWidth, nTextHeight );
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 	if ( eAlg == ALIGN_BASELINE )
937*8718d260SArmin Le Grand 		aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
938cdf0e10cSrcweir 	else if ( eAlg == ALIGN_BOTTOM )
939cdf0e10cSrcweir 		aPos.Y() -= nTextHeight;
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	Rectangle aTextRect( aPos, aSize );
942cdf0e10cSrcweir 	SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
945cdf0e10cSrcweir 	{
946cdf0e10cSrcweir 		pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
947*8718d260SArmin Le Grand 		pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
948cdf0e10cSrcweir 		// don't let the margins eat the space needed for the text
949cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextUpperDistItem (0));
950cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextLowerDistItem (0));
951cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextRightDistItem (0));
952cdf0e10cSrcweir 		pText->SetMergedItem ( SdrTextLeftDistItem (0));
953cdf0e10cSrcweir 		pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
954cdf0e10cSrcweir 	}
955cdf0e10cSrcweir 	else
956*8718d260SArmin Le Grand 		pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) );
957cdf0e10cSrcweir 
958*8718d260SArmin Le Grand 	pText->SetModel(mpModel);
959*8718d260SArmin Le Grand 	pText->SetLayer(mnLayer);
960cdf0e10cSrcweir 	pText->NbcSetText( rStr );
961*8718d260SArmin Le Grand 	SetAttributes( pText, true );
962cdf0e10cSrcweir 	pText->SetSnapRect( aTextRect );
963cdf0e10cSrcweir 
964cdf0e10cSrcweir 	if (!aFnt.IsTransparent())
965cdf0e10cSrcweir 	{
966*8718d260SArmin Le Grand 		SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
967cdf0e10cSrcweir 		aAttr.Put(XFillStyleItem(XFILL_SOLID));
968cdf0e10cSrcweir 		aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
969cdf0e10cSrcweir 		pText->SetMergedItemSet(aAttr);
970cdf0e10cSrcweir 	}
971cdf0e10cSrcweir 	sal_uInt32 nWink = aFnt.GetOrientation();
972cdf0e10cSrcweir 	if ( nWink )
973cdf0e10cSrcweir 	{
974cdf0e10cSrcweir 		nWink*=10;
975cdf0e10cSrcweir 		double a=nWink*nPi180;
976cdf0e10cSrcweir 		double nSin=sin(a);
977cdf0e10cSrcweir 		double nCos=cos(a);
978cdf0e10cSrcweir 		pText->NbcRotate(aPos,nWink,nSin,nCos);
979cdf0e10cSrcweir 	}
980*8718d260SArmin Le Grand 	InsertObj( pText, false );
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
984cdf0e10cSrcweir {
985cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
986cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
987cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
988cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
994cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
995cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
996cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
997cdf0e10cSrcweir }
998cdf0e10cSrcweir 
999cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
1002cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
1003cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
1004cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
1008cdf0e10cSrcweir {
1009cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
1010cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
101147a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1012cdf0e10cSrcweir 	InsertObj(pGraf);
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1018cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
101947a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1020cdf0e10cSrcweir 	InsertObj(pGraf);
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
1026cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
102747a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1028cdf0e10cSrcweir 	InsertObj(pGraf);
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1034cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
103547a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1036cdf0e10cSrcweir 	InsertObj(pGraf);
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
1044cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 	if(aSource.count())
1047cdf0e10cSrcweir 	{
1048*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1049cdf0e10cSrcweir 		aSource.transform(aTransform);
1050cdf0e10cSrcweir 
1051*8718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1052cdf0e10cSrcweir 		{
1053cdf0e10cSrcweir 			const Hatch& rHatch = rAct.GetHatch();
105447a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1055*8718d260SArmin Le Grand 			SfxItemSet aHatchAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0);
1056cdf0e10cSrcweir 			XHatchStyle eStyle;
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir 			switch(rHatch.GetStyle())
1059cdf0e10cSrcweir 			{
1060cdf0e10cSrcweir 				case(HATCH_TRIPLE) :
1061cdf0e10cSrcweir 				{
1062cdf0e10cSrcweir 					eStyle = XHATCH_TRIPLE;
1063cdf0e10cSrcweir 					break;
1064cdf0e10cSrcweir 				}
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 				case(HATCH_DOUBLE) :
1067cdf0e10cSrcweir 				{
1068cdf0e10cSrcweir 					eStyle = XHATCH_DOUBLE;
1069cdf0e10cSrcweir 					break;
1070cdf0e10cSrcweir 				}
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 				default:
1073cdf0e10cSrcweir 				{
1074cdf0e10cSrcweir 					eStyle = XHATCH_SINGLE;
1075cdf0e10cSrcweir 					break;
1076cdf0e10cSrcweir 				}
1077cdf0e10cSrcweir 			}
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir 			SetAttributes(pPath);
1080cdf0e10cSrcweir 			aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
1081*8718d260SArmin Le Grand 			aHatchAttr.Put(XFillHatchItem(&mpModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
1082cdf0e10cSrcweir 			pPath->SetMergedItemSet(aHatchAttr);
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 			InsertObj(pPath, false);
1085cdf0e10cSrcweir 		}
1086cdf0e10cSrcweir 	}
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
1092cdf0e10cSrcweir {
1093*8718d260SArmin Le Grand 	rAct.Execute(&maVD);
1094cdf0e10cSrcweir }
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir 	MapScaling();
1099*8718d260SArmin Le Grand 	rAct.Execute(&maVD);
1100*8718d260SArmin Le Grand 	mbLastObjWasPolyWithoutLine = false;
1101*8718d260SArmin Le Grand 	mbLastObjWasLine = false;
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling()
1105cdf0e10cSrcweir {
1106*8718d260SArmin Le Grand 	const sal_uInt32 nAnz(maTmpList.size());
1107*8718d260SArmin Le Grand 	sal_uInt32 i(0);
1108*8718d260SArmin Le Grand 	const MapMode& rMap = maVD.GetMapMode();
1109cdf0e10cSrcweir 	Point aMapOrg( rMap.GetOrigin() );
1110*8718d260SArmin Le Grand 	bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0);
1111*8718d260SArmin Le Grand 
1112*8718d260SArmin Le Grand     if(bMov2)
1113cdf0e10cSrcweir     {
1114*8718d260SArmin Le Grand 		for(i = mnMapScalingOfs; i < nAnz; i++)
1115cdf0e10cSrcweir         {
1116*8718d260SArmin Le Grand 			SdrObject* pObj = maTmpList[i];
1117*8718d260SArmin Le Grand 
1118*8718d260SArmin Le Grand             pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
1119cdf0e10cSrcweir 		}
1120cdf0e10cSrcweir 	}
1121*8718d260SArmin Le Grand 
1122*8718d260SArmin Le Grand     mnMapScalingOfs = nAnz;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir 	ByteString aSkipComment;
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 	if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1132cdf0e10cSrcweir 	{
1133cdf0e10cSrcweir 		MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 		if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
1136cdf0e10cSrcweir 		{
1137cdf0e10cSrcweir 			// #i73407# reformulation to use new B2DPolygon classes
1138cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir 			if(aSource.count())
1141cdf0e10cSrcweir 			{
1142*8718d260SArmin Le Grand 				if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1143cdf0e10cSrcweir 				{
1144cdf0e10cSrcweir 					const Gradient&	rGrad = pAct->GetGradient();
114547a7c0c1SArmin Le Grand                     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1146*8718d260SArmin Le Grand 					SfxItemSet aGradAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1147cdf0e10cSrcweir 					XGradient aXGradient;
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir 					aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
1150cdf0e10cSrcweir 					aXGradient.SetStartColor(rGrad.GetStartColor());
1151cdf0e10cSrcweir 					aXGradient.SetEndColor(rGrad.GetEndColor());
1152cdf0e10cSrcweir 					aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
1153cdf0e10cSrcweir 					aXGradient.SetBorder(rGrad.GetBorder());
1154cdf0e10cSrcweir 					aXGradient.SetXOffset(rGrad.GetOfsX());
1155cdf0e10cSrcweir 					aXGradient.SetYOffset(rGrad.GetOfsY());
1156cdf0e10cSrcweir 					aXGradient.SetStartIntens(rGrad.GetStartIntensity());
1157cdf0e10cSrcweir 					aXGradient.SetEndIntens(rGrad.GetEndIntensity());
1158cdf0e10cSrcweir 					aXGradient.SetSteps(rGrad.GetSteps());
1159cdf0e10cSrcweir 
1160*8718d260SArmin Le Grand             		if(maVD.IsLineColor())
1161cdf0e10cSrcweir                     {
1162cdf0e10cSrcweir                         // switch line off; when there was one there will be a
1163cdf0e10cSrcweir                         // META_POLYLINE_ACTION following creating another object
1164*8718d260SArmin Le Grand     		            const Color aLineColor(maVD.GetLineColor());
1165*8718d260SArmin Le Grand     		            maVD.SetLineColor();
1166cdf0e10cSrcweir                         SetAttributes(pPath);
1167*8718d260SArmin Le Grand     		            maVD.SetLineColor(aLineColor);
1168cdf0e10cSrcweir                     }
1169cdf0e10cSrcweir                     else
1170cdf0e10cSrcweir                     {
1171cdf0e10cSrcweir                         SetAttributes(pPath);
1172cdf0e10cSrcweir                     }
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 					aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
1175*8718d260SArmin Le Grand 					aGradAttr.Put(XFillGradientItem(&mpModel->GetItemPool(), aXGradient));
1176cdf0e10cSrcweir 					pPath->SetMergedItemSet(aGradAttr);
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 					InsertObj(pPath);
1179cdf0e10cSrcweir 				}
1180cdf0e10cSrcweir 			}
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir 			aSkipComment = "XGRAD_SEQ_END";
1183cdf0e10cSrcweir 		}
1184cdf0e10cSrcweir 	}
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir 	if(aSkipComment.Len())
1187cdf0e10cSrcweir 	{
1188cdf0e10cSrcweir 		MetaAction* pSkipAct = pMtf->NextAction();
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir 		while( pSkipAct
1191cdf0e10cSrcweir 			&& ((pSkipAct->GetType() != META_COMMENT_ACTION )
1192cdf0e10cSrcweir 				|| (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
1193cdf0e10cSrcweir 		{
1194cdf0e10cSrcweir 			pSkipAct = pMtf->NextAction();
1195cdf0e10cSrcweir 		}
1196cdf0e10cSrcweir 	}
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir 
1199*8718d260SArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
1200*8718d260SArmin Le Grand 
1201*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
1202*8718d260SArmin Le Grand {
1203*8718d260SArmin Le Grand     GDIMetaFile aTemp;
1204*8718d260SArmin Le Grand 
1205*8718d260SArmin Le Grand     maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
1206*8718d260SArmin Le Grand     DoLoopActions(aTemp, 0, 0);
1207*8718d260SArmin Le Grand }
1208*8718d260SArmin Le Grand 
1209*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
1210*8718d260SArmin Le Grand {
1211*8718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
1212*8718d260SArmin Le Grand     Bitmap aBitmap(rAct.GetBitmap());
1213*8718d260SArmin Le Grand 
1214*8718d260SArmin Le Grand     aRect.Right()++;
1215*8718d260SArmin Le Grand     aRect.Bottom()++;
1216*8718d260SArmin Le Grand     aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
1217*8718d260SArmin Le Grand 
1218*8718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
1219*8718d260SArmin Le Grand 
1220*8718d260SArmin Le Grand     InsertObj(pGraf);
1221*8718d260SArmin Le Grand }
1222*8718d260SArmin Le Grand 
1223*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
1224*8718d260SArmin Le Grand {
1225*8718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(),rAct.GetDestSize());
1226*8718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmapEx());
1227*8718d260SArmin Le Grand 
1228*8718d260SArmin Le Grand     aRect.Right()++;
1229*8718d260SArmin Le Grand     aRect.Bottom()++;
1230*8718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
1231*8718d260SArmin Le Grand 
1232*8718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
1233*8718d260SArmin Le Grand 
1234*8718d260SArmin Le Grand     InsertObj(pGraf);
1235*8718d260SArmin Le Grand }
1236*8718d260SArmin Le Grand 
1237*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
1238*8718d260SArmin Le Grand {
1239*8718d260SArmin Le Grand 	Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
1240*8718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
1241*8718d260SArmin Le Grand 
1242*8718d260SArmin Le Grand     aRect.Right()++;
1243*8718d260SArmin Le Grand     aRect.Bottom()++;
1244*8718d260SArmin Le Grand 
1245*8718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
1246*8718d260SArmin Le Grand 
1247*8718d260SArmin Le Grand     InsertObj(pGraf);
1248*8718d260SArmin Le Grand }
1249*8718d260SArmin Le Grand 
1250*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
1251*8718d260SArmin Le Grand {
1252*8718d260SArmin Le Grand 	Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
1253*8718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
1254*8718d260SArmin Le Grand 
1255*8718d260SArmin Le Grand     aRect.Right()++;
1256*8718d260SArmin Le Grand     aRect.Bottom()++;
1257*8718d260SArmin Le Grand 
1258*8718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
1259*8718d260SArmin Le Grand 
1260*8718d260SArmin Le Grand     InsertObj(pGraf);
1261*8718d260SArmin Le Grand }
1262*8718d260SArmin Le Grand 
1263*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
1264*8718d260SArmin Le Grand {
1265*8718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
1266*8718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
1267*8718d260SArmin Le Grand 
1268*8718d260SArmin Le Grand     aRect.Right()++;
1269*8718d260SArmin Le Grand     aRect.Bottom()++;
1270*8718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
1271*8718d260SArmin Le Grand 
1272*8718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
1273*8718d260SArmin Le Grand 
1274*8718d260SArmin Le Grand     InsertObj(pGraf);
1275*8718d260SArmin Le Grand }
1276*8718d260SArmin Le Grand 
1277*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
1278*8718d260SArmin Le Grand {
1279*8718d260SArmin Le Grand     basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom());
1280*8718d260SArmin Le Grand 
1281*8718d260SArmin Le Grand 	if(!aRange.isEmpty())
1282*8718d260SArmin Le Grand 	{
1283*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1284*8718d260SArmin Le Grand 		aRange.transform(aTransform);
1285*8718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
1286*8718d260SArmin Le Grand         SdrRectObj* pRect = new SdrRectObj(
1287*8718d260SArmin Le Grand             Rectangle(
1288*8718d260SArmin Le Grand                 floor(aRange.getMinX()),
1289*8718d260SArmin Le Grand                 floor(aRange.getMinY()),
1290*8718d260SArmin Le Grand                 ceil(aRange.getMaxX()),
1291*8718d260SArmin Le Grand                 ceil(aRange.getMaxY())));
1292*8718d260SArmin Le Grand 		SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1293*8718d260SArmin Le Grand         XGradientStyle aXGradientStyle(XGRAD_LINEAR);
1294*8718d260SArmin Le Grand 
1295*8718d260SArmin Le Grand         switch(rGradient.GetStyle())
1296*8718d260SArmin Le Grand         {
1297*8718d260SArmin Le Grand             case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
1298*8718d260SArmin Le Grand             case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
1299*8718d260SArmin Le Grand             case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
1300*8718d260SArmin Le Grand             case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
1301*8718d260SArmin Le Grand             case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
1302*8718d260SArmin Le Grand             case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
1303*8718d260SArmin Le Grand         }
1304*8718d260SArmin Le Grand 
1305*8718d260SArmin Le Grand         const XFillGradientItem aXFillGradientItem(
1306*8718d260SArmin Le Grand             &mpModel->GetItemPool(),
1307*8718d260SArmin Le Grand             XGradient(
1308*8718d260SArmin Le Grand                 rGradient.GetStartColor(),
1309*8718d260SArmin Le Grand                 rGradient.GetEndColor(),
1310*8718d260SArmin Le Grand                 aXGradientStyle,
1311*8718d260SArmin Le Grand                 rGradient.GetAngle(),
1312*8718d260SArmin Le Grand                 rGradient.GetOfsX(),
1313*8718d260SArmin Le Grand                 rGradient.GetOfsY(),
1314*8718d260SArmin Le Grand                 rGradient.GetBorder(),
1315*8718d260SArmin Le Grand                 rGradient.GetStartIntensity(),
1316*8718d260SArmin Le Grand                 rGradient.GetEndIntensity(),
1317*8718d260SArmin Le Grand                 rGradient.GetSteps()));
1318*8718d260SArmin Le Grand 
1319*8718d260SArmin Le Grand 		SetAttributes(pRect);
1320*8718d260SArmin Le Grand 		aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
1321*8718d260SArmin Le Grand 		aGradientAttr.Put(aXFillGradientItem);
1322*8718d260SArmin Le Grand 		pRect->SetMergedItemSet(aGradientAttr);
1323*8718d260SArmin Le Grand 
1324*8718d260SArmin Le Grand 		InsertObj(pRect, false);
1325*8718d260SArmin Le Grand 	}
1326*8718d260SArmin Le Grand }
1327*8718d260SArmin Le Grand 
1328*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& rAct)
1329*8718d260SArmin Le Grand {
1330*8718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)");
1331*8718d260SArmin Le Grand }
1332*8718d260SArmin Le Grand 
1333*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct)
1334*8718d260SArmin Le Grand {
1335*8718d260SArmin Le Grand 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1336*8718d260SArmin Le Grand 
1337*8718d260SArmin Le Grand 	if(aSource.count())
1338*8718d260SArmin Le Grand 	{
1339*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1340*8718d260SArmin Le Grand 		aSource.transform(aTransform);
1341*8718d260SArmin Le Grand     	aSource.setClosed(true);
1342*8718d260SArmin Le Grand 
1343*8718d260SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1344*8718d260SArmin Le Grand 		SetAttributes(pPath);
1345*8718d260SArmin Le Grand         pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
1346*8718d260SArmin Le Grand 		InsertObj(pPath, false);
1347*8718d260SArmin Le Grand 	}
1348*8718d260SArmin Le Grand }
1349*8718d260SArmin Le Grand 
1350*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& rAct)
1351*8718d260SArmin Le Grand {
1352*8718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)");
1353*8718d260SArmin Le Grand }
1354*8718d260SArmin Le Grand 
1355*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& rAct)
1356*8718d260SArmin Le Grand {
1357*8718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)");
1358*8718d260SArmin Le Grand }
1359*8718d260SArmin Le Grand 
1360*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
1361*8718d260SArmin Le Grand {
1362*8718d260SArmin Le Grand 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1363*8718d260SArmin Le Grand 
1364*8718d260SArmin Le Grand 	if(aSource.count())
1365*8718d260SArmin Le Grand 	{
1366*8718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1367*8718d260SArmin Le Grand 		aSource.transform(aTransform);
1368*8718d260SArmin Le Grand 
1369*8718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1370*8718d260SArmin Le Grand 		{
1371*8718d260SArmin Le Grand         	const Gradient& rGradient = rAct.GetGradient();
1372*8718d260SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1373*8718d260SArmin Le Grand 			SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1374*8718d260SArmin Le Grand             XGradientStyle aXGradientStyle(XGRAD_LINEAR);
1375*8718d260SArmin Le Grand 
1376*8718d260SArmin Le Grand             switch(rGradient.GetStyle())
1377*8718d260SArmin Le Grand             {
1378*8718d260SArmin Le Grand                 case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
1379*8718d260SArmin Le Grand                 case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
1380*8718d260SArmin Le Grand                 case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
1381*8718d260SArmin Le Grand                 case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
1382*8718d260SArmin Le Grand                 case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
1383*8718d260SArmin Le Grand                 case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
1384*8718d260SArmin Le Grand             }
1385*8718d260SArmin Le Grand 
1386*8718d260SArmin Le Grand             const XFillGradientItem aXFillGradientItem(
1387*8718d260SArmin Le Grand                 &mpModel->GetItemPool(),
1388*8718d260SArmin Le Grand                 XGradient(
1389*8718d260SArmin Le Grand                     rGradient.GetStartColor(),
1390*8718d260SArmin Le Grand                     rGradient.GetEndColor(),
1391*8718d260SArmin Le Grand                     aXGradientStyle,
1392*8718d260SArmin Le Grand                     rGradient.GetAngle(),
1393*8718d260SArmin Le Grand                     rGradient.GetOfsX(),
1394*8718d260SArmin Le Grand                     rGradient.GetOfsY(),
1395*8718d260SArmin Le Grand                     rGradient.GetBorder(),
1396*8718d260SArmin Le Grand                     rGradient.GetStartIntensity(),
1397*8718d260SArmin Le Grand                     rGradient.GetEndIntensity(),
1398*8718d260SArmin Le Grand                     rGradient.GetSteps()));
1399*8718d260SArmin Le Grand 
1400*8718d260SArmin Le Grand 			SetAttributes(pPath);
1401*8718d260SArmin Le Grand 			aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
1402*8718d260SArmin Le Grand 			aGradientAttr.Put(aXFillGradientItem);
1403*8718d260SArmin Le Grand 			pPath->SetMergedItemSet(aGradientAttr);
1404*8718d260SArmin Le Grand 
1405*8718d260SArmin Le Grand 			InsertObj(pPath, false);
1406*8718d260SArmin Le Grand 		}
1407*8718d260SArmin Le Grand 	}
1408*8718d260SArmin Le Grand }
1409*8718d260SArmin Le Grand 
1410*8718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
1411*8718d260SArmin Le Grand {
1412*8718d260SArmin Le Grand 	const GDIMetaFile& rMtf = rAct.GetGDIMetaFile();
1413*8718d260SArmin Le Grand 
1414*8718d260SArmin Le Grand     if(rMtf.GetActionCount())
1415*8718d260SArmin Le Grand     {
1416*8718d260SArmin Le Grand 	    Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1417*8718d260SArmin Le Grand 	    aRect.Right()++; aRect.Bottom()++;
1418*8718d260SArmin Le Grand 
1419*8718d260SArmin Le Grand         // get metafile content as bitmap
1420*8718d260SArmin Le Grand         const basegfx::B2DRange aTargetRange(
1421*8718d260SArmin Le Grand             aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
1422*8718d260SArmin Le Grand 		const drawinglayer::primitive2d::Primitive2DReference aMtf(
1423*8718d260SArmin Le Grand 			new drawinglayer::primitive2d::MetafilePrimitive2D(
1424*8718d260SArmin Le Grand 				basegfx::tools::createScaleTranslateB2DHomMatrix(
1425*8718d260SArmin Le Grand                     aTargetRange.getRange(),
1426*8718d260SArmin Le Grand                     aTargetRange.getMinimum()),
1427*8718d260SArmin Le Grand 				rMtf));
1428*8718d260SArmin Le Grand         BitmapEx aBitmapEx(convertPrimitive2DSequenceToBitmapEx(
1429*8718d260SArmin Le Grand     		drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1),
1430*8718d260SArmin Le Grand             aTargetRange));
1431*8718d260SArmin Le Grand 
1432*8718d260SArmin Le Grand         // handle colors
1433*8718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
1434*8718d260SArmin Le Grand 	    basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
1435*8718d260SArmin Le Grand 	    basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
1436*8718d260SArmin Le Grand 
1437*8718d260SArmin Le Grand         if(100 != rGradient.GetStartIntensity())
1438*8718d260SArmin Le Grand 	    {
1439*8718d260SArmin Le Grand             aStart *= (double)rGradient.GetStartIntensity() / 100.0;
1440*8718d260SArmin Le Grand 	    }
1441*8718d260SArmin Le Grand 
1442*8718d260SArmin Le Grand         if(100 != rGradient.GetEndIntensity())
1443*8718d260SArmin Le Grand 	    {
1444*8718d260SArmin Le Grand             aEnd *= (double)rGradient.GetEndIntensity() / 100.0;
1445*8718d260SArmin Le Grand 	    }
1446*8718d260SArmin Le Grand 
1447*8718d260SArmin Le Grand         const bool bEqualColors(aStart == aEnd);
1448*8718d260SArmin Le Grand         const bool bNoSteps(1 == rGradient.GetSteps());
1449*8718d260SArmin Le Grand         bool bCreateObject(true);
1450*8718d260SArmin Le Grand         bool bHasNewMask(false);
1451*8718d260SArmin Le Grand         AlphaMask aNewMask;
1452*8718d260SArmin Le Grand 
1453*8718d260SArmin Le Grand         if(bEqualColors || bNoSteps)
1454*8718d260SArmin Le Grand         {
1455*8718d260SArmin Le Grand             // single transparence
1456*8718d260SArmin Le Grand             const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
1457*8718d260SArmin Le Grand             const double fTransparence(aMedium.luminance());
1458*8718d260SArmin Le Grand 
1459*8718d260SArmin Le Grand             if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
1460*8718d260SArmin Le Grand             {
1461*8718d260SArmin Le Grand                 // no transparence needed, all done
1462*8718d260SArmin Le Grand             }
1463*8718d260SArmin Le Grand             else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0))
1464*8718d260SArmin Le Grand             {
1465*8718d260SArmin Le Grand                 // all transparent, no object
1466*8718d260SArmin Le Grand                 bCreateObject = false;
1467*8718d260SArmin Le Grand             }
1468*8718d260SArmin Le Grand             else
1469*8718d260SArmin Le Grand             {
1470*8718d260SArmin Le Grand                 // 0.0 < transparence < 1.0, apply
1471*8718d260SArmin Le Grand                 sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
1472*8718d260SArmin Le Grand 
1473*8718d260SArmin Le Grand                 aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
1474*8718d260SArmin Le Grand                 bHasNewMask = true;
1475*8718d260SArmin Le Grand             }
1476*8718d260SArmin Le Grand         }
1477*8718d260SArmin Le Grand         else
1478*8718d260SArmin Le Grand         {
1479*8718d260SArmin Le Grand             // gradient transparence
1480*8718d260SArmin Le Grand             VirtualDevice aVDev;
1481*8718d260SArmin Le Grand 
1482*8718d260SArmin Le Grand             aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
1483*8718d260SArmin Le Grand             aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
1484*8718d260SArmin Le Grand 
1485*8718d260SArmin Le Grand             aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
1486*8718d260SArmin Le Grand             bHasNewMask = true;
1487*8718d260SArmin Le Grand         }
1488*8718d260SArmin Le Grand 
1489*8718d260SArmin Le Grand         if(bCreateObject)
1490*8718d260SArmin Le Grand         {
1491*8718d260SArmin Le Grand             if(bHasNewMask)
1492*8718d260SArmin Le Grand             {
1493*8718d260SArmin Le Grand                 if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
1494*8718d260SArmin Le Grand                 {
1495*8718d260SArmin Le Grand                     // no transparence yet, apply new one
1496*8718d260SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
1497*8718d260SArmin Le Grand                 }
1498*8718d260SArmin Le Grand                 else
1499*8718d260SArmin Le Grand                 {
1500*8718d260SArmin Le Grand                     // mix existing and new alpha mask
1501*8718d260SArmin Le Grand                     AlphaMask aOldMask;
1502*8718d260SArmin Le Grand 
1503*8718d260SArmin Le Grand                     if(aBitmapEx.IsAlpha())
1504*8718d260SArmin Le Grand                     {
1505*8718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetAlpha();
1506*8718d260SArmin Le Grand                     }
1507*8718d260SArmin Le Grand                     else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType())
1508*8718d260SArmin Le Grand                     {
1509*8718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetMask();
1510*8718d260SArmin Le Grand                     }
1511*8718d260SArmin Le Grand                     else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType())
1512*8718d260SArmin Le Grand                     {
1513*8718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
1514*8718d260SArmin Le Grand                     }
1515*8718d260SArmin Le Grand 
1516*8718d260SArmin Le Grand                     BitmapReadAccess* pOld = aOldMask.AcquireReadAccess();
1517*8718d260SArmin Le Grand                     BitmapWriteAccess* pNew = aNewMask.AcquireWriteAccess();
1518*8718d260SArmin Le Grand 
1519*8718d260SArmin Le Grand                     if(pOld && pNew)
1520*8718d260SArmin Le Grand                     {
1521*8718d260SArmin Le Grand                         if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height())
1522*8718d260SArmin Le Grand                         {
1523*8718d260SArmin Le Grand                             for(sal_uInt32 y(0); y < pNew->Height(); y++)
1524*8718d260SArmin Le Grand                             {
1525*8718d260SArmin Le Grand                                 for(sal_uInt32 x(0); x < pNew->Width(); x++)
1526*8718d260SArmin Le Grand                                 {
1527*8718d260SArmin Le Grand                                     const BitmapColor aColOld(pOld->GetPixel(y, x));
1528*8718d260SArmin Le Grand                                     const BitmapColor aColNew(pNew->GetPixel(y, x));
1529*8718d260SArmin Le Grand                                     const sal_uInt16 aCombine(sal_uInt16(aColOld.GetIndex()) + sal_uInt16(aColNew.GetIndex()));
1530*8718d260SArmin Le Grand 
1531*8718d260SArmin Le Grand                                     pNew->SetPixel(y, x, BitmapColor(aCombine > 255 ? 255 : sal_uInt8(aCombine)));
1532*8718d260SArmin Le Grand                                 }
1533*8718d260SArmin Le Grand                             }
1534*8718d260SArmin Le Grand                         }
1535*8718d260SArmin Le Grand                         else
1536*8718d260SArmin Le Grand                         {
1537*8718d260SArmin Le Grand                             OSL_ENSURE(false, "Alpha masks have different sizes (!)");
1538*8718d260SArmin Le Grand                         }
1539*8718d260SArmin Le Grand 
1540*8718d260SArmin Le Grand                         aOldMask.ReleaseAccess(pOld);
1541*8718d260SArmin Le Grand                         aNewMask.ReleaseAccess(pNew);
1542*8718d260SArmin Le Grand                     }
1543*8718d260SArmin Le Grand                     else
1544*8718d260SArmin Le Grand                     {
1545*8718d260SArmin Le Grand                         OSL_ENSURE(false, "Got no access to alpha bitmaps (!)");
1546*8718d260SArmin Le Grand                     }
1547*8718d260SArmin Le Grand 
1548*8718d260SArmin Le Grand                     // apply combined bitmap as mask
1549*8718d260SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
1550*8718d260SArmin Le Grand                 }
1551*8718d260SArmin Le Grand             }
1552*8718d260SArmin Le Grand 
1553*8718d260SArmin Le Grand             // create and add object
1554*8718d260SArmin Le Grand             SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
1555*8718d260SArmin Le Grand 
1556*8718d260SArmin Le Grand             InsertObj(pGraf);
1557*8718d260SArmin Le Grand         }
1558*8718d260SArmin Le Grand     }
1559*8718d260SArmin Le Grand }
1560*8718d260SArmin Le Grand 
1561cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1562cdf0e10cSrcweir // eof
1563