1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
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
10cdf0e10cSrcweir *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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>
78674b939bSArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx>
79674b939bSArmin Le Grand #include <svx/svditer.hxx>
80674b939bSArmin 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++)
138cdf0e10cSrcweir {
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;
183*690281a1SArmin Le Grand
184*690281a1SArmin Le Grand // #i125211# MetaCommentAction may change index, thus hand it over
185*690281a1SArmin Le Grand case META_COMMENT_ACTION : DoAction((MetaCommentAction&)*pAct, rMtf, a);
186*690281a1SArmin Le Grand break;
1878718d260SArmin Le Grand
1888718d260SArmin Le Grand // missing actions added
1898718d260SArmin Le Grand case META_TEXTRECT_ACTION : DoAction((MetaTextRectAction&)*pAct); break;
1908718d260SArmin Le Grand case META_BMPSCALEPART_ACTION : DoAction((MetaBmpScalePartAction&)*pAct); break;
1918718d260SArmin Le Grand case META_BMPEXSCALEPART_ACTION : DoAction((MetaBmpExScalePartAction&)*pAct); break;
1928718d260SArmin Le Grand case META_MASK_ACTION : DoAction((MetaMaskAction&)*pAct); break;
1938718d260SArmin Le Grand case META_MASKSCALE_ACTION : DoAction((MetaMaskScaleAction&)*pAct); break;
1948718d260SArmin Le Grand case META_MASKSCALEPART_ACTION : DoAction((MetaMaskScalePartAction&)*pAct); break;
1958718d260SArmin Le Grand case META_GRADIENT_ACTION : DoAction((MetaGradientAction&)*pAct); break;
1968718d260SArmin Le Grand case META_WALLPAPER_ACTION : DoAction((MetaWallpaperAction&)*pAct); break;
1978718d260SArmin Le Grand case META_TRANSPARENT_ACTION : DoAction((MetaTransparentAction&)*pAct); break;
1988718d260SArmin Le Grand case META_EPS_ACTION : DoAction((MetaEPSAction&)*pAct); break;
1998718d260SArmin Le Grand case META_REFPOINT_ACTION : DoAction((MetaRefPointAction&)*pAct); break;
2008718d260SArmin Le Grand case META_TEXTLINECOLOR_ACTION : DoAction((MetaTextLineColorAction&)*pAct); break;
2018718d260SArmin Le Grand case META_TEXTLINE_ACTION : DoAction((MetaTextLineAction&)*pAct); break;
2028718d260SArmin Le Grand case META_FLOATTRANSPARENT_ACTION : DoAction((MetaFloatTransparentAction&)*pAct); break;
2038718d260SArmin Le Grand case META_GRADIENTEX_ACTION : DoAction((MetaGradientExAction&)*pAct); break;
2048718d260SArmin Le Grand case META_LAYOUTMODE_ACTION : DoAction((MetaLayoutModeAction&)*pAct); break;
2058718d260SArmin Le Grand case META_TEXTLANGUAGE_ACTION : DoAction((MetaTextLanguageAction&)*pAct); break;
2068718d260SArmin Le Grand case META_OVERLINECOLOR_ACTION : DoAction((MetaOverlineColorAction&)*pAct); break;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
2098718d260SArmin Le Grand if(pProgrInfo && pActionsToReport)
210cdf0e10cSrcweir {
2118718d260SArmin Le Grand (*pActionsToReport)++;
2128718d260SArmin Le Grand
2138718d260SArmin Le Grand if(*pActionsToReport >= 16) // Alle 16 Action updaten
214cdf0e10cSrcweir {
2158718d260SArmin Le Grand if(!pProgrInfo->ReportActions(*pActionsToReport))
216cdf0e10cSrcweir break;
2178718d260SArmin Le Grand
2188718d260SArmin Le Grand *pActionsToReport = 0;
2198718d260SArmin Le Grand }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir }
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
DoImport(const GDIMetaFile & rMtf,SdrObjList & rOL,sal_uInt32 nInsPos,SvdProgressInfo * pProgrInfo)2248718d260SArmin Le Grand sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(
2258718d260SArmin Le Grand const GDIMetaFile& rMtf,
2268718d260SArmin Le Grand SdrObjList& rOL,
2278718d260SArmin Le Grand sal_uInt32 nInsPos,
2288718d260SArmin Le Grand SvdProgressInfo* pProgrInfo)
2298718d260SArmin Le Grand {
2308718d260SArmin Le Grand // setup some global scale parameter
2318718d260SArmin Le Grand // mfScaleX, mfScaleY, maScaleX, maScaleY, mbMov, mbSize
2328718d260SArmin Le Grand mfScaleX = mfScaleY = 1.0;
2338718d260SArmin Le Grand const Size aMtfSize(rMtf.GetPrefSize());
2348718d260SArmin Le Grand
2358718d260SArmin Le Grand if(aMtfSize.Width() & aMtfSize.Height() && (!maScaleRect.IsEmpty()))
2368718d260SArmin Le Grand {
2378718d260SArmin Le Grand maOfs = maScaleRect.TopLeft();
2388718d260SArmin Le Grand
2398718d260SArmin Le Grand if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2408718d260SArmin Le Grand {
2418718d260SArmin Le Grand mfScaleX = (double)( maScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
2428718d260SArmin Le Grand }
2438718d260SArmin Le Grand
2448718d260SArmin Le Grand if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2458718d260SArmin Le Grand {
2468718d260SArmin Le Grand mfScaleY = (double)( maScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
2478718d260SArmin Le Grand }
2488718d260SArmin Le Grand }
2498718d260SArmin Le Grand
2508718d260SArmin Le Grand mbMov = maOfs.X()!=0 || maOfs.Y()!=0;
2518718d260SArmin Le Grand mbSize = false;
2528718d260SArmin Le Grand maScaleX = Fraction( 1, 1 );
2538718d260SArmin Le Grand maScaleY = Fraction( 1, 1 );
2548718d260SArmin Le Grand
2558718d260SArmin Le Grand if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2568718d260SArmin Le Grand {
2578718d260SArmin Le Grand maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width());
2588718d260SArmin Le Grand mbSize = true;
2598718d260SArmin Le Grand }
2608718d260SArmin Le Grand
2618718d260SArmin Le Grand if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2628718d260SArmin Le Grand {
2638718d260SArmin Le Grand maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height());
2648718d260SArmin Le Grand mbSize = true;
2658718d260SArmin Le Grand }
2668718d260SArmin Le Grand
2678718d260SArmin Le Grand if(pProgrInfo)
2688718d260SArmin Le Grand {
2698718d260SArmin Le Grand pProgrInfo->SetActionCount(rMtf.GetActionCount());
2708718d260SArmin Le Grand }
2718718d260SArmin Le Grand
2728718d260SArmin Le Grand sal_uInt32 nActionsToReport(0);
2738718d260SArmin Le Grand
2748718d260SArmin Le Grand // execute
2758718d260SArmin Le Grand DoLoopActions(const_cast< GDIMetaFile& >(rMtf), pProgrInfo, &nActionsToReport);
2768718d260SArmin Le Grand
2778718d260SArmin Le Grand if(pProgrInfo)
278cdf0e10cSrcweir {
279cdf0e10cSrcweir pProgrInfo->ReportActions(nActionsToReport);
280cdf0e10cSrcweir nActionsToReport = 0;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
283cdf0e10cSrcweir // MapMode-Scaling vornehmen
284cdf0e10cSrcweir MapScaling();
285cdf0e10cSrcweir
286cdf0e10cSrcweir // Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
2878718d260SArmin Le Grand // Da in maTmpList allerdings weniger eintraege als GetActionCount()
288cdf0e10cSrcweir // existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
289cdf0e10cSrcweir // hinzugefuegt werden.
2908718d260SArmin Le Grand nActionsToReport = (rMtf.GetActionCount() - maTmpList.size()) * 2;
291cdf0e10cSrcweir
292cdf0e10cSrcweir // Alle noch nicht gemeldeten Rescales melden
293cdf0e10cSrcweir if(pProgrInfo)
294cdf0e10cSrcweir {
295cdf0e10cSrcweir pProgrInfo->ReportRescales(nActionsToReport);
2968718d260SArmin Le Grand pProgrInfo->SetInsertCount(maTmpList.size());
297cdf0e10cSrcweir }
2988718d260SArmin Le Grand
299cdf0e10cSrcweir nActionsToReport = 0;
300cdf0e10cSrcweir
3018718d260SArmin Le Grand // alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
3028718d260SArmin Le Grand if(nInsPos > rOL.GetObjCount())
303cdf0e10cSrcweir {
3048718d260SArmin Le Grand nInsPos = rOL.GetObjCount();
3058718d260SArmin Le Grand }
3068718d260SArmin Le Grand
3078718d260SArmin Le Grand SdrInsertReason aReason(SDRREASON_VIEWCALL);
3088718d260SArmin Le Grand
3098718d260SArmin Le Grand for(sal_uInt32 i(0); i < maTmpList.size(); i++)
3108718d260SArmin Le Grand {
3118718d260SArmin Le Grand SdrObject* pObj = maTmpList[i];
312cdf0e10cSrcweir rOL.NbcInsertObject(pObj, nInsPos, &aReason);
313cdf0e10cSrcweir nInsPos++;
314cdf0e10cSrcweir
3158718d260SArmin Le Grand if(pProgrInfo)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir nActionsToReport++;
3188718d260SArmin Le Grand
319cdf0e10cSrcweir if(nActionsToReport >= 32) // Alle 32 Action updaten
320cdf0e10cSrcweir {
321cdf0e10cSrcweir pProgrInfo->ReportInserts(nActionsToReport);
322cdf0e10cSrcweir nActionsToReport = 0;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir }
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir // ein letztesmal alle verbliebennen Inserts reporten
3288718d260SArmin Le Grand if(pProgrInfo)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir pProgrInfo->ReportInserts(nActionsToReport);
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
3338718d260SArmin Le Grand return maTmpList.size();
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
SetAttributes(SdrObject * pObj,bool bForceTextAttr)3368718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
337cdf0e10cSrcweir {
3388718d260SArmin Le Grand mbNoLine = false;
3398718d260SArmin Le Grand mbNoFill = false;
3408718d260SArmin Le Grand bool bLine(!bForceTextAttr);
3418718d260SArmin Le Grand bool bFill(!pObj || (pObj->IsClosedObj() && !bForceTextAttr));
3428718d260SArmin Le Grand bool bText(bForceTextAttr || (pObj && pObj->GetOutlinerParaObject()));
343cdf0e10cSrcweir
344cdf0e10cSrcweir if(bLine)
345cdf0e10cSrcweir {
3468718d260SArmin Le Grand if(mnLineWidth)
347cdf0e10cSrcweir {
3488718d260SArmin Le Grand mpLineAttr->Put(XLineWidthItem(mnLineWidth));
349cdf0e10cSrcweir }
350cdf0e10cSrcweir else
3518718d260SArmin Le Grand {
3528718d260SArmin Le Grand mpLineAttr->Put(XLineWidthItem(0));
3538718d260SArmin Le Grand }
3548718d260SArmin Le Grand
3558718d260SArmin Le Grand maOldLineColor = maVD.GetLineColor();
3568718d260SArmin Le Grand
3578718d260SArmin Le Grand if(maVD.IsLineColor())
3588718d260SArmin Le Grand {
3598718d260SArmin Le Grand mpLineAttr->Put(XLineStyleItem(XLINE_SOLID));
3608718d260SArmin Le Grand mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor()));
3618718d260SArmin Le Grand }
3628718d260SArmin Le Grand else
3638718d260SArmin Le Grand {
3648718d260SArmin Le Grand mpLineAttr->Put(XLineStyleItem(XLINE_NONE));
3658718d260SArmin Le Grand }
366cdf0e10cSrcweir
367cdf0e10cSrcweir switch(maLineJoin)
368cdf0e10cSrcweir {
369cdf0e10cSrcweir default : // basegfx::B2DLINEJOIN_NONE
370d5370dc8SArmin Le Grand mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_NONE));
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir case basegfx::B2DLINEJOIN_MIDDLE:
373d5370dc8SArmin Le Grand mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_MIDDLE));
374cdf0e10cSrcweir break;
375cdf0e10cSrcweir case basegfx::B2DLINEJOIN_BEVEL:
376d5370dc8SArmin Le Grand mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL));
377cdf0e10cSrcweir break;
378cdf0e10cSrcweir case basegfx::B2DLINEJOIN_MITER:
379d5370dc8SArmin Le Grand mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_MITER));
380cdf0e10cSrcweir break;
381cdf0e10cSrcweir case basegfx::B2DLINEJOIN_ROUND:
382d5370dc8SArmin Le Grand mpLineAttr->Put(XLineJointItem(com::sun::star::drawing::LineJoint_ROUND));
383cdf0e10cSrcweir break;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
3865aaf853bSArmin Le Grand // Add LineCap support
3878718d260SArmin Le Grand mpLineAttr->Put(XLineCapItem(maLineCap));
3885aaf853bSArmin Le Grand
389cdf0e10cSrcweir if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
390cdf0e10cSrcweir {
3918718d260SArmin Le Grand mpLineAttr->Put(XLineDashItem(String(), maDash));
392cdf0e10cSrcweir }
393cdf0e10cSrcweir else
394cdf0e10cSrcweir {
3958718d260SArmin Le Grand mpLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
396cdf0e10cSrcweir }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir else
3998718d260SArmin Le Grand {
4008718d260SArmin Le Grand mbNoLine = true;
4018718d260SArmin Le Grand }
402cdf0e10cSrcweir
403cdf0e10cSrcweir if(bFill)
404cdf0e10cSrcweir {
4058718d260SArmin Le Grand if(maVD.IsFillColor())
406cdf0e10cSrcweir {
4078718d260SArmin Le Grand mpFillAttr->Put(XFillStyleItem(XFILL_SOLID));
4088718d260SArmin Le Grand mpFillAttr->Put(XFillColorItem(String(), maVD.GetFillColor()));
409cdf0e10cSrcweir }
410cdf0e10cSrcweir else
4118718d260SArmin Le Grand {
4128718d260SArmin Le Grand mpFillAttr->Put(XFillStyleItem(XFILL_NONE));
4138718d260SArmin Le Grand }
414cdf0e10cSrcweir }
415cdf0e10cSrcweir else
4168718d260SArmin Le Grand {
4178718d260SArmin Le Grand mbNoFill = true;
4188718d260SArmin Le Grand }
419cdf0e10cSrcweir
4208718d260SArmin Le Grand if(bText && mbFntDirty)
421cdf0e10cSrcweir {
4228718d260SArmin Le Grand Font aFnt(maVD.GetFont());
4238718d260SArmin Le Grand const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * mfScaleY));
4248718d260SArmin Le Grand
4258718d260SArmin Le Grand mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
4268718d260SArmin Le Grand mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
4278718d260SArmin Le Grand mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
4288718d260SArmin Le Grand mpTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
4298718d260SArmin Le Grand mpTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
4308718d260SArmin Le Grand mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
4318718d260SArmin Le Grand mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
4328718d260SArmin Le Grand mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
4338718d260SArmin Le Grand mpTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
4348718d260SArmin Le Grand mpTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
4358718d260SArmin Le Grand mpTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
4368718d260SArmin Le Grand mpTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
4378718d260SArmin Le Grand mpTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
438a5258243SPedro Giffuni
439a5258243SPedro Giffuni // #i118485# Setting this item leads to problems (written #i118498# for this)
4408718d260SArmin Le Grand // mpTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
441a5258243SPedro Giffuni
4428718d260SArmin Le Grand mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
4438718d260SArmin Le Grand mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
4448718d260SArmin Le Grand mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
445cdf0e10cSrcweir //... svxfont textitem svditext
4468718d260SArmin Le Grand mbFntDirty = false;
447cdf0e10cSrcweir }
4488718d260SArmin Le Grand
4498718d260SArmin Le Grand if(pObj)
450cdf0e10cSrcweir {
4518718d260SArmin Le Grand pObj->SetLayer(mnLayer);
4528718d260SArmin Le Grand
4538718d260SArmin Le Grand if(bLine)
4548718d260SArmin Le Grand {
4558718d260SArmin Le Grand pObj->SetMergedItemSet(*mpLineAttr);
4568718d260SArmin Le Grand }
4578718d260SArmin Le Grand
4588718d260SArmin Le Grand if(bFill)
4598718d260SArmin Le Grand {
4608718d260SArmin Le Grand pObj->SetMergedItemSet(*mpFillAttr);
4618718d260SArmin Le Grand }
4628718d260SArmin Le Grand
463cdf0e10cSrcweir if(bText)
464cdf0e10cSrcweir {
4658718d260SArmin Le Grand pObj->SetMergedItemSet(*mpTextAttr);
466cdf0e10cSrcweir pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
467cdf0e10cSrcweir }
468cdf0e10cSrcweir }
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
InsertObj(SdrObject * pObj,bool bScale)4718718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
472cdf0e10cSrcweir {
4738718d260SArmin Le Grand if(bScale && !maScaleRect.IsEmpty())
474cdf0e10cSrcweir {
4758718d260SArmin Le Grand if(mbSize)
4768718d260SArmin Le Grand {
4778718d260SArmin Le Grand pObj->NbcResize(Point(), maScaleX, maScaleY);
4788718d260SArmin Le Grand }
4798718d260SArmin Le Grand
4808718d260SArmin Le Grand if(mbMov)
4818718d260SArmin Le Grand {
4828718d260SArmin Le Grand pObj->NbcMove(Size(maOfs.X(), maOfs.Y()));
4838718d260SArmin Le Grand }
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
48647a7c0c1SArmin Le Grand if(isClip())
48747a7c0c1SArmin Le Grand {
48847a7c0c1SArmin Le Grand const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
48947a7c0c1SArmin Le Grand const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
49047a7c0c1SArmin Le Grand const SdrLayerID aOldLayer(pObj->GetLayer());
49147a7c0c1SArmin Le Grand const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
49247a7c0c1SArmin Le Grand const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
493674b939bSArmin Le Grand const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj);
494674b939bSArmin Le Grand
495674b939bSArmin Le Grand if(pSdrTextObj && pSdrTextObj->HasText())
496674b939bSArmin Le Grand {
497674b939bSArmin Le Grand // all text objects are created from ImportText and have no line or fill attributes, so
498674b939bSArmin Le Grand // it is okay to concentrate on the text itself
499674b939bSArmin Le Grand while(true)
500674b939bSArmin Le Grand {
501674b939bSArmin Le Grand const basegfx::B2DPolyPolygon aTextContour(pSdrTextObj->TakeContour());
502674b939bSArmin Le Grand const basegfx::B2DRange aTextRange(aTextContour.getB2DRange());
503674b939bSArmin Le Grand const basegfx::B2DRange aClipRange(maClip.getB2DRange());
504674b939bSArmin Le Grand
505674b939bSArmin Le Grand // no overlap -> completely outside
506674b939bSArmin Le Grand if(!aClipRange.overlaps(aTextRange))
507674b939bSArmin Le Grand {
508674b939bSArmin Le Grand SdrObject::Free(pObj);
509674b939bSArmin Le Grand break;
510674b939bSArmin Le Grand }
511674b939bSArmin Le Grand
512674b939bSArmin Le Grand // when the clip is a rectangle fast check for inside is possible
513674b939bSArmin Le Grand if(basegfx::tools::isRectangle(maClip) && aClipRange.isInside(aTextRange))
514674b939bSArmin Le Grand {
515674b939bSArmin Le Grand // completely inside ClipRect
516674b939bSArmin Le Grand break;
517674b939bSArmin Le Grand }
518674b939bSArmin Le Grand
519674b939bSArmin Le Grand // here text needs to be clipped; to do so, convert to SdrObjects with polygons
520674b939bSArmin Le Grand // and add these recursively. Delete original object, do not add in this run
521674b939bSArmin Le Grand SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
522674b939bSArmin Le Grand SdrObject::Free(pObj);
523674b939bSArmin Le Grand
524674b939bSArmin Le Grand if(pConverted)
525674b939bSArmin Le Grand {
526674b939bSArmin Le Grand // recursively add created conversion; per definition this shall not
527674b939bSArmin Le Grand // contain further SdrTextObjs. Visit only non-group objects
528674b939bSArmin Le Grand SdrObjListIter aIter(*pConverted, IM_DEEPNOGROUPS);
529674b939bSArmin Le Grand
530674b939bSArmin Le Grand // work with clones; the created conversion may contain group objects
531674b939bSArmin Le Grand // and when working with the original objects the loop itself could
532674b939bSArmin Le Grand // break and the cleanup later would be pretty complicated (only delete group
533674b939bSArmin Le Grand // objects, are these empty, ...?)
534674b939bSArmin Le Grand while(aIter.IsMore())
535674b939bSArmin Le Grand {
536674b939bSArmin Le Grand SdrObject* pCandidate = aIter.Next();
537674b939bSArmin Le Grand OSL_ENSURE(pCandidate && 0 == dynamic_cast< SdrObjGroup* >(pCandidate), "SdrObjListIter with IM_DEEPNOGROUPS error (!)");
538674b939bSArmin Le Grand SdrObject* pNewClone = pCandidate->Clone();
539674b939bSArmin Le Grand
540674b939bSArmin Le Grand if(pNewClone)
541674b939bSArmin Le Grand {
542674b939bSArmin Le Grand InsertObj(pNewClone, false);
543674b939bSArmin Le Grand }
544674b939bSArmin Le Grand else
545674b939bSArmin Le Grand {
546674b939bSArmin Le Grand OSL_ENSURE(false, "SdrObject::Clone() failed (!)");
547674b939bSArmin Le Grand }
548674b939bSArmin Le Grand }
549674b939bSArmin Le Grand
550674b939bSArmin Le Grand // cleanup temporary conversion objects
551674b939bSArmin Le Grand SdrObject::Free(pConverted);
552674b939bSArmin Le Grand }
553674b939bSArmin Le Grand
554674b939bSArmin Le Grand break;
555674b939bSArmin Le Grand }
556674b939bSArmin Le Grand }
557674b939bSArmin Le Grand else
558674b939bSArmin Le Grand {
55947a7c0c1SArmin Le Grand BitmapEx aBitmapEx;
56047a7c0c1SArmin Le Grand
56147a7c0c1SArmin Le Grand if(pSdrGrafObj)
56247a7c0c1SArmin Le Grand {
56347a7c0c1SArmin Le Grand aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
56447a7c0c1SArmin Le Grand }
56547a7c0c1SArmin Le Grand
56647a7c0c1SArmin Le Grand SdrObject::Free(pObj);
56747a7c0c1SArmin Le Grand
56847a7c0c1SArmin Le Grand if(!aOldRange.isEmpty())
56947a7c0c1SArmin Le Grand {
57047a7c0c1SArmin Le Grand // clip against ClipRegion
57147a7c0c1SArmin Le Grand const basegfx::B2DPolyPolygon aNewPoly(
57247a7c0c1SArmin Le Grand basegfx::tools::clipPolyPolygonOnPolyPolygon(
57347a7c0c1SArmin Le Grand aPoly,
57447a7c0c1SArmin Le Grand maClip,
57547a7c0c1SArmin Le Grand true,
57647a7c0c1SArmin Le Grand aPoly.isClosed() ? false : true));
57747a7c0c1SArmin Le Grand const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
57847a7c0c1SArmin Le Grand
57947a7c0c1SArmin Le Grand if(!aNewRange.isEmpty())
58047a7c0c1SArmin Le Grand {
58147a7c0c1SArmin Le Grand pObj = new SdrPathObj(
58247a7c0c1SArmin Le Grand aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
58347a7c0c1SArmin Le Grand aNewPoly);
58447a7c0c1SArmin Le Grand
58547a7c0c1SArmin Le Grand pObj->SetLayer(aOldLayer);
58647a7c0c1SArmin Le Grand pObj->SetMergedItemSet(aOldItemSet);
58747a7c0c1SArmin Le Grand
58847a7c0c1SArmin Le Grand if(!!aBitmapEx)
58947a7c0c1SArmin Le Grand {
59047a7c0c1SArmin Le Grand // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
59147a7c0c1SArmin Le Grand const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
59247a7c0c1SArmin Le Grand const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
59347a7c0c1SArmin Le Grand basegfx::B2DRange aPixel(aNewRange);
59447a7c0c1SArmin Le Grand basegfx::B2DHomMatrix aTrans;
59547a7c0c1SArmin Le Grand
59647a7c0c1SArmin Le Grand aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
59747a7c0c1SArmin Le Grand aTrans.scale(fScaleX, fScaleY);
59847a7c0c1SArmin Le Grand aPixel.transform(aTrans);
59947a7c0c1SArmin Le Grand
600468982e4SArmin Le Grand const Size aOrigSizePixel(aBitmapEx.GetSizePixel());
601468982e4SArmin Le Grand const Point aClipTopLeft(
602468982e4SArmin Le Grand basegfx::fround(floor(std::max(0.0, aPixel.getMinX()))),
603468982e4SArmin Le Grand basegfx::fround(floor(std::max(0.0, aPixel.getMinY()))));
604468982e4SArmin Le Grand const Size aClipSize(
605468982e4SArmin Le Grand basegfx::fround(ceil(std::min((double)aOrigSizePixel.Width(), aPixel.getWidth()))),
606468982e4SArmin Le Grand basegfx::fround(ceil(std::min((double)aOrigSizePixel.Height(), aPixel.getHeight()))));
60747a7c0c1SArmin Le Grand const BitmapEx aClippedBitmap(
60847a7c0c1SArmin Le Grand aBitmapEx,
609468982e4SArmin Le Grand aClipTopLeft,
610468982e4SArmin Le Grand aClipSize);
61147a7c0c1SArmin Le Grand
61247a7c0c1SArmin Le Grand pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
61370d3707aSArmin Le Grand pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
6149f63b866SArmin Le Grand pObj->SetMergedItem(XFillBmpTileItem(false));
6159f63b866SArmin Le Grand pObj->SetMergedItem(XFillBmpStretchItem(true));
61647a7c0c1SArmin Le Grand }
61747a7c0c1SArmin Le Grand }
61847a7c0c1SArmin Le Grand }
61947a7c0c1SArmin Le Grand }
620674b939bSArmin Le Grand }
62147a7c0c1SArmin Le Grand
62247a7c0c1SArmin Le Grand if(pObj)
62347a7c0c1SArmin Le Grand {
624cdf0e10cSrcweir // #i111954# check object for visibility
625cdf0e10cSrcweir // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
626cdf0e10cSrcweir bool bVisible(false);
627cdf0e10cSrcweir
628cdf0e10cSrcweir if(pObj->HasLineStyle())
629cdf0e10cSrcweir {
630cdf0e10cSrcweir bVisible = true;
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
633cdf0e10cSrcweir if(!bVisible && pObj->HasFillStyle())
634cdf0e10cSrcweir {
635cdf0e10cSrcweir bVisible = true;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
638cdf0e10cSrcweir if(!bVisible)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
641cdf0e10cSrcweir
642cdf0e10cSrcweir if(pTextObj && pTextObj->HasText())
643cdf0e10cSrcweir {
644cdf0e10cSrcweir bVisible = true;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir }
647cdf0e10cSrcweir
648cdf0e10cSrcweir if(!bVisible)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
651cdf0e10cSrcweir
652cdf0e10cSrcweir if(pGrafObj)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir // this may be refined to check if the graphic really is visible. It
655cdf0e10cSrcweir // is here to ensure that graphic objects without fill, line and text
656cdf0e10cSrcweir // get created
657cdf0e10cSrcweir bVisible = true;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir if(!bVisible)
662cdf0e10cSrcweir {
663cdf0e10cSrcweir SdrObject::Free(pObj);
664cdf0e10cSrcweir }
665cdf0e10cSrcweir else
666cdf0e10cSrcweir {
6678718d260SArmin Le Grand maTmpList.push_back(pObj);
6688718d260SArmin Le Grand
6698718d260SArmin Le Grand if(dynamic_cast< SdrPathObj* >(pObj))
670cdf0e10cSrcweir {
6718718d260SArmin Le Grand const bool bClosed(pObj->IsClosedObj());
6728718d260SArmin Le Grand
6738718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = mbNoLine && bClosed;
6748718d260SArmin Le Grand mbLastObjWasLine = !bClosed;
675cdf0e10cSrcweir }
676cdf0e10cSrcweir else
677cdf0e10cSrcweir {
6788718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = false;
6798718d260SArmin Le Grand mbLastObjWasLine = false;
680cdf0e10cSrcweir }
681cdf0e10cSrcweir }
682cdf0e10cSrcweir }
68347a7c0c1SArmin Le Grand }
684cdf0e10cSrcweir
685cdf0e10cSrcweir /**************************************************************************************************/
686cdf0e10cSrcweir
DoAction(MetaPixelAction &)687cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir }
690cdf0e10cSrcweir
DoAction(MetaPointAction &)691cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
DoAction(MetaLineAction & rAct)695cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
696cdf0e10cSrcweir {
697cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
698cdf0e10cSrcweir const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
699cdf0e10cSrcweir const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
700cdf0e10cSrcweir
701cdf0e10cSrcweir if(!aStart.equal(aEnd))
702cdf0e10cSrcweir {
703cdf0e10cSrcweir basegfx::B2DPolygon aLine;
7048718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
705cdf0e10cSrcweir
706cdf0e10cSrcweir aLine.append(aStart);
707cdf0e10cSrcweir aLine.append(aEnd);
708cdf0e10cSrcweir aLine.transform(aTransform);
709cdf0e10cSrcweir
710cdf0e10cSrcweir const LineInfo& rLineInfo = rAct.GetLineInfo();
711cdf0e10cSrcweir const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
712cdf0e10cSrcweir bool bCreateLineObject(true);
713cdf0e10cSrcweir
7148718d260SArmin Le Grand if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine))
715cdf0e10cSrcweir {
716cdf0e10cSrcweir bCreateLineObject = false;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir
719cdf0e10cSrcweir if(bCreateLineObject)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
7228718d260SArmin Le Grand mnLineWidth = nNewLineWidth;
723cdf0e10cSrcweir maLineJoin = rLineInfo.GetLineJoin();
7245aaf853bSArmin Le Grand maLineCap = rLineInfo.GetLineCap();
725cdf0e10cSrcweir maDash = XDash(XDASH_RECT,
726cdf0e10cSrcweir rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
727cdf0e10cSrcweir rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
728cdf0e10cSrcweir rLineInfo.GetDistance());
729cdf0e10cSrcweir SetAttributes(pPath);
7308718d260SArmin Le Grand mnLineWidth = 0;
731cdf0e10cSrcweir maLineJoin = basegfx::B2DLINEJOIN_NONE;
732cdf0e10cSrcweir maDash = XDash();
733cdf0e10cSrcweir InsertObj(pPath, false);
734cdf0e10cSrcweir }
735cdf0e10cSrcweir }
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
DoAction(MetaRectAction & rAct)738cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
739cdf0e10cSrcweir {
740cdf0e10cSrcweir SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
741cdf0e10cSrcweir SetAttributes(pRect);
742cdf0e10cSrcweir InsertObj(pRect);
743cdf0e10cSrcweir }
744cdf0e10cSrcweir
DoAction(MetaRoundRectAction & rAct)745cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
748cdf0e10cSrcweir SetAttributes(pRect);
749cdf0e10cSrcweir long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
750cdf0e10cSrcweir if (nRad!=0) {
7518718d260SArmin Le Grand SfxItemSet aSet(*mpLineAttr->GetPool(), SDRATTR_ECKENRADIUS, SDRATTR_ECKENRADIUS, 0, 0);
752cdf0e10cSrcweir aSet.Put(SdrEckenradiusItem(nRad));
753cdf0e10cSrcweir pRect->SetMergedItemSet(aSet);
754cdf0e10cSrcweir }
755cdf0e10cSrcweir InsertObj(pRect);
756cdf0e10cSrcweir }
757cdf0e10cSrcweir
758cdf0e10cSrcweir /**************************************************************************************************/
759cdf0e10cSrcweir
DoAction(MetaEllipseAction & rAct)760cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
761cdf0e10cSrcweir {
762cdf0e10cSrcweir SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
763cdf0e10cSrcweir SetAttributes(pCirc);
764cdf0e10cSrcweir InsertObj(pCirc);
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
DoAction(MetaArcAction & rAct)767cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
768cdf0e10cSrcweir {
769cdf0e10cSrcweir Point aCenter(rAct.GetRect().Center());
770cdf0e10cSrcweir long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
771cdf0e10cSrcweir long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
772cdf0e10cSrcweir SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
773cdf0e10cSrcweir SetAttributes(pCirc);
774cdf0e10cSrcweir InsertObj(pCirc);
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
DoAction(MetaPieAction & rAct)777cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir Point aCenter(rAct.GetRect().Center());
780cdf0e10cSrcweir long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
781cdf0e10cSrcweir long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
782cdf0e10cSrcweir SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
783cdf0e10cSrcweir SetAttributes(pCirc);
784cdf0e10cSrcweir InsertObj(pCirc);
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
DoAction(MetaChordAction & rAct)787cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
788cdf0e10cSrcweir {
789cdf0e10cSrcweir Point aCenter(rAct.GetRect().Center());
790cdf0e10cSrcweir long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
791cdf0e10cSrcweir long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
792cdf0e10cSrcweir SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
793cdf0e10cSrcweir SetAttributes(pCirc);
794cdf0e10cSrcweir InsertObj(pCirc);
795cdf0e10cSrcweir }
796cdf0e10cSrcweir
797cdf0e10cSrcweir /**************************************************************************************************/
798cdf0e10cSrcweir
CheckLastLineMerge(const basegfx::B2DPolygon & rSrcPoly)799cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
800cdf0e10cSrcweir {
801cdf0e10cSrcweir // #i102706# Do not merge closed polygons
802cdf0e10cSrcweir if(rSrcPoly.isClosed())
803cdf0e10cSrcweir {
804cdf0e10cSrcweir return false;
805cdf0e10cSrcweir }
806cdf0e10cSrcweir
807cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
8088718d260SArmin Le Grand if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
809cdf0e10cSrcweir {
8108718d260SArmin Le Grand SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
8118718d260SArmin Le Grand SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
812cdf0e10cSrcweir
813cdf0e10cSrcweir if(pLastPoly)
814cdf0e10cSrcweir {
815cdf0e10cSrcweir if(1L == pLastPoly->GetPathPoly().count())
816cdf0e10cSrcweir {
817cdf0e10cSrcweir bool bOk(false);
818cdf0e10cSrcweir basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
819cdf0e10cSrcweir
820cdf0e10cSrcweir // #i102706# Do not merge closed polygons
821cdf0e10cSrcweir if(aDstPoly.isClosed())
822cdf0e10cSrcweir {
823cdf0e10cSrcweir return false;
824cdf0e10cSrcweir }
825cdf0e10cSrcweir
826cdf0e10cSrcweir if(aDstPoly.count())
827cdf0e10cSrcweir {
828cdf0e10cSrcweir const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
829cdf0e10cSrcweir const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
830cdf0e10cSrcweir
831cdf0e10cSrcweir if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
832cdf0e10cSrcweir {
833cdf0e10cSrcweir aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
834cdf0e10cSrcweir bOk = true;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
837cdf0e10cSrcweir {
838cdf0e10cSrcweir basegfx::B2DPolygon aNew(rSrcPoly);
839cdf0e10cSrcweir aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
840cdf0e10cSrcweir aDstPoly = aNew;
841cdf0e10cSrcweir bOk = true;
842cdf0e10cSrcweir }
843cdf0e10cSrcweir else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
844cdf0e10cSrcweir {
845cdf0e10cSrcweir aDstPoly.flip();
846cdf0e10cSrcweir aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
847cdf0e10cSrcweir bOk = true;
848cdf0e10cSrcweir }
849cdf0e10cSrcweir else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
850cdf0e10cSrcweir {
851cdf0e10cSrcweir basegfx::B2DPolygon aNew(rSrcPoly);
852cdf0e10cSrcweir aNew.flip();
853cdf0e10cSrcweir aDstPoly.append(aNew, 1L, aNew.count() - 1L);
854cdf0e10cSrcweir bOk = true;
855cdf0e10cSrcweir }
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir if(bOk)
859cdf0e10cSrcweir {
860cdf0e10cSrcweir pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
863cdf0e10cSrcweir return bOk;
864cdf0e10cSrcweir }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
868cdf0e10cSrcweir return false;
869cdf0e10cSrcweir }
870cdf0e10cSrcweir
CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)871cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
872cdf0e10cSrcweir {
873cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
8748718d260SArmin Le Grand if(mbLastObjWasPolyWithoutLine)
875cdf0e10cSrcweir {
8768718d260SArmin Le Grand SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
8778718d260SArmin Le Grand SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
878cdf0e10cSrcweir
879cdf0e10cSrcweir if(pLastPoly)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir if(pLastPoly->GetPathPoly() == rPolyPolygon)
882cdf0e10cSrcweir {
883cdf0e10cSrcweir SetAttributes(NULL);
884cdf0e10cSrcweir
8858718d260SArmin Le Grand if(!mbNoLine && mbNoFill)
886cdf0e10cSrcweir {
8878718d260SArmin Le Grand pLastPoly->SetMergedItemSet(*mpLineAttr);
888cdf0e10cSrcweir
889cdf0e10cSrcweir return true;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir }
892cdf0e10cSrcweir }
893cdf0e10cSrcweir }
894cdf0e10cSrcweir
895cdf0e10cSrcweir return false;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir
checkClip()89847a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::checkClip()
89947a7c0c1SArmin Le Grand {
9008718d260SArmin Le Grand if(maVD.IsClipRegion())
90147a7c0c1SArmin Le Grand {
902e6f63103SArmin Le Grand maClip = maVD.GetClipRegion().GetAsB2DPolyPolygon();
90347a7c0c1SArmin Le Grand
90447a7c0c1SArmin Le Grand if(isClip())
90547a7c0c1SArmin Le Grand {
90647a7c0c1SArmin Le Grand const basegfx::B2DHomMatrix aTransform(
90747a7c0c1SArmin Le Grand basegfx::tools::createScaleTranslateB2DHomMatrix(
9088718d260SArmin Le Grand mfScaleX,
9098718d260SArmin Le Grand mfScaleY,
9108718d260SArmin Le Grand maOfs.X(),
9118718d260SArmin Le Grand maOfs.Y()));
91247a7c0c1SArmin Le Grand
91347a7c0c1SArmin Le Grand maClip.transform(aTransform);
91447a7c0c1SArmin Le Grand }
91547a7c0c1SArmin Le Grand }
91647a7c0c1SArmin Le Grand }
91747a7c0c1SArmin Le Grand
isClip() const91847a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const
91947a7c0c1SArmin Le Grand {
92047a7c0c1SArmin Le Grand return !maClip.getB2DRange().isEmpty();
92147a7c0c1SArmin Le Grand }
922cdf0e10cSrcweir
DoAction(MetaPolyLineAction & rAct)923cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
926cdf0e10cSrcweir basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
927cdf0e10cSrcweir
928cdf0e10cSrcweir if(aSource.count())
929cdf0e10cSrcweir {
9308718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
931cdf0e10cSrcweir aSource.transform(aTransform);
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
934cdf0e10cSrcweir const LineInfo& rLineInfo = rAct.GetLineInfo();
935cdf0e10cSrcweir const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
936cdf0e10cSrcweir bool bCreateLineObject(true);
937cdf0e10cSrcweir
9388718d260SArmin Le Grand if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource))
939cdf0e10cSrcweir {
940cdf0e10cSrcweir bCreateLineObject = false;
941cdf0e10cSrcweir }
9428718d260SArmin Le Grand else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
943cdf0e10cSrcweir {
944cdf0e10cSrcweir bCreateLineObject = false;
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
947cdf0e10cSrcweir if(bCreateLineObject)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(
950cdf0e10cSrcweir aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
951cdf0e10cSrcweir basegfx::B2DPolyPolygon(aSource));
9528718d260SArmin Le Grand mnLineWidth = nNewLineWidth;
953cdf0e10cSrcweir maLineJoin = rLineInfo.GetLineJoin();
9545aaf853bSArmin Le Grand maLineCap = rLineInfo.GetLineCap();
955cdf0e10cSrcweir maDash = XDash(XDASH_RECT,
956cdf0e10cSrcweir rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
957cdf0e10cSrcweir rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
958cdf0e10cSrcweir rLineInfo.GetDistance());
959cdf0e10cSrcweir SetAttributes(pPath);
9608718d260SArmin Le Grand mnLineWidth = 0;
961cdf0e10cSrcweir maLineJoin = basegfx::B2DLINEJOIN_NONE;
962cdf0e10cSrcweir maDash = XDash();
963cdf0e10cSrcweir InsertObj(pPath, false);
964cdf0e10cSrcweir }
965cdf0e10cSrcweir }
966cdf0e10cSrcweir
DoAction(MetaPolygonAction & rAct)967cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
968cdf0e10cSrcweir {
969cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
970cdf0e10cSrcweir basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
971cdf0e10cSrcweir
972cdf0e10cSrcweir if(aSource.count())
973cdf0e10cSrcweir {
9748718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
975cdf0e10cSrcweir aSource.transform(aTransform);
976cdf0e10cSrcweir
9778718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
978cdf0e10cSrcweir {
979cdf0e10cSrcweir // #i73407# make sure polygon is closed, it's a filled primitive
980cdf0e10cSrcweir aSource.setClosed(true);
981cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
982cdf0e10cSrcweir SetAttributes(pPath);
983cdf0e10cSrcweir InsertObj(pPath, false);
984cdf0e10cSrcweir }
985cdf0e10cSrcweir }
986cdf0e10cSrcweir }
987cdf0e10cSrcweir
DoAction(MetaPolyPolygonAction & rAct)988cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
989cdf0e10cSrcweir {
990cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
991cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
992cdf0e10cSrcweir
993cdf0e10cSrcweir if(aSource.count())
994cdf0e10cSrcweir {
9958718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
996cdf0e10cSrcweir aSource.transform(aTransform);
997cdf0e10cSrcweir
9988718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir // #i73407# make sure polygon is closed, it's a filled primitive
1001cdf0e10cSrcweir aSource.setClosed(true);
1002cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1003cdf0e10cSrcweir SetAttributes(pPath);
1004cdf0e10cSrcweir InsertObj(pPath, false);
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir /**************************************************************************************************/
1010cdf0e10cSrcweir
ImportText(const Point & rPos,const XubString & rStr,const MetaAction & rAct)1011cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir // calc text box size, add 5% to make it fit safely
1014cdf0e10cSrcweir
10158718d260SArmin Le Grand FontMetric aFontMetric( maVD.GetFontMetric() );
10168718d260SArmin Le Grand Font aFnt( maVD.GetFont() );
1017cdf0e10cSrcweir FontAlign eAlg( aFnt.GetAlign() );
1018cdf0e10cSrcweir
10198718d260SArmin Le Grand sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX );
10208718d260SArmin Le Grand sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY );
1021cdf0e10cSrcweir //sal_Int32 nDxWidth = 0;
1022cdf0e10cSrcweir //sal_Int32 nLen = rStr.Len();
1023cdf0e10cSrcweir
10248718d260SArmin Le Grand Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) );
1025cdf0e10cSrcweir Size aSize( nTextWidth, nTextHeight );
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir if ( eAlg == ALIGN_BASELINE )
10288718d260SArmin Le Grand aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
1029cdf0e10cSrcweir else if ( eAlg == ALIGN_BOTTOM )
1030cdf0e10cSrcweir aPos.Y() -= nTextHeight;
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir Rectangle aTextRect( aPos, aSize );
1033cdf0e10cSrcweir SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
1034cdf0e10cSrcweir
1035674b939bSArmin Le Grand pText->SetMergedItem ( SdrTextUpperDistItem (0));
1036674b939bSArmin Le Grand pText->SetMergedItem ( SdrTextLowerDistItem (0));
1037674b939bSArmin Le Grand pText->SetMergedItem ( SdrTextRightDistItem (0));
1038674b939bSArmin Le Grand pText->SetMergedItem ( SdrTextLeftDistItem (0));
1039674b939bSArmin Le Grand
1040cdf0e10cSrcweir if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
10438718d260SArmin Le Grand pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
1044cdf0e10cSrcweir // don't let the margins eat the space needed for the text
104526734c99SArmin Le Grand pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir else
1048674b939bSArmin Le Grand {
10498718d260SArmin Le Grand pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) );
1050674b939bSArmin Le Grand }
1051cdf0e10cSrcweir
10528718d260SArmin Le Grand pText->SetModel(mpModel);
10538718d260SArmin Le Grand pText->SetLayer(mnLayer);
1054cdf0e10cSrcweir pText->NbcSetText( rStr );
10558718d260SArmin Le Grand SetAttributes( pText, true );
1056cdf0e10cSrcweir pText->SetSnapRect( aTextRect );
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir if (!aFnt.IsTransparent())
1059cdf0e10cSrcweir {
10608718d260SArmin Le Grand SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
1061cdf0e10cSrcweir aAttr.Put(XFillStyleItem(XFILL_SOLID));
1062cdf0e10cSrcweir aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
1063cdf0e10cSrcweir pText->SetMergedItemSet(aAttr);
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir sal_uInt32 nWink = aFnt.GetOrientation();
1066cdf0e10cSrcweir if ( nWink )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir nWink*=10;
1069cdf0e10cSrcweir double a=nWink*nPi180;
1070cdf0e10cSrcweir double nSin=sin(a);
1071cdf0e10cSrcweir double nCos=cos(a);
1072cdf0e10cSrcweir pText->NbcRotate(aPos,nWink,nSin,nCos);
1073cdf0e10cSrcweir }
10748718d260SArmin Le Grand InsertObj( pText, false );
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
DoAction(MetaTextAction & rAct)1077cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir XubString aStr(rAct.GetText());
1080cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex());
1081cdf0e10cSrcweir aStr.Erase(rAct.GetLen());
1082cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct );
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir
DoAction(MetaTextArrayAction & rAct)1085cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir XubString aStr(rAct.GetText());
1088cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex());
1089cdf0e10cSrcweir aStr.Erase(rAct.GetLen());
1090cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct );
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir
DoAction(MetaStretchTextAction & rAct)1093cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir XubString aStr(rAct.GetText());
1096cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex());
1097cdf0e10cSrcweir aStr.Erase(rAct.GetLen());
1098cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct );
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir
DoAction(MetaBmpAction & rAct)1101cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
1104cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++;
1105cdf0e10cSrcweir SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1106468982e4SArmin Le Grand
1107468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1108468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1109468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1110cdf0e10cSrcweir InsertObj(pGraf);
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir
DoAction(MetaBmpScaleAction & rAct)1113cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1116cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++;
1117cdf0e10cSrcweir SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1118468982e4SArmin Le Grand
1119468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1120468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1121468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1122cdf0e10cSrcweir InsertObj(pGraf);
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir
DoAction(MetaBmpExAction & rAct)1125cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
1128cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++;
1129cdf0e10cSrcweir SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1130468982e4SArmin Le Grand
1131468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1132468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1133468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1134cdf0e10cSrcweir InsertObj(pGraf);
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir
DoAction(MetaBmpExScaleAction & rAct)1137cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1140cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++;
1141cdf0e10cSrcweir SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1142468982e4SArmin Le Grand
1143468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1144468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1145468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
1146cdf0e10cSrcweir InsertObj(pGraf);
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1150cdf0e10cSrcweir
DoAction(MetaHatchAction & rAct)1151cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
1154cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir if(aSource.count())
1157cdf0e10cSrcweir {
11588718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1159cdf0e10cSrcweir aSource.transform(aTransform);
1160cdf0e10cSrcweir
11618718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir const Hatch& rHatch = rAct.GetHatch();
1164cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1165*690281a1SArmin Le Grand // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
1166*690281a1SArmin Le Grand SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
1167cdf0e10cSrcweir XHatchStyle eStyle;
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir switch(rHatch.GetStyle())
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir case(HATCH_TRIPLE) :
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir eStyle = XHATCH_TRIPLE;
1174cdf0e10cSrcweir break;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir case(HATCH_DOUBLE) :
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir eStyle = XHATCH_DOUBLE;
1180cdf0e10cSrcweir break;
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir default:
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir eStyle = XHATCH_SINGLE;
1186cdf0e10cSrcweir break;
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir SetAttributes(pPath);
1191cdf0e10cSrcweir aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
11928718d260SArmin Le Grand aHatchAttr.Put(XFillHatchItem(&mpModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
1193cdf0e10cSrcweir pPath->SetMergedItemSet(aHatchAttr);
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir InsertObj(pPath, false);
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1201cdf0e10cSrcweir
DoAction(MetaLineColorAction & rAct)1202cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
1203cdf0e10cSrcweir {
12048718d260SArmin Le Grand rAct.Execute(&maVD);
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir
DoAction(MetaMapModeAction & rAct)1207cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir MapScaling();
12108718d260SArmin Le Grand rAct.Execute(&maVD);
12118718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = false;
12128718d260SArmin Le Grand mbLastObjWasLine = false;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir
MapScaling()1215cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling()
1216cdf0e10cSrcweir {
12178718d260SArmin Le Grand const sal_uInt32 nAnz(maTmpList.size());
12188718d260SArmin Le Grand sal_uInt32 i(0);
12198718d260SArmin Le Grand const MapMode& rMap = maVD.GetMapMode();
1220cdf0e10cSrcweir Point aMapOrg( rMap.GetOrigin() );
12218718d260SArmin Le Grand bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0);
12228718d260SArmin Le Grand
1223cdf0e10cSrcweir if(bMov2)
1224cdf0e10cSrcweir {
12258718d260SArmin Le Grand for(i = mnMapScalingOfs; i < nAnz; i++)
1226cdf0e10cSrcweir {
12278718d260SArmin Le Grand SdrObject* pObj = maTmpList[i];
12288718d260SArmin Le Grand
1229cdf0e10cSrcweir pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir }
12328718d260SArmin Le Grand
12338718d260SArmin Le Grand mnMapScalingOfs = nAnz;
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir
1236cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1237cdf0e10cSrcweir
DoAction(MetaCommentAction & rAct,GDIMetaFile & rMtf,sal_uLong & a)1238*690281a1SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile& rMtf, sal_uLong& a) // GDIMetaFile* pMtf )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir ByteString aSkipComment;
1241cdf0e10cSrcweir
1242*690281a1SArmin Le Grand if( a < rMtf.GetActionCount() && rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1243cdf0e10cSrcweir {
1244*690281a1SArmin Le Grand // #i125211# Check if next action is a MetaGradientExAction
1245*690281a1SArmin Le Grand MetaGradientExAction* pAct = dynamic_cast< MetaGradientExAction* >(rMtf.GetAction(a + 1));
1246cdf0e10cSrcweir
1247cdf0e10cSrcweir if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes
1250cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir if(aSource.count())
1253cdf0e10cSrcweir {
12548718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir const Gradient& rGrad = pAct->GetGradient();
1257cdf0e10cSrcweir SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1258*690281a1SArmin Le Grand // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
1259*690281a1SArmin Le Grand SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
1260cdf0e10cSrcweir XGradient aXGradient;
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
1263cdf0e10cSrcweir aXGradient.SetStartColor(rGrad.GetStartColor());
1264cdf0e10cSrcweir aXGradient.SetEndColor(rGrad.GetEndColor());
1265cdf0e10cSrcweir aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
1266cdf0e10cSrcweir aXGradient.SetBorder(rGrad.GetBorder());
1267cdf0e10cSrcweir aXGradient.SetXOffset(rGrad.GetOfsX());
1268cdf0e10cSrcweir aXGradient.SetYOffset(rGrad.GetOfsY());
1269cdf0e10cSrcweir aXGradient.SetStartIntens(rGrad.GetStartIntensity());
1270cdf0e10cSrcweir aXGradient.SetEndIntens(rGrad.GetEndIntensity());
1271cdf0e10cSrcweir aXGradient.SetSteps(rGrad.GetSteps());
1272cdf0e10cSrcweir
1273468982e4SArmin Le Grand // no need to use SetAttributes(..) here since line and fill style
1274468982e4SArmin Le Grand // need to be set individually
1275468982e4SArmin Le Grand // SetAttributes(pPath);
1276468982e4SArmin Le Grand
1277cdf0e10cSrcweir // switch line off; when there was one there will be a
1278cdf0e10cSrcweir // META_POLYLINE_ACTION following creating another object
1279468982e4SArmin Le Grand aGradAttr.Put(XLineStyleItem(XLINE_NONE));
1280cdf0e10cSrcweir
1281468982e4SArmin Le Grand // add detected gradient fillstyle
1282cdf0e10cSrcweir aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
12838718d260SArmin Le Grand aGradAttr.Put(XFillGradientItem(&mpModel->GetItemPool(), aXGradient));
1284468982e4SArmin Le Grand
1285cdf0e10cSrcweir pPath->SetMergedItemSet(aGradAttr);
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir InsertObj(pPath);
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir }
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir aSkipComment = "XGRAD_SEQ_END";
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir if(aSkipComment.Len())
1296cdf0e10cSrcweir {
1297*690281a1SArmin Le Grand // #i125211# forward until closing MetaCommentAction
1298*690281a1SArmin Le Grand MetaAction* pSkipAct = rMtf.GetAction(++a);
1299cdf0e10cSrcweir
1300cdf0e10cSrcweir while( pSkipAct
1301cdf0e10cSrcweir && ((pSkipAct->GetType() != META_COMMENT_ACTION )
1302cdf0e10cSrcweir || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
1303cdf0e10cSrcweir {
1304*690281a1SArmin Le Grand pSkipAct = rMtf.GetAction(++a);
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
13108718d260SArmin Le Grand
DoAction(MetaTextRectAction & rAct)13118718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
13128718d260SArmin Le Grand {
13138718d260SArmin Le Grand GDIMetaFile aTemp;
13148718d260SArmin Le Grand
13158718d260SArmin Le Grand maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
13168718d260SArmin Le Grand DoLoopActions(aTemp, 0, 0);
13178718d260SArmin Le Grand }
13188718d260SArmin Le Grand
DoAction(MetaBmpScalePartAction & rAct)13198718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
13208718d260SArmin Le Grand {
13218718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
13228718d260SArmin Le Grand Bitmap aBitmap(rAct.GetBitmap());
13238718d260SArmin Le Grand
13248718d260SArmin Le Grand aRect.Right()++;
13258718d260SArmin Le Grand aRect.Bottom()++;
13268718d260SArmin Le Grand aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13278718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
13288718d260SArmin Le Grand
1329468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1330468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1331468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13328718d260SArmin Le Grand InsertObj(pGraf);
13338718d260SArmin Le Grand }
13348718d260SArmin Le Grand
DoAction(MetaBmpExScalePartAction & rAct)13358718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
13368718d260SArmin Le Grand {
13378718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(),rAct.GetDestSize());
13388718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmapEx());
13398718d260SArmin Le Grand
13408718d260SArmin Le Grand aRect.Right()++;
13418718d260SArmin Le Grand aRect.Bottom()++;
13428718d260SArmin Le Grand aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13438718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13448718d260SArmin Le Grand
1345468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1346468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1347468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13488718d260SArmin Le Grand InsertObj(pGraf);
13498718d260SArmin Le Grand }
13508718d260SArmin Le Grand
DoAction(MetaMaskAction & rAct)13518718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
13528718d260SArmin Le Grand {
13538718d260SArmin Le Grand Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
13548718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13558718d260SArmin Le Grand
1356468982e4SArmin Le Grand aRect.Right()++; aRect.Bottom()++;
13578718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13588718d260SArmin Le Grand
1359468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1360468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1361468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13628718d260SArmin Le Grand InsertObj(pGraf);
13638718d260SArmin Le Grand }
13648718d260SArmin Le Grand
DoAction(MetaMaskScaleAction & rAct)13658718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
13668718d260SArmin Le Grand {
13678718d260SArmin Le Grand Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
13688718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13698718d260SArmin Le Grand
1370468982e4SArmin Le Grand aRect.Right()++; aRect.Bottom()++;
13718718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13728718d260SArmin Le Grand
1373468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1374468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1375468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13768718d260SArmin Le Grand InsertObj(pGraf);
13778718d260SArmin Le Grand }
13788718d260SArmin Le Grand
DoAction(MetaMaskScalePartAction & rAct)13798718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
13808718d260SArmin Le Grand {
13818718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
13828718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
13838718d260SArmin Le Grand
1384468982e4SArmin Le Grand aRect.Right()++; aRect.Bottom()++;
13858718d260SArmin Le Grand aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
13868718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
13878718d260SArmin Le Grand
1388468982e4SArmin Le Grand // This action is not creating line and fill, set directly, do not use SetAttributes(..)
1389468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1390468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
13918718d260SArmin Le Grand InsertObj(pGraf);
13928718d260SArmin Le Grand }
13938718d260SArmin Le Grand
getXGradientStyleFromGradientStyle(const GradientStyle & rGradientStyle)1394603e43faSArmin Le Grand XGradientStyle getXGradientStyleFromGradientStyle(const GradientStyle& rGradientStyle)
1395603e43faSArmin Le Grand {
1396603e43faSArmin Le Grand XGradientStyle aXGradientStyle(XGRAD_LINEAR);
1397603e43faSArmin Le Grand
1398603e43faSArmin Le Grand switch(rGradientStyle)
1399603e43faSArmin Le Grand {
1400603e43faSArmin Le Grand case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
1401603e43faSArmin Le Grand case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
1402603e43faSArmin Le Grand case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
1403603e43faSArmin Le Grand case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
1404603e43faSArmin Le Grand case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
1405603e43faSArmin Le Grand case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
1406603e43faSArmin Le Grand
1407603e43faSArmin Le Grand // Needed due to GRADIENT_FORCE_EQUAL_SIZE; this again is needed
1408603e43faSArmin Le Grand // to force the enum defines in VCL to a defined size for the compilers,
1409603e43faSArmin Le Grand // so despite it is never used it cannot be removed (would break the
1410603e43faSArmin Le Grand // API implementation probably).
1411603e43faSArmin Le Grand default: break;
1412603e43faSArmin Le Grand }
1413603e43faSArmin Le Grand
1414603e43faSArmin Le Grand return aXGradientStyle;
1415603e43faSArmin Le Grand }
1416603e43faSArmin Le Grand
DoAction(MetaGradientAction & rAct)14178718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
14188718d260SArmin Le Grand {
14198718d260SArmin Le Grand basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom());
14208718d260SArmin Le Grand
14218718d260SArmin Le Grand if(!aRange.isEmpty())
14228718d260SArmin Le Grand {
14238718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14248718d260SArmin Le Grand aRange.transform(aTransform);
14258718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient();
14268718d260SArmin Le Grand SdrRectObj* pRect = new SdrRectObj(
14278718d260SArmin Le Grand Rectangle(
14288718d260SArmin Le Grand floor(aRange.getMinX()),
14298718d260SArmin Le Grand floor(aRange.getMinY()),
14308718d260SArmin Le Grand ceil(aRange.getMaxX()),
14318718d260SArmin Le Grand ceil(aRange.getMaxY())));
1432*690281a1SArmin Le Grand // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
1433*690281a1SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), pRect->GetMergedItemSet().GetRanges());
1434603e43faSArmin Le Grand const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
14358718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem(
14368718d260SArmin Le Grand &mpModel->GetItemPool(),
14378718d260SArmin Le Grand XGradient(
14388718d260SArmin Le Grand rGradient.GetStartColor(),
14398718d260SArmin Le Grand rGradient.GetEndColor(),
14408718d260SArmin Le Grand aXGradientStyle,
14418718d260SArmin Le Grand rGradient.GetAngle(),
14428718d260SArmin Le Grand rGradient.GetOfsX(),
14438718d260SArmin Le Grand rGradient.GetOfsY(),
14448718d260SArmin Le Grand rGradient.GetBorder(),
14458718d260SArmin Le Grand rGradient.GetStartIntensity(),
14468718d260SArmin Le Grand rGradient.GetEndIntensity(),
14478718d260SArmin Le Grand rGradient.GetSteps()));
14488718d260SArmin Le Grand
14498718d260SArmin Le Grand SetAttributes(pRect);
1450*690281a1SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_GRADIENT)); // #i125211#
14518718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem);
14528718d260SArmin Le Grand pRect->SetMergedItemSet(aGradientAttr);
14538718d260SArmin Le Grand
14548718d260SArmin Le Grand InsertObj(pRect, false);
14558718d260SArmin Le Grand }
14568718d260SArmin Le Grand }
14578718d260SArmin Le Grand
DoAction(MetaWallpaperAction &)1458603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& /*rAct*/)
14598718d260SArmin Le Grand {
14608718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)");
14618718d260SArmin Le Grand }
14628718d260SArmin Le Grand
DoAction(MetaTransparentAction & rAct)14638718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct)
14648718d260SArmin Le Grand {
14658718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
14668718d260SArmin Le Grand
14678718d260SArmin Le Grand if(aSource.count())
14688718d260SArmin Le Grand {
14698718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14708718d260SArmin Le Grand aSource.transform(aTransform);
14718718d260SArmin Le Grand aSource.setClosed(true);
14728718d260SArmin Le Grand
14738718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
14748718d260SArmin Le Grand SetAttributes(pPath);
14758718d260SArmin Le Grand pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
14768718d260SArmin Le Grand InsertObj(pPath, false);
14778718d260SArmin Le Grand }
14788718d260SArmin Le Grand }
14798718d260SArmin Le Grand
DoAction(MetaEPSAction &)1480603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& /*rAct*/)
14818718d260SArmin Le Grand {
14828718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)");
14838718d260SArmin Le Grand }
14848718d260SArmin Le Grand
DoAction(MetaTextLineAction &)1485603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& /*rAct*/)
14868718d260SArmin Le Grand {
14878718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)");
14888718d260SArmin Le Grand }
14898718d260SArmin Le Grand
DoAction(MetaGradientExAction & rAct)14908718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
14918718d260SArmin Le Grand {
14928718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
14938718d260SArmin Le Grand
14948718d260SArmin Le Grand if(aSource.count())
14958718d260SArmin Le Grand {
14968718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
14978718d260SArmin Le Grand aSource.transform(aTransform);
14988718d260SArmin Le Grand
14998718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
15008718d260SArmin Le Grand {
15018718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient();
15028718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
1503*690281a1SArmin Le Grand // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
1504*690281a1SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
1505603e43faSArmin Le Grand const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
15068718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem(
15078718d260SArmin Le Grand &mpModel->GetItemPool(),
15088718d260SArmin Le Grand XGradient(
15098718d260SArmin Le Grand rGradient.GetStartColor(),
15108718d260SArmin Le Grand rGradient.GetEndColor(),
15118718d260SArmin Le Grand aXGradientStyle,
15128718d260SArmin Le Grand rGradient.GetAngle(),
15138718d260SArmin Le Grand rGradient.GetOfsX(),
15148718d260SArmin Le Grand rGradient.GetOfsY(),
15158718d260SArmin Le Grand rGradient.GetBorder(),
15168718d260SArmin Le Grand rGradient.GetStartIntensity(),
15178718d260SArmin Le Grand rGradient.GetEndIntensity(),
15188718d260SArmin Le Grand rGradient.GetSteps()));
15198718d260SArmin Le Grand
15208718d260SArmin Le Grand SetAttributes(pPath);
1521*690281a1SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_GRADIENT)); // #i125211#
15228718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem);
15238718d260SArmin Le Grand pPath->SetMergedItemSet(aGradientAttr);
15248718d260SArmin Le Grand
15258718d260SArmin Le Grand InsertObj(pPath, false);
15268718d260SArmin Le Grand }
15278718d260SArmin Le Grand }
15288718d260SArmin Le Grand }
15298718d260SArmin Le Grand
DoAction(MetaFloatTransparentAction & rAct)15308718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
15318718d260SArmin Le Grand {
15328718d260SArmin Le Grand const GDIMetaFile& rMtf = rAct.GetGDIMetaFile();
15338718d260SArmin Le Grand
15348718d260SArmin Le Grand if(rMtf.GetActionCount())
15358718d260SArmin Le Grand {
15369f63b866SArmin Le Grand const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
15378718d260SArmin Le Grand
1538468982e4SArmin Le Grand Rectangle aHairline;
1539468982e4SArmin Le Grand const Rectangle aBoundRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairline));
1540468982e4SArmin Le Grand
15419f63b866SArmin Le Grand // convert metafile sub-content to BitmapEx
15429f63b866SArmin Le Grand BitmapEx aBitmapEx(
15439f63b866SArmin Le Grand convertMetafileToBitmapEx(
15449f63b866SArmin Le Grand rMtf,
15459f63b866SArmin Le Grand basegfx::B2DRange(
15469f63b866SArmin Le Grand aRect.Left(), aRect.Top(),
15479f63b866SArmin Le Grand aRect.Right(), aRect.Bottom()),
15489f63b866SArmin Le Grand 125000));
15498718d260SArmin Le Grand
15508718d260SArmin Le Grand // handle colors
15518718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient();
15528718d260SArmin Le Grand basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
15538718d260SArmin Le Grand basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
15548718d260SArmin Le Grand
15558718d260SArmin Le Grand if(100 != rGradient.GetStartIntensity())
15568718d260SArmin Le Grand {
15578718d260SArmin Le Grand aStart *= (double)rGradient.GetStartIntensity() / 100.0;
15588718d260SArmin Le Grand }
15598718d260SArmin Le Grand
15608718d260SArmin Le Grand if(100 != rGradient.GetEndIntensity())
15618718d260SArmin Le Grand {
15628718d260SArmin Le Grand aEnd *= (double)rGradient.GetEndIntensity() / 100.0;
15638718d260SArmin Le Grand }
15648718d260SArmin Le Grand
15658718d260SArmin Le Grand const bool bEqualColors(aStart == aEnd);
15668718d260SArmin Le Grand const bool bNoSteps(1 == rGradient.GetSteps());
15678718d260SArmin Le Grand bool bCreateObject(true);
15688718d260SArmin Le Grand bool bHasNewMask(false);
15698718d260SArmin Le Grand AlphaMask aNewMask;
15709f63b866SArmin Le Grand double fTransparence(0.0);
15719f63b866SArmin Le Grand bool bFixedTransparence(false);
15728718d260SArmin Le Grand
15738718d260SArmin Le Grand if(bEqualColors || bNoSteps)
15748718d260SArmin Le Grand {
15758718d260SArmin Le Grand // single transparence
15768718d260SArmin Le Grand const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
15779f63b866SArmin Le Grand fTransparence = aMedium.luminance();
15788718d260SArmin Le Grand
15798718d260SArmin Le Grand if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
15808718d260SArmin Le Grand {
15818718d260SArmin Le Grand // no transparence needed, all done
15828718d260SArmin Le Grand }
15838718d260SArmin Le Grand else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0))
15848718d260SArmin Le Grand {
15858718d260SArmin Le Grand // all transparent, no object
15868718d260SArmin Le Grand bCreateObject = false;
15878718d260SArmin Le Grand }
15888718d260SArmin Le Grand else
15898718d260SArmin Le Grand {
15909f63b866SArmin Le Grand // 0.0 < transparence < 1.0, apply fixed transparence
15919f63b866SArmin Le Grand bFixedTransparence = true;
15928718d260SArmin Le Grand }
15938718d260SArmin Le Grand }
15948718d260SArmin Le Grand else
15958718d260SArmin Le Grand {
15968718d260SArmin Le Grand // gradient transparence
15978718d260SArmin Le Grand VirtualDevice aVDev;
15988718d260SArmin Le Grand
15998718d260SArmin Le Grand aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
16008718d260SArmin Le Grand aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
16018718d260SArmin Le Grand
16028718d260SArmin Le Grand aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
16038718d260SArmin Le Grand bHasNewMask = true;
16048718d260SArmin Le Grand }
16058718d260SArmin Le Grand
16068718d260SArmin Le Grand if(bCreateObject)
16078718d260SArmin Le Grand {
16089f63b866SArmin Le Grand if(bHasNewMask || bFixedTransparence)
16098718d260SArmin Le Grand {
16108718d260SArmin Le Grand if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
16118718d260SArmin Le Grand {
16128718d260SArmin Le Grand // no transparence yet, apply new one
16139f63b866SArmin Le Grand if(bFixedTransparence)
16149f63b866SArmin Le Grand {
16159f63b866SArmin Le Grand sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
16169f63b866SArmin Le Grand
16179f63b866SArmin Le Grand aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
16189f63b866SArmin Le Grand }
16199f63b866SArmin Le Grand
16208718d260SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
16218718d260SArmin Le Grand }
16228718d260SArmin Le Grand else
16238718d260SArmin Le Grand {
16248718d260SArmin Le Grand // mix existing and new alpha mask
16258718d260SArmin Le Grand AlphaMask aOldMask;
16268718d260SArmin Le Grand
16278718d260SArmin Le Grand if(aBitmapEx.IsAlpha())
16288718d260SArmin Le Grand {
16298718d260SArmin Le Grand aOldMask = aBitmapEx.GetAlpha();
16308718d260SArmin Le Grand }
16318718d260SArmin Le Grand else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType())
16328718d260SArmin Le Grand {
16338718d260SArmin Le Grand aOldMask = aBitmapEx.GetMask();
16348718d260SArmin Le Grand }
16358718d260SArmin Le Grand else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType())
16368718d260SArmin Le Grand {
16378718d260SArmin Le Grand aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
16388718d260SArmin Le Grand }
16398718d260SArmin Le Grand
16409f63b866SArmin Le Grand BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
16418718d260SArmin Le Grand
16429f63b866SArmin Le Grand if(pOld)
16439f63b866SArmin Le Grand {
16449f63b866SArmin Le Grand const double fFactor(1.0 / 255.0);
16459f63b866SArmin Le Grand
16469f63b866SArmin Le Grand if(bFixedTransparence)
16479f63b866SArmin Le Grand {
16489f63b866SArmin Le Grand const double fOpNew(1.0 - fTransparence);
16499f63b866SArmin Le Grand
1650603e43faSArmin Le Grand for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
16519f63b866SArmin Le Grand {
1652603e43faSArmin Le Grand for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
16539f63b866SArmin Le Grand {
16549f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
16559f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
16569f63b866SArmin Le Grand
16579f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol));
16589f63b866SArmin Le Grand }
16599f63b866SArmin Le Grand }
16609f63b866SArmin Le Grand }
16619f63b866SArmin Le Grand else
16629f63b866SArmin Le Grand {
16639f63b866SArmin Le Grand BitmapReadAccess* pNew = aNewMask.AcquireReadAccess();
16649f63b866SArmin Le Grand
16659f63b866SArmin Le Grand if(pNew)
16668718d260SArmin Le Grand {
16678718d260SArmin Le Grand if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height())
16688718d260SArmin Le Grand {
1669603e43faSArmin Le Grand for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
16708718d260SArmin Le Grand {
1671603e43faSArmin Le Grand for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
16728718d260SArmin Le Grand {
16739f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
16749f63b866SArmin Le Grand const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor));
16759f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
16768718d260SArmin Le Grand
16779f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol));
16788718d260SArmin Le Grand }
16798718d260SArmin Le Grand }
16808718d260SArmin Le Grand }
16818718d260SArmin Le Grand else
16828718d260SArmin Le Grand {
16838718d260SArmin Le Grand OSL_ENSURE(false, "Alpha masks have different sizes (!)");
16848718d260SArmin Le Grand }
16858718d260SArmin Le Grand
16868718d260SArmin Le Grand aNewMask.ReleaseAccess(pNew);
16878718d260SArmin Le Grand }
16888718d260SArmin Le Grand else
16898718d260SArmin Le Grand {
16909f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to new alpha mask (!)");
16919f63b866SArmin Le Grand }
16929f63b866SArmin Le Grand }
16939f63b866SArmin Le Grand
16949f63b866SArmin Le Grand aOldMask.ReleaseAccess(pOld);
16959f63b866SArmin Le Grand }
16969f63b866SArmin Le Grand else
16979f63b866SArmin Le Grand {
16989f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to old alpha mask (!)");
16998718d260SArmin Le Grand }
17008718d260SArmin Le Grand
17018718d260SArmin Le Grand // apply combined bitmap as mask
17029f63b866SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
17038718d260SArmin Le Grand }
17048718d260SArmin Le Grand }
17058718d260SArmin Le Grand
17068718d260SArmin Le Grand // create and add object
17078718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
17088718d260SArmin Le Grand
1709468982e4SArmin Le Grand // for MetaFloatTransparentAction, do not use SetAttributes(...)
1710468982e4SArmin Le Grand // since these metafile content is not used to draw line/fill
1711468982e4SArmin Le Grand // dependent of these setting at the device content
1712468982e4SArmin Le Grand pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
1713468982e4SArmin Le Grand pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
17148718d260SArmin Le Grand InsertObj(pGraf);
17158718d260SArmin Le Grand }
17168718d260SArmin Le Grand }
17178718d260SArmin Le Grand }
17188718d260SArmin Le Grand
17198718d260SArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
1720cdf0e10cSrcweir // eof
1721