xref: /AOO42X/main/svx/source/svdraw/svdfmtf.cxx (revision 603e43faaee35b03f187156765ac1d8b75cf2a41)
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>
78cdf0e10cSrcweir 
79cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
80cdf0e10cSrcweir 
818718d260SArmin Le Grand ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
828718d260SArmin Le Grand     SdrModel& rModel,
838718d260SArmin Le Grand     SdrLayerID nLay,
848718d260SArmin Le Grand     const Rectangle& rRect)
858718d260SArmin Le Grand :   maTmpList(),
868718d260SArmin Le Grand     maVD(),
878718d260SArmin Le Grand     maScaleRect(rRect),
888718d260SArmin Le Grand     mnMapScalingOfs(0),
898718d260SArmin Le Grand     mpLineAttr(0),
908718d260SArmin Le Grand     mpFillAttr(0),
918718d260SArmin Le Grand     mpTextAttr(0),
928718d260SArmin Le Grand     mpModel(&rModel),
938718d260SArmin Le Grand     mnLayer(nLay),
948718d260SArmin Le Grand     maOldLineColor(),
958718d260SArmin Le Grand     mnLineWidth(0),
96cdf0e10cSrcweir     maLineJoin(basegfx::B2DLINEJOIN_NONE),
975aaf853bSArmin Le Grand     maLineCap(com::sun::star::drawing::LineCap_BUTT),
98cdf0e10cSrcweir     maDash(XDASH_RECT, 0, 0, 0, 0, 0),
998718d260SArmin Le Grand     mbMov(false),
1008718d260SArmin Le Grand     mbSize(false),
1018718d260SArmin Le Grand     maOfs(0, 0),
1028718d260SArmin Le Grand     mfScaleX(1.0),
1038718d260SArmin Le Grand     mfScaleY(1.0),
1048718d260SArmin Le Grand     maScaleX(1.0),
1058718d260SArmin Le Grand     maScaleY(1.0),
1068718d260SArmin Le Grand     mbFntDirty(true),
1078718d260SArmin Le Grand     mbLastObjWasPolyWithoutLine(false),
1088718d260SArmin Le Grand     mbNoLine(false),
1098718d260SArmin Le Grand     mbNoFill(false),
1108718d260SArmin Le Grand     mbLastObjWasLine(false),
11147a7c0c1SArmin Le Grand     maClip()
112cdf0e10cSrcweir {
1138718d260SArmin Le Grand     maVD.EnableOutput(false);
1148718d260SArmin Le Grand     maVD.SetLineColor();
1158718d260SArmin Le Grand     maVD.SetFillColor();
1168718d260SArmin Le Grand     maOldLineColor.SetRed( maVD.GetLineColor().GetRed() + 1 );
1178718d260SArmin Le Grand     mpLineAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_LINE_FIRST, XATTR_LINE_LAST, 0, 0);
1188718d260SArmin Le Grand     mpFillAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
1198718d260SArmin Le Grand     mpTextAttr = new SfxItemSet(rModel.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END, 0, 0);
12047a7c0c1SArmin Le Grand     checkClip();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
124cdf0e10cSrcweir {
1258718d260SArmin Le Grand     delete mpLineAttr;
1268718d260SArmin Le Grand     delete mpFillAttr;
1278718d260SArmin Le Grand     delete mpTextAttr;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
1308718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
131cdf0e10cSrcweir {
1328718d260SArmin Le Grand     for( MetaAction* pAct = rMtf.FirstAction(); pAct; pAct = rMtf.NextAction() )
133cdf0e10cSrcweir     {
134cdf0e10cSrcweir         switch (pAct->GetType())
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             case META_PIXEL_ACTION          : DoAction((MetaPixelAction          &)*pAct); break;
137cdf0e10cSrcweir             case META_POINT_ACTION          : DoAction((MetaPointAction          &)*pAct); break;
138cdf0e10cSrcweir             case META_LINE_ACTION           : DoAction((MetaLineAction           &)*pAct); break;
139cdf0e10cSrcweir             case META_RECT_ACTION           : DoAction((MetaRectAction           &)*pAct); break;
140cdf0e10cSrcweir             case META_ROUNDRECT_ACTION      : DoAction((MetaRoundRectAction      &)*pAct); break;
141cdf0e10cSrcweir             case META_ELLIPSE_ACTION        : DoAction((MetaEllipseAction        &)*pAct); break;
142cdf0e10cSrcweir             case META_ARC_ACTION            : DoAction((MetaArcAction            &)*pAct); break;
143cdf0e10cSrcweir             case META_PIE_ACTION            : DoAction((MetaPieAction            &)*pAct); break;
144cdf0e10cSrcweir             case META_CHORD_ACTION          : DoAction((MetaChordAction          &)*pAct); break;
145cdf0e10cSrcweir             case META_POLYLINE_ACTION       : DoAction((MetaPolyLineAction       &)*pAct); break;
146cdf0e10cSrcweir             case META_POLYGON_ACTION        : DoAction((MetaPolygonAction        &)*pAct); break;
147cdf0e10cSrcweir             case META_POLYPOLYGON_ACTION    : DoAction((MetaPolyPolygonAction    &)*pAct); break;
148cdf0e10cSrcweir             case META_TEXT_ACTION           : DoAction((MetaTextAction           &)*pAct); break;
149cdf0e10cSrcweir             case META_TEXTARRAY_ACTION      : DoAction((MetaTextArrayAction      &)*pAct); break;
150cdf0e10cSrcweir             case META_STRETCHTEXT_ACTION    : DoAction((MetaStretchTextAction    &)*pAct); break;
151cdf0e10cSrcweir             case META_BMP_ACTION            : DoAction((MetaBmpAction            &)*pAct); break;
152cdf0e10cSrcweir             case META_BMPSCALE_ACTION       : DoAction((MetaBmpScaleAction       &)*pAct); break;
153cdf0e10cSrcweir             case META_BMPEX_ACTION          : DoAction((MetaBmpExAction          &)*pAct); break;
154cdf0e10cSrcweir             case META_BMPEXSCALE_ACTION     : DoAction((MetaBmpExScaleAction     &)*pAct); break;
155cdf0e10cSrcweir             case META_LINECOLOR_ACTION      : DoAction((MetaLineColorAction      &)*pAct); break;
156cdf0e10cSrcweir             case META_FILLCOLOR_ACTION      : DoAction((MetaFillColorAction      &)*pAct); break;
157cdf0e10cSrcweir             case META_TEXTCOLOR_ACTION      : DoAction((MetaTextColorAction      &)*pAct); break;
158cdf0e10cSrcweir             case META_TEXTFILLCOLOR_ACTION  : DoAction((MetaTextFillColorAction  &)*pAct); break;
159cdf0e10cSrcweir             case META_FONT_ACTION           : DoAction((MetaFontAction           &)*pAct); break;
160cdf0e10cSrcweir             case META_TEXTALIGN_ACTION      : DoAction((MetaTextAlignAction      &)*pAct); break;
161cdf0e10cSrcweir             case META_MAPMODE_ACTION        : DoAction((MetaMapModeAction        &)*pAct); break;
162cdf0e10cSrcweir             case META_CLIPREGION_ACTION     : DoAction((MetaClipRegionAction     &)*pAct); break;
163cdf0e10cSrcweir             case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
164cdf0e10cSrcweir             case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
165cdf0e10cSrcweir             case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
166cdf0e10cSrcweir             case META_RASTEROP_ACTION       : DoAction((MetaRasterOpAction       &)*pAct); break;
167cdf0e10cSrcweir             case META_PUSH_ACTION           : DoAction((MetaPushAction           &)*pAct); break;
168cdf0e10cSrcweir             case META_POP_ACTION            : DoAction((MetaPopAction            &)*pAct); break;
169cdf0e10cSrcweir             case META_HATCH_ACTION          : DoAction((MetaHatchAction          &)*pAct); break;
1708718d260SArmin Le Grand             case META_COMMENT_ACTION        : DoAction((MetaCommentAction        &)*pAct, &rMtf); break;
1718718d260SArmin Le Grand 
1728718d260SArmin Le Grand             // missing actions added
1738718d260SArmin Le Grand             case META_TEXTRECT_ACTION       : DoAction((MetaTextRectAction&)*pAct); break;
1748718d260SArmin Le Grand             case META_BMPSCALEPART_ACTION   : DoAction((MetaBmpScalePartAction&)*pAct); break;
1758718d260SArmin Le Grand             case META_BMPEXSCALEPART_ACTION : DoAction((MetaBmpExScalePartAction&)*pAct); break;
1768718d260SArmin Le Grand             case META_MASK_ACTION           : DoAction((MetaMaskAction&)*pAct); break;
1778718d260SArmin Le Grand             case META_MASKSCALE_ACTION      : DoAction((MetaMaskScaleAction&)*pAct); break;
1788718d260SArmin Le Grand             case META_MASKSCALEPART_ACTION  : DoAction((MetaMaskScalePartAction&)*pAct); break;
1798718d260SArmin Le Grand             case META_GRADIENT_ACTION       : DoAction((MetaGradientAction&)*pAct); break;
1808718d260SArmin Le Grand             case META_WALLPAPER_ACTION      : DoAction((MetaWallpaperAction&)*pAct); break;
1818718d260SArmin Le Grand             case META_TRANSPARENT_ACTION    : DoAction((MetaTransparentAction&)*pAct); break;
1828718d260SArmin Le Grand             case META_EPS_ACTION            : DoAction((MetaEPSAction&)*pAct); break;
1838718d260SArmin Le Grand             case META_REFPOINT_ACTION       : DoAction((MetaRefPointAction&)*pAct); break;
1848718d260SArmin Le Grand             case META_TEXTLINECOLOR_ACTION  : DoAction((MetaTextLineColorAction&)*pAct); break;
1858718d260SArmin Le Grand             case META_TEXTLINE_ACTION       : DoAction((MetaTextLineAction&)*pAct); break;
1868718d260SArmin Le Grand             case META_FLOATTRANSPARENT_ACTION : DoAction((MetaFloatTransparentAction&)*pAct); break;
1878718d260SArmin Le Grand             case META_GRADIENTEX_ACTION     : DoAction((MetaGradientExAction&)*pAct); break;
1888718d260SArmin Le Grand             case META_LAYOUTMODE_ACTION     : DoAction((MetaLayoutModeAction&)*pAct); break;
1898718d260SArmin Le Grand             case META_TEXTLANGUAGE_ACTION   : DoAction((MetaTextLanguageAction&)*pAct); break;
1908718d260SArmin Le Grand             case META_OVERLINECOLOR_ACTION  : DoAction((MetaOverlineColorAction&)*pAct); break;
191cdf0e10cSrcweir         }
192cdf0e10cSrcweir 
1938718d260SArmin Le Grand         if(pProgrInfo && pActionsToReport)
194cdf0e10cSrcweir         {
1958718d260SArmin Le Grand             (*pActionsToReport)++;
1968718d260SArmin Le Grand 
1978718d260SArmin Le Grand             if(*pActionsToReport >= 16) // Alle 16 Action updaten
198cdf0e10cSrcweir             {
1998718d260SArmin Le Grand                 if(!pProgrInfo->ReportActions(*pActionsToReport))
200cdf0e10cSrcweir                     break;
2018718d260SArmin Le Grand 
2028718d260SArmin Le Grand                 *pActionsToReport = 0;
2038718d260SArmin Le Grand             }
204cdf0e10cSrcweir         }
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
2088718d260SArmin Le Grand sal_uInt32 ImpSdrGDIMetaFileImport::DoImport(
2098718d260SArmin Le Grand     const GDIMetaFile& rMtf,
2108718d260SArmin Le Grand     SdrObjList& rOL,
2118718d260SArmin Le Grand     sal_uInt32 nInsPos,
2128718d260SArmin Le Grand     SvdProgressInfo* pProgrInfo)
2138718d260SArmin Le Grand {
2148718d260SArmin Le Grand     // setup some global scale parameter
2158718d260SArmin Le Grand     // mfScaleX, mfScaleY, maScaleX, maScaleY, mbMov, mbSize
2168718d260SArmin Le Grand     mfScaleX = mfScaleY = 1.0;
2178718d260SArmin Le Grand     const Size aMtfSize(rMtf.GetPrefSize());
2188718d260SArmin Le Grand 
2198718d260SArmin Le Grand     if(aMtfSize.Width() & aMtfSize.Height() && (!maScaleRect.IsEmpty()))
2208718d260SArmin Le Grand     {
2218718d260SArmin Le Grand         maOfs = maScaleRect.TopLeft();
2228718d260SArmin Le Grand 
2238718d260SArmin Le Grand         if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2248718d260SArmin Le Grand         {
2258718d260SArmin Le Grand             mfScaleX = (double)( maScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
2268718d260SArmin Le Grand         }
2278718d260SArmin Le Grand 
2288718d260SArmin Le Grand         if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2298718d260SArmin Le Grand         {
2308718d260SArmin Le Grand             mfScaleY = (double)( maScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
2318718d260SArmin Le Grand         }
2328718d260SArmin Le Grand     }
2338718d260SArmin Le Grand 
2348718d260SArmin Le Grand     mbMov = maOfs.X()!=0 || maOfs.Y()!=0;
2358718d260SArmin Le Grand     mbSize = false;
2368718d260SArmin Le Grand     maScaleX = Fraction( 1, 1 );
2378718d260SArmin Le Grand     maScaleY = Fraction( 1, 1 );
2388718d260SArmin Le Grand 
2398718d260SArmin Le Grand     if(aMtfSize.Width() != (maScaleRect.GetWidth() - 1))
2408718d260SArmin Le Grand     {
2418718d260SArmin Le Grand         maScaleX = Fraction(maScaleRect.GetWidth() - 1, aMtfSize.Width());
2428718d260SArmin Le Grand         mbSize = true;
2438718d260SArmin Le Grand     }
2448718d260SArmin Le Grand 
2458718d260SArmin Le Grand     if(aMtfSize.Height() != (maScaleRect.GetHeight() - 1))
2468718d260SArmin Le Grand     {
2478718d260SArmin Le Grand         maScaleY = Fraction(maScaleRect.GetHeight() - 1, aMtfSize.Height());
2488718d260SArmin Le Grand         mbSize = true;
2498718d260SArmin Le Grand     }
2508718d260SArmin Le Grand 
2518718d260SArmin Le Grand     if(pProgrInfo)
2528718d260SArmin Le Grand     {
2538718d260SArmin Le Grand         pProgrInfo->SetActionCount(rMtf.GetActionCount());
2548718d260SArmin Le Grand     }
2558718d260SArmin Le Grand 
2568718d260SArmin Le Grand     sal_uInt32 nActionsToReport(0);
2578718d260SArmin Le Grand 
2588718d260SArmin Le Grand     // execute
2598718d260SArmin Le Grand     DoLoopActions(const_cast< GDIMetaFile& >(rMtf), pProgrInfo, &nActionsToReport);
2608718d260SArmin Le Grand 
2618718d260SArmin Le Grand     if(pProgrInfo)
262cdf0e10cSrcweir     {
263cdf0e10cSrcweir         pProgrInfo->ReportActions(nActionsToReport);
264cdf0e10cSrcweir         nActionsToReport = 0;
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     // MapMode-Scaling  vornehmen
268cdf0e10cSrcweir     MapScaling();
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     // Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
2718718d260SArmin Le Grand     // Da in maTmpList allerdings weniger eintraege als GetActionCount()
272cdf0e10cSrcweir     // existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
273cdf0e10cSrcweir     // hinzugefuegt werden.
2748718d260SArmin Le Grand     nActionsToReport = (rMtf.GetActionCount() - maTmpList.size()) * 2;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     // Alle noch nicht gemeldeten Rescales melden
277cdf0e10cSrcweir     if(pProgrInfo)
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         pProgrInfo->ReportRescales(nActionsToReport);
2808718d260SArmin Le Grand         pProgrInfo->SetInsertCount(maTmpList.size());
281cdf0e10cSrcweir     }
2828718d260SArmin Le Grand 
283cdf0e10cSrcweir     nActionsToReport = 0;
284cdf0e10cSrcweir 
2858718d260SArmin Le Grand     // alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
2868718d260SArmin Le Grand     if(nInsPos > rOL.GetObjCount())
287cdf0e10cSrcweir     {
2888718d260SArmin Le Grand         nInsPos = rOL.GetObjCount();
2898718d260SArmin Le Grand     }
2908718d260SArmin Le Grand 
2918718d260SArmin Le Grand     SdrInsertReason aReason(SDRREASON_VIEWCALL);
2928718d260SArmin Le Grand 
2938718d260SArmin Le Grand     for(sal_uInt32 i(0); i < maTmpList.size(); i++)
2948718d260SArmin Le Grand     {
2958718d260SArmin Le Grand         SdrObject* pObj = maTmpList[i];
296cdf0e10cSrcweir         rOL.NbcInsertObject(pObj, nInsPos, &aReason);
297cdf0e10cSrcweir         nInsPos++;
298cdf0e10cSrcweir 
2998718d260SArmin Le Grand         if(pProgrInfo)
300cdf0e10cSrcweir         {
301cdf0e10cSrcweir             nActionsToReport++;
3028718d260SArmin Le Grand 
303cdf0e10cSrcweir             if(nActionsToReport >= 32) // Alle 32 Action updaten
304cdf0e10cSrcweir             {
305cdf0e10cSrcweir                 pProgrInfo->ReportInserts(nActionsToReport);
306cdf0e10cSrcweir                 nActionsToReport = 0;
307cdf0e10cSrcweir             }
308cdf0e10cSrcweir         }
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     // ein letztesmal alle verbliebennen Inserts reporten
3128718d260SArmin Le Grand     if(pProgrInfo)
313cdf0e10cSrcweir     {
314cdf0e10cSrcweir         pProgrInfo->ReportInserts(nActionsToReport);
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir 
3178718d260SArmin Le Grand     return maTmpList.size();
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
3208718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
321cdf0e10cSrcweir {
3228718d260SArmin Le Grand     mbNoLine = false;
3238718d260SArmin Le Grand     mbNoFill = false;
3248718d260SArmin Le Grand     bool bLine(!bForceTextAttr);
3258718d260SArmin Le Grand     bool bFill(!pObj || (pObj->IsClosedObj() && !bForceTextAttr));
3268718d260SArmin Le Grand     bool bText(bForceTextAttr || (pObj && pObj->GetOutlinerParaObject()));
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     if(bLine)
329cdf0e10cSrcweir     {
3308718d260SArmin Le Grand         if(mnLineWidth)
331cdf0e10cSrcweir         {
3328718d260SArmin Le Grand             mpLineAttr->Put(XLineWidthItem(mnLineWidth));
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir         else
3358718d260SArmin Le Grand         {
3368718d260SArmin Le Grand             mpLineAttr->Put(XLineWidthItem(0));
3378718d260SArmin Le Grand         }
3388718d260SArmin Le Grand 
3398718d260SArmin Le Grand         maOldLineColor = maVD.GetLineColor();
3408718d260SArmin Le Grand 
3418718d260SArmin Le Grand         if(maVD.IsLineColor())
3428718d260SArmin Le Grand         {
3438718d260SArmin Le Grand             mpLineAttr->Put(XLineStyleItem(XLINE_SOLID));
3448718d260SArmin Le Grand             mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor()));
3458718d260SArmin Le Grand         }
3468718d260SArmin Le Grand         else
3478718d260SArmin Le Grand         {
3488718d260SArmin Le Grand             mpLineAttr->Put(XLineStyleItem(XLINE_NONE));
3498718d260SArmin Le Grand         }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir         switch(maLineJoin)
352cdf0e10cSrcweir         {
353cdf0e10cSrcweir             default : // basegfx::B2DLINEJOIN_NONE
3548718d260SArmin Le Grand                 mpLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
355cdf0e10cSrcweir                 break;
356cdf0e10cSrcweir             case basegfx::B2DLINEJOIN_MIDDLE:
3578718d260SArmin Le Grand                 mpLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
358cdf0e10cSrcweir                 break;
359cdf0e10cSrcweir             case basegfx::B2DLINEJOIN_BEVEL:
3608718d260SArmin Le Grand                 mpLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
361cdf0e10cSrcweir                 break;
362cdf0e10cSrcweir             case basegfx::B2DLINEJOIN_MITER:
3638718d260SArmin Le Grand                 mpLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
364cdf0e10cSrcweir                 break;
365cdf0e10cSrcweir             case basegfx::B2DLINEJOIN_ROUND:
3668718d260SArmin Le Grand                 mpLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
367cdf0e10cSrcweir                 break;
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir 
3705aaf853bSArmin Le Grand         // Add LineCap support
3718718d260SArmin Le Grand         mpLineAttr->Put(XLineCapItem(maLineCap));
3725aaf853bSArmin Le Grand 
373cdf0e10cSrcweir         if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
374cdf0e10cSrcweir         {
3758718d260SArmin Le Grand             mpLineAttr->Put(XLineDashItem(String(), maDash));
376cdf0e10cSrcweir         }
377cdf0e10cSrcweir         else
378cdf0e10cSrcweir         {
3798718d260SArmin Le Grand             mpLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
380cdf0e10cSrcweir         }
381cdf0e10cSrcweir     }
382cdf0e10cSrcweir     else
3838718d260SArmin Le Grand     {
3848718d260SArmin Le Grand         mbNoLine = true;
3858718d260SArmin Le Grand     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if(bFill)
388cdf0e10cSrcweir     {
3898718d260SArmin Le Grand         if(maVD.IsFillColor())
390cdf0e10cSrcweir         {
3918718d260SArmin Le Grand             mpFillAttr->Put(XFillStyleItem(XFILL_SOLID));
3928718d260SArmin Le Grand             mpFillAttr->Put(XFillColorItem(String(), maVD.GetFillColor()));
393cdf0e10cSrcweir         }
394cdf0e10cSrcweir         else
3958718d260SArmin Le Grand         {
3968718d260SArmin Le Grand             mpFillAttr->Put(XFillStyleItem(XFILL_NONE));
3978718d260SArmin Le Grand         }
398cdf0e10cSrcweir     }
399cdf0e10cSrcweir     else
4008718d260SArmin Le Grand     {
4018718d260SArmin Le Grand         mbNoFill = true;
4028718d260SArmin Le Grand     }
403cdf0e10cSrcweir 
4048718d260SArmin Le Grand     if(bText && mbFntDirty)
405cdf0e10cSrcweir     {
4068718d260SArmin Le Grand         Font aFnt(maVD.GetFont());
4078718d260SArmin Le Grand         const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * mfScaleY));
4088718d260SArmin Le Grand 
4098718d260SArmin Le Grand         mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
4108718d260SArmin Le Grand         mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
4118718d260SArmin Le Grand         mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
4128718d260SArmin Le Grand         mpTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
4138718d260SArmin Le Grand         mpTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
4148718d260SArmin Le Grand         mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
4158718d260SArmin Le Grand         mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
4168718d260SArmin Le Grand         mpTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
4178718d260SArmin Le Grand         mpTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
4188718d260SArmin Le Grand         mpTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
4198718d260SArmin Le Grand         mpTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
4208718d260SArmin Le Grand         mpTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
4218718d260SArmin Le Grand         mpTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
422a5258243SPedro Giffuni 
423a5258243SPedro Giffuni         // #i118485# Setting this item leads to problems (written #i118498# for this)
4248718d260SArmin Le Grand         // mpTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
425a5258243SPedro Giffuni 
4268718d260SArmin Le Grand         mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
4278718d260SArmin Le Grand         mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
4288718d260SArmin Le Grand         mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
429cdf0e10cSrcweir         //... svxfont textitem svditext
4308718d260SArmin Le Grand         mbFntDirty = false;
431cdf0e10cSrcweir     }
4328718d260SArmin Le Grand 
4338718d260SArmin Le Grand     if(pObj)
434cdf0e10cSrcweir     {
4358718d260SArmin Le Grand         pObj->SetLayer(mnLayer);
4368718d260SArmin Le Grand 
4378718d260SArmin Le Grand         if(bLine)
4388718d260SArmin Le Grand         {
4398718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpLineAttr);
4408718d260SArmin Le Grand         }
4418718d260SArmin Le Grand 
4428718d260SArmin Le Grand         if(bFill)
4438718d260SArmin Le Grand         {
4448718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpFillAttr);
4458718d260SArmin Le Grand         }
4468718d260SArmin Le Grand 
447cdf0e10cSrcweir         if(bText)
448cdf0e10cSrcweir         {
4498718d260SArmin Le Grand             pObj->SetMergedItemSet(*mpTextAttr);
450cdf0e10cSrcweir             pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT));
451cdf0e10cSrcweir         }
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
4558718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
456cdf0e10cSrcweir {
4578718d260SArmin Le Grand     if(bScale && !maScaleRect.IsEmpty())
458cdf0e10cSrcweir     {
4598718d260SArmin Le Grand         if(mbSize)
4608718d260SArmin Le Grand         {
4618718d260SArmin Le Grand             pObj->NbcResize(Point(), maScaleX, maScaleY);
4628718d260SArmin Le Grand         }
4638718d260SArmin Le Grand 
4648718d260SArmin Le Grand         if(mbMov)
4658718d260SArmin Le Grand         {
4668718d260SArmin Le Grand             pObj->NbcMove(Size(maOfs.X(), maOfs.Y()));
4678718d260SArmin Le Grand         }
468cdf0e10cSrcweir     }
469cdf0e10cSrcweir 
47047a7c0c1SArmin Le Grand     if(isClip())
47147a7c0c1SArmin Le Grand     {
47247a7c0c1SArmin Le Grand         const basegfx::B2DPolyPolygon aPoly(pObj->TakeXorPoly());
47347a7c0c1SArmin Le Grand         const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
47447a7c0c1SArmin Le Grand         const SdrLayerID aOldLayer(pObj->GetLayer());
47547a7c0c1SArmin Le Grand         const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
47647a7c0c1SArmin Le Grand         const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
47747a7c0c1SArmin Le Grand         BitmapEx aBitmapEx;
47847a7c0c1SArmin Le Grand 
47947a7c0c1SArmin Le Grand         if(pSdrGrafObj)
48047a7c0c1SArmin Le Grand         {
48147a7c0c1SArmin Le Grand             aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
48247a7c0c1SArmin Le Grand         }
48347a7c0c1SArmin Le Grand 
48447a7c0c1SArmin Le Grand         SdrObject::Free(pObj);
48547a7c0c1SArmin Le Grand 
48647a7c0c1SArmin Le Grand         if(!aOldRange.isEmpty())
48747a7c0c1SArmin Le Grand         {
48847a7c0c1SArmin Le Grand             // clip against ClipRegion
48947a7c0c1SArmin Le Grand             const basegfx::B2DPolyPolygon aNewPoly(
49047a7c0c1SArmin Le Grand                 basegfx::tools::clipPolyPolygonOnPolyPolygon(
49147a7c0c1SArmin Le Grand                     aPoly,
49247a7c0c1SArmin Le Grand                     maClip,
49347a7c0c1SArmin Le Grand                     true,
49447a7c0c1SArmin Le Grand                     aPoly.isClosed() ? false : true));
49547a7c0c1SArmin Le Grand             const basegfx::B2DRange aNewRange(aNewPoly.getB2DRange());
49647a7c0c1SArmin Le Grand 
49747a7c0c1SArmin Le Grand             if(!aNewRange.isEmpty())
49847a7c0c1SArmin Le Grand             {
49947a7c0c1SArmin Le Grand                 pObj = new SdrPathObj(
50047a7c0c1SArmin Le Grand                     aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
50147a7c0c1SArmin Le Grand                     aNewPoly);
50247a7c0c1SArmin Le Grand 
50347a7c0c1SArmin Le Grand                 pObj->SetLayer(aOldLayer);
50447a7c0c1SArmin Le Grand                 pObj->SetMergedItemSet(aOldItemSet);
50547a7c0c1SArmin Le Grand 
50647a7c0c1SArmin Le Grand                 if(!!aBitmapEx)
50747a7c0c1SArmin Le Grand                 {
50847a7c0c1SArmin Le Grand                     // aNewRange is inside of aOldRange and defines which part of aBitmapEx is used
50947a7c0c1SArmin Le Grand                     const double fScaleX(aBitmapEx.GetSizePixel().Width() / (aOldRange.getWidth() ? aOldRange.getWidth() : 1.0));
51047a7c0c1SArmin Le Grand                     const double fScaleY(aBitmapEx.GetSizePixel().Height() / (aOldRange.getHeight() ? aOldRange.getHeight() : 1.0));
51147a7c0c1SArmin Le Grand                     basegfx::B2DRange aPixel(aNewRange);
51247a7c0c1SArmin Le Grand                     basegfx::B2DHomMatrix aTrans;
51347a7c0c1SArmin Le Grand 
51447a7c0c1SArmin Le Grand                     aTrans.translate(-aOldRange.getMinX(), -aOldRange.getMinY());
51547a7c0c1SArmin Le Grand                     aTrans.scale(fScaleX, fScaleY);
51647a7c0c1SArmin Le Grand                     aPixel.transform(aTrans);
51747a7c0c1SArmin Le Grand 
51847a7c0c1SArmin Le Grand                     const BitmapEx aClippedBitmap(
51947a7c0c1SArmin Le Grand                         aBitmapEx,
52047a7c0c1SArmin Le Grand                         Point(floor(std::max(0.0, aPixel.getMinX())), floor(std::max(0.0, aPixel.getMinY()))),
52147a7c0c1SArmin Le Grand                         Size(ceil(aPixel.getWidth()), ceil(aPixel.getHeight())));
52247a7c0c1SArmin Le Grand 
52347a7c0c1SArmin Le Grand                     pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
52470d3707aSArmin Le Grand                     pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
5259f63b866SArmin Le Grand                     pObj->SetMergedItem(XFillBmpTileItem(false));
5269f63b866SArmin Le Grand                     pObj->SetMergedItem(XFillBmpStretchItem(true));
52747a7c0c1SArmin Le Grand                 }
52847a7c0c1SArmin Le Grand             }
52947a7c0c1SArmin Le Grand         }
53047a7c0c1SArmin Le Grand     }
53147a7c0c1SArmin Le Grand 
53247a7c0c1SArmin Le Grand     if(pObj)
53347a7c0c1SArmin Le Grand     {
534cdf0e10cSrcweir         // #i111954# check object for visibility
535cdf0e10cSrcweir         // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
536cdf0e10cSrcweir         bool bVisible(false);
537cdf0e10cSrcweir 
538cdf0e10cSrcweir         if(pObj->HasLineStyle())
539cdf0e10cSrcweir         {
540cdf0e10cSrcweir             bVisible = true;
541cdf0e10cSrcweir         }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir         if(!bVisible && pObj->HasFillStyle())
544cdf0e10cSrcweir         {
545cdf0e10cSrcweir             bVisible = true;
546cdf0e10cSrcweir         }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir         if(!bVisible)
549cdf0e10cSrcweir         {
550cdf0e10cSrcweir             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
551cdf0e10cSrcweir 
552cdf0e10cSrcweir             if(pTextObj && pTextObj->HasText())
553cdf0e10cSrcweir             {
554cdf0e10cSrcweir                 bVisible = true;
555cdf0e10cSrcweir             }
556cdf0e10cSrcweir         }
557cdf0e10cSrcweir 
558cdf0e10cSrcweir         if(!bVisible)
559cdf0e10cSrcweir         {
560cdf0e10cSrcweir             SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
561cdf0e10cSrcweir 
562cdf0e10cSrcweir             if(pGrafObj)
563cdf0e10cSrcweir             {
564cdf0e10cSrcweir                 // this may be refined to check if the graphic really is visible. It
565cdf0e10cSrcweir                 // is here to ensure that graphic objects without fill, line and text
566cdf0e10cSrcweir                 // get created
567cdf0e10cSrcweir                 bVisible = true;
568cdf0e10cSrcweir             }
569cdf0e10cSrcweir         }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir         if(!bVisible)
572cdf0e10cSrcweir         {
573cdf0e10cSrcweir             SdrObject::Free(pObj);
574cdf0e10cSrcweir         }
575cdf0e10cSrcweir         else
576cdf0e10cSrcweir         {
5778718d260SArmin Le Grand             maTmpList.push_back(pObj);
5788718d260SArmin Le Grand 
5798718d260SArmin Le Grand             if(dynamic_cast< SdrPathObj* >(pObj))
580cdf0e10cSrcweir             {
5818718d260SArmin Le Grand                 const bool bClosed(pObj->IsClosedObj());
5828718d260SArmin Le Grand 
5838718d260SArmin Le Grand                 mbLastObjWasPolyWithoutLine = mbNoLine && bClosed;
5848718d260SArmin Le Grand                 mbLastObjWasLine = !bClosed;
585cdf0e10cSrcweir             }
586cdf0e10cSrcweir             else
587cdf0e10cSrcweir             {
5888718d260SArmin Le Grand                 mbLastObjWasPolyWithoutLine = false;
5898718d260SArmin Le Grand                 mbLastObjWasLine = false;
590cdf0e10cSrcweir             }
591cdf0e10cSrcweir         }
592cdf0e10cSrcweir     }
59347a7c0c1SArmin Le Grand }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir /**************************************************************************************************/
596cdf0e10cSrcweir 
597cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
598cdf0e10cSrcweir {
599cdf0e10cSrcweir }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
605cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
606cdf0e10cSrcweir {
607cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
608cdf0e10cSrcweir     const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
609cdf0e10cSrcweir     const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     if(!aStart.equal(aEnd))
612cdf0e10cSrcweir     {
613cdf0e10cSrcweir         basegfx::B2DPolygon aLine;
6148718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
615cdf0e10cSrcweir 
616cdf0e10cSrcweir         aLine.append(aStart);
617cdf0e10cSrcweir         aLine.append(aEnd);
618cdf0e10cSrcweir         aLine.transform(aTransform);
619cdf0e10cSrcweir 
620cdf0e10cSrcweir         const LineInfo& rLineInfo = rAct.GetLineInfo();
621cdf0e10cSrcweir         const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
622cdf0e10cSrcweir         bool bCreateLineObject(true);
623cdf0e10cSrcweir 
6248718d260SArmin Le Grand         if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine))
625cdf0e10cSrcweir         {
626cdf0e10cSrcweir             bCreateLineObject = false;
627cdf0e10cSrcweir         }
628cdf0e10cSrcweir 
629cdf0e10cSrcweir         if(bCreateLineObject)
630cdf0e10cSrcweir         {
631cdf0e10cSrcweir             SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
6328718d260SArmin Le Grand             mnLineWidth = nNewLineWidth;
633cdf0e10cSrcweir             maLineJoin = rLineInfo.GetLineJoin();
6345aaf853bSArmin Le Grand             maLineCap = rLineInfo.GetLineCap();
635cdf0e10cSrcweir             maDash = XDash(XDASH_RECT,
636cdf0e10cSrcweir                 rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
637cdf0e10cSrcweir                 rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
638cdf0e10cSrcweir                 rLineInfo.GetDistance());
639cdf0e10cSrcweir             SetAttributes(pPath);
6408718d260SArmin Le Grand             mnLineWidth = 0;
641cdf0e10cSrcweir             maLineJoin = basegfx::B2DLINEJOIN_NONE;
642cdf0e10cSrcweir             maDash = XDash();
643cdf0e10cSrcweir             InsertObj(pPath, false);
644cdf0e10cSrcweir         }
645cdf0e10cSrcweir     }
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
648cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
651cdf0e10cSrcweir     SetAttributes(pRect);
652cdf0e10cSrcweir     InsertObj(pRect);
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
656cdf0e10cSrcweir {
657cdf0e10cSrcweir     SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
658cdf0e10cSrcweir     SetAttributes(pRect);
659cdf0e10cSrcweir     long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
660cdf0e10cSrcweir     if (nRad!=0) {
6618718d260SArmin Le Grand         SfxItemSet aSet(*mpLineAttr->GetPool(), SDRATTR_ECKENRADIUS, SDRATTR_ECKENRADIUS, 0, 0);
662cdf0e10cSrcweir         aSet.Put(SdrEckenradiusItem(nRad));
663cdf0e10cSrcweir         pRect->SetMergedItemSet(aSet);
664cdf0e10cSrcweir     }
665cdf0e10cSrcweir     InsertObj(pRect);
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir /**************************************************************************************************/
669cdf0e10cSrcweir 
670cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
673cdf0e10cSrcweir     SetAttributes(pCirc);
674cdf0e10cSrcweir     InsertObj(pCirc);
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
678cdf0e10cSrcweir {
679cdf0e10cSrcweir     Point aCenter(rAct.GetRect().Center());
680cdf0e10cSrcweir     long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
681cdf0e10cSrcweir     long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
682cdf0e10cSrcweir     SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
683cdf0e10cSrcweir     SetAttributes(pCirc);
684cdf0e10cSrcweir     InsertObj(pCirc);
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir     Point aCenter(rAct.GetRect().Center());
690cdf0e10cSrcweir     long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
691cdf0e10cSrcweir     long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
692cdf0e10cSrcweir     SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
693cdf0e10cSrcweir     SetAttributes(pCirc);
694cdf0e10cSrcweir     InsertObj(pCirc);
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
698cdf0e10cSrcweir {
699cdf0e10cSrcweir     Point aCenter(rAct.GetRect().Center());
700cdf0e10cSrcweir     long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
701cdf0e10cSrcweir     long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
702cdf0e10cSrcweir     SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
703cdf0e10cSrcweir     SetAttributes(pCirc);
704cdf0e10cSrcweir     InsertObj(pCirc);
705cdf0e10cSrcweir }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir /**************************************************************************************************/
708cdf0e10cSrcweir 
709cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir     // #i102706# Do not merge closed polygons
712cdf0e10cSrcweir     if(rSrcPoly.isClosed())
713cdf0e10cSrcweir     {
714cdf0e10cSrcweir         return false;
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
7188718d260SArmin Le Grand     if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
719cdf0e10cSrcweir     {
7208718d260SArmin Le Grand         SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
7218718d260SArmin Le Grand         SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
722cdf0e10cSrcweir 
723cdf0e10cSrcweir         if(pLastPoly)
724cdf0e10cSrcweir         {
725cdf0e10cSrcweir             if(1L == pLastPoly->GetPathPoly().count())
726cdf0e10cSrcweir             {
727cdf0e10cSrcweir                 bool bOk(false);
728cdf0e10cSrcweir                 basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
729cdf0e10cSrcweir 
730cdf0e10cSrcweir                 // #i102706# Do not merge closed polygons
731cdf0e10cSrcweir                 if(aDstPoly.isClosed())
732cdf0e10cSrcweir                 {
733cdf0e10cSrcweir                     return false;
734cdf0e10cSrcweir                 }
735cdf0e10cSrcweir 
736cdf0e10cSrcweir                 if(aDstPoly.count())
737cdf0e10cSrcweir                 {
738cdf0e10cSrcweir                     const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
739cdf0e10cSrcweir                     const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
740cdf0e10cSrcweir 
741cdf0e10cSrcweir                     if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
742cdf0e10cSrcweir                     {
743cdf0e10cSrcweir                         aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
744cdf0e10cSrcweir                         bOk = true;
745cdf0e10cSrcweir                     }
746cdf0e10cSrcweir                     else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
747cdf0e10cSrcweir                     {
748cdf0e10cSrcweir                         basegfx::B2DPolygon aNew(rSrcPoly);
749cdf0e10cSrcweir                         aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
750cdf0e10cSrcweir                         aDstPoly = aNew;
751cdf0e10cSrcweir                         bOk = true;
752cdf0e10cSrcweir                     }
753cdf0e10cSrcweir                     else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
754cdf0e10cSrcweir                     {
755cdf0e10cSrcweir                         aDstPoly.flip();
756cdf0e10cSrcweir                         aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
757cdf0e10cSrcweir                         bOk = true;
758cdf0e10cSrcweir                     }
759cdf0e10cSrcweir                     else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
760cdf0e10cSrcweir                     {
761cdf0e10cSrcweir                         basegfx::B2DPolygon aNew(rSrcPoly);
762cdf0e10cSrcweir                         aNew.flip();
763cdf0e10cSrcweir                         aDstPoly.append(aNew, 1L, aNew.count() - 1L);
764cdf0e10cSrcweir                         bOk = true;
765cdf0e10cSrcweir                     }
766cdf0e10cSrcweir                 }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir                 if(bOk)
769cdf0e10cSrcweir                 {
770cdf0e10cSrcweir                     pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
771cdf0e10cSrcweir                 }
772cdf0e10cSrcweir 
773cdf0e10cSrcweir                 return bOk;
774cdf0e10cSrcweir             }
775cdf0e10cSrcweir         }
776cdf0e10cSrcweir     }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir     return false;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
782cdf0e10cSrcweir {
783cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
7848718d260SArmin Le Grand     if(mbLastObjWasPolyWithoutLine)
785cdf0e10cSrcweir     {
7868718d260SArmin Le Grand         SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
7878718d260SArmin Le Grand         SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
788cdf0e10cSrcweir 
789cdf0e10cSrcweir         if(pLastPoly)
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             if(pLastPoly->GetPathPoly() == rPolyPolygon)
792cdf0e10cSrcweir             {
793cdf0e10cSrcweir                 SetAttributes(NULL);
794cdf0e10cSrcweir 
7958718d260SArmin Le Grand                 if(!mbNoLine && mbNoFill)
796cdf0e10cSrcweir                 {
7978718d260SArmin Le Grand                     pLastPoly->SetMergedItemSet(*mpLineAttr);
798cdf0e10cSrcweir 
799cdf0e10cSrcweir                     return true;
800cdf0e10cSrcweir                 }
801cdf0e10cSrcweir             }
802cdf0e10cSrcweir         }
803cdf0e10cSrcweir     }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir     return false;
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
80847a7c0c1SArmin Le Grand void ImpSdrGDIMetaFileImport::checkClip()
80947a7c0c1SArmin Le Grand {
8108718d260SArmin Le Grand     if(maVD.IsClipRegion())
81147a7c0c1SArmin Le Grand     {
8128718d260SArmin Le Grand         Region aRegion(maVD.GetClipRegion());
81347a7c0c1SArmin Le Grand 
81447a7c0c1SArmin Le Grand         maClip = aRegion.ConvertToB2DPolyPolygon();
81547a7c0c1SArmin Le Grand 
81647a7c0c1SArmin Le Grand         if(isClip())
81747a7c0c1SArmin Le Grand         {
81847a7c0c1SArmin Le Grand             const basegfx::B2DHomMatrix aTransform(
81947a7c0c1SArmin Le Grand                 basegfx::tools::createScaleTranslateB2DHomMatrix(
8208718d260SArmin Le Grand                     mfScaleX,
8218718d260SArmin Le Grand                     mfScaleY,
8228718d260SArmin Le Grand                     maOfs.X(),
8238718d260SArmin Le Grand                     maOfs.Y()));
82447a7c0c1SArmin Le Grand 
82547a7c0c1SArmin Le Grand             maClip.transform(aTransform);
82647a7c0c1SArmin Le Grand         }
82747a7c0c1SArmin Le Grand     }
82847a7c0c1SArmin Le Grand }
82947a7c0c1SArmin Le Grand 
83047a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const
83147a7c0c1SArmin Le Grand {
83247a7c0c1SArmin Le Grand     return !maClip.getB2DRange().isEmpty();
83347a7c0c1SArmin Le Grand }
834cdf0e10cSrcweir 
835cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
838cdf0e10cSrcweir     basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
839cdf0e10cSrcweir 
840cdf0e10cSrcweir     if(aSource.count())
841cdf0e10cSrcweir     {
8428718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
843cdf0e10cSrcweir         aSource.transform(aTransform);
844cdf0e10cSrcweir     }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir     const LineInfo& rLineInfo = rAct.GetLineInfo();
847cdf0e10cSrcweir     const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
848cdf0e10cSrcweir     bool bCreateLineObject(true);
849cdf0e10cSrcweir 
8508718d260SArmin Le Grand     if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource))
851cdf0e10cSrcweir     {
852cdf0e10cSrcweir         bCreateLineObject = false;
853cdf0e10cSrcweir     }
8548718d260SArmin Le Grand     else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
855cdf0e10cSrcweir     {
856cdf0e10cSrcweir         bCreateLineObject = false;
857cdf0e10cSrcweir     }
858cdf0e10cSrcweir 
859cdf0e10cSrcweir     if(bCreateLineObject)
860cdf0e10cSrcweir     {
861cdf0e10cSrcweir         SdrPathObj* pPath = new SdrPathObj(
862cdf0e10cSrcweir             aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
863cdf0e10cSrcweir             basegfx::B2DPolyPolygon(aSource));
8648718d260SArmin Le Grand         mnLineWidth = nNewLineWidth;
865cdf0e10cSrcweir         maLineJoin = rLineInfo.GetLineJoin();
8665aaf853bSArmin Le Grand         maLineCap = rLineInfo.GetLineCap();
867cdf0e10cSrcweir         maDash = XDash(XDASH_RECT,
868cdf0e10cSrcweir             rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
869cdf0e10cSrcweir             rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
870cdf0e10cSrcweir             rLineInfo.GetDistance());
871cdf0e10cSrcweir         SetAttributes(pPath);
8728718d260SArmin Le Grand         mnLineWidth = 0;
873cdf0e10cSrcweir         maLineJoin = basegfx::B2DLINEJOIN_NONE;
874cdf0e10cSrcweir         maDash = XDash();
875cdf0e10cSrcweir         InsertObj(pPath, false);
876cdf0e10cSrcweir     }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
882cdf0e10cSrcweir     basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
883cdf0e10cSrcweir 
884cdf0e10cSrcweir     if(aSource.count())
885cdf0e10cSrcweir     {
8868718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
887cdf0e10cSrcweir         aSource.transform(aTransform);
888cdf0e10cSrcweir 
8898718d260SArmin Le Grand         if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
890cdf0e10cSrcweir         {
891cdf0e10cSrcweir             // #i73407# make sure polygon is closed, it's a filled primitive
892cdf0e10cSrcweir             aSource.setClosed(true);
893cdf0e10cSrcweir             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
894cdf0e10cSrcweir             SetAttributes(pPath);
895cdf0e10cSrcweir             InsertObj(pPath, false);
896cdf0e10cSrcweir         }
897cdf0e10cSrcweir     }
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
901cdf0e10cSrcweir {
902cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
903cdf0e10cSrcweir     basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
904cdf0e10cSrcweir 
905cdf0e10cSrcweir     if(aSource.count())
906cdf0e10cSrcweir     {
9078718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
908cdf0e10cSrcweir         aSource.transform(aTransform);
909cdf0e10cSrcweir 
9108718d260SArmin Le Grand         if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
911cdf0e10cSrcweir         {
912cdf0e10cSrcweir             // #i73407# make sure polygon is closed, it's a filled primitive
913cdf0e10cSrcweir             aSource.setClosed(true);
914cdf0e10cSrcweir             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
915cdf0e10cSrcweir             SetAttributes(pPath);
916cdf0e10cSrcweir             InsertObj(pPath, false);
917cdf0e10cSrcweir         }
918cdf0e10cSrcweir     }
919cdf0e10cSrcweir }
920cdf0e10cSrcweir 
921cdf0e10cSrcweir /**************************************************************************************************/
922cdf0e10cSrcweir 
923cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir     // calc text box size, add 5% to make it fit safely
926cdf0e10cSrcweir 
9278718d260SArmin Le Grand     FontMetric aFontMetric( maVD.GetFontMetric() );
9288718d260SArmin Le Grand     Font aFnt( maVD.GetFont() );
929cdf0e10cSrcweir     FontAlign eAlg( aFnt.GetAlign() );
930cdf0e10cSrcweir 
9318718d260SArmin Le Grand     sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX );
9328718d260SArmin Le Grand     sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY );
933cdf0e10cSrcweir     //sal_Int32 nDxWidth = 0;
934cdf0e10cSrcweir     //sal_Int32 nLen = rStr.Len();
935cdf0e10cSrcweir 
9368718d260SArmin Le Grand     Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) );
937cdf0e10cSrcweir     Size aSize( nTextWidth, nTextHeight );
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     if ( eAlg == ALIGN_BASELINE )
9408718d260SArmin Le Grand         aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
941cdf0e10cSrcweir     else if ( eAlg == ALIGN_BOTTOM )
942cdf0e10cSrcweir         aPos.Y() -= nTextHeight;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir     Rectangle aTextRect( aPos, aSize );
945cdf0e10cSrcweir     SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
946cdf0e10cSrcweir 
947cdf0e10cSrcweir     if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
948cdf0e10cSrcweir     {
949cdf0e10cSrcweir         pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
9508718d260SArmin Le Grand         pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
951cdf0e10cSrcweir         // don't let the margins eat the space needed for the text
952cdf0e10cSrcweir         pText->SetMergedItem ( SdrTextUpperDistItem (0));
953cdf0e10cSrcweir         pText->SetMergedItem ( SdrTextLowerDistItem (0));
954cdf0e10cSrcweir         pText->SetMergedItem ( SdrTextRightDistItem (0));
955cdf0e10cSrcweir         pText->SetMergedItem ( SdrTextLeftDistItem (0));
956cdf0e10cSrcweir         pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
957cdf0e10cSrcweir     }
958cdf0e10cSrcweir     else
9598718d260SArmin Le Grand         pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) );
960cdf0e10cSrcweir 
9618718d260SArmin Le Grand     pText->SetModel(mpModel);
9628718d260SArmin Le Grand     pText->SetLayer(mnLayer);
963cdf0e10cSrcweir     pText->NbcSetText( rStr );
9648718d260SArmin Le Grand     SetAttributes( pText, true );
965cdf0e10cSrcweir     pText->SetSnapRect( aTextRect );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     if (!aFnt.IsTransparent())
968cdf0e10cSrcweir     {
9698718d260SArmin Le Grand         SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
970cdf0e10cSrcweir         aAttr.Put(XFillStyleItem(XFILL_SOLID));
971cdf0e10cSrcweir         aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
972cdf0e10cSrcweir         pText->SetMergedItemSet(aAttr);
973cdf0e10cSrcweir     }
974cdf0e10cSrcweir     sal_uInt32 nWink = aFnt.GetOrientation();
975cdf0e10cSrcweir     if ( nWink )
976cdf0e10cSrcweir     {
977cdf0e10cSrcweir         nWink*=10;
978cdf0e10cSrcweir         double a=nWink*nPi180;
979cdf0e10cSrcweir         double nSin=sin(a);
980cdf0e10cSrcweir         double nCos=cos(a);
981cdf0e10cSrcweir         pText->NbcRotate(aPos,nWink,nSin,nCos);
982cdf0e10cSrcweir     }
9838718d260SArmin Le Grand     InsertObj( pText, false );
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
986cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
987cdf0e10cSrcweir {
988cdf0e10cSrcweir     XubString aStr(rAct.GetText());
989cdf0e10cSrcweir     aStr.Erase(0,rAct.GetIndex());
990cdf0e10cSrcweir     aStr.Erase(rAct.GetLen());
991cdf0e10cSrcweir     ImportText( rAct.GetPoint(), aStr, rAct );
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
994cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
995cdf0e10cSrcweir {
996cdf0e10cSrcweir     XubString aStr(rAct.GetText());
997cdf0e10cSrcweir     aStr.Erase(0,rAct.GetIndex());
998cdf0e10cSrcweir     aStr.Erase(rAct.GetLen());
999cdf0e10cSrcweir     ImportText( rAct.GetPoint(), aStr, rAct );
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir     XubString aStr(rAct.GetText());
1005cdf0e10cSrcweir     aStr.Erase(0,rAct.GetIndex());
1006cdf0e10cSrcweir     aStr.Erase(rAct.GetLen());
1007cdf0e10cSrcweir     ImportText( rAct.GetPoint(), aStr, rAct );
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir     Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
1013cdf0e10cSrcweir     aRect.Right()++; aRect.Bottom()++;
1014cdf0e10cSrcweir     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1015cdf0e10cSrcweir     InsertObj(pGraf);
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir     Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1021cdf0e10cSrcweir     aRect.Right()++; aRect.Bottom()++;
1022cdf0e10cSrcweir     SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
1023cdf0e10cSrcweir     InsertObj(pGraf);
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir     Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
1029cdf0e10cSrcweir     aRect.Right()++; aRect.Bottom()++;
1030cdf0e10cSrcweir     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1031cdf0e10cSrcweir     InsertObj(pGraf);
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir     Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
1037cdf0e10cSrcweir     aRect.Right()++; aRect.Bottom()++;
1038cdf0e10cSrcweir     SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
1039cdf0e10cSrcweir     InsertObj(pGraf);
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir     // #i73407# reformulation to use new B2DPolygon classes
1047cdf0e10cSrcweir     basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir     if(aSource.count())
1050cdf0e10cSrcweir     {
10518718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
1052cdf0e10cSrcweir         aSource.transform(aTransform);
1053cdf0e10cSrcweir 
10548718d260SArmin Le Grand         if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1055cdf0e10cSrcweir         {
1056cdf0e10cSrcweir             const Hatch& rHatch = rAct.GetHatch();
1057cdf0e10cSrcweir             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
10588718d260SArmin Le Grand             SfxItemSet aHatchAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0);
1059cdf0e10cSrcweir             XHatchStyle eStyle;
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir             switch(rHatch.GetStyle())
1062cdf0e10cSrcweir             {
1063cdf0e10cSrcweir                 case(HATCH_TRIPLE) :
1064cdf0e10cSrcweir                 {
1065cdf0e10cSrcweir                     eStyle = XHATCH_TRIPLE;
1066cdf0e10cSrcweir                     break;
1067cdf0e10cSrcweir                 }
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir                 case(HATCH_DOUBLE) :
1070cdf0e10cSrcweir                 {
1071cdf0e10cSrcweir                     eStyle = XHATCH_DOUBLE;
1072cdf0e10cSrcweir                     break;
1073cdf0e10cSrcweir                 }
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir                 default:
1076cdf0e10cSrcweir                 {
1077cdf0e10cSrcweir                     eStyle = XHATCH_SINGLE;
1078cdf0e10cSrcweir                     break;
1079cdf0e10cSrcweir                 }
1080cdf0e10cSrcweir             }
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir             SetAttributes(pPath);
1083cdf0e10cSrcweir             aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
10848718d260SArmin Le Grand             aHatchAttr.Put(XFillHatchItem(&mpModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
1085cdf0e10cSrcweir             pPath->SetMergedItemSet(aHatchAttr);
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir             InsertObj(pPath, false);
1088cdf0e10cSrcweir         }
1089cdf0e10cSrcweir     }
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
1095cdf0e10cSrcweir {
10968718d260SArmin Le Grand     rAct.Execute(&maVD);
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir     MapScaling();
11028718d260SArmin Le Grand     rAct.Execute(&maVD);
11038718d260SArmin Le Grand     mbLastObjWasPolyWithoutLine = false;
11048718d260SArmin Le Grand     mbLastObjWasLine = false;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling()
1108cdf0e10cSrcweir {
11098718d260SArmin Le Grand     const sal_uInt32 nAnz(maTmpList.size());
11108718d260SArmin Le Grand     sal_uInt32 i(0);
11118718d260SArmin Le Grand     const MapMode& rMap = maVD.GetMapMode();
1112cdf0e10cSrcweir     Point aMapOrg( rMap.GetOrigin() );
11138718d260SArmin Le Grand     bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0);
11148718d260SArmin Le Grand 
1115cdf0e10cSrcweir     if(bMov2)
1116cdf0e10cSrcweir     {
11178718d260SArmin Le Grand         for(i = mnMapScalingOfs; i < nAnz; i++)
1118cdf0e10cSrcweir         {
11198718d260SArmin Le Grand             SdrObject* pObj = maTmpList[i];
11208718d260SArmin Le Grand 
1121cdf0e10cSrcweir             pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
1122cdf0e10cSrcweir         }
1123cdf0e10cSrcweir     }
11248718d260SArmin Le Grand 
11258718d260SArmin Le Grand     mnMapScalingOfs = nAnz;
1126cdf0e10cSrcweir }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir     ByteString aSkipComment;
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir     if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
1135cdf0e10cSrcweir     {
1136cdf0e10cSrcweir         MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir         if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
1139cdf0e10cSrcweir         {
1140cdf0e10cSrcweir             // #i73407# reformulation to use new B2DPolygon classes
1141cdf0e10cSrcweir             basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir             if(aSource.count())
1144cdf0e10cSrcweir             {
11458718d260SArmin Le Grand                 if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
1146cdf0e10cSrcweir                 {
1147cdf0e10cSrcweir                     const Gradient& rGrad = pAct->GetGradient();
1148cdf0e10cSrcweir                     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
11498718d260SArmin Le Grand                     SfxItemSet aGradAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1150cdf0e10cSrcweir                     XGradient aXGradient;
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir                     aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
1153cdf0e10cSrcweir                     aXGradient.SetStartColor(rGrad.GetStartColor());
1154cdf0e10cSrcweir                     aXGradient.SetEndColor(rGrad.GetEndColor());
1155cdf0e10cSrcweir                     aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
1156cdf0e10cSrcweir                     aXGradient.SetBorder(rGrad.GetBorder());
1157cdf0e10cSrcweir                     aXGradient.SetXOffset(rGrad.GetOfsX());
1158cdf0e10cSrcweir                     aXGradient.SetYOffset(rGrad.GetOfsY());
1159cdf0e10cSrcweir                     aXGradient.SetStartIntens(rGrad.GetStartIntensity());
1160cdf0e10cSrcweir                     aXGradient.SetEndIntens(rGrad.GetEndIntensity());
1161cdf0e10cSrcweir                     aXGradient.SetSteps(rGrad.GetSteps());
1162cdf0e10cSrcweir 
11638718d260SArmin Le Grand                     if(maVD.IsLineColor())
1164cdf0e10cSrcweir                     {
1165cdf0e10cSrcweir                         // switch line off; when there was one there will be a
1166cdf0e10cSrcweir                         // META_POLYLINE_ACTION following creating another object
11678718d260SArmin Le Grand                         const Color aLineColor(maVD.GetLineColor());
11688718d260SArmin Le Grand                         maVD.SetLineColor();
1169cdf0e10cSrcweir                         SetAttributes(pPath);
11708718d260SArmin Le Grand                         maVD.SetLineColor(aLineColor);
1171cdf0e10cSrcweir                     }
1172cdf0e10cSrcweir                     else
1173cdf0e10cSrcweir                     {
1174cdf0e10cSrcweir                         SetAttributes(pPath);
1175cdf0e10cSrcweir                     }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir                     aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
11788718d260SArmin Le Grand                     aGradAttr.Put(XFillGradientItem(&mpModel->GetItemPool(), aXGradient));
1179cdf0e10cSrcweir                     pPath->SetMergedItemSet(aGradAttr);
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir                     InsertObj(pPath);
1182cdf0e10cSrcweir                 }
1183cdf0e10cSrcweir             }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir             aSkipComment = "XGRAD_SEQ_END";
1186cdf0e10cSrcweir         }
1187cdf0e10cSrcweir     }
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     if(aSkipComment.Len())
1190cdf0e10cSrcweir     {
1191cdf0e10cSrcweir         MetaAction* pSkipAct = pMtf->NextAction();
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir         while( pSkipAct
1194cdf0e10cSrcweir             && ((pSkipAct->GetType() != META_COMMENT_ACTION )
1195cdf0e10cSrcweir                 || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
1196cdf0e10cSrcweir         {
1197cdf0e10cSrcweir             pSkipAct = pMtf->NextAction();
1198cdf0e10cSrcweir         }
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
12038718d260SArmin Le Grand 
12048718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
12058718d260SArmin Le Grand {
12068718d260SArmin Le Grand     GDIMetaFile aTemp;
12078718d260SArmin Le Grand 
12088718d260SArmin Le Grand     maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
12098718d260SArmin Le Grand     DoLoopActions(aTemp, 0, 0);
12108718d260SArmin Le Grand }
12118718d260SArmin Le Grand 
12128718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
12138718d260SArmin Le Grand {
12148718d260SArmin Le Grand     Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
12158718d260SArmin Le Grand     Bitmap aBitmap(rAct.GetBitmap());
12168718d260SArmin Le Grand 
12178718d260SArmin Le Grand     aRect.Right()++;
12188718d260SArmin Le Grand     aRect.Bottom()++;
12198718d260SArmin Le Grand     aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
12208718d260SArmin Le Grand 
12218718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
12228718d260SArmin Le Grand 
12238718d260SArmin Le Grand     InsertObj(pGraf);
12248718d260SArmin Le Grand }
12258718d260SArmin Le Grand 
12268718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
12278718d260SArmin Le Grand {
12288718d260SArmin Le Grand     Rectangle aRect(rAct.GetDestPoint(),rAct.GetDestSize());
12298718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmapEx());
12308718d260SArmin Le Grand 
12318718d260SArmin Le Grand     aRect.Right()++;
12328718d260SArmin Le Grand     aRect.Bottom()++;
12338718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
12348718d260SArmin Le Grand 
12358718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
12368718d260SArmin Le Grand 
12378718d260SArmin Le Grand     InsertObj(pGraf);
12388718d260SArmin Le Grand }
12398718d260SArmin Le Grand 
12408718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
12418718d260SArmin Le Grand {
12428718d260SArmin Le Grand     Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
12438718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
12448718d260SArmin Le Grand 
12458718d260SArmin Le Grand     aRect.Right()++;
12468718d260SArmin Le Grand     aRect.Bottom()++;
12478718d260SArmin Le Grand 
12488718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
12498718d260SArmin Le Grand 
12508718d260SArmin Le Grand     InsertObj(pGraf);
12518718d260SArmin Le Grand }
12528718d260SArmin Le Grand 
12538718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
12548718d260SArmin Le Grand {
12558718d260SArmin Le Grand     Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
12568718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
12578718d260SArmin Le Grand 
12588718d260SArmin Le Grand     aRect.Right()++;
12598718d260SArmin Le Grand     aRect.Bottom()++;
12608718d260SArmin Le Grand 
12618718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
12628718d260SArmin Le Grand 
12638718d260SArmin Le Grand     InsertObj(pGraf);
12648718d260SArmin Le Grand }
12658718d260SArmin Le Grand 
12668718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
12678718d260SArmin Le Grand {
12688718d260SArmin Le Grand     Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
12698718d260SArmin Le Grand     BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
12708718d260SArmin Le Grand 
12718718d260SArmin Le Grand     aRect.Right()++;
12728718d260SArmin Le Grand     aRect.Bottom()++;
12738718d260SArmin Le Grand     aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
12748718d260SArmin Le Grand 
12758718d260SArmin Le Grand     SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
12768718d260SArmin Le Grand 
12778718d260SArmin Le Grand     InsertObj(pGraf);
12788718d260SArmin Le Grand }
12798718d260SArmin Le Grand 
1280*603e43faSArmin Le Grand XGradientStyle getXGradientStyleFromGradientStyle(const GradientStyle& rGradientStyle)
1281*603e43faSArmin Le Grand {
1282*603e43faSArmin Le Grand     XGradientStyle aXGradientStyle(XGRAD_LINEAR);
1283*603e43faSArmin Le Grand 
1284*603e43faSArmin Le Grand     switch(rGradientStyle)
1285*603e43faSArmin Le Grand     {
1286*603e43faSArmin Le Grand         case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
1287*603e43faSArmin Le Grand         case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
1288*603e43faSArmin Le Grand         case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
1289*603e43faSArmin Le Grand         case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
1290*603e43faSArmin Le Grand         case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
1291*603e43faSArmin Le Grand         case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
1292*603e43faSArmin Le Grand 
1293*603e43faSArmin Le Grand         // Needed due to GRADIENT_FORCE_EQUAL_SIZE; this again is needed
1294*603e43faSArmin Le Grand         // to force the enum defines in VCL to a defined size for the compilers,
1295*603e43faSArmin Le Grand         // so despite it is never used it cannot be removed (would break the
1296*603e43faSArmin Le Grand         // API implementation probably).
1297*603e43faSArmin Le Grand         default: break;
1298*603e43faSArmin Le Grand     }
1299*603e43faSArmin Le Grand 
1300*603e43faSArmin Le Grand     return aXGradientStyle;
1301*603e43faSArmin Le Grand }
1302*603e43faSArmin Le Grand 
13038718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct)
13048718d260SArmin Le Grand {
13058718d260SArmin Le Grand     basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom());
13068718d260SArmin Le Grand 
13078718d260SArmin Le Grand     if(!aRange.isEmpty())
13088718d260SArmin Le Grand     {
13098718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
13108718d260SArmin Le Grand         aRange.transform(aTransform);
13118718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
13128718d260SArmin Le Grand         SdrRectObj* pRect = new SdrRectObj(
13138718d260SArmin Le Grand             Rectangle(
13148718d260SArmin Le Grand                 floor(aRange.getMinX()),
13158718d260SArmin Le Grand                 floor(aRange.getMinY()),
13168718d260SArmin Le Grand                 ceil(aRange.getMaxX()),
13178718d260SArmin Le Grand                 ceil(aRange.getMaxY())));
13188718d260SArmin Le Grand         SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1319*603e43faSArmin Le Grand         const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
13208718d260SArmin Le Grand         const XFillGradientItem aXFillGradientItem(
13218718d260SArmin Le Grand             &mpModel->GetItemPool(),
13228718d260SArmin Le Grand             XGradient(
13238718d260SArmin Le Grand                 rGradient.GetStartColor(),
13248718d260SArmin Le Grand                 rGradient.GetEndColor(),
13258718d260SArmin Le Grand                 aXGradientStyle,
13268718d260SArmin Le Grand                 rGradient.GetAngle(),
13278718d260SArmin Le Grand                 rGradient.GetOfsX(),
13288718d260SArmin Le Grand                 rGradient.GetOfsY(),
13298718d260SArmin Le Grand                 rGradient.GetBorder(),
13308718d260SArmin Le Grand                 rGradient.GetStartIntensity(),
13318718d260SArmin Le Grand                 rGradient.GetEndIntensity(),
13328718d260SArmin Le Grand                 rGradient.GetSteps()));
13338718d260SArmin Le Grand 
13348718d260SArmin Le Grand         SetAttributes(pRect);
13358718d260SArmin Le Grand         aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
13368718d260SArmin Le Grand         aGradientAttr.Put(aXFillGradientItem);
13378718d260SArmin Le Grand         pRect->SetMergedItemSet(aGradientAttr);
13388718d260SArmin Le Grand 
13398718d260SArmin Le Grand         InsertObj(pRect, false);
13408718d260SArmin Le Grand     }
13418718d260SArmin Le Grand }
13428718d260SArmin Le Grand 
1343*603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& /*rAct*/)
13448718d260SArmin Le Grand {
13458718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)");
13468718d260SArmin Le Grand }
13478718d260SArmin Le Grand 
13488718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct)
13498718d260SArmin Le Grand {
13508718d260SArmin Le Grand     basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
13518718d260SArmin Le Grand 
13528718d260SArmin Le Grand     if(aSource.count())
13538718d260SArmin Le Grand     {
13548718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
13558718d260SArmin Le Grand         aSource.transform(aTransform);
13568718d260SArmin Le Grand         aSource.setClosed(true);
13578718d260SArmin Le Grand 
13588718d260SArmin Le Grand         SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
13598718d260SArmin Le Grand         SetAttributes(pPath);
13608718d260SArmin Le Grand         pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
13618718d260SArmin Le Grand         InsertObj(pPath, false);
13628718d260SArmin Le Grand     }
13638718d260SArmin Le Grand }
13648718d260SArmin Le Grand 
1365*603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& /*rAct*/)
13668718d260SArmin Le Grand {
13678718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)");
13688718d260SArmin Le Grand }
13698718d260SArmin Le Grand 
1370*603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& /*rAct*/)
13718718d260SArmin Le Grand {
13728718d260SArmin Le Grand     OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)");
13738718d260SArmin Le Grand }
13748718d260SArmin Le Grand 
13758718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct)
13768718d260SArmin Le Grand {
13778718d260SArmin Le Grand     basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
13788718d260SArmin Le Grand 
13798718d260SArmin Le Grand     if(aSource.count())
13808718d260SArmin Le Grand     {
13818718d260SArmin Le Grand         const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
13828718d260SArmin Le Grand         aSource.transform(aTransform);
13838718d260SArmin Le Grand 
13848718d260SArmin Le Grand         if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
13858718d260SArmin Le Grand         {
13868718d260SArmin Le Grand             const Gradient& rGradient = rAct.GetGradient();
13878718d260SArmin Le Grand             SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
13888718d260SArmin Le Grand             SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0);
1389*603e43faSArmin Le Grand             const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
13908718d260SArmin Le Grand             const XFillGradientItem aXFillGradientItem(
13918718d260SArmin Le Grand                 &mpModel->GetItemPool(),
13928718d260SArmin Le Grand                 XGradient(
13938718d260SArmin Le Grand                     rGradient.GetStartColor(),
13948718d260SArmin Le Grand                     rGradient.GetEndColor(),
13958718d260SArmin Le Grand                     aXGradientStyle,
13968718d260SArmin Le Grand                     rGradient.GetAngle(),
13978718d260SArmin Le Grand                     rGradient.GetOfsX(),
13988718d260SArmin Le Grand                     rGradient.GetOfsY(),
13998718d260SArmin Le Grand                     rGradient.GetBorder(),
14008718d260SArmin Le Grand                     rGradient.GetStartIntensity(),
14018718d260SArmin Le Grand                     rGradient.GetEndIntensity(),
14028718d260SArmin Le Grand                     rGradient.GetSteps()));
14038718d260SArmin Le Grand 
14048718d260SArmin Le Grand             SetAttributes(pPath);
14058718d260SArmin Le Grand             aGradientAttr.Put(XFillStyleItem(XFILL_HATCH));
14068718d260SArmin Le Grand             aGradientAttr.Put(aXFillGradientItem);
14078718d260SArmin Le Grand             pPath->SetMergedItemSet(aGradientAttr);
14088718d260SArmin Le Grand 
14098718d260SArmin Le Grand             InsertObj(pPath, false);
14108718d260SArmin Le Grand         }
14118718d260SArmin Le Grand     }
14128718d260SArmin Le Grand }
14138718d260SArmin Le Grand 
14148718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
14158718d260SArmin Le Grand {
14168718d260SArmin Le Grand     const GDIMetaFile& rMtf = rAct.GetGDIMetaFile();
14178718d260SArmin Le Grand 
14188718d260SArmin Le Grand     if(rMtf.GetActionCount())
14198718d260SArmin Le Grand     {
14209f63b866SArmin Le Grand         const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
14218718d260SArmin Le Grand 
14229f63b866SArmin Le Grand         // convert metafile sub-content to BitmapEx
14239f63b866SArmin Le Grand         BitmapEx aBitmapEx(
14249f63b866SArmin Le Grand             convertMetafileToBitmapEx(
14259f63b866SArmin Le Grand                 rMtf,
14269f63b866SArmin Le Grand                 basegfx::B2DRange(
14279f63b866SArmin Le Grand                     aRect.Left(), aRect.Top(),
14289f63b866SArmin Le Grand                     aRect.Right(), aRect.Bottom()),
14299f63b866SArmin Le Grand                 125000));
14308718d260SArmin Le Grand 
14318718d260SArmin Le Grand         // handle colors
14328718d260SArmin Le Grand         const Gradient& rGradient = rAct.GetGradient();
14338718d260SArmin Le Grand         basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
14348718d260SArmin Le Grand         basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
14358718d260SArmin Le Grand 
14368718d260SArmin Le Grand         if(100 != rGradient.GetStartIntensity())
14378718d260SArmin Le Grand         {
14388718d260SArmin Le Grand             aStart *= (double)rGradient.GetStartIntensity() / 100.0;
14398718d260SArmin Le Grand         }
14408718d260SArmin Le Grand 
14418718d260SArmin Le Grand         if(100 != rGradient.GetEndIntensity())
14428718d260SArmin Le Grand         {
14438718d260SArmin Le Grand             aEnd *= (double)rGradient.GetEndIntensity() / 100.0;
14448718d260SArmin Le Grand         }
14458718d260SArmin Le Grand 
14468718d260SArmin Le Grand         const bool bEqualColors(aStart == aEnd);
14478718d260SArmin Le Grand         const bool bNoSteps(1 == rGradient.GetSteps());
14488718d260SArmin Le Grand         bool bCreateObject(true);
14498718d260SArmin Le Grand         bool bHasNewMask(false);
14508718d260SArmin Le Grand         AlphaMask aNewMask;
14519f63b866SArmin Le Grand         double fTransparence(0.0);
14529f63b866SArmin Le Grand         bool bFixedTransparence(false);
14538718d260SArmin Le Grand 
14548718d260SArmin Le Grand         if(bEqualColors || bNoSteps)
14558718d260SArmin Le Grand         {
14568718d260SArmin Le Grand             // single transparence
14578718d260SArmin Le Grand             const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
14589f63b866SArmin Le Grand             fTransparence = aMedium.luminance();
14598718d260SArmin Le Grand 
14608718d260SArmin Le Grand             if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
14618718d260SArmin Le Grand             {
14628718d260SArmin Le Grand                 // no transparence needed, all done
14638718d260SArmin Le Grand             }
14648718d260SArmin Le Grand             else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0))
14658718d260SArmin Le Grand             {
14668718d260SArmin Le Grand                 // all transparent, no object
14678718d260SArmin Le Grand                 bCreateObject = false;
14688718d260SArmin Le Grand             }
14698718d260SArmin Le Grand             else
14708718d260SArmin Le Grand             {
14719f63b866SArmin Le Grand                 // 0.0 < transparence < 1.0, apply fixed transparence
14729f63b866SArmin Le Grand                 bFixedTransparence = true;
14738718d260SArmin Le Grand             }
14748718d260SArmin Le Grand         }
14758718d260SArmin Le Grand         else
14768718d260SArmin Le Grand         {
14778718d260SArmin Le Grand             // gradient transparence
14788718d260SArmin Le Grand             VirtualDevice aVDev;
14798718d260SArmin Le Grand 
14808718d260SArmin Le Grand             aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
14818718d260SArmin Le Grand             aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
14828718d260SArmin Le Grand 
14838718d260SArmin Le Grand             aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
14848718d260SArmin Le Grand             bHasNewMask = true;
14858718d260SArmin Le Grand         }
14868718d260SArmin Le Grand 
14878718d260SArmin Le Grand         if(bCreateObject)
14888718d260SArmin Le Grand         {
14899f63b866SArmin Le Grand             if(bHasNewMask || bFixedTransparence)
14908718d260SArmin Le Grand             {
14918718d260SArmin Le Grand                 if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
14928718d260SArmin Le Grand                 {
14938718d260SArmin Le Grand                     // no transparence yet, apply new one
14949f63b866SArmin Le Grand                     if(bFixedTransparence)
14959f63b866SArmin Le Grand                     {
14969f63b866SArmin Le Grand                         sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
14979f63b866SArmin Le Grand 
14989f63b866SArmin Le Grand                         aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
14999f63b866SArmin Le Grand                     }
15009f63b866SArmin Le Grand 
15018718d260SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
15028718d260SArmin Le Grand                 }
15038718d260SArmin Le Grand                 else
15048718d260SArmin Le Grand                 {
15058718d260SArmin Le Grand                     // mix existing and new alpha mask
15068718d260SArmin Le Grand                     AlphaMask aOldMask;
15078718d260SArmin Le Grand 
15088718d260SArmin Le Grand                     if(aBitmapEx.IsAlpha())
15098718d260SArmin Le Grand                     {
15108718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetAlpha();
15118718d260SArmin Le Grand                     }
15128718d260SArmin Le Grand                     else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType())
15138718d260SArmin Le Grand                     {
15148718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetMask();
15158718d260SArmin Le Grand                     }
15168718d260SArmin Le Grand                     else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType())
15178718d260SArmin Le Grand                     {
15188718d260SArmin Le Grand                         aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
15198718d260SArmin Le Grand                     }
15208718d260SArmin Le Grand 
15219f63b866SArmin Le Grand                     BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
15228718d260SArmin Le Grand 
15239f63b866SArmin Le Grand                     if(pOld)
15249f63b866SArmin Le Grand                     {
15259f63b866SArmin Le Grand                         const double fFactor(1.0 / 255.0);
15269f63b866SArmin Le Grand 
15279f63b866SArmin Le Grand                         if(bFixedTransparence)
15289f63b866SArmin Le Grand                         {
15299f63b866SArmin Le Grand                             const double fOpNew(1.0 - fTransparence);
15309f63b866SArmin Le Grand 
1531*603e43faSArmin Le Grand                             for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
15329f63b866SArmin Le Grand                             {
1533*603e43faSArmin Le Grand                                 for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
15349f63b866SArmin Le Grand                                 {
15359f63b866SArmin Le Grand                                     const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
15369f63b866SArmin Le Grand                                     const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
15379f63b866SArmin Le Grand 
15389f63b866SArmin Le Grand                                     pOld->SetPixel(y, x, BitmapColor(aCol));
15399f63b866SArmin Le Grand                                 }
15409f63b866SArmin Le Grand                             }
15419f63b866SArmin Le Grand                         }
15429f63b866SArmin Le Grand                         else
15439f63b866SArmin Le Grand                         {
15449f63b866SArmin Le Grand                             BitmapReadAccess* pNew = aNewMask.AcquireReadAccess();
15459f63b866SArmin Le Grand 
15469f63b866SArmin Le Grand                             if(pNew)
15478718d260SArmin Le Grand                             {
15488718d260SArmin Le Grand                                 if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height())
15498718d260SArmin Le Grand                                 {
1550*603e43faSArmin Le Grand                                     for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++)
15518718d260SArmin Le Grand                                     {
1552*603e43faSArmin Le Grand                                         for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++)
15538718d260SArmin Le Grand                                         {
15549f63b866SArmin Le Grand                                             const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
15559f63b866SArmin Le Grand                                             const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor));
15569f63b866SArmin Le Grand                                             const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
15578718d260SArmin Le Grand 
15589f63b866SArmin Le Grand                                             pOld->SetPixel(y, x, BitmapColor(aCol));
15598718d260SArmin Le Grand                                         }
15608718d260SArmin Le Grand                                     }
15618718d260SArmin Le Grand                                 }
15628718d260SArmin Le Grand                                 else
15638718d260SArmin Le Grand                                 {
15648718d260SArmin Le Grand                                     OSL_ENSURE(false, "Alpha masks have different sizes (!)");
15658718d260SArmin Le Grand                                 }
15668718d260SArmin Le Grand 
15678718d260SArmin Le Grand                                 aNewMask.ReleaseAccess(pNew);
15688718d260SArmin Le Grand                             }
15698718d260SArmin Le Grand                             else
15708718d260SArmin Le Grand                             {
15719f63b866SArmin Le Grand                                 OSL_ENSURE(false, "Got no access to new alpha mask (!)");
15729f63b866SArmin Le Grand                             }
15739f63b866SArmin Le Grand                         }
15749f63b866SArmin Le Grand 
15759f63b866SArmin Le Grand                         aOldMask.ReleaseAccess(pOld);
15769f63b866SArmin Le Grand                     }
15779f63b866SArmin Le Grand                     else
15789f63b866SArmin Le Grand                     {
15799f63b866SArmin Le Grand                         OSL_ENSURE(false, "Got no access to old alpha mask (!)");
15808718d260SArmin Le Grand                     }
15818718d260SArmin Le Grand 
15828718d260SArmin Le Grand                     // apply combined bitmap as mask
15839f63b866SArmin Le Grand                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
15848718d260SArmin Le Grand                 }
15858718d260SArmin Le Grand             }
15868718d260SArmin Le Grand 
15878718d260SArmin Le Grand             // create and add object
15888718d260SArmin Le Grand             SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
15898718d260SArmin Le Grand 
15908718d260SArmin Le Grand             InsertObj(pGraf);
15918718d260SArmin Le Grand         }
15928718d260SArmin Le Grand     }
15938718d260SArmin Le Grand }
15948718d260SArmin Le Grand 
15958718d260SArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
1596cdf0e10cSrcweir // eof
1597