xref: /aoo41x/main/svx/source/svdraw/svdfmtf.cxx (revision 674b939b)
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>
738718d260SArmin Le Grand #include <svx/xfltrit.hxx>
748718d260SArmin Le Grand #include <vcl/bmpacc.hxx>
759f63b866SArmin Le Grand #include <svx/xflbmtit.hxx>
769f63b866SArmin Le Grand #include <svx/xflbstit.hxx>
779f63b866SArmin Le Grand #include <svx/svdpntv.hxx>
78*674b939bSArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx>
79*674b939bSArmin Le Grand #include <svx/svditer.hxx>
80*674b939bSArmin Le Grand #include <svx/svdogrp.hxx>
81cdf0e10cSrcweir 
82cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
83cdf0e10cSrcweir 
ImpSdrGDIMetaFileImport(SdrModel & rModel,SdrLayerID nLay,const Rectangle & rRect)848718d260SArmin Le Grand ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
858718d260SArmin Le Grand     SdrModel& rModel,
868718d260SArmin Le Grand     SdrLayerID nLay,
878718d260SArmin Le Grand     const Rectangle& rRect)
888718d260SArmin Le Grand :   maTmpList(),
898718d260SArmin Le Grand     maVD(),
908718d260SArmin Le Grand     maScaleRect(rRect),
918718d260SArmin Le Grand     mnMapScalingOfs(0),
928718d260SArmin Le Grand 	mpLineAttr(0),
938718d260SArmin Le Grand     mpFillAttr(0),
948718d260SArmin Le Grand     mpTextAttr(0),
958718d260SArmin Le Grand     mpModel(&rModel),
968718d260SArmin Le Grand     mnLayer(nLay),
978718d260SArmin Le Grand     maOldLineColor(),
988718d260SArmin Le Grand 	mnLineWidth(0),
99cdf0e10cSrcweir 	maLineJoin(basegfx::B2DLINEJOIN_NONE),
1005aaf853bSArmin Le Grand 	maLineCap(com::sun::star::drawing::LineCap_BUTT),
101cdf0e10cSrcweir 	maDash(XDASH_RECT, 0, 0, 0, 0, 0),
1028718d260SArmin Le Grand     mbMov(false),
1038718d260SArmin Le Grand     mbSize(false),
1048718d260SArmin Le Grand     maOfs(0, 0),
1058718d260SArmin Le Grand     mfScaleX(1.0),
1068718d260SArmin Le Grand     mfScaleY(1.0),
1078718d260SArmin Le Grand     maScaleX(1.0),
1088718d260SArmin Le Grand     maScaleY(1.0),
1098718d260SArmin Le Grand 	mbFntDirty(true),
1108718d260SArmin Le Grand 	mbLastObjWasPolyWithoutLine(false),
1118718d260SArmin Le Grand     mbNoLine(false),
1128718d260SArmin Le Grand     mbNoFill(false),
1138718d260SArmin Le Grand     mbLastObjWasLine(false),
11447a7c0c1SArmin Le Grand     maClip()
115cdf0e10cSrcweir {
1168718d260SArmin Le Grand 	maVD.EnableOutput(false);
1178718d260SArmin Le Grand     maVD.SetLineColor();
1188718d260SArmin Le Grand     maVD.SetFillColor();
1198718d260SArmin Le Grand 	maOldLineColor.SetRed( maVD.GetLineColor().GetRed() + 1 );
1208718d260SArmin Le Grand 	mpLineAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_LINE_FIRST, XATTR_LINE_LAST, 0, 0);
1218718d260SArmin Le Grand 	mpFillAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
1228718d260SArmin Le Grand 	mpTextAttr = new SfxItemSet(rModel.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END, 0, 0);
12347a7c0c1SArmin Le Grand     checkClip();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
~ImpSdrGDIMetaFileImport()126cdf0e10cSrcweir ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
127cdf0e10cSrcweir {
1288718d260SArmin Le Grand 	delete mpLineAttr;
1298718d260SArmin Le Grand 	delete mpFillAttr;
1308718d260SArmin Le Grand 	delete mpTextAttr;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
DoLoopActions(GDIMetaFile & rMtf,SvdProgressInfo * pProgrInfo,sal_uInt32 * pActionsToReport)1338718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
134cdf0e10cSrcweir {
135468982e4SArmin Le Grand     const sal_uLong nCount(rMtf.GetActionCount());
136468982e4SArmin Le Grand 
137468982e4SArmin Le Grand     for(sal_uLong a(0); a < nCount; a++)
138468982e4SArmin Le Grand     {
139468982e4SArmin Le Grand         MetaAction* pAct = rMtf.GetAction(a);
140468982e4SArmin Le Grand 
141468982e4SArmin Le Grand         if(!pAct)
142468982e4SArmin Le Grand         {
143468982e4SArmin Le Grand             OSL_ENSURE(false, "OOps, no action at valid position (!)");
144468982e4SArmin Le Grand             pAct = rMtf.GetAction(0);
145468982e4SArmin Le Grand         }
146468982e4SArmin Le Grand 
147cdf0e10cSrcweir 		switch (pAct->GetType())
148cdf0e10cSrcweir 		{
149cdf0e10cSrcweir 			case META_PIXEL_ACTION          : DoAction((MetaPixelAction          &)*pAct); break;
150cdf0e10cSrcweir 			case META_POINT_ACTION          : DoAction((MetaPointAction          &)*pAct); break;
151cdf0e10cSrcweir 			case META_LINE_ACTION           : DoAction((MetaLineAction           &)*pAct); break;
152cdf0e10cSrcweir 			case META_RECT_ACTION           : DoAction((MetaRectAction           &)*pAct); break;
153cdf0e10cSrcweir 			case META_ROUNDRECT_ACTION      : DoAction((MetaRoundRectAction      &)*pAct); break;
154cdf0e10cSrcweir 			case META_ELLIPSE_ACTION        : DoAction((MetaEllipseAction        &)*pAct); break;
155cdf0e10cSrcweir 			case META_ARC_ACTION            : DoAction((MetaArcAction            &)*pAct); break;
156cdf0e10cSrcweir 			case META_PIE_ACTION            : DoAction((MetaPieAction            &)*pAct); break;
157cdf0e10cSrcweir 			case META_CHORD_ACTION          : DoAction((MetaChordAction          &)*pAct); break;
158cdf0e10cSrcweir 			case META_POLYLINE_ACTION	    : DoAction((MetaPolyLineAction		 &)*pAct); break;
159cdf0e10cSrcweir 			case META_POLYGON_ACTION        : DoAction((MetaPolygonAction        &)*pAct); break;
160cdf0e10cSrcweir 			case META_POLYPOLYGON_ACTION    : DoAction((MetaPolyPolygonAction    &)*pAct); break;
161cdf0e10cSrcweir 			case META_TEXT_ACTION           : DoAction((MetaTextAction           &)*pAct); break;
162cdf0e10cSrcweir 			case META_TEXTARRAY_ACTION      : DoAction((MetaTextArrayAction      &)*pAct); break;
163cdf0e10cSrcweir 			case META_STRETCHTEXT_ACTION    : DoAction((MetaStretchTextAction    &)*pAct); break;
164cdf0e10cSrcweir 			case META_BMP_ACTION			: DoAction((MetaBmpAction			 &)*pAct); break;
165cdf0e10cSrcweir 			case META_BMPSCALE_ACTION		: DoAction((MetaBmpScaleAction		 &)*pAct); break;
166cdf0e10cSrcweir 			case META_BMPEX_ACTION			: DoAction((MetaBmpExAction			 &)*pAct); break;
167cdf0e10cSrcweir 			case META_BMPEXSCALE_ACTION		: DoAction((MetaBmpExScaleAction	 &)*pAct); break;
168cdf0e10cSrcweir 			case META_LINECOLOR_ACTION      : DoAction((MetaLineColorAction      &)*pAct); break;
169cdf0e10cSrcweir 			case META_FILLCOLOR_ACTION      : DoAction((MetaFillColorAction      &)*pAct); break;
170cdf0e10cSrcweir 			case META_TEXTCOLOR_ACTION      : DoAction((MetaTextColorAction      &)*pAct); break;
171cdf0e10cSrcweir 			case META_TEXTFILLCOLOR_ACTION  : DoAction((MetaTextFillColorAction  &)*pAct); break;
172cdf0e10cSrcweir 			case META_FONT_ACTION           : DoAction((MetaFontAction           &)*pAct); break;
173cdf0e10cSrcweir 			case META_TEXTALIGN_ACTION		: DoAction((MetaTextAlignAction		 &)*pAct); break;
174cdf0e10cSrcweir 			case META_MAPMODE_ACTION        : DoAction((MetaMapModeAction        &)*pAct); break;
175cdf0e10cSrcweir 			case META_CLIPREGION_ACTION     : DoAction((MetaClipRegionAction     &)*pAct); break;
176cdf0e10cSrcweir 			case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
177cdf0e10cSrcweir 			case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
178cdf0e10cSrcweir 			case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
179cdf0e10cSrcweir 			case META_RASTEROP_ACTION       : DoAction((MetaRasterOpAction       &)*pAct); break;
180cdf0e10cSrcweir 			case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
181cdf0e10cSrcweir 			case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
182cdf0e10cSrcweir 			case META_HATCH_ACTION			: DoAction((MetaHatchAction          &)*pAct); break;
1838718d260SArmin Le Grand 			case META_COMMENT_ACTION		: DoAction((MetaCommentAction        &)*pAct, &rMtf); break;
1848718d260SArmin Le Grand 
1858718d260SArmin Le Grand             // missing actions added
1868718d260SArmin Le Grand             case META_TEXTRECT_ACTION       : DoAction((MetaTextRectAction&)*pAct); break;
1878718d260SArmin Le Grand             case META_BMPSCALEPART_ACTION   : DoAction((MetaBmpScalePartAction&)*pAct); break;
1888718d260SArmin Le Grand             case META_BMPEXSCALEPART_ACTION : DoAction((MetaBmpExScalePartAction&)*pAct); break;
1898718d260SArmin Le Grand             case META_MASK_ACTION           : DoAction((MetaMaskAction&)*pAct); break;
1908718d260SArmin Le Grand             case META_MASKSCALE_ACTION      : DoAction((MetaMaskScaleAction&)*pAct); break;
1918718d260SArmin Le Grand             case META_MASKSCALEPART_ACTION  : DoAction((MetaMaskScalePartAction&)*pAct); break;
1928718d260SArmin Le Grand             case META_GRADIENT_ACTION       : DoAction((MetaGradientAction&)*pAct); break;
1938718d260SArmin Le Grand             case META_WALLPAPER_ACTION      : DoAction((MetaWallpaperAction&)*pAct); break;
1948718d260SArmin Le Grand             case META_TRANSPARENT_ACTION    : DoAction((MetaTransparentAction&)*pAct); break;
1958718d260SArmin Le Grand             case META_EPS_ACTION            : DoAction((MetaEPSAction&)*pAct); break;
1968718d260SArmin Le Grand             case META_REFPOINT_ACTION       : DoAction((MetaRefPointAction&)*pAct); break;
1978718d260SArmin Le Grand             case META_TEXTLINECOLOR_ACTION  : DoAction((MetaTextLineColorAction&)*pAct); break;
1988718d260SArmin Le Grand             case META_TEXTLINE_ACTION       : DoAction((MetaTextLineAction&)*pAct); break;
1998718d260SArmin Le Grand             case META_FLOATTRANSPARENT_ACTION : DoAction((MetaFloatTransparentAction&)*pAct); break;
2008718d260SArmin Le Grand             case META_GRADIENTEX_ACTION     : DoAction((MetaGradientExAction&)*pAct); break;
2018718d260SArmin Le Grand             case META_LAYOUTMODE_ACTION     : DoAction((MetaLayoutModeAction&)*pAct); break;
2028718d260SArmin Le Grand             case META_TEXTLANGUAGE_ACTION   : DoAction((MetaTextLanguageAction&)*pAct); break;
2038718d260SArmin Le Grand             case META_OVERLINECOLOR_ACTION  : DoAction((MetaOverlineColorAction&)*pAct); break;
204cdf0e10cSrcweir 		}
205cdf0e10cSrcweir 
2068718d260SArmin Le Grand 		if(pProgrInfo && pActionsToReport)
207cdf0e10cSrcweir 		{
2088718d260SArmin Le Grand             (*pActionsToReport)++;
2098718d260SArmin Le Grand 
2108718d260SArmin Le Grand             if(*pActionsToReport >= 16) // Alle 16 Action updaten
2118718d260SArmin Le Grand             {
2128718d260SArmin Le Grand                 if(!pProgrInfo->ReportActions(*pActionsToReport))
2138718d260SArmin Le Grand                     break;
2148718d260SArmin Le Grand 
2158718d260SArmin Le Grand                 *pActionsToReport = 0;
2168718d260SArmin Le Grand             }
217cdf0e10cSrcweir 		}
218cdf0e10cSrcweir 	}
2198718d260SArmin Le Grand }
220cdf0e10cSrcweir 
DoImport(const GDIMetaFile & rMtf,SdrObjList & rOL,sal_uInt32 nInsPos,SvdProgressInfo * pProgrInfo)2218718d260SArmin Le Grand sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(
2228718d260SArmin Le Grand     const GDIMetaFile& rMtf,
2238718d260SArmin Le Grand 	SdrObjList& rOL,
2248718d260SArmin Le Grand 	sal_uInt32 nInsPos,
2258718d260SArmin Le Grand 	SvdProgressInfo* pProgrInfo)
2268718d260SArmin Le Grand {
2278718d260SArmin Le Grand 	// setup some global scale parameter
2288718d260SArmin Le Grand 	// mfScaleX, mfScaleY, maScaleX, maScaleY, mbMov, mbSize
2298718d260SArmin Le Grand     mfScaleX = mfScaleY = 1.0;
2308718d260SArmin Le Grand 	const Size aMtfSize(rMtf.GetPrefSize());
2318718d260SArmin Le Grand 
2328718d260SArmin Le Grand     if(aMtfSize.Width() & aMtfSize.Height() && (!maScaleRect.IsEmpty()))
2338718d260SArmin Le Grand     {
2348718d260SArmin Le Grand 		maOfs = maScaleRect.TopLeft();
2358718d260SArmin Le Grand 
2368718d260SArmin Le Grand         if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2378718d260SArmin Le Grand         {
2388718d260SArmin Le Grand             mfScaleX = (double)( maScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
2398718d260SArmin Le Grand         }
2408718d260SArmin Le Grand 
2418718d260SArmin Le Grand         if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2428718d260SArmin Le Grand         {
2438718d260SArmin Le Grand             mfScaleY = (double)( maScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
2448718d260SArmin Le Grand         }
2458718d260SArmin Le Grand     }
2468718d260SArmin Le Grand 
2478718d260SArmin Le Grand 	mbMov = maOfs.X()!=0 || maOfs.Y()!=0;
2488718d260SArmin Le Grand     mbSize = false;
2498718d260SArmin Le Grand 	maScaleX = Fraction( 1, 1 );
2508718d260SArmin Le Grand 	maScaleY = Fraction( 1, 1 );
2518718d260SArmin Le Grand 
2528718d260SArmin Le Grand     if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2538718d260SArmin Le Grand     {
2548718d260SArmin Le Grand         maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width());
2558718d260SArmin Le Grand         mbSize = true;
2568718d260SArmin Le Grand     }
2578718d260SArmin Le Grand 
2588718d260SArmin Le Grand     if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2598718d260SArmin Le Grand     {
2608718d260SArmin Le Grand         maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height());
2618718d260SArmin Le Grand         mbSize = true;
2628718d260SArmin Le Grand     }
2638718d260SArmin Le Grand 
2648718d260SArmin Le Grand 	if(pProgrInfo)
2658718d260SArmin Le Grand     {
2668718d260SArmin Le Grand 		pProgrInfo->SetActionCount(rMtf.GetActionCount());
2678718d260SArmin Le Grand     }
2688718d260SArmin Le Grand 
2698718d260SArmin Le Grand 	sal_uInt32 nActionsToReport(0);
2708718d260SArmin Le Grand 
2718718d260SArmin Le Grand     // execute
2728718d260SArmin Le Grand     DoLoopActions(const_cast< GDIMetaFile& >(rMtf), pProgrInfo, &nActionsToReport);
2738718d260SArmin Le Grand 
2748718d260SArmin Le Grand     if(pProgrInfo)
275cdf0e10cSrcweir 	{
276cdf0e10cSrcweir 		pProgrInfo->ReportActions(nActionsToReport);
277cdf0e10cSrcweir 		nActionsToReport = 0;
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	// MapMode-Scaling  vornehmen
281cdf0e10cSrcweir 	MapScaling();
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	// Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
2848718d260SArmin Le Grand 	// Da in maTmpList allerdings weniger eintraege als GetActionCount()
285cdf0e10cSrcweir 	// existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
286cdf0e10cSrcweir 	// hinzugefuegt werden.
2878718d260SArmin Le Grand 	nActionsToReport = (rMtf.GetActionCount() - maTmpList.size()) * 2;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	// Alle noch nicht gemeldeten Rescales melden
290cdf0e10cSrcweir 	if(pProgrInfo)
291cdf0e10cSrcweir 	{
292cdf0e10cSrcweir 		pProgrInfo->ReportRescales(nActionsToReport);
2938718d260SArmin Le Grand 		pProgrInfo->SetInsertCount(maTmpList.size());
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir 
2968718d260SArmin Le Grand     nActionsToReport = 0;
2978718d260SArmin Le Grand 
2988718d260SArmin Le Grand 	// alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
2998718d260SArmin Le Grand 	if(nInsPos > rOL.GetObjCount())
3008718d260SArmin Le Grand     {
3018718d260SArmin Le Grand         nInsPos = rOL.GetObjCount();
3028718d260SArmin Le Grand     }
3038718d260SArmin Le Grand 
304cdf0e10cSrcweir 	SdrInsertReason aReason(SDRREASON_VIEWCALL);
3058718d260SArmin Le Grand 
3068718d260SArmin Le Grand 	for(sal_uInt32 i(0); i < maTmpList.size(); i++)
307cdf0e10cSrcweir 	{
3088718d260SArmin Le Grand 		SdrObject* pObj = maTmpList[i];
3098718d260SArmin Le Grand 		rOL.NbcInsertObject(pObj, nInsPos, &aReason);
3108718d260SArmin Le Grand 		nInsPos++;
311cdf0e10cSrcweir 
3128718d260SArmin Le Grand 		if(pProgrInfo)
313cdf0e10cSrcweir 		{
314cdf0e10cSrcweir 			nActionsToReport++;
3158718d260SArmin Le Grand 
3168718d260SArmin Le Grand             if(nActionsToReport >= 32) // Alle 32 Action updaten
317cdf0e10cSrcweir 			{
318cdf0e10cSrcweir 				pProgrInfo->ReportInserts(nActionsToReport);
319cdf0e10cSrcweir 				nActionsToReport = 0;
320cdf0e10cSrcweir 			}
321cdf0e10cSrcweir 		}
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	// ein letztesmal alle verbliebennen Inserts reporten
3258718d260SArmin Le Grand 	if(pProgrInfo)
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		pProgrInfo->ReportInserts(nActionsToReport);
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 
3308718d260SArmin Le Grand 	return maTmpList.size();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
SetAttributes(SdrObject * pObj,bool bForceTextAttr)3338718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
334cdf0e10cSrcweir {
3358718d260SArmin Le Grand 	mbNoLine = false;
3368718d260SArmin Le Grand     mbNoFill = false;
3378718d260SArmin Le Grand 	bool bLine(!bForceTextAttr);
3388718d260SArmin Le Grand 	bool bFill(!pObj || (pObj->IsClosedObj() && !bForceTextAttr));
3398718d260SArmin Le Grand 	bool bText(bForceTextAttr || (pObj && pObj->GetOutlinerParaObject()));
340cdf0e10cSrcweir 
3418718d260SArmin Le Grand 	if(bLine)
342cdf0e10cSrcweir 	{
3438718d260SArmin Le Grand 		if(mnLineWidth)
3448718d260SArmin Le Grand         {
3458718d260SArmin Le Grand 			mpLineAttr->Put(XLineWidthItem(mnLineWidth));
3468718d260SArmin Le Grand         }
347cdf0e10cSrcweir         else
3488718d260SArmin Le Grand         {
3498718d260SArmin Le Grand 			mpLineAttr->Put(XLineWidthItem(0));
3508718d260SArmin Le Grand         }
3518718d260SArmin Le Grand 
3528718d260SArmin Le Grand 		maOldLineColor = maVD.GetLineColor();
353cdf0e10cSrcweir 
3548718d260SArmin Le Grand         if(maVD.IsLineColor())
355cdf0e10cSrcweir 		{
3568718d260SArmin Le Grand 			mpLineAttr->Put(XLineStyleItem(XLINE_SOLID));
3578718d260SArmin Le Grand 			mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor()));
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 		else
3608718d260SArmin Le Grand         {
3618718d260SArmin Le Grand 			mpLineAttr->Put(XLineStyleItem(XLINE_NONE));
3628718d260SArmin Le Grand         }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 		switch(maLineJoin)
365cdf0e10cSrcweir 		{
366cdf0e10cSrcweir 			default : // basegfx::B2DLINEJOIN_NONE
367d5370dc8SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_NONE));
368cdf0e10cSrcweir 				break;
369cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MIDDLE:
370d5370dc8SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_MIDDLE));
371cdf0e10cSrcweir 				break;
372cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_BEVEL:
373d5370dc8SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL));
374cdf0e10cSrcweir 				break;
375cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_MITER:
376d5370dc8SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_MITER));
377cdf0e10cSrcweir 				break;
378cdf0e10cSrcweir 			case basegfx::B2DLINEJOIN_ROUND:
379d5370dc8SArmin Le Grand 				mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_ROUND));
380cdf0e10cSrcweir 				break;
381cdf0e10cSrcweir 		}
382cdf0e10cSrcweir 
3835aaf853bSArmin Le Grand         // Add LineCap support
3848718d260SArmin Le Grand         mpLineAttr->Put(XLineCapItem(maLineCap));
3855aaf853bSArmin Le Grand 
386cdf0e10cSrcweir 		if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
387cdf0e10cSrcweir 		{
3888718d260SArmin Le Grand 			mpLineAttr->Put(XLineDashItem(String(), maDash));
389cdf0e10cSrcweir 		}
390cdf0e10cSrcweir         else
391cdf0e10cSrcweir         {
3928718d260SArmin Le Grand 			mpLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
393cdf0e10cSrcweir         }
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 	else
3968718d260SArmin Le Grand     {
3978718d260SArmin Le Grand 		mbNoLine = true;
3988718d260SArmin Le Grand     }
399cdf0e10cSrcweir 
4008718d260SArmin Le Grand 	if(bFill)
401cdf0e10cSrcweir 	{
4028718d260SArmin Le Grand 		if(maVD.IsFillColor())
403cdf0e10cSrcweir 		{
4048718d260SArmin Le Grand 			mpFillAttr->Put(XFillStyleItem(XFILL_SOLID));
4058718d260SArmin Le Grand 			mpFillAttr->Put(XFillColorItem(String(), maVD.GetFillColor()));
406cdf0e10cSrcweir 		}
407cdf0e10cSrcweir 		else
4088718d260SArmin Le Grand         {
4098718d260SArmin Le Grand 			mpFillAttr->Put(XFillStyleItem(XFILL_NONE));
4108718d260SArmin Le Grand         }
411cdf0e10cSrcweir 	}
412cdf0e10cSrcweir 	else
4138718d260SArmin Le Grand     {
4148718d260SArmin Le Grand 		mbNoFill = true;
4158718d260SArmin Le Grand     }
416cdf0e10cSrcweir 
4178718d260SArmin Le Grand 	if(bText && mbFntDirty)
418cdf0e10cSrcweir 	{
4198718d260SArmin Le Grand 		Font aFnt(maVD.GetFont());
4208718d260SArmin Le Grand 		const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * mfScaleY));
4218718d260SArmin Le Grand 
4228718d260SArmin Le Grand         mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
4238718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
4248718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
4258718d260SArmin Le Grand         mpTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
4268718d260SArmin Le Grand         mpTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
4278718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
4288718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
4298718d260SArmin Le Grand 		mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
4308718d260SArmin Le Grand         mpTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
4318718d260SArmin Le Grand         mpTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
4328718d260SArmin Le Grand         mpTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
4338718d260SArmin Le Grand         mpTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
4348718d260SArmin Le Grand         mpTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
435a5258243SPedro Giffuni 
436a5258243SPedro Giffuni         // #i118485# Setting this item leads to problems (written #i118498# for this)
4378718d260SArmin Le Grand         // mpTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
438a5258243SPedro Giffuni 
4398718d260SArmin Le Grand         mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
4408718d260SArmin Le Grand         mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
4418718d260SArmin Le Grand         mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
442cdf0e10cSrcweir 		//... svxfont textitem svditext
4438718d260SArmin Le Grand 		mbFntDirty = false;
444cdf0e10cSrcweir 	}
4458718d260SArmin Le Grand 
4468718d260SArmin Le Grand     if(pObj)
447cdf0e10cSrcweir 	{
4488718d260SArmin Le Grand 		pObj->SetLayer(mnLayer);
4498718d260SArmin Le Grand 
4508718d260SArmin Le Grand         if(bLine)
4518718d260SArmin Le Grand         {
4528718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpLineAttr);
4538718d260SArmin Le Grand         }
4548718d260SArmin Le Grand 
4558718d260SArmin Le Grand 		if(bFill)
4568718d260SArmin Le Grand         {
4578718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpFillAttr);
4588718d260SArmin Le Grand         }
4598718d260SArmin Le Grand 
4608718d260SArmin Le Grand 		if(bText)
461cdf0e10cSrcweir 		{
4628718d260SArmin Le Grand 			pObj->SetMergedItemSet(*mpTextAttr);
4638718d260SArmin Le Grand 			pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
464cdf0e10cSrcweir 		}
465cdf0e10cSrcweir 	}
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
InsertObj(SdrObject * pObj,bool bScale)4688718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
469cdf0e10cSrcweir {
4708718d260SArmin Le Grand     if(bScale && !maScaleRect.IsEmpty())
471cdf0e10cSrcweir     {
4728718d260SArmin Le Grand 		if(mbSize)
4738718d260SArmin Le Grand         {
4748718d260SArmin Le Grand 			pObj->NbcResize(Point(), maScaleX, maScaleY);
4758718d260SArmin Le Grand         }
4768718d260SArmin Le Grand 
4778718d260SArmin Le Grand         if(mbMov)
4788718d260SArmin Le Grand         {
4798718d260SArmin Le Grand 			pObj->NbcMove(Size(maOfs.X(), maOfs.Y()));
4808718d260SArmin Le Grand         }
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 
48347a7c0c1SArmin Le Grand     if(isClip())
484cdf0e10cSrcweir     {
48547a7c0c1SArmin Le Grand         const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
48647a7c0c1SArmin Le Grand         const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
48747a7c0c1SArmin Le Grand     	const SdrLayerID aOldLayer(pObj->GetLayer());
48847a7c0c1SArmin Le Grand     	const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
48947a7c0c1SArmin Le Grand         const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
490*674b939bSArmin Le Grand         const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj);
49147a7c0c1SArmin Le Grand 
492*674b939bSArmin Le Grand         if(pSdrTextObj && pSdrTextObj->HasText())
49347a7c0c1SArmin Le Grand         {
494*674b939bSArmin Le Grand             // all text objects are created from ImportText and have no line or fill attributes, so
495*674b939bSArmin Le Grand             // it is okay to concentrate on the text itself
496*674b939bSArmin Le Grand             while(true)
497*674b939bSArmin Le Grand             {
498*674b939bSArmin Le Grand                 const basegfx::B2DPolyPolygon aTextContour(pSdrTextObj->TakeContour());
499*674b939bSArmin Le Grand                 const basegfx::B2DRange aTextRange(aTextContour.getB2DRange());
500*674b939bSArmin Le Grand                 const basegfx::B2DRange aClipRange(maClip.getB2DRange());
501*674b939bSArmin Le Grand 
502*674b939bSArmin Le Grand                 // no overlap -> completely outside
503*674b939bSArmin Le Grand                 if(!aClipRange.overlaps(aTextRange))
504*674b939bSArmin Le Grand                 {
505*674b939bSArmin Le Grand                     SdrObject::Free(pObj);
506*674b939bSArmin Le Grand                     break;
507*674b939bSArmin Le Grand                 }
508*674b939bSArmin Le Grand 
509*674b939bSArmin Le Grand                 // when the clip is a rectangle fast check for inside is possible
510*674b939bSArmin Le Grand                 if(basegfx::tools::isRectangle(maClip) && aClipRange.isInside(aTextRange))
511*674b939bSArmin Le Grand                 {
512*674b939bSArmin Le Grand                     // completely inside ClipRect
513*674b939bSArmin Le Grand                     break;
514*674b939bSArmin Le Grand                 }
515cdf0e10cSrcweir 
516*674b939bSArmin Le Grand                 // here text needs to be clipped; to do so, convert to SdrObjects with polygons
517*674b939bSArmin Le Grand                 // and add these recursively. Delete original object, do not add in this run
518*674b939bSArmin Le Grand                 SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
519*674b939bSArmin Le Grand                 SdrObject::Free(pObj);
52047a7c0c1SArmin Le Grand 
521*674b939bSArmin Le Grand                 if(pConverted)
522*674b939bSArmin Le Grand                 {
523*674b939bSArmin Le Grand                     // recursively add created conversion; per definition this shall not
524*674b939bSArmin Le Grand                     // contain further SdrTextObjs. Visit only non-group objects
525*674b939bSArmin Le Grand                     SdrObjListIter aIter(*pConverted, IM_DEEPNOGROUPS);
526*674b939bSArmin Le Grand 
527*674b939bSArmin Le Grand                     // work with clones; the created conversion may contain group objects
528*674b939bSArmin Le Grand                     // and when working with the original objects the loop itself could
529*674b939bSArmin Le Grand                     // break and the cleanup later would be pretty complicated (only delete group
530*674b939bSArmin Le Grand                     // objects, are these empty, ...?)
531*674b939bSArmin Le Grand                     while(aIter.IsMore())
532*674b939bSArmin Le Grand                     {
533*674b939bSArmin Le Grand                         SdrObject* pCandidate = aIter.Next();
534*674b939bSArmin Le Grand                         OSL_ENSURE(pCandidate && 0 == dynamic_cast< SdrObjGroup* >(pCandidate), "SdrObjListIter with IM_DEEPNOGROUPS error (!)");
535*674b939bSArmin Le Grand                         SdrObject* pNewClone = pCandidate->Clone();
536*674b939bSArmin Le Grand 
537*674b939bSArmin Le Grand                         if(pNewClone)
538*674b939bSArmin Le Grand                         {
539*674b939bSArmin Le Grand                             InsertObj(pNewClone, false);
540*674b939bSArmin Le Grand                         }
541*674b939bSArmin Le Grand                         else
542*674b939bSArmin Le Grand                         {
543*674b939bSArmin Le Grand                             OSL_ENSURE(false, "SdrObject::Clone() failed (!)");
544*674b939bSArmin Le Grand                         }
545*674b939bSArmin Le Grand                     }
546*674b939bSArmin Le Grand 
547*674b939bSArmin Le Grand                     // cleanup temporary conversion objects
548*674b939bSArmin Le Grand                     SdrObject::Free(pConverted);
549*674b939bSArmin Le Grand                 }
550*674b939bSArmin Le Grand 
551*674b939bSArmin Le Grand                 break;
552*674b939bSArmin Le Grand             }
553*674b939bSArmin Le Grand         }
554*674b939bSArmin Le Grand         else
55547a7c0c1SArmin Le Grand         {
556*674b939bSArmin Le Grand             BitmapEx aBitmapEx;
557*674b939bSArmin Le Grand 
558*674b939bSArmin Le Grand             if(pSdrGrafObj)
55947a7c0c1SArmin Le Grand             {
560*674b939bSArmin Le Grand                 aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
561*674b939bSArmin Le Grand             }
56247a7c0c1SArmin Le Grand 
563*674b939bSArmin Le Grand             SdrObject::Free(pObj);
564*674b939bSArmin Le Grand 
565*674b939bSArmin Le Grand             if(!aOldRange.isEmpty())
566*674b939bSArmin Le Grand             {
567*674b939bSArmin Le Grand                 // clip against ClipRegion
568*674b939bSArmin Le Grand                 const basegfx::B2DPolyPolygon aNewPoly(
569*674b939bSArmin Le Grand                     basegfx::tools::clipPolyPolygonOnPolyPolygon(
570*674b939bSArmin Le Grand                         aPoly,
571*674b939bSArmin Le Grand                         maClip,
572*674b939bSArmin Le Grand                         true,
573*674b939bSArmin Le Grand                         aPoly.isClosed() ? false : true));
574*674b939bSArmin Le Grand                 const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
575*674b939bSArmin Le Grand 
576*674b939bSArmin Le Grand                 if(!aNewRange.isEmpty())
57747a7c0c1SArmin Le Grand                 {
578*674b939bSArmin Le Grand                     pObj = new SdrPathObj(
579*674b939bSArmin Le Grand                         aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
580*674b939bSArmin Le Grand                         aNewPoly);
581*674b939bSArmin Le Grand 
582*674b939bSArmin Le Grand                     pObj->SetLayer(aOldLayer);
583*674b939bSArmin Le Grand                     pObj->SetMergedItemSet(aOldItemSet);
584*674b939bSArmin Le Grand 
585*674b939bSArmin Le Grand                     if(!!aBitmapEx)
586*674b939bSArmin Le Grand                     {
587*674b939bSArmin Le Grand                         // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
588*674b939bSArmin Le Grand                         const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
589*674b939bSArmin Le Grand                         const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
590*674b939bSArmin Le Grand                         basegfx::B2DRange aPixel(aNewRange);
591*674b939bSArmin Le Grand                         basegfx::B2DHomMatrix aTrans;
592*674b939bSArmin Le Grand 
593*674b939bSArmin Le Grand                         aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
594*674b939bSArmin Le Grand                         aTrans.scale(fScaleX, fScaleY);
595*674b939bSArmin Le Grand                         aPixel.transform(aTrans);
596*674b939bSArmin Le Grand 
597*674b939bSArmin Le Grand                         const Size aOrigSizePixel(aBitmapEx.GetSizePixel());
598*674b939bSArmin Le Grand                         const Point aClipTopLeft(
599*674b939bSArmin Le Grand                             basegfx::fround(floor(std::max(0.0, aPixel.getMinX()))),
600*674b939bSArmin Le Grand                             basegfx::fround(floor(std::max(0.0, aPixel.getMinY()))));
601*674b939bSArmin Le Grand                         const Size aClipSize(
602*674b939bSArmin Le Grand                             basegfx::fround(ceil(std::min((double)aOrigSizePixel.Width(), aPixel.getWidth()))),
603*674b939bSArmin Le Grand                             basegfx::fround(ceil(std::min((double)aOrigSizePixel.Height(), aPixel.getHeight()))));
604*674b939bSArmin Le Grand                         const BitmapEx aClippedBitmap(
605*674b939bSArmin Le Grand                             aBitmapEx,
606*674b939bSArmin Le Grand                             aClipTopLeft,
607*674b939bSArmin Le Grand                             aClipSize);
608*674b939bSArmin Le Grand 
609*674b939bSArmin Le Grand                         pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
610*674b939bSArmin Le Grand                         pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
611*674b939bSArmin Le Grand                         pObj->SetMergedItem(XFillBmpTileItem(false));
612*674b939bSArmin Le Grand                         pObj->SetMergedItem(XFillBmpStretchItem(true));
613*674b939bSArmin Le Grand                     }
61447a7c0c1SArmin Le Grand                 }
61547a7c0c1SArmin Le Grand             }
61647a7c0c1SArmin Le Grand         }
617cdf0e10cSrcweir     }
618cdf0e10cSrcweir 
61947a7c0c1SArmin Le Grand     if(pObj)
620cdf0e10cSrcweir     {
62147a7c0c1SArmin Le Grand         // #i111954# check object for visibility
62247a7c0c1SArmin Le Grand         // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
62347a7c0c1SArmin Le Grand         bool bVisible(false);
624cdf0e10cSrcweir 
62547a7c0c1SArmin Le Grand         if(pObj->HasLineStyle())
626cdf0e10cSrcweir         {
627cdf0e10cSrcweir             bVisible = true;
628cdf0e10cSrcweir         }
629cdf0e10cSrcweir 
63047a7c0c1SArmin Le Grand         if(!bVisible && pObj->HasFillStyle())
631cdf0e10cSrcweir         {
632cdf0e10cSrcweir             bVisible = true;
633cdf0e10cSrcweir         }
634cdf0e10cSrcweir 
63547a7c0c1SArmin Le Grand         if(!bVisible)
63647a7c0c1SArmin Le Grand         {
63747a7c0c1SArmin Le Grand             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
63847a7c0c1SArmin Le Grand 
63947a7c0c1SArmin Le Grand             if(pTextObj && pTextObj->HasText())
64047a7c0c1SArmin Le Grand             {
64147a7c0c1SArmin Le Grand                 bVisible = true;
64247a7c0c1SArmin Le Grand             }
64347a7c0c1SArmin Le Grand         }
64447a7c0c1SArmin Le Grand 
64547a7c0c1SArmin Le Grand         if(!bVisible)
64647a7c0c1SArmin Le Grand         {
64747a7c0c1SArmin Le Grand             SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
64847a7c0c1SArmin Le Grand 
64947a7c0c1SArmin Le Grand             if(pGrafObj)
65047a7c0c1SArmin Le Grand             {
65147a7c0c1SArmin Le Grand                 // this may be refined to check if the graphic really is visible. It
65247a7c0c1SArmin Le Grand                 // is here to ensure that graphic objects without fill, line and text
65347a7c0c1SArmin Le Grand                 // get created
65447a7c0c1SArmin Le Grand                 bVisible = true;
65547a7c0c1SArmin Le Grand             }
65647a7c0c1SArmin Le Grand         }
65747a7c0c1SArmin Le Grand 
65847a7c0c1SArmin Le Grand         if(!bVisible)
65947a7c0c1SArmin Le Grand         {
66047a7c0c1SArmin Le Grand             SdrObject::Free(pObj);
66147a7c0c1SArmin Le Grand         }
66247a7c0c1SArmin Le Grand         else
66347a7c0c1SArmin Le Grand         {
6648718d260SArmin Le Grand 	        maTmpList.push_back(pObj);
6658718d260SArmin Le Grand 
6668718d260SArmin Le Grand             if(dynamic_cast< SdrPathObj* >(pObj))
66747a7c0c1SArmin Le Grand 	        {
6688718d260SArmin Le Grand 		        const bool bClosed(pObj->IsClosedObj());
6698718d260SArmin Le Grand 
6708718d260SArmin Le Grand                 mbLastObjWasPolyWithoutLine = mbNoLine && bClosed;
6718718d260SArmin Le Grand 		        mbLastObjWasLine = !bClosed;
67247a7c0c1SArmin Le Grand 	        }
67347a7c0c1SArmin Le Grand 	        else
67447a7c0c1SArmin Le Grand 	        {
6758718d260SArmin Le Grand 		        mbLastObjWasPolyWithoutLine = false;
6768718d260SArmin Le Grand 		        mbLastObjWasLine = false;
67747a7c0c1SArmin Le Grand 	        }
67847a7c0c1SArmin Le Grand         }
679cdf0e10cSrcweir     }
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
682cdf0e10cSrcweir /**************************************************************************************************/
683cdf0e10cSrcweir 
DoAction(MetaPixelAction &)684cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
685cdf0e10cSrcweir {
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
DoAction(MetaPointAction &)688cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
689cdf0e10cSrcweir {
690cdf0e10cSrcweir }
691cdf0e10cSrcweir 
DoAction(MetaLineAction & rAct)692cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
693cdf0e10cSrcweir {
694cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
695cdf0e10cSrcweir 	const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
696cdf0e10cSrcweir 	const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 	if(!aStart.equal(aEnd))
699cdf0e10cSrcweir 	{
700cdf0e10cSrcweir 		basegfx::B2DPolygon aLine;
7018718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 		aLine.append(aStart);
704cdf0e10cSrcweir 		aLine.append(aEnd);
705cdf0e10cSrcweir 		aLine.transform(aTransform);
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 		const LineInfo& rLineInfo = rAct.GetLineInfo();
708cdf0e10cSrcweir 		const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
709cdf0e10cSrcweir 		bool bCreateLineObject(true);
710cdf0e10cSrcweir 
7118718d260SArmin Le Grand 		if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine))
712cdf0e10cSrcweir 		{
713cdf0e10cSrcweir 			bCreateLineObject = false;
714cdf0e10cSrcweir 		}
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 		if(bCreateLineObject)
717cdf0e10cSrcweir 		{
718cdf0e10cSrcweir 			SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
7198718d260SArmin Le Grand 			mnLineWidth = nNewLineWidth;
720cdf0e10cSrcweir 			maLineJoin = rLineInfo.GetLineJoin();
7215aaf853bSArmin Le Grand             maLineCap = rLineInfo.GetLineCap();
722cdf0e10cSrcweir 			maDash = XDash(XDASH_RECT,
723cdf0e10cSrcweir 				rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
724cdf0e10cSrcweir 				rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
725cdf0e10cSrcweir 				rLineInfo.GetDistance());
726cdf0e10cSrcweir 			SetAttributes(pPath);
7278718d260SArmin Le Grand 			mnLineWidth = 0;
728cdf0e10cSrcweir 			maLineJoin = basegfx::B2DLINEJOIN_NONE;
729cdf0e10cSrcweir 			maDash = XDash();
730cdf0e10cSrcweir 			InsertObj(pPath, false);
731cdf0e10cSrcweir 		}
732cdf0e10cSrcweir 	}
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
DoAction(MetaRectAction & rAct)735cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
736cdf0e10cSrcweir {
73747a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
738cdf0e10cSrcweir 	SetAttributes(pRect);
739cdf0e10cSrcweir 	InsertObj(pRect);
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
DoAction(MetaRoundRectAction & rAct)742cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
743cdf0e10cSrcweir {
74447a7c0c1SArmin Le Grand     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
745cdf0e10cSrcweir 	SetAttributes(pRect);
746cdf0e10cSrcweir 	long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
747cdf0e10cSrcweir 	if (nRad!=0) {
7488718d260SArmin Le Grand 		SfxItemSet aSet(*mpLineAttr->GetPool(), SDRATTR_ECKENRADIUS, SDRATTR_ECKENRADIUS, 0, 0);
749cdf0e10cSrcweir 		aSet.Put(SdrEckenradiusItem(nRad));
750cdf0e10cSrcweir 		pRect->SetMergedItemSet(aSet);
751cdf0e10cSrcweir 	}
752cdf0e10cSrcweir 	InsertObj(pRect);
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
755cdf0e10cSrcweir /**************************************************************************************************/
756cdf0e10cSrcweir 
DoAction(MetaEllipseAction & rAct)757cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
758cdf0e10cSrcweir {
75947a7c0c1SArmin Le Grand     SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
760cdf0e10cSrcweir 	SetAttributes(pCirc);
761cdf0e10cSrcweir 	InsertObj(pCirc);
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
DoAction(MetaArcAction & rAct)764cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
765cdf0e10cSrcweir {
76647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
767cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
768cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
769cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
770cdf0e10cSrcweir 	SetAttributes(pCirc);
771cdf0e10cSrcweir 	InsertObj(pCirc);
772cdf0e10cSrcweir }
773cdf0e10cSrcweir 
DoAction(MetaPieAction & rAct)774cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
775cdf0e10cSrcweir {
77647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
777cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
778cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
779cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
780cdf0e10cSrcweir 	SetAttributes(pCirc);
781cdf0e10cSrcweir 	InsertObj(pCirc);
782cdf0e10cSrcweir }
783cdf0e10cSrcweir 
DoAction(MetaChordAction & rAct)784cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
785cdf0e10cSrcweir {
78647a7c0c1SArmin Le Grand     Point aCenter(rAct.GetRect().Center());
787cdf0e10cSrcweir 	long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
788cdf0e10cSrcweir 	long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
789cdf0e10cSrcweir 	SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
790cdf0e10cSrcweir 	SetAttributes(pCirc);
791cdf0e10cSrcweir 	InsertObj(pCirc);
792cdf0e10cSrcweir }
793cdf0e10cSrcweir 
794cdf0e10cSrcweir /**************************************************************************************************/
795cdf0e10cSrcweir 
CheckLastLineMerge(const basegfx::B2DPolygon & rSrcPoly)796cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir 	// #i102706# Do not merge closed polygons
799cdf0e10cSrcweir 	if(rSrcPoly.isClosed())
800cdf0e10cSrcweir 	{
801cdf0e10cSrcweir 		return false;
802cdf0e10cSrcweir 	}
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
8058718d260SArmin Le Grand 	if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
806cdf0e10cSrcweir 	{
8078718d260SArmin Le Grand 		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
8088718d260SArmin Le Grand 		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 		if(pLastPoly)
811cdf0e10cSrcweir 		{
812cdf0e10cSrcweir 			if(1L == pLastPoly->GetPathPoly().count())
813cdf0e10cSrcweir 			{
814cdf0e10cSrcweir 				bool bOk(false);
815cdf0e10cSrcweir 				basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 				// #i102706# Do not merge closed polygons
818cdf0e10cSrcweir 				if(aDstPoly.isClosed())
819cdf0e10cSrcweir 				{
820cdf0e10cSrcweir 					return false;
821cdf0e10cSrcweir 				}
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 				if(aDstPoly.count())
824cdf0e10cSrcweir 				{
825cdf0e10cSrcweir 					const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
826cdf0e10cSrcweir 					const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 					if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
829cdf0e10cSrcweir 					{
830cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
831cdf0e10cSrcweir 						bOk = true;
832cdf0e10cSrcweir 					}
833cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
834cdf0e10cSrcweir 					{
835cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
836cdf0e10cSrcweir 						aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
837cdf0e10cSrcweir 						aDstPoly = aNew;
838cdf0e10cSrcweir 						bOk = true;
839cdf0e10cSrcweir 					}
840cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
841cdf0e10cSrcweir 					{
842cdf0e10cSrcweir 						aDstPoly.flip();
843cdf0e10cSrcweir 						aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
844cdf0e10cSrcweir 						bOk = true;
845cdf0e10cSrcweir 					}
846cdf0e10cSrcweir 					else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
847cdf0e10cSrcweir 					{
848cdf0e10cSrcweir 						basegfx::B2DPolygon aNew(rSrcPoly);
849cdf0e10cSrcweir 						aNew.flip();
850cdf0e10cSrcweir 						aDstPoly.append(aNew, 1L, aNew.count() - 1L);
851cdf0e10cSrcweir 						bOk = true;
852cdf0e10cSrcweir 					}
853cdf0e10cSrcweir 				}
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 				if(bOk)
856cdf0e10cSrcweir 				{
857cdf0e10cSrcweir 					pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
858cdf0e10cSrcweir 				}
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 				return bOk;
861cdf0e10cSrcweir 			}
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 	return false;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir 
CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)868cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
869cdf0e10cSrcweir {
870cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
8718718d260SArmin Le Grand 	if(mbLastObjWasPolyWithoutLine)
872cdf0e10cSrcweir 	{
8738718d260SArmin Le Grand 		SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
8748718d260SArmin Le Grand 		SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 		if(pLastPoly)
877cdf0e10cSrcweir 		{
878cdf0e10cSrcweir 			if(pLastPoly->GetPathPoly() == rPolyPolygon)
879cdf0e10cSrcweir 			{
880cdf0e10cSrcweir 				SetAttributes(NULL);
881cdf0e10cSrcweir 
8828718d260SArmin Le Grand 				if(!mbNoLine && mbNoFill)
883cdf0e10cSrcweir 				{
8848718d260SArmin Le Grand 					pLastPoly->SetMergedItemSet(*mpLineAttr);
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 					return true;
887cdf0e10cSrcweir 				}
888cdf0e10cSrcweir 			}
889cdf0e10cSrcweir 		}
890cdf0e10cSrcweir 	}
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 	return false;
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
checkClip()89547a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::checkClip()
89647a7c0c1SArmin Le Grand {
8978718d260SArmin Le Grand     if(maVD.IsClipRegion())
89847a7c0c1SArmin Le Grand     {
899e6f63103SArmin Le Grand         maClip = maVD.GetClipRegion().GetAsB2DPolyPolygon();
90047a7c0c1SArmin Le Grand 
90147a7c0c1SArmin Le Grand         if(isClip())
90247a7c0c1SArmin Le Grand         {
90347a7c0c1SArmin Le Grand     		const basegfx::B2DHomMatrix aTransform(
90447a7c0c1SArmin Le Grand                 basegfx::tools::createScaleTranslateB2DHomMatrix(
9058718d260SArmin Le Grand                     mfScaleX,
9068718d260SArmin Le Grand                     mfScaleY,
9078718d260SArmin Le Grand                     maOfs.X(),
9088718d260SArmin Le Grand                     maOfs.Y()));
90947a7c0c1SArmin Le Grand 
91047a7c0c1SArmin Le Grand             maClip.transform(aTransform);
91147a7c0c1SArmin Le Grand         }
91247a7c0c1SArmin Le Grand     }
91347a7c0c1SArmin Le Grand }
91447a7c0c1SArmin Le Grand 
isClip() const91547a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const
91647a7c0c1SArmin Le Grand {
91747a7c0c1SArmin Le Grand     return !maClip.getB2DRange().isEmpty();
91847a7c0c1SArmin Le Grand }
919cdf0e10cSrcweir 
DoAction(MetaPolyLineAction & rAct)920cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
923cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
924cdf0e10cSrcweir 
925cdf0e10cSrcweir 	if(aSource.count())
926cdf0e10cSrcweir 	{
9278718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
928cdf0e10cSrcweir 		aSource.transform(aTransform);
929cdf0e10cSrcweir 	}
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 	const LineInfo& rLineInfo = rAct.GetLineInfo();
932cdf0e10cSrcweir 	const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
933cdf0e10cSrcweir 	bool bCreateLineObject(true);
934cdf0e10cSrcweir 
9358718d260SArmin Le Grand 	if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource))
936cdf0e10cSrcweir 	{
937cdf0e10cSrcweir 		bCreateLineObject = false;
938cdf0e10cSrcweir 	}
9398718d260SArmin Le Grand 	else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
940cdf0e10cSrcweir 	{
941cdf0e10cSrcweir 		bCreateLineObject = false;
942cdf0e10cSrcweir 	}
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	if(bCreateLineObject)
945cdf0e10cSrcweir 	{
94647a7c0c1SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(
947cdf0e10cSrcweir 			aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
948cdf0e10cSrcweir 			basegfx::B2DPolyPolygon(aSource));
9498718d260SArmin Le Grand 		mnLineWidth = nNewLineWidth;
950cdf0e10cSrcweir 		maLineJoin = rLineInfo.GetLineJoin();
9515aaf853bSArmin Le Grand         maLineCap = rLineInfo.GetLineCap();
952cdf0e10cSrcweir 		maDash = XDash(XDASH_RECT,
953cdf0e10cSrcweir 			rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
954cdf0e10cSrcweir 			rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
955cdf0e10cSrcweir 			rLineInfo.GetDistance());
956cdf0e10cSrcweir 		SetAttributes(pPath);
9578718d260SArmin Le Grand 		mnLineWidth = 0;
958cdf0e10cSrcweir 		maLineJoin = basegfx::B2DLINEJOIN_NONE;
959cdf0e10cSrcweir 		maDash = XDash();
960cdf0e10cSrcweir 		InsertObj(pPath, false);
961cdf0e10cSrcweir 	}
962cdf0e10cSrcweir }
963cdf0e10cSrcweir 
DoAction(MetaPolygonAction & rAct)964cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
965cdf0e10cSrcweir {
966cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
967cdf0e10cSrcweir 	basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 	if(aSource.count())
970cdf0e10cSrcweir 	{
9718718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
972cdf0e10cSrcweir 		aSource.transform(aTransform);
973cdf0e10cSrcweir 
9748718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
975cdf0e10cSrcweir 		{
976cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
977cdf0e10cSrcweir 			aSource.setClosed(true);
97847a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
979cdf0e10cSrcweir 			SetAttributes(pPath);
980cdf0e10cSrcweir 			InsertObj(pPath, false);
981cdf0e10cSrcweir 		}
982cdf0e10cSrcweir 	}
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
DoAction(MetaPolyPolygonAction & rAct)985cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
986cdf0e10cSrcweir {
987cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
988cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
989cdf0e10cSrcweir 
990cdf0e10cSrcweir 	if(aSource.count())
991cdf0e10cSrcweir 	{
9928718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
993cdf0e10cSrcweir 		aSource.transform(aTransform);
994cdf0e10cSrcweir 
9958718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
996cdf0e10cSrcweir 		{
997cdf0e10cSrcweir 			// #i73407# make sure polygon is closed, it's a filled primitive
998cdf0e10cSrcweir 			aSource.setClosed(true);
99947a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1000cdf0e10cSrcweir 			SetAttributes(pPath);
1001cdf0e10cSrcweir 			InsertObj(pPath, false);
1002cdf0e10cSrcweir 		}
1003cdf0e10cSrcweir 	}
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir /**************************************************************************************************/
1007cdf0e10cSrcweir 
ImportText(const Point & rPos,const XubString & rStr,const MetaAction & rAct)1008cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir 	// calc text box size, add 5% to make it fit safely
1011cdf0e10cSrcweir 
10128718d260SArmin Le Grand 	FontMetric aFontMetric( maVD.GetFontMetric() );
10138718d260SArmin Le Grand 	Font aFnt( maVD.GetFont() );
1014cdf0e10cSrcweir 	FontAlign eAlg( aFnt.GetAlign() );
1015cdf0e10cSrcweir 
10168718d260SArmin Le Grand     sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX );
10178718d260SArmin Le Grand     sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY );
1018cdf0e10cSrcweir 	//sal_Int32 nDxWidth = 0;
1019cdf0e10cSrcweir 	//sal_Int32 nLen = rStr.Len();
1020cdf0e10cSrcweir 
10218718d260SArmin Le Grand 	Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) );
1022cdf0e10cSrcweir     Size aSize( nTextWidth, nTextHeight );
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	if ( eAlg == ALIGN_BASELINE )
10258718d260SArmin Le Grand 		aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
1026cdf0e10cSrcweir 	else if ( eAlg == ALIGN_BOTTOM )
1027cdf0e10cSrcweir 		aPos.Y() -= nTextHeight;
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 	Rectangle aTextRect( aPos, aSize );
1030cdf0e10cSrcweir 	SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
1031cdf0e10cSrcweir 
1032*674b939bSArmin Le Grand 	pText->SetMergedItem ( SdrTextUpperDistItem (0));
1033*674b939bSArmin Le Grand 	pText->SetMergedItem ( SdrTextLowerDistItem (0));
1034*674b939bSArmin Le Grand 	pText->SetMergedItem ( SdrTextRightDistItem (0));
1035*674b939bSArmin Le Grand 	pText->SetMergedItem ( SdrTextLeftDistItem (0));
1036*674b939bSArmin Le Grand 
1037*674b939bSArmin Le Grand     if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
1038cdf0e10cSrcweir 	{
1039cdf0e10cSrcweir 		pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
10408718d260SArmin Le Grand 		pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
1041cdf0e10cSrcweir 		// don't let the margins eat the space needed for the text
104226734c99SArmin Le Grand 		pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
1043cdf0e10cSrcweir 	}
1044cdf0e10cSrcweir 	else
1045*674b939bSArmin Le Grand     {
10468718d260SArmin Le Grand 		pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) );
1047*674b939bSArmin Le Grand     }
1048cdf0e10cSrcweir 
10498718d260SArmin Le Grand 	pText->SetModel(mpModel);
10508718d260SArmin Le Grand 	pText->SetLayer(mnLayer);
1051cdf0e10cSrcweir 	pText->NbcSetText( rStr );
10528718d260SArmin Le Grand 	SetAttributes( pText, true );
1053cdf0e10cSrcweir 	pText->SetSnapRect( aTextRect );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 	if (!aFnt.IsTransparent())
1056cdf0e10cSrcweir 	{
10578718d260SArmin Le Grand 		SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
1058cdf0e10cSrcweir 		aAttr.Put(XFillStyleItem(XFILL_SOLID));
1059cdf0e10cSrcweir 		aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
1060cdf0e10cSrcweir 		pText->SetMergedItemSet(aAttr);
1061cdf0e10cSrcweir 	}
1062cdf0e10cSrcweir 	sal_uInt32 nWink = aFnt.GetOrientation();
1063cdf0e10cSrcweir 	if ( nWink )
1064cdf0e10cSrcweir 	{
1065cdf0e10cSrcweir 		nWink*=10;
1066cdf0e10cSrcweir 		double a=nWink*nPi180;
1067cdf0e10cSrcweir 		double nSin=sin(a);
1068cdf0e10cSrcweir 		double nCos=cos(a);
1069cdf0e10cSrcweir 		pText->NbcRotate(aPos,nWink,nSin,nCos);
1070cdf0e10cSrcweir 	}
10718718d260SArmin Le Grand 	InsertObj( pText, false );
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir 
DoAction(MetaTextAction & rAct)1074cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
1077cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
1078cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
1079cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir 
DoAction(MetaTextArrayAction & rAct)1082cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
1085cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
1086cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
1087cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir 
DoAction(MetaStretchTextAction & rAct)1090cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir 	XubString aStr(rAct.GetText());
1093cdf0e10cSrcweir 	aStr.Erase(0,rAct.GetIndex());
1094cdf0e10cSrcweir 	aStr.Erase(rAct.GetLen());
1095cdf0e10cSrcweir 	ImportText( rAct.GetPoint(), aStr, rAct );
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
DoAction(MetaBmpAction & rAct)1098cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
1101cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
110247a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1103468982e4SArmin Le Grand 
1104468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1105468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1106468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1107468982e4SArmin Le Grand     InsertObj(pGraf);
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
DoAction(MetaBmpScaleAction & rAct)1110cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1113cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
111447a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1115468982e4SArmin Le Grand 
1116468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1117468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1118468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1119468982e4SArmin Le Grand     InsertObj(pGraf);
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
DoAction(MetaBmpExAction & rAct)1122cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
1125cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
112647a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1127468982e4SArmin Le Grand 
1128468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1129468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1130468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1131468982e4SArmin Le Grand     InsertObj(pGraf);
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir 
DoAction(MetaBmpExScaleAction & rAct)1134cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir 	Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1137cdf0e10cSrcweir 	aRect.Right()++; aRect.Bottom()++;
113847a7c0c1SArmin Le Grand     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1139468982e4SArmin Le Grand 
1140468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1141468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1142468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1143cdf0e10cSrcweir 	InsertObj(pGraf);
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1147cdf0e10cSrcweir 
DoAction(MetaHatchAction & rAct)1148cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir 	// #i73407# reformulation to use new B2DPolygon classes
1151cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 	if(aSource.count())
1154cdf0e10cSrcweir 	{
11558718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1156cdf0e10cSrcweir 		aSource.transform(aTransform);
1157cdf0e10cSrcweir 
11588718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1159cdf0e10cSrcweir 		{
1160cdf0e10cSrcweir 			const Hatch& rHatch = rAct.GetHatch();
116147a7c0c1SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
11628718d260SArmin Le Grand 			SfxItemSet aHatchAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0);
1163cdf0e10cSrcweir 			XHatchStyle eStyle;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 			switch(rHatch.GetStyle())
1166cdf0e10cSrcweir 			{
1167cdf0e10cSrcweir 				case(HATCH_TRIPLE) :
1168cdf0e10cSrcweir 				{
1169cdf0e10cSrcweir 					eStyle = XHATCH_TRIPLE;
1170cdf0e10cSrcweir 					break;
1171cdf0e10cSrcweir 				}
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 				case(HATCH_DOUBLE) :
1174cdf0e10cSrcweir 				{
1175cdf0e10cSrcweir 					eStyle = XHATCH_DOUBLE;
1176cdf0e10cSrcweir 					break;
1177cdf0e10cSrcweir 				}
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir 				default:
1180cdf0e10cSrcweir 				{
1181cdf0e10cSrcweir 					eStyle = XHATCH_SINGLE;
1182cdf0e10cSrcweir 					break;
1183cdf0e10cSrcweir 				}
1184cdf0e10cSrcweir 			}
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir 			SetAttributes(pPath);
1187cdf0e10cSrcweir 			aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
11888718d260SArmin Le Grand 			aHatchAttr.Put(XFillHatchItem(&mpModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
1189cdf0e10cSrcweir 			pPath->SetMergedItemSet(aHatchAttr);
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir 			InsertObj(pPath, false);
1192cdf0e10cSrcweir 		}
1193cdf0e10cSrcweir 	}
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1197cdf0e10cSrcweir 
DoAction(MetaLineColorAction & rAct)1198cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
1199cdf0e10cSrcweir {
12008718d260SArmin Le Grand 	rAct.Execute(&maVD);
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
DoAction(MetaMapModeAction & rAct)1203cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir 	MapScaling();
12068718d260SArmin Le Grand 	rAct.Execute(&maVD);
12078718d260SArmin Le Grand 	mbLastObjWasPolyWithoutLine = false;
12088718d260SArmin Le Grand 	mbLastObjWasLine = false;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir 
MapScaling()1211cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling()
1212cdf0e10cSrcweir {
12138718d260SArmin Le Grand 	const sal_uInt32 nAnz(maTmpList.size());
12148718d260SArmin Le Grand 	sal_uInt32 i(0);
12158718d260SArmin Le Grand 	const MapMode& rMap = maVD.GetMapMode();
1216cdf0e10cSrcweir 	Point aMapOrg( rMap.GetOrigin() );
12178718d260SArmin Le Grand 	bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0);
12188718d260SArmin Le Grand 
12198718d260SArmin Le Grand     if(bMov2)
1220cdf0e10cSrcweir     {
12218718d260SArmin Le Grand 		for(i = mnMapScalingOfs; i < nAnz; i++)
1222cdf0e10cSrcweir         {
12238718d260SArmin Le Grand 			SdrObject* pObj = maTmpList[i];
12248718d260SArmin Le Grand 
12258718d260SArmin Le Grand             pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
1226cdf0e10cSrcweir 		}
1227cdf0e10cSrcweir 	}
12288718d260SArmin Le Grand 
12298718d260SArmin Le Grand     mnMapScalingOfs = nAnz;
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1233cdf0e10cSrcweir 
DoAction(MetaCommentAction & rAct,GDIMetaFile * pMtf)1234cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir 	ByteString aSkipComment;
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 	if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1239cdf0e10cSrcweir 	{
1240cdf0e10cSrcweir 		MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir 		if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
1243cdf0e10cSrcweir 		{
1244cdf0e10cSrcweir 			// #i73407# reformulation to use new B2DPolygon classes
1245cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 			if(aSource.count())
1248cdf0e10cSrcweir 			{
12498718d260SArmin Le Grand 				if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1250cdf0e10cSrcweir 				{
1251cdf0e10cSrcweir 					const Gradient&	rGrad = pAct->GetGradient();
125247a7c0c1SArmin Le Grand                     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
12538718d260SArmin Le Grand 					SfxItemSet aGradAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1254cdf0e10cSrcweir 					XGradient aXGradient;
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir 					aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
1257cdf0e10cSrcweir 					aXGradient.SetStartColor(rGrad.GetStartColor());
1258cdf0e10cSrcweir 					aXGradient.SetEndColor(rGrad.GetEndColor());
1259cdf0e10cSrcweir 					aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
1260cdf0e10cSrcweir 					aXGradient.SetBorder(rGrad.GetBorder());
1261cdf0e10cSrcweir 					aXGradient.SetXOffset(rGrad.GetOfsX());
1262cdf0e10cSrcweir 					aXGradient.SetYOffset(rGrad.GetOfsY());
1263cdf0e10cSrcweir 					aXGradient.SetStartIntens(rGrad.GetStartIntensity());
1264cdf0e10cSrcweir 					aXGradient.SetEndIntens(rGrad.GetEndIntensity());
1265cdf0e10cSrcweir 					aXGradient.SetSteps(rGrad.GetSteps());
1266cdf0e10cSrcweir 
1267468982e4SArmin Le Grand                     // no need to use SetAttributes(..) here since line and fill style
1268468982e4SArmin Le Grand                     // need to be set individually
1269468982e4SArmin Le Grand                     // SetAttributes(pPath);
1270468982e4SArmin Le Grand 
1271468982e4SArmin Le Grand                     // switch line off; when there was one there will be a
1272468982e4SArmin Le Grand                     // META_POLYLINE_ACTION following creating another object
1273468982e4SArmin Le Grand                     aGradAttr.Put(XLineStyleItem(XLINE_NONE));
1274cdf0e10cSrcweir 
1275468982e4SArmin Le Grand                     // add detected gradient fillstyle
1276468982e4SArmin Le Grand                     aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
1277468982e4SArmin Le Grand                     aGradAttr.Put(XFillGradientItem(&mpModel->GetItemPool(), aXGradient));
1278468982e4SArmin Le Grand 
1279468982e4SArmin Le Grand                     pPath->SetMergedItemSet(aGradAttr);
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 					InsertObj(pPath);
1282cdf0e10cSrcweir 				}
1283cdf0e10cSrcweir 			}
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir 			aSkipComment = "XGRAD_SEQ_END";
1286cdf0e10cSrcweir 		}
1287cdf0e10cSrcweir 	}
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir 	if(aSkipComment.Len())
1290cdf0e10cSrcweir 	{
1291cdf0e10cSrcweir 		MetaAction* pSkipAct = pMtf->NextAction();
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir 		while( pSkipAct
1294cdf0e10cSrcweir 			&& ((pSkipAct->GetType() != META_COMMENT_ACTION )
1295cdf0e10cSrcweir 				|| (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
1296cdf0e10cSrcweir 		{
1297cdf0e10cSrcweir 			pSkipAct = pMtf->NextAction();
1298cdf0e10cSrcweir 		}
1299cdf0e10cSrcweir 	}
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir 
13028718d260SArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
13038718d260SArmin Le Grand 
DoAction(MetaTextRectAction & rAct)13048718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
13058718d260SArmin Le Grand {
13068718d260SArmin Le Grand     GDIMetaFile aTemp;
13078718d260SArmin Le Grand 
13088718d260SArmin Le Grand     maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
13098718d260SArmin Le Grand     DoLoopActions(aTemp, 0, 0);
13108718d260SArmin Le Grand }
13118718d260SArmin Le Grand 
DoAction(MetaBmpScalePartAction & rAct)13128718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
13138718d260SArmin Le Grand {
13148718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
13158718d260SArmin Le Grand     Bitmap aBitmap(rAct.GetBitmap());
13168718d260SArmin Le Grand 
13178718d260SArmin Le Grand     aRect.Right()++;
13188718d260SArmin Le Grand     aRect.Bottom()++;
13198718d260SArmin Le Grand     aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13208718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
13218718d260SArmin Le Grand 
1322468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1323468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1324468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13258718d260SArmin Le Grand     InsertObj(pGraf);
13268718d260SArmin Le Grand }
13278718d260SArmin Le Grand 
DoAction(MetaBmpExScalePartAction & rAct)13288718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
13298718d260SArmin Le Grand {
13308718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(),rAct.GetDestSize());
13318718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmapEx());
13328718d260SArmin Le Grand 
13338718d260SArmin Le Grand     aRect.Right()++;
13348718d260SArmin Le Grand     aRect.Bottom()++;
13358718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13368718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13378718d260SArmin Le Grand 
1338468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1339468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1340468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13418718d260SArmin Le Grand     InsertObj(pGraf);
13428718d260SArmin Le Grand }
13438718d260SArmin Le Grand 
DoAction(MetaMaskAction & rAct)13448718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
13458718d260SArmin Le Grand {
13468718d260SArmin Le Grand 	Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
13478718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13488718d260SArmin Le Grand 
1349468982e4SArmin Le Grand     aRect.Right()++; aRect.Bottom()++;
13508718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13518718d260SArmin Le Grand 
1352468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1353468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1354468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13558718d260SArmin Le Grand     InsertObj(pGraf);
13568718d260SArmin Le Grand }
13578718d260SArmin Le Grand 
DoAction(MetaMaskScaleAction & rAct)13588718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
13598718d260SArmin Le Grand {
13608718d260SArmin Le Grand 	Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
13618718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13628718d260SArmin Le Grand 
1363468982e4SArmin Le Grand     aRect.Right()++; aRect.Bottom()++;
13648718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13658718d260SArmin Le Grand 
1366468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1367468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1368468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13698718d260SArmin Le Grand     InsertObj(pGraf);
13708718d260SArmin Le Grand }
13718718d260SArmin Le Grand 
DoAction(MetaMaskScalePartAction & rAct)13728718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
13738718d260SArmin Le Grand {
13748718d260SArmin Le Grand 	Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
13758718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13768718d260SArmin Le Grand 
1377468982e4SArmin Le Grand     aRect.Right()++; aRect.Bottom()++;
13788718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13798718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13808718d260SArmin Le Grand 
1381468982e4SArmin Le Grand     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1382468982e4SArmin Le Grand     pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1383468982e4SArmin Le Grand     pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13848718d260SArmin Le Grand     InsertObj(pGraf);
13858718d260SArmin Le Grand }
13868718d260SArmin Le Grand 
getXGradientStyleFromGradientStyle(const GradientStyle & rGradientStyle)1387603e43faSArmin Le Grand XGradientStyle getXGradientStyleFromGradientStyle(const GradientStyle& rGradientStyle)
1388603e43faSArmin Le Grand {
1389603e43faSArmin Le Grand     XGradientStyle aXGradientStyle(XGRAD_LINEAR);
1390603e43faSArmin Le Grand 
1391603e43faSArmin Le Grand     switch(rGradientStyle)
1392603e43faSArmin Le Grand     {
1393603e43faSArmin Le Grand         case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
1394603e43faSArmin Le Grand         case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
1395603e43faSArmin Le Grand         case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
1396603e43faSArmin Le Grand         case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
1397603e43faSArmin Le Grand         case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
1398603e43faSArmin Le Grand         case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
1399603e43faSArmin Le Grand 
1400603e43faSArmin Le Grand         // Needed due to GRADIENT_FORCE_EQUAL_SIZE; this again is needed
1401603e43faSArmin Le Grand         // to force the enum defines in VCL to a defined size for the compilers,
1402603e43faSArmin Le Grand         // so despite it is never used it cannot be removed (would break the
1403603e43faSArmin Le Grand         // API implementation probably).
1404603e43faSArmin Le Grand         default: break;
1405603e43faSArmin Le Grand     }
1406603e43faSArmin Le Grand 
1407603e43faSArmin Le Grand     return aXGradientStyle;
1408603e43faSArmin Le Grand }
1409603e43faSArmin Le Grand 
DoAction(MetaGradientAction & rAct)14108718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
14118718d260SArmin Le Grand {
14128718d260SArmin Le Grand     basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom());
14138718d260SArmin Le Grand 
14148718d260SArmin Le Grand 	if(!aRange.isEmpty())
14158718d260SArmin Le Grand 	{
14168718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14178718d260SArmin Le Grand 		aRange.transform(aTransform);
14188718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
14198718d260SArmin Le Grand         SdrRectObj* pRect = new SdrRectObj(
14208718d260SArmin Le Grand             Rectangle(
14218718d260SArmin Le Grand                 floor(aRange.getMinX()),
14228718d260SArmin Le Grand                 floor(aRange.getMinY()),
14238718d260SArmin Le Grand                 ceil(aRange.getMaxX()),
14248718d260SArmin Le Grand                 ceil(aRange.getMaxY())));
14258718d260SArmin Le Grand 		SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1426603e43faSArmin Le Grand         const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
14278718d260SArmin Le Grand         const XFillGradientItem aXFillGradientItem(
14288718d260SArmin Le Grand             &mpModel->GetItemPool(),
14298718d260SArmin Le Grand             XGradient(
14308718d260SArmin Le Grand                 rGradient.GetStartColor(),
14318718d260SArmin Le Grand                 rGradient.GetEndColor(),
14328718d260SArmin Le Grand                 aXGradientStyle,
14338718d260SArmin Le Grand                 rGradient.GetAngle(),
14348718d260SArmin Le Grand                 rGradient.GetOfsX(),
14358718d260SArmin Le Grand                 rGradient.GetOfsY(),
14368718d260SArmin Le Grand                 rGradient.GetBorder(),
14378718d260SArmin Le Grand                 rGradient.GetStartIntensity(),
14388718d260SArmin Le Grand                 rGradient.GetEndIntensity(),
14398718d260SArmin Le Grand                 rGradient.GetSteps()));
14408718d260SArmin Le Grand 
14418718d260SArmin Le Grand 		SetAttributes(pRect);
14428718d260SArmin Le Grand 		aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
14438718d260SArmin Le Grand 		aGradientAttr.Put(aXFillGradientItem);
14448718d260SArmin Le Grand 		pRect->SetMergedItemSet(aGradientAttr);
14458718d260SArmin Le Grand 
14468718d260SArmin Le Grand 		InsertObj(pRect, false);
14478718d260SArmin Le Grand 	}
14488718d260SArmin Le Grand }
14498718d260SArmin Le Grand 
DoAction(MetaWallpaperAction &)1450603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& /*rAct*/)
14518718d260SArmin Le Grand {
14528718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)");
14538718d260SArmin Le Grand }
14548718d260SArmin Le Grand 
DoAction(MetaTransparentAction & rAct)14558718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct)
14568718d260SArmin Le Grand {
14578718d260SArmin Le Grand 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
14588718d260SArmin Le Grand 
14598718d260SArmin Le Grand 	if(aSource.count())
14608718d260SArmin Le Grand 	{
14618718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14628718d260SArmin Le Grand 		aSource.transform(aTransform);
14638718d260SArmin Le Grand     	aSource.setClosed(true);
14648718d260SArmin Le Grand 
14658718d260SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
14668718d260SArmin Le Grand 		SetAttributes(pPath);
14678718d260SArmin Le Grand         pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
14688718d260SArmin Le Grand 		InsertObj(pPath, false);
14698718d260SArmin Le Grand 	}
14708718d260SArmin Le Grand }
14718718d260SArmin Le Grand 
DoAction(MetaEPSAction &)1472603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& /*rAct*/)
14738718d260SArmin Le Grand {
14748718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)");
14758718d260SArmin Le Grand }
14768718d260SArmin Le Grand 
DoAction(MetaTextLineAction &)1477603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& /*rAct*/)
14788718d260SArmin Le Grand {
14798718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)");
14808718d260SArmin Le Grand }
14818718d260SArmin Le Grand 
DoAction(MetaGradientExAction & rAct)14828718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
14838718d260SArmin Le Grand {
14848718d260SArmin Le Grand 	basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
14858718d260SArmin Le Grand 
14868718d260SArmin Le Grand 	if(aSource.count())
14878718d260SArmin Le Grand 	{
14888718d260SArmin Le Grand 		const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14898718d260SArmin Le Grand 		aSource.transform(aTransform);
14908718d260SArmin Le Grand 
14918718d260SArmin Le Grand 		if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
14928718d260SArmin Le Grand 		{
14938718d260SArmin Le Grand         	const Gradient& rGradient = rAct.GetGradient();
14948718d260SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
14958718d260SArmin Le Grand 			SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1496603e43faSArmin Le Grand             const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
14978718d260SArmin Le Grand             const XFillGradientItem aXFillGradientItem(
14988718d260SArmin Le Grand                 &mpModel->GetItemPool(),
14998718d260SArmin Le Grand                 XGradient(
15008718d260SArmin Le Grand                     rGradient.GetStartColor(),
15018718d260SArmin Le Grand                     rGradient.GetEndColor(),
15028718d260SArmin Le Grand                     aXGradientStyle,
15038718d260SArmin Le Grand                     rGradient.GetAngle(),
15048718d260SArmin Le Grand                     rGradient.GetOfsX(),
15058718d260SArmin Le Grand                     rGradient.GetOfsY(),
15068718d260SArmin Le Grand                     rGradient.GetBorder(),
15078718d260SArmin Le Grand                     rGradient.GetStartIntensity(),
15088718d260SArmin Le Grand                     rGradient.GetEndIntensity(),
15098718d260SArmin Le Grand                     rGradient.GetSteps()));
15108718d260SArmin Le Grand 
15118718d260SArmin Le Grand 			SetAttributes(pPath);
15128718d260SArmin Le Grand 			aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
15138718d260SArmin Le Grand 			aGradientAttr.Put(aXFillGradientItem);
15148718d260SArmin Le Grand 			pPath->SetMergedItemSet(aGradientAttr);
15158718d260SArmin Le Grand 
15168718d260SArmin Le Grand 			InsertObj(pPath, false);
15178718d260SArmin Le Grand 		}
15188718d260SArmin Le Grand 	}
15198718d260SArmin Le Grand }
15208718d260SArmin Le Grand 
DoAction(MetaFloatTransparentAction & rAct)15218718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
15228718d260SArmin Le Grand {
15238718d260SArmin Le Grand 	const GDIMetaFile& rMtf = rAct.GetGDIMetaFile();
15248718d260SArmin Le Grand 
15258718d260SArmin Le Grand     if(rMtf.GetActionCount())
15268718d260SArmin Le Grand     {
15279f63b866SArmin Le Grand 	    const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
15289f63b866SArmin Le Grand 
1529468982e4SArmin Le Grand         Rectangle aHairline;
1530468982e4SArmin Le Grand         const Rectangle aBoundRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairline));
1531468982e4SArmin Le Grand 
15329f63b866SArmin Le Grand         // convert metafile sub-content to BitmapEx
15339f63b866SArmin Le Grand         BitmapEx aBitmapEx(
15349f63b866SArmin Le Grand             convertMetafileToBitmapEx(
15359f63b866SArmin Le Grand                 rMtf,
15369f63b866SArmin Le Grand                 basegfx::B2DRange(
15379f63b866SArmin Le Grand                     aRect.Left(), aRect.Top(),
15389f63b866SArmin Le Grand                     aRect.Right(), aRect.Bottom()),
15399f63b866SArmin Le Grand                 125000));
15408718d260SArmin Le Grand 
15418718d260SArmin Le Grand         // handle colors
15428718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
15438718d260SArmin Le Grand 	    basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
15448718d260SArmin Le Grand 	    basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
15458718d260SArmin Le Grand 
15468718d260SArmin Le Grand         if(100 != rGradient.GetStartIntensity())
15478718d260SArmin Le Grand 	    {
15488718d260SArmin Le Grand             aStart *= (double)rGradient.GetStartIntensity() / 100.0;
15498718d260SArmin Le Grand 	    }
15508718d260SArmin Le Grand 
15518718d260SArmin Le Grand         if(100 != rGradient.GetEndIntensity())
15528718d260SArmin Le Grand 	    {
15538718d260SArmin Le Grand             aEnd *= (double)rGradient.GetEndIntensity() / 100.0;
15548718d260SArmin Le Grand 	    }
15558718d260SArmin Le Grand 
15568718d260SArmin Le Grand         const bool bEqualColors(aStart == aEnd);
15578718d260SArmin Le Grand         const bool bNoSteps(1 == rGradient.GetSteps());
15588718d260SArmin Le Grand         bool bCreateObject(true);
15598718d260SArmin Le Grand         bool bHasNewMask(false);
15608718d260SArmin Le Grand         AlphaMask aNewMask;
15619f63b866SArmin Le Grand         double fTransparence(0.0);
15629f63b866SArmin Le Grand         bool bFixedTransparence(false);
15638718d260SArmin Le Grand 
15648718d260SArmin Le Grand         if(bEqualColors || bNoSteps)
15658718d260SArmin Le Grand         {
15668718d260SArmin Le Grand             // single transparence
15678718d260SArmin Le Grand             const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
15689f63b866SArmin Le Grand             fTransparence = aMedium.luminance();
15698718d260SArmin Le Grand 
15708718d260SArmin Le Grand             if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
15718718d260SArmin Le Grand             {
15728718d260SArmin Le Grand                 // no transparence needed, all done
15738718d260SArmin Le Grand             }
15748718d260SArmin Le Grand             else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0))
15758718d260SArmin Le Grand             {
15768718d260SArmin Le Grand                 // all transparent, no object
15778718d260SArmin Le Grand                 bCreateObject = false;
15788718d260SArmin Le Grand             }
15798718d260SArmin Le Grand             else
15808718d260SArmin Le Grand             {
15819f63b866SArmin Le Grand                 // 0.0 < transparence < 1.0, apply fixed transparence
15829f63b866SArmin Le Grand                 bFixedTransparence = true;
15838718d260SArmin Le Grand             }
15848718d260SArmin Le Grand         }
15858718d260SArmin Le Grand         else
15868718d260SArmin Le Grand         {
15878718d260SArmin Le Grand             // gradient transparence
15888718d260SArmin Le Grand             VirtualDevice aVDev;
15898718d260SArmin Le Grand 
15908718d260SArmin Le Grand             aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
15918718d260SArmin Le Grand             aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
15928718d260SArmin Le Grand 
15938718d260SArmin Le Grand             aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
15948718d260SArmin Le Grand             bHasNewMask = true;
15958718d260SArmin Le Grand         }
15968718d260SArmin Le Grand 
15978718d260SArmin Le Grand         if(bCreateObject)
15988718d260SArmin Le Grand         {
15999f63b866SArmin Le Grand             if(bHasNewMask || bFixedTransparence)
16008718d260SArmin Le Grand             {
16018718d260SArmin Le Grand                 if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
16028718d260SArmin Le Grand                 {
16038718d260SArmin Le Grand                     // no transparence yet, apply new one
16049f63b866SArmin Le Grand                     if(bFixedTransparence)
16059f63b866SArmin Le Grand                     {
16069f63b866SArmin Le Grand                         sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
16079f63b866SArmin Le Grand 
16089f63b866SArmin Le Grand                         aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
16099f63b866SArmin Le Grand                     }
16109f63b866SArmin Le Grand 
16118718d260SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
16128718d260SArmin Le Grand                 }
16138718d260SArmin Le Grand                 else
16148718d260SArmin Le Grand                 {
16158718d260SArmin Le Grand                     // mix existing and new alpha mask
16168718d260SArmin Le Grand                     AlphaMask aOldMask;
16178718d260SArmin Le Grand 
16188718d260SArmin Le Grand                     if(aBitmapEx.IsAlpha())
16198718d260SArmin Le Grand                     {
16208718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetAlpha();
16218718d260SArmin Le Grand                     }
16228718d260SArmin Le Grand                     else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType())
16238718d260SArmin Le Grand                     {
16248718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetMask();
16258718d260SArmin Le Grand                     }
16268718d260SArmin Le Grand                     else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType())
16278718d260SArmin Le Grand                     {
16288718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
16298718d260SArmin Le Grand                     }
16308718d260SArmin Le Grand 
16319f63b866SArmin Le Grand                     BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
16328718d260SArmin Le Grand 
16339f63b866SArmin Le Grand                     if(pOld)
16348718d260SArmin Le Grand                     {
16359f63b866SArmin Le Grand                         const double fFactor(1.0 / 255.0);
16369f63b866SArmin Le Grand 
16379f63b866SArmin Le Grand                         if(bFixedTransparence)
16388718d260SArmin Le Grand                         {
16399f63b866SArmin Le Grand                             const double fOpNew(1.0 - fTransparence);
16409f63b866SArmin Le Grand 
1641603e43faSArmin Le Grand                             for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
16428718d260SArmin Le Grand                             {
1643603e43faSArmin Le Grand                                 for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
16448718d260SArmin Le Grand                                 {
16459f63b866SArmin Le Grand                                     const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
16469f63b866SArmin Le Grand                                     const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
16479f63b866SArmin Le Grand 
16489f63b866SArmin Le Grand                                     pOld->SetPixel(y, x, BitmapColor(aCol));
16498718d260SArmin Le Grand                                 }
16508718d260SArmin Le Grand                             }
16518718d260SArmin Le Grand                         }
16528718d260SArmin Le Grand                         else
16538718d260SArmin Le Grand                         {
16549f63b866SArmin Le Grand                             BitmapReadAccess* pNew = aNewMask.AcquireReadAccess();
16559f63b866SArmin Le Grand 
16569f63b866SArmin Le Grand                             if(pNew)
16579f63b866SArmin Le Grand                             {
16589f63b866SArmin Le Grand                                 if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height())
16599f63b866SArmin Le Grand                                 {
1660603e43faSArmin Le Grand                                     for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
16619f63b866SArmin Le Grand                                     {
1662603e43faSArmin Le Grand                                         for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
16639f63b866SArmin Le Grand                                         {
16649f63b866SArmin Le Grand                                             const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
16659f63b866SArmin Le Grand                                             const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor));
16669f63b866SArmin Le Grand                                             const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
16679f63b866SArmin Le Grand 
16689f63b866SArmin Le Grand                                             pOld->SetPixel(y, x, BitmapColor(aCol));
16699f63b866SArmin Le Grand                                         }
16709f63b866SArmin Le Grand                                     }
16719f63b866SArmin Le Grand                                 }
16729f63b866SArmin Le Grand                                 else
16739f63b866SArmin Le Grand                                 {
16749f63b866SArmin Le Grand                                     OSL_ENSURE(false, "Alpha masks have different sizes (!)");
16759f63b866SArmin Le Grand                                 }
16768718d260SArmin Le Grand 
16779f63b866SArmin Le Grand                                 aNewMask.ReleaseAccess(pNew);
16789f63b866SArmin Le Grand                             }
16799f63b866SArmin Le Grand                             else
16809f63b866SArmin Le Grand                             {
16819f63b866SArmin Le Grand                                 OSL_ENSURE(false, "Got no access to new alpha mask (!)");
16829f63b866SArmin Le Grand                             }
16839f63b866SArmin Le Grand                         }
16849f63b866SArmin Le Grand 
16858718d260SArmin Le Grand                         aOldMask.ReleaseAccess(pOld);
16868718d260SArmin Le Grand                     }
16878718d260SArmin Le Grand                     else
16888718d260SArmin Le Grand                     {
16899f63b866SArmin Le Grand                         OSL_ENSURE(false, "Got no access to old alpha mask (!)");
16908718d260SArmin Le Grand                     }
16918718d260SArmin Le Grand 
16928718d260SArmin Le Grand                     // apply combined bitmap as mask
16939f63b866SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
16948718d260SArmin Le Grand                 }
16958718d260SArmin Le Grand             }
16968718d260SArmin Le Grand 
16978718d260SArmin Le Grand             // create and add object
16988718d260SArmin Le Grand             SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
16998718d260SArmin Le Grand 
1700468982e4SArmin Le Grand             // for MetaFloatTransparentAction, do not use SetAttributes(...)
1701468982e4SArmin Le Grand             // since these metafile content is not used to draw line/fill
1702468982e4SArmin Le Grand             // dependent of these setting at the device content
1703468982e4SArmin Le Grand             pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1704468982e4SArmin Le Grand             pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
17058718d260SArmin Le Grand             InsertObj(pGraf);
17068718d260SArmin Le Grand         }
17078718d260SArmin Le Grand     }
17088718d260SArmin Le Grand }
17098718d260SArmin Le Grand 
1710cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1711cdf0e10cSrcweir // eof
1712