1f6e50924SAndrew Rist /************************************************************** 2f6e50924SAndrew Rist * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svdfmtf.hxx" 28cdf0e10cSrcweir #include <editeng/editdata.hxx> 29cdf0e10cSrcweir #include <math.h> 30cdf0e10cSrcweir #include <svx/xpoly.hxx> 31cdf0e10cSrcweir #include <vcl/svapp.hxx> 32cdf0e10cSrcweir #include <editeng/eeitem.hxx> 33cdf0e10cSrcweir #include <editeng/fhgtitem.hxx> 34cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 35cdf0e10cSrcweir #include <editeng/postitem.hxx> 36cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 37cdf0e10cSrcweir #include <editeng/crsditem.hxx> 38cdf0e10cSrcweir #include <editeng/shdditem.hxx> 39cdf0e10cSrcweir #include <svx/xlnclit.hxx> 405aaf853bSArmin Le Grand #include <svx/xlncapit.hxx> 41cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 42cdf0e10cSrcweir #include <svx/xflclit.hxx> 43cdf0e10cSrcweir #include <svx/xgrad.hxx> 44cdf0e10cSrcweir #include <svx/xflgrit.hxx> 45cdf0e10cSrcweir #include <editeng/fontitem.hxx> 46cdf0e10cSrcweir #include <editeng/akrnitem.hxx> 47cdf0e10cSrcweir #include <editeng/wrlmitem.hxx> 48cdf0e10cSrcweir #include <editeng/cntritem.hxx> 49cdf0e10cSrcweir #include <editeng/colritem.hxx> 50cdf0e10cSrcweir #include <vcl/metric.hxx> 51cdf0e10cSrcweir #include <editeng/charscaleitem.hxx> 52cdf0e10cSrcweir #include <svx/xflhtit.hxx> 53cdf0e10cSrcweir #include <svx/svdattr.hxx> 54cdf0e10cSrcweir #include <svx/svdmodel.hxx> 55cdf0e10cSrcweir #include <svx/svdpage.hxx> 56cdf0e10cSrcweir #include <svx/svdobj.hxx> 57cdf0e10cSrcweir #include "svx/svditext.hxx" 58cdf0e10cSrcweir #include <svx/svdotext.hxx> 59cdf0e10cSrcweir #include <svx/svdorect.hxx> 60cdf0e10cSrcweir #include <svx/svdocirc.hxx> 61cdf0e10cSrcweir #include <svx/svdograf.hxx> 62cdf0e10cSrcweir #include <svx/svdopath.hxx> 63cdf0e10cSrcweir #include <svx/svdetc.hxx> 64cdf0e10cSrcweir #include <svl/itemset.hxx> 65cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 66cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound 67cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 68cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 69cdf0e10cSrcweir #include <svx/xlinjoit.hxx> 70cdf0e10cSrcweir #include <svx/xlndsit.hxx> 7147a7c0c1SArmin Le Grand #include <basegfx/polygon/b2dpolygonclipper.hxx> 7247a7c0c1SArmin Le Grand #include <svx/xbtmpit.hxx> 738718d260SArmin Le Grand #include <svx/xfltrit.hxx> 748718d260SArmin Le Grand #include <vcl/bmpacc.hxx> 759f63b866SArmin Le Grand #include <svx/xflbmtit.hxx> 769f63b866SArmin Le Grand #include <svx/xflbstit.hxx> 779f63b866SArmin Le Grand #include <svx/svdpntv.hxx> 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 1988718d260SArmin Le Grand { 1998718d260SArmin Le Grand if(!pProgrInfo->ReportActions(*pActionsToReport)) 2008718d260SArmin Le Grand break; 2018718d260SArmin Le Grand 2028718d260SArmin Le Grand *pActionsToReport = 0; 2038718d260SArmin Le Grand } 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 2068718d260SArmin Le Grand } 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 } 282cdf0e10cSrcweir 2838718d260SArmin Le Grand nActionsToReport = 0; 2848718d260SArmin Le Grand 2858718d260SArmin Le Grand // alle in maTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen 2868718d260SArmin Le Grand if(nInsPos > rOL.GetObjCount()) 2878718d260SArmin Le Grand { 2888718d260SArmin Le Grand nInsPos = rOL.GetObjCount(); 2898718d260SArmin Le Grand } 2908718d260SArmin Le Grand 291cdf0e10cSrcweir SdrInsertReason aReason(SDRREASON_VIEWCALL); 2928718d260SArmin Le Grand 2938718d260SArmin Le Grand for(sal_uInt32 i(0); i < maTmpList.size(); i++) 294cdf0e10cSrcweir { 2958718d260SArmin Le Grand SdrObject* pObj = maTmpList[i]; 2968718d260SArmin Le Grand rOL.NbcInsertObject(pObj, nInsPos, &aReason); 2978718d260SArmin Le Grand nInsPos++; 298cdf0e10cSrcweir 2998718d260SArmin Le Grand if(pProgrInfo) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir nActionsToReport++; 3028718d260SArmin Le Grand 3038718d260SArmin Le Grand 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 3288718d260SArmin Le Grand if(bLine) 329cdf0e10cSrcweir { 3308718d260SArmin Le Grand if(mnLineWidth) 3318718d260SArmin Le Grand { 3328718d260SArmin Le Grand mpLineAttr->Put(XLineWidthItem(mnLineWidth)); 3338718d260SArmin Le Grand } 334cdf0e10cSrcweir else 3358718d260SArmin Le Grand { 3368718d260SArmin Le Grand mpLineAttr->Put(XLineWidthItem(0)); 3378718d260SArmin Le Grand } 3388718d260SArmin Le Grand 3398718d260SArmin Le Grand maOldLineColor = maVD.GetLineColor(); 340cdf0e10cSrcweir 3418718d260SArmin Le Grand if(maVD.IsLineColor()) 342cdf0e10cSrcweir { 3438718d260SArmin Le Grand mpLineAttr->Put(XLineStyleItem(XLINE_SOLID)); 3448718d260SArmin Le Grand mpLineAttr->Put(XLineColorItem(String(), maVD.GetLineColor())); 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 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 3878718d260SArmin Le Grand 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 4478718d260SArmin Le Grand if(bText) 448cdf0e10cSrcweir { 4498718d260SArmin Le Grand pObj->SetMergedItemSet(*mpTextAttr); 4508718d260SArmin Le Grand 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()) 471cdf0e10cSrcweir { 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 } 483cdf0e10cSrcweir 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 } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 53247a7c0c1SArmin Le Grand if(pObj) 533cdf0e10cSrcweir { 53447a7c0c1SArmin Le Grand // #i111954# check object for visibility 53547a7c0c1SArmin Le Grand // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj 53647a7c0c1SArmin Le Grand bool bVisible(false); 537cdf0e10cSrcweir 53847a7c0c1SArmin Le Grand if(pObj->HasLineStyle()) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir bVisible = true; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 54347a7c0c1SArmin Le Grand if(!bVisible && pObj->HasFillStyle()) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir bVisible = true; 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 54847a7c0c1SArmin Le Grand if(!bVisible) 54947a7c0c1SArmin Le Grand { 55047a7c0c1SArmin Le Grand SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj); 55147a7c0c1SArmin Le Grand 55247a7c0c1SArmin Le Grand if(pTextObj && pTextObj->HasText()) 55347a7c0c1SArmin Le Grand { 55447a7c0c1SArmin Le Grand bVisible = true; 55547a7c0c1SArmin Le Grand } 55647a7c0c1SArmin Le Grand } 55747a7c0c1SArmin Le Grand 55847a7c0c1SArmin Le Grand if(!bVisible) 55947a7c0c1SArmin Le Grand { 56047a7c0c1SArmin Le Grand SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj); 56147a7c0c1SArmin Le Grand 56247a7c0c1SArmin Le Grand if(pGrafObj) 56347a7c0c1SArmin Le Grand { 56447a7c0c1SArmin Le Grand // this may be refined to check if the graphic really is visible. It 56547a7c0c1SArmin Le Grand // is here to ensure that graphic objects without fill, line and text 56647a7c0c1SArmin Le Grand // get created 56747a7c0c1SArmin Le Grand bVisible = true; 56847a7c0c1SArmin Le Grand } 56947a7c0c1SArmin Le Grand } 57047a7c0c1SArmin Le Grand 57147a7c0c1SArmin Le Grand if(!bVisible) 57247a7c0c1SArmin Le Grand { 57347a7c0c1SArmin Le Grand SdrObject::Free(pObj); 57447a7c0c1SArmin Le Grand } 57547a7c0c1SArmin Le Grand else 57647a7c0c1SArmin Le Grand { 5778718d260SArmin Le Grand maTmpList.push_back(pObj); 5788718d260SArmin Le Grand 5798718d260SArmin Le Grand if(dynamic_cast< SdrPathObj* >(pObj)) 58047a7c0c1SArmin Le Grand { 5818718d260SArmin Le Grand const bool bClosed(pObj->IsClosedObj()); 5828718d260SArmin Le Grand 5838718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = mbNoLine && bClosed; 5848718d260SArmin Le Grand mbLastObjWasLine = !bClosed; 58547a7c0c1SArmin Le Grand } 58647a7c0c1SArmin Le Grand else 58747a7c0c1SArmin Le Grand { 5888718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = false; 5898718d260SArmin Le Grand mbLastObjWasLine = false; 59047a7c0c1SArmin Le Grand } 59147a7c0c1SArmin Le Grand } 592cdf0e10cSrcweir } 593cdf0e10cSrcweir } 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 { 65047a7c0c1SArmin Le Grand SdrRectObj* pRect=new SdrRectObj(rAct.GetRect()); 651cdf0e10cSrcweir SetAttributes(pRect); 652cdf0e10cSrcweir InsertObj(pRect); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct) 656cdf0e10cSrcweir { 65747a7c0c1SArmin Le Grand 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 { 67247a7c0c1SArmin Le Grand SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect()); 673cdf0e10cSrcweir SetAttributes(pCirc); 674cdf0e10cSrcweir InsertObj(pCirc); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct) 678cdf0e10cSrcweir { 67947a7c0c1SArmin Le Grand 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 { 68947a7c0c1SArmin Le Grand 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 { 69947a7c0c1SArmin Le Grand 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 { 812*e6f63103SArmin Le Grand maClip = maVD.GetClipRegion().GetAsB2DPolyPolygon(); 81347a7c0c1SArmin Le Grand 81447a7c0c1SArmin Le Grand if(isClip()) 81547a7c0c1SArmin Le Grand { 81647a7c0c1SArmin Le Grand const basegfx::B2DHomMatrix aTransform( 81747a7c0c1SArmin Le Grand basegfx::tools::createScaleTranslateB2DHomMatrix( 8188718d260SArmin Le Grand mfScaleX, 8198718d260SArmin Le Grand mfScaleY, 8208718d260SArmin Le Grand maOfs.X(), 8218718d260SArmin Le Grand maOfs.Y())); 82247a7c0c1SArmin Le Grand 82347a7c0c1SArmin Le Grand maClip.transform(aTransform); 82447a7c0c1SArmin Le Grand } 82547a7c0c1SArmin Le Grand } 82647a7c0c1SArmin Le Grand } 82747a7c0c1SArmin Le Grand 82847a7c0c1SArmin Le Grand bool ImpSdrGDIMetaFileImport::isClip() const 82947a7c0c1SArmin Le Grand { 83047a7c0c1SArmin Le Grand return !maClip.getB2DRange().isEmpty(); 83147a7c0c1SArmin Le Grand } 832cdf0e10cSrcweir 833cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes 836cdf0e10cSrcweir basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon()); 837cdf0e10cSrcweir 838cdf0e10cSrcweir if(aSource.count()) 839cdf0e10cSrcweir { 8408718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 841cdf0e10cSrcweir aSource.transform(aTransform); 842cdf0e10cSrcweir } 843cdf0e10cSrcweir 844cdf0e10cSrcweir const LineInfo& rLineInfo = rAct.GetLineInfo(); 845cdf0e10cSrcweir const sal_Int32 nNewLineWidth(rLineInfo.GetWidth()); 846cdf0e10cSrcweir bool bCreateLineObject(true); 847cdf0e10cSrcweir 8488718d260SArmin Le Grand if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aSource)) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir bCreateLineObject = false; 851cdf0e10cSrcweir } 8528718d260SArmin Le Grand else if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir bCreateLineObject = false; 855cdf0e10cSrcweir } 856cdf0e10cSrcweir 857cdf0e10cSrcweir if(bCreateLineObject) 858cdf0e10cSrcweir { 85947a7c0c1SArmin Le Grand SdrPathObj* pPath = new SdrPathObj( 860cdf0e10cSrcweir aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, 861cdf0e10cSrcweir basegfx::B2DPolyPolygon(aSource)); 8628718d260SArmin Le Grand mnLineWidth = nNewLineWidth; 863cdf0e10cSrcweir maLineJoin = rLineInfo.GetLineJoin(); 8645aaf853bSArmin Le Grand maLineCap = rLineInfo.GetLineCap(); 865cdf0e10cSrcweir maDash = XDash(XDASH_RECT, 866cdf0e10cSrcweir rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), 867cdf0e10cSrcweir rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), 868cdf0e10cSrcweir rLineInfo.GetDistance()); 869cdf0e10cSrcweir SetAttributes(pPath); 8708718d260SArmin Le Grand mnLineWidth = 0; 871cdf0e10cSrcweir maLineJoin = basegfx::B2DLINEJOIN_NONE; 872cdf0e10cSrcweir maDash = XDash(); 873cdf0e10cSrcweir InsertObj(pPath, false); 874cdf0e10cSrcweir } 875cdf0e10cSrcweir } 876cdf0e10cSrcweir 877cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct ) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes 880cdf0e10cSrcweir basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon()); 881cdf0e10cSrcweir 882cdf0e10cSrcweir if(aSource.count()) 883cdf0e10cSrcweir { 8848718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 885cdf0e10cSrcweir aSource.transform(aTransform); 886cdf0e10cSrcweir 8878718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir // #i73407# make sure polygon is closed, it's a filled primitive 890cdf0e10cSrcweir aSource.setClosed(true); 89147a7c0c1SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource)); 892cdf0e10cSrcweir SetAttributes(pPath); 893cdf0e10cSrcweir InsertObj(pPath, false); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir } 896cdf0e10cSrcweir } 897cdf0e10cSrcweir 898cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct) 899cdf0e10cSrcweir { 900cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes 901cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 902cdf0e10cSrcweir 903cdf0e10cSrcweir if(aSource.count()) 904cdf0e10cSrcweir { 9058718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 906cdf0e10cSrcweir aSource.transform(aTransform); 907cdf0e10cSrcweir 9088718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir // #i73407# make sure polygon is closed, it's a filled primitive 911cdf0e10cSrcweir aSource.setClosed(true); 91247a7c0c1SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 913cdf0e10cSrcweir SetAttributes(pPath); 914cdf0e10cSrcweir InsertObj(pPath, false); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir } 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir /**************************************************************************************************/ 920cdf0e10cSrcweir 921cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct ) 922cdf0e10cSrcweir { 923cdf0e10cSrcweir // calc text box size, add 5% to make it fit safely 924cdf0e10cSrcweir 9258718d260SArmin Le Grand FontMetric aFontMetric( maVD.GetFontMetric() ); 9268718d260SArmin Le Grand Font aFnt( maVD.GetFont() ); 927cdf0e10cSrcweir FontAlign eAlg( aFnt.GetAlign() ); 928cdf0e10cSrcweir 9298718d260SArmin Le Grand sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX ); 9308718d260SArmin Le Grand sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY ); 931cdf0e10cSrcweir //sal_Int32 nDxWidth = 0; 932cdf0e10cSrcweir //sal_Int32 nLen = rStr.Len(); 933cdf0e10cSrcweir 9348718d260SArmin Le Grand Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) ); 935cdf0e10cSrcweir Size aSize( nTextWidth, nTextHeight ); 936cdf0e10cSrcweir 937cdf0e10cSrcweir if ( eAlg == ALIGN_BASELINE ) 9388718d260SArmin Le Grand aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY); 939cdf0e10cSrcweir else if ( eAlg == ALIGN_BOTTOM ) 940cdf0e10cSrcweir aPos.Y() -= nTextHeight; 941cdf0e10cSrcweir 942cdf0e10cSrcweir Rectangle aTextRect( aPos, aSize ); 943cdf0e10cSrcweir SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect ); 944cdf0e10cSrcweir 945cdf0e10cSrcweir if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) ) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH ); 9488718d260SArmin Le Grand pText->SetMergedItem( SdrTextAutoGrowHeightItem( false ) ); 949cdf0e10cSrcweir // don't let the margins eat the space needed for the text 950cdf0e10cSrcweir pText->SetMergedItem ( SdrTextUpperDistItem (0)); 951cdf0e10cSrcweir pText->SetMergedItem ( SdrTextLowerDistItem (0)); 952cdf0e10cSrcweir pText->SetMergedItem ( SdrTextRightDistItem (0)); 953cdf0e10cSrcweir pText->SetMergedItem ( SdrTextLeftDistItem (0)); 95426734c99SArmin Le Grand pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) ); 955cdf0e10cSrcweir } 956cdf0e10cSrcweir else 9578718d260SArmin Le Grand pText->SetMergedItem( SdrTextAutoGrowWidthItem( true ) ); 958cdf0e10cSrcweir 9598718d260SArmin Le Grand pText->SetModel(mpModel); 9608718d260SArmin Le Grand pText->SetLayer(mnLayer); 961cdf0e10cSrcweir pText->NbcSetText( rStr ); 9628718d260SArmin Le Grand SetAttributes( pText, true ); 963cdf0e10cSrcweir pText->SetSnapRect( aTextRect ); 964cdf0e10cSrcweir 965cdf0e10cSrcweir if (!aFnt.IsTransparent()) 966cdf0e10cSrcweir { 9678718d260SArmin Le Grand SfxItemSet aAttr(*mpFillAttr->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0); 968cdf0e10cSrcweir aAttr.Put(XFillStyleItem(XFILL_SOLID)); 969cdf0e10cSrcweir aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor())); 970cdf0e10cSrcweir pText->SetMergedItemSet(aAttr); 971cdf0e10cSrcweir } 972cdf0e10cSrcweir sal_uInt32 nWink = aFnt.GetOrientation(); 973cdf0e10cSrcweir if ( nWink ) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir nWink*=10; 976cdf0e10cSrcweir double a=nWink*nPi180; 977cdf0e10cSrcweir double nSin=sin(a); 978cdf0e10cSrcweir double nCos=cos(a); 979cdf0e10cSrcweir pText->NbcRotate(aPos,nWink,nSin,nCos); 980cdf0e10cSrcweir } 9818718d260SArmin Le Grand InsertObj( pText, false ); 982cdf0e10cSrcweir } 983cdf0e10cSrcweir 984cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct) 985cdf0e10cSrcweir { 986cdf0e10cSrcweir XubString aStr(rAct.GetText()); 987cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex()); 988cdf0e10cSrcweir aStr.Erase(rAct.GetLen()); 989cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct ); 990cdf0e10cSrcweir } 991cdf0e10cSrcweir 992cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir XubString aStr(rAct.GetText()); 995cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex()); 996cdf0e10cSrcweir aStr.Erase(rAct.GetLen()); 997cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct ); 998cdf0e10cSrcweir } 999cdf0e10cSrcweir 1000cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir XubString aStr(rAct.GetText()); 1003cdf0e10cSrcweir aStr.Erase(0,rAct.GetIndex()); 1004cdf0e10cSrcweir aStr.Erase(rAct.GetLen()); 1005cdf0e10cSrcweir ImportText( rAct.GetPoint(), aStr, rAct ); 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel()); 1011cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++; 101247a7c0c1SArmin Le Grand SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect); 1013cdf0e10cSrcweir InsertObj(pGraf); 1014cdf0e10cSrcweir } 1015cdf0e10cSrcweir 1016cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct) 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); 1019cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++; 102047a7c0c1SArmin Le Grand SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect); 1021cdf0e10cSrcweir InsertObj(pGraf); 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct) 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel()); 1027cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++; 102847a7c0c1SArmin Le Grand SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect ); 1029cdf0e10cSrcweir InsertObj(pGraf); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); 1035cdf0e10cSrcweir aRect.Right()++; aRect.Bottom()++; 103647a7c0c1SArmin Le Grand SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect ); 1037cdf0e10cSrcweir InsertObj(pGraf); 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct ) 1043cdf0e10cSrcweir { 1044cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes 1045cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir if(aSource.count()) 1048cdf0e10cSrcweir { 10498718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 1050cdf0e10cSrcweir aSource.transform(aTransform); 1051cdf0e10cSrcweir 10528718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir const Hatch& rHatch = rAct.GetHatch(); 105547a7c0c1SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 10568718d260SArmin Le Grand SfxItemSet aHatchAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0); 1057cdf0e10cSrcweir XHatchStyle eStyle; 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir switch(rHatch.GetStyle()) 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir case(HATCH_TRIPLE) : 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir eStyle = XHATCH_TRIPLE; 1064cdf0e10cSrcweir break; 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir case(HATCH_DOUBLE) : 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir eStyle = XHATCH_DOUBLE; 1070cdf0e10cSrcweir break; 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir default: 1074cdf0e10cSrcweir { 1075cdf0e10cSrcweir eStyle = XHATCH_SINGLE; 1076cdf0e10cSrcweir break; 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir SetAttributes(pPath); 1081cdf0e10cSrcweir aHatchAttr.Put(XFillStyleItem(XFILL_HATCH)); 10828718d260SArmin Le Grand aHatchAttr.Put(XFillHatchItem(&mpModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle()))); 1083cdf0e10cSrcweir pPath->SetMergedItemSet(aHatchAttr); 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir InsertObj(pPath, false); 1086cdf0e10cSrcweir } 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct) 1093cdf0e10cSrcweir { 10948718d260SArmin Le Grand rAct.Execute(&maVD); 1095cdf0e10cSrcweir } 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir MapScaling(); 11008718d260SArmin Le Grand rAct.Execute(&maVD); 11018718d260SArmin Le Grand mbLastObjWasPolyWithoutLine = false; 11028718d260SArmin Le Grand mbLastObjWasLine = false; 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::MapScaling() 1106cdf0e10cSrcweir { 11078718d260SArmin Le Grand const sal_uInt32 nAnz(maTmpList.size()); 11088718d260SArmin Le Grand sal_uInt32 i(0); 11098718d260SArmin Le Grand const MapMode& rMap = maVD.GetMapMode(); 1110cdf0e10cSrcweir Point aMapOrg( rMap.GetOrigin() ); 11118718d260SArmin Le Grand bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0); 11128718d260SArmin Le Grand 11138718d260SArmin Le Grand if(bMov2) 1114cdf0e10cSrcweir { 11158718d260SArmin Le Grand for(i = mnMapScalingOfs; i < nAnz; i++) 1116cdf0e10cSrcweir { 11178718d260SArmin Le Grand SdrObject* pObj = maTmpList[i]; 11188718d260SArmin Le Grand 11198718d260SArmin Le Grand pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y())); 1120cdf0e10cSrcweir } 1121cdf0e10cSrcweir } 11228718d260SArmin Le Grand 11238718d260SArmin Le Grand mnMapScalingOfs = nAnz; 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf ) 1129cdf0e10cSrcweir { 1130cdf0e10cSrcweir ByteString aSkipComment; 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction(); 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION ) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir // #i73407# reformulation to use new B2DPolygon classes 1139cdf0e10cSrcweir basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon()); 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir if(aSource.count()) 1142cdf0e10cSrcweir { 11438718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) 1144cdf0e10cSrcweir { 1145cdf0e10cSrcweir const Gradient& rGrad = pAct->GetGradient(); 114647a7c0c1SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 11478718d260SArmin Le Grand SfxItemSet aGradAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0); 1148cdf0e10cSrcweir XGradient aXGradient; 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle()); 1151cdf0e10cSrcweir aXGradient.SetStartColor(rGrad.GetStartColor()); 1152cdf0e10cSrcweir aXGradient.SetEndColor(rGrad.GetEndColor()); 1153cdf0e10cSrcweir aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle()); 1154cdf0e10cSrcweir aXGradient.SetBorder(rGrad.GetBorder()); 1155cdf0e10cSrcweir aXGradient.SetXOffset(rGrad.GetOfsX()); 1156cdf0e10cSrcweir aXGradient.SetYOffset(rGrad.GetOfsY()); 1157cdf0e10cSrcweir aXGradient.SetStartIntens(rGrad.GetStartIntensity()); 1158cdf0e10cSrcweir aXGradient.SetEndIntens(rGrad.GetEndIntensity()); 1159cdf0e10cSrcweir aXGradient.SetSteps(rGrad.GetSteps()); 1160cdf0e10cSrcweir 11618718d260SArmin Le Grand if(maVD.IsLineColor()) 1162cdf0e10cSrcweir { 1163cdf0e10cSrcweir // switch line off; when there was one there will be a 1164cdf0e10cSrcweir // META_POLYLINE_ACTION following creating another object 11658718d260SArmin Le Grand const Color aLineColor(maVD.GetLineColor()); 11668718d260SArmin Le Grand maVD.SetLineColor(); 1167cdf0e10cSrcweir SetAttributes(pPath); 11688718d260SArmin Le Grand maVD.SetLineColor(aLineColor); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir else 1171cdf0e10cSrcweir { 1172cdf0e10cSrcweir SetAttributes(pPath); 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT)); 11768718d260SArmin Le Grand aGradAttr.Put(XFillGradientItem(&mpModel->GetItemPool(), aXGradient)); 1177cdf0e10cSrcweir pPath->SetMergedItemSet(aGradAttr); 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir InsertObj(pPath); 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir } 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir aSkipComment = "XGRAD_SEQ_END"; 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir if(aSkipComment.Len()) 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir MetaAction* pSkipAct = pMtf->NextAction(); 1190cdf0e10cSrcweir 1191cdf0e10cSrcweir while( pSkipAct 1192cdf0e10cSrcweir && ((pSkipAct->GetType() != META_COMMENT_ACTION ) 1193cdf0e10cSrcweir || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL))) 1194cdf0e10cSrcweir { 1195cdf0e10cSrcweir pSkipAct = pMtf->NextAction(); 1196cdf0e10cSrcweir } 1197cdf0e10cSrcweir } 1198cdf0e10cSrcweir } 1199cdf0e10cSrcweir 12008718d260SArmin Le Grand //////////////////////////////////////////////////////////////////////////////////////////////////// 12018718d260SArmin Le Grand 12028718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct) 12038718d260SArmin Le Grand { 12048718d260SArmin Le Grand GDIMetaFile aTemp; 12058718d260SArmin Le Grand 12068718d260SArmin Le Grand maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp); 12078718d260SArmin Le Grand DoLoopActions(aTemp, 0, 0); 12088718d260SArmin Le Grand } 12098718d260SArmin Le Grand 12108718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct) 12118718d260SArmin Le Grand { 12128718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize()); 12138718d260SArmin Le Grand Bitmap aBitmap(rAct.GetBitmap()); 12148718d260SArmin Le Grand 12158718d260SArmin Le Grand aRect.Right()++; 12168718d260SArmin Le Grand aRect.Bottom()++; 12178718d260SArmin Le Grand aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize())); 12188718d260SArmin Le Grand 12198718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect); 12208718d260SArmin Le Grand 12218718d260SArmin Le Grand InsertObj(pGraf); 12228718d260SArmin Le Grand } 12238718d260SArmin Le Grand 12248718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct) 12258718d260SArmin Le Grand { 12268718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(),rAct.GetDestSize()); 12278718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmapEx()); 12288718d260SArmin Le Grand 12298718d260SArmin Le Grand aRect.Right()++; 12308718d260SArmin Le Grand aRect.Bottom()++; 12318718d260SArmin Le Grand aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize())); 12328718d260SArmin Le Grand 12338718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 12348718d260SArmin Le Grand 12358718d260SArmin Le Grand InsertObj(pGraf); 12368718d260SArmin Le Grand } 12378718d260SArmin Le Grand 12388718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct) 12398718d260SArmin Le Grand { 12408718d260SArmin Le Grand Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel()); 12418718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor()); 12428718d260SArmin Le Grand 12438718d260SArmin Le Grand aRect.Right()++; 12448718d260SArmin Le Grand aRect.Bottom()++; 12458718d260SArmin Le Grand 12468718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 12478718d260SArmin Le Grand 12488718d260SArmin Le Grand InsertObj(pGraf); 12498718d260SArmin Le Grand } 12508718d260SArmin Le Grand 12518718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct) 12528718d260SArmin Le Grand { 12538718d260SArmin Le Grand Rectangle aRect(rAct.GetPoint(), rAct.GetSize()); 12548718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor()); 12558718d260SArmin Le Grand 12568718d260SArmin Le Grand aRect.Right()++; 12578718d260SArmin Le Grand aRect.Bottom()++; 12588718d260SArmin Le Grand 12598718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 12608718d260SArmin Le Grand 12618718d260SArmin Le Grand InsertObj(pGraf); 12628718d260SArmin Le Grand } 12638718d260SArmin Le Grand 12648718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct) 12658718d260SArmin Le Grand { 12668718d260SArmin Le Grand Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize()); 12678718d260SArmin Le Grand BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor()); 12688718d260SArmin Le Grand 12698718d260SArmin Le Grand aRect.Right()++; 12708718d260SArmin Le Grand aRect.Bottom()++; 12718718d260SArmin Le Grand aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize())); 12728718d260SArmin Le Grand 12738718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 12748718d260SArmin Le Grand 12758718d260SArmin Le Grand InsertObj(pGraf); 12768718d260SArmin Le Grand } 12778718d260SArmin Le Grand 1278603e43faSArmin Le Grand XGradientStyle getXGradientStyleFromGradientStyle(const GradientStyle& rGradientStyle) 1279603e43faSArmin Le Grand { 1280603e43faSArmin Le Grand XGradientStyle aXGradientStyle(XGRAD_LINEAR); 1281603e43faSArmin Le Grand 1282603e43faSArmin Le Grand switch(rGradientStyle) 1283603e43faSArmin Le Grand { 1284603e43faSArmin Le Grand case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break; 1285603e43faSArmin Le Grand case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break; 1286603e43faSArmin Le Grand case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break; 1287603e43faSArmin Le Grand case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break; 1288603e43faSArmin Le Grand case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break; 1289603e43faSArmin Le Grand case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break; 1290603e43faSArmin Le Grand 1291603e43faSArmin Le Grand // Needed due to GRADIENT_FORCE_EQUAL_SIZE; this again is needed 1292603e43faSArmin Le Grand // to force the enum defines in VCL to a defined size for the compilers, 1293603e43faSArmin Le Grand // so despite it is never used it cannot be removed (would break the 1294603e43faSArmin Le Grand // API implementation probably). 1295603e43faSArmin Le Grand default: break; 1296603e43faSArmin Le Grand } 1297603e43faSArmin Le Grand 1298603e43faSArmin Le Grand return aXGradientStyle; 1299603e43faSArmin Le Grand } 1300603e43faSArmin Le Grand 13018718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct) 13028718d260SArmin Le Grand { 13038718d260SArmin Le Grand basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom()); 13048718d260SArmin Le Grand 13058718d260SArmin Le Grand if(!aRange.isEmpty()) 13068718d260SArmin Le Grand { 13078718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 13088718d260SArmin Le Grand aRange.transform(aTransform); 13098718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 13108718d260SArmin Le Grand SdrRectObj* pRect = new SdrRectObj( 13118718d260SArmin Le Grand Rectangle( 13128718d260SArmin Le Grand floor(aRange.getMinX()), 13138718d260SArmin Le Grand floor(aRange.getMinY()), 13148718d260SArmin Le Grand ceil(aRange.getMaxX()), 13158718d260SArmin Le Grand ceil(aRange.getMaxY()))); 13168718d260SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0); 1317603e43faSArmin Le Grand const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle())); 13188718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem( 13198718d260SArmin Le Grand &mpModel->GetItemPool(), 13208718d260SArmin Le Grand XGradient( 13218718d260SArmin Le Grand rGradient.GetStartColor(), 13228718d260SArmin Le Grand rGradient.GetEndColor(), 13238718d260SArmin Le Grand aXGradientStyle, 13248718d260SArmin Le Grand rGradient.GetAngle(), 13258718d260SArmin Le Grand rGradient.GetOfsX(), 13268718d260SArmin Le Grand rGradient.GetOfsY(), 13278718d260SArmin Le Grand rGradient.GetBorder(), 13288718d260SArmin Le Grand rGradient.GetStartIntensity(), 13298718d260SArmin Le Grand rGradient.GetEndIntensity(), 13308718d260SArmin Le Grand rGradient.GetSteps())); 13318718d260SArmin Le Grand 13328718d260SArmin Le Grand SetAttributes(pRect); 13338718d260SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_HATCH)); 13348718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem); 13358718d260SArmin Le Grand pRect->SetMergedItemSet(aGradientAttr); 13368718d260SArmin Le Grand 13378718d260SArmin Le Grand InsertObj(pRect, false); 13388718d260SArmin Le Grand } 13398718d260SArmin Le Grand } 13408718d260SArmin Le Grand 1341603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& /*rAct*/) 13428718d260SArmin Le Grand { 13438718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)"); 13448718d260SArmin Le Grand } 13458718d260SArmin Le Grand 13468718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct) 13478718d260SArmin Le Grand { 13488718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 13498718d260SArmin Le Grand 13508718d260SArmin Le Grand if(aSource.count()) 13518718d260SArmin Le Grand { 13528718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 13538718d260SArmin Le Grand aSource.transform(aTransform); 13548718d260SArmin Le Grand aSource.setClosed(true); 13558718d260SArmin Le Grand 13568718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 13578718d260SArmin Le Grand SetAttributes(pPath); 13588718d260SArmin Le Grand pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence())); 13598718d260SArmin Le Grand InsertObj(pPath, false); 13608718d260SArmin Le Grand } 13618718d260SArmin Le Grand } 13628718d260SArmin Le Grand 1363603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& /*rAct*/) 13648718d260SArmin Le Grand { 13658718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)"); 13668718d260SArmin Le Grand } 13678718d260SArmin Le Grand 1368603e43faSArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& /*rAct*/) 13698718d260SArmin Le Grand { 13708718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)"); 13718718d260SArmin Le Grand } 13728718d260SArmin Le Grand 13738718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct) 13748718d260SArmin Le Grand { 13758718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 13768718d260SArmin Le Grand 13778718d260SArmin Le Grand if(aSource.count()) 13788718d260SArmin Le Grand { 13798718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 13808718d260SArmin Le Grand aSource.transform(aTransform); 13818718d260SArmin Le Grand 13828718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) 13838718d260SArmin Le Grand { 13848718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 13858718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 13868718d260SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0); 1387603e43faSArmin Le Grand const XGradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle())); 13888718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem( 13898718d260SArmin Le Grand &mpModel->GetItemPool(), 13908718d260SArmin Le Grand XGradient( 13918718d260SArmin Le Grand rGradient.GetStartColor(), 13928718d260SArmin Le Grand rGradient.GetEndColor(), 13938718d260SArmin Le Grand aXGradientStyle, 13948718d260SArmin Le Grand rGradient.GetAngle(), 13958718d260SArmin Le Grand rGradient.GetOfsX(), 13968718d260SArmin Le Grand rGradient.GetOfsY(), 13978718d260SArmin Le Grand rGradient.GetBorder(), 13988718d260SArmin Le Grand rGradient.GetStartIntensity(), 13998718d260SArmin Le Grand rGradient.GetEndIntensity(), 14008718d260SArmin Le Grand rGradient.GetSteps())); 14018718d260SArmin Le Grand 14028718d260SArmin Le Grand SetAttributes(pPath); 14038718d260SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_HATCH)); 14048718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem); 14058718d260SArmin Le Grand pPath->SetMergedItemSet(aGradientAttr); 14068718d260SArmin Le Grand 14078718d260SArmin Le Grand InsertObj(pPath, false); 14088718d260SArmin Le Grand } 14098718d260SArmin Le Grand } 14108718d260SArmin Le Grand } 14118718d260SArmin Le Grand 14128718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) 14138718d260SArmin Le Grand { 14148718d260SArmin Le Grand const GDIMetaFile& rMtf = rAct.GetGDIMetaFile(); 14158718d260SArmin Le Grand 14168718d260SArmin Le Grand if(rMtf.GetActionCount()) 14178718d260SArmin Le Grand { 14189f63b866SArmin Le Grand const Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); 14199f63b866SArmin Le Grand 14209f63b866SArmin Le Grand // convert metafile sub-content to BitmapEx 14219f63b866SArmin Le Grand BitmapEx aBitmapEx( 14229f63b866SArmin Le Grand convertMetafileToBitmapEx( 14239f63b866SArmin Le Grand rMtf, 14249f63b866SArmin Le Grand basegfx::B2DRange( 14259f63b866SArmin Le Grand aRect.Left(), aRect.Top(), 14269f63b866SArmin Le Grand aRect.Right(), aRect.Bottom()), 14279f63b866SArmin Le Grand 125000)); 14288718d260SArmin Le Grand 14298718d260SArmin Le Grand // handle colors 14308718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 14318718d260SArmin Le Grand basegfx::BColor aStart(rGradient.GetStartColor().getBColor()); 14328718d260SArmin Le Grand basegfx::BColor aEnd(rGradient.GetEndColor().getBColor()); 14338718d260SArmin Le Grand 14348718d260SArmin Le Grand if(100 != rGradient.GetStartIntensity()) 14358718d260SArmin Le Grand { 14368718d260SArmin Le Grand aStart *= (double)rGradient.GetStartIntensity() / 100.0; 14378718d260SArmin Le Grand } 14388718d260SArmin Le Grand 14398718d260SArmin Le Grand if(100 != rGradient.GetEndIntensity()) 14408718d260SArmin Le Grand { 14418718d260SArmin Le Grand aEnd *= (double)rGradient.GetEndIntensity() / 100.0; 14428718d260SArmin Le Grand } 14438718d260SArmin Le Grand 14448718d260SArmin Le Grand const bool bEqualColors(aStart == aEnd); 14458718d260SArmin Le Grand const bool bNoSteps(1 == rGradient.GetSteps()); 14468718d260SArmin Le Grand bool bCreateObject(true); 14478718d260SArmin Le Grand bool bHasNewMask(false); 14488718d260SArmin Le Grand AlphaMask aNewMask; 14499f63b866SArmin Le Grand double fTransparence(0.0); 14509f63b866SArmin Le Grand bool bFixedTransparence(false); 14518718d260SArmin Le Grand 14528718d260SArmin Le Grand if(bEqualColors || bNoSteps) 14538718d260SArmin Le Grand { 14548718d260SArmin Le Grand // single transparence 14558718d260SArmin Le Grand const basegfx::BColor aMedium(basegfx::average(aStart, aEnd)); 14569f63b866SArmin Le Grand fTransparence = aMedium.luminance(); 14578718d260SArmin Le Grand 14588718d260SArmin Le Grand if(basegfx::fTools::lessOrEqual(fTransparence, 0.0)) 14598718d260SArmin Le Grand { 14608718d260SArmin Le Grand // no transparence needed, all done 14618718d260SArmin Le Grand } 14628718d260SArmin Le Grand else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0)) 14638718d260SArmin Le Grand { 14648718d260SArmin Le Grand // all transparent, no object 14658718d260SArmin Le Grand bCreateObject = false; 14668718d260SArmin Le Grand } 14678718d260SArmin Le Grand else 14688718d260SArmin Le Grand { 14699f63b866SArmin Le Grand // 0.0 < transparence < 1.0, apply fixed transparence 14709f63b866SArmin Le Grand bFixedTransparence = true; 14718718d260SArmin Le Grand } 14728718d260SArmin Le Grand } 14738718d260SArmin Le Grand else 14748718d260SArmin Le Grand { 14758718d260SArmin Le Grand // gradient transparence 14768718d260SArmin Le Grand VirtualDevice aVDev; 14778718d260SArmin Le Grand 14788718d260SArmin Le Grand aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel()); 14798718d260SArmin Le Grand aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient); 14808718d260SArmin Le Grand 14818718d260SArmin Le Grand aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel())); 14828718d260SArmin Le Grand bHasNewMask = true; 14838718d260SArmin Le Grand } 14848718d260SArmin Le Grand 14858718d260SArmin Le Grand if(bCreateObject) 14868718d260SArmin Le Grand { 14879f63b866SArmin Le Grand if(bHasNewMask || bFixedTransparence) 14888718d260SArmin Le Grand { 14898718d260SArmin Le Grand if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) 14908718d260SArmin Le Grand { 14918718d260SArmin Le Grand // no transparence yet, apply new one 14929f63b866SArmin Le Grand if(bFixedTransparence) 14939f63b866SArmin Le Grand { 14949f63b866SArmin Le Grand sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); 14959f63b866SArmin Le Grand 14969f63b866SArmin Le Grand aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); 14979f63b866SArmin Le Grand } 14989f63b866SArmin Le Grand 14998718d260SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); 15008718d260SArmin Le Grand } 15018718d260SArmin Le Grand else 15028718d260SArmin Le Grand { 15038718d260SArmin Le Grand // mix existing and new alpha mask 15048718d260SArmin Le Grand AlphaMask aOldMask; 15058718d260SArmin Le Grand 15068718d260SArmin Le Grand if(aBitmapEx.IsAlpha()) 15078718d260SArmin Le Grand { 15088718d260SArmin Le Grand aOldMask = aBitmapEx.GetAlpha(); 15098718d260SArmin Le Grand } 15108718d260SArmin Le Grand else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType()) 15118718d260SArmin Le Grand { 15128718d260SArmin Le Grand aOldMask = aBitmapEx.GetMask(); 15138718d260SArmin Le Grand } 15148718d260SArmin Le Grand else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType()) 15158718d260SArmin Le Grand { 15168718d260SArmin Le Grand aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor()); 15178718d260SArmin Le Grand } 15188718d260SArmin Le Grand 15199f63b866SArmin Le Grand BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess(); 15208718d260SArmin Le Grand 15219f63b866SArmin Le Grand if(pOld) 15228718d260SArmin Le Grand { 15239f63b866SArmin Le Grand const double fFactor(1.0 / 255.0); 15249f63b866SArmin Le Grand 15259f63b866SArmin Le Grand if(bFixedTransparence) 15268718d260SArmin Le Grand { 15279f63b866SArmin Le Grand const double fOpNew(1.0 - fTransparence); 15289f63b866SArmin Le Grand 1529603e43faSArmin Le Grand for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++) 15308718d260SArmin Le Grand { 1531603e43faSArmin Le Grand for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++) 15328718d260SArmin Le Grand { 15339f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); 15349f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); 15359f63b866SArmin Le Grand 15369f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol)); 15378718d260SArmin Le Grand } 15388718d260SArmin Le Grand } 15398718d260SArmin Le Grand } 15408718d260SArmin Le Grand else 15418718d260SArmin Le Grand { 15429f63b866SArmin Le Grand BitmapReadAccess* pNew = aNewMask.AcquireReadAccess(); 15439f63b866SArmin Le Grand 15449f63b866SArmin Le Grand if(pNew) 15459f63b866SArmin Le Grand { 15469f63b866SArmin Le Grand if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height()) 15479f63b866SArmin Le Grand { 1548603e43faSArmin Le Grand for(sal_uInt32 y(0); y < static_cast< sal_uInt32 >(pOld->Height()); y++) 15499f63b866SArmin Le Grand { 1550603e43faSArmin Le Grand for(sal_uInt32 x(0); x < static_cast< sal_uInt32 >(pOld->Width()); x++) 15519f63b866SArmin Le Grand { 15529f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); 15539f63b866SArmin Le Grand const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor)); 15549f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); 15559f63b866SArmin Le Grand 15569f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol)); 15579f63b866SArmin Le Grand } 15589f63b866SArmin Le Grand } 15599f63b866SArmin Le Grand } 15609f63b866SArmin Le Grand else 15619f63b866SArmin Le Grand { 15629f63b866SArmin Le Grand OSL_ENSURE(false, "Alpha masks have different sizes (!)"); 15639f63b866SArmin Le Grand } 15648718d260SArmin Le Grand 15659f63b866SArmin Le Grand aNewMask.ReleaseAccess(pNew); 15669f63b866SArmin Le Grand } 15679f63b866SArmin Le Grand else 15689f63b866SArmin Le Grand { 15699f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to new alpha mask (!)"); 15709f63b866SArmin Le Grand } 15719f63b866SArmin Le Grand } 15729f63b866SArmin Le Grand 15738718d260SArmin Le Grand aOldMask.ReleaseAccess(pOld); 15748718d260SArmin Le Grand } 15758718d260SArmin Le Grand else 15768718d260SArmin Le Grand { 15779f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to old alpha mask (!)"); 15788718d260SArmin Le Grand } 15798718d260SArmin Le Grand 15808718d260SArmin Le Grand // apply combined bitmap as mask 15819f63b866SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask); 15828718d260SArmin Le Grand } 15838718d260SArmin Le Grand } 15848718d260SArmin Le Grand 15858718d260SArmin Le Grand // create and add object 15868718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 15878718d260SArmin Le Grand 15888718d260SArmin Le Grand InsertObj(pGraf); 15898718d260SArmin Le Grand } 15908718d260SArmin Le Grand } 15918718d260SArmin Le Grand } 15928718d260SArmin Le Grand 1593cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1594cdf0e10cSrcweir // eof 1595