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> 75*9f63b866SArmin Le Grand #include <svx/xflbmtit.hxx> 76*9f63b866SArmin Le Grand #include <svx/xflbstit.hxx> 77*9f63b866SArmin 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))); 525*9f63b866SArmin Le Grand pObj->SetMergedItem(XFillBmpTileItem(false)); 526*9f63b866SArmin 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 { 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 { 86147a7c0c1SArmin Le Grand 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); 89347a7c0c1SArmin Le Grand 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); 91447a7c0c1SArmin Le Grand 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()++; 101447a7c0c1SArmin Le Grand 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()++; 102247a7c0c1SArmin Le Grand 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()++; 103047a7c0c1SArmin Le Grand 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()++; 103847a7c0c1SArmin Le Grand 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(); 105747a7c0c1SArmin Le Grand 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 11158718d260SArmin Le Grand if(bMov2) 1116cdf0e10cSrcweir { 11178718d260SArmin Le Grand for(i = mnMapScalingOfs; i < nAnz; i++) 1118cdf0e10cSrcweir { 11198718d260SArmin Le Grand SdrObject* pObj = maTmpList[i]; 11208718d260SArmin Le Grand 11218718d260SArmin Le Grand 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(); 114847a7c0c1SArmin Le Grand 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 12028718d260SArmin Le Grand //////////////////////////////////////////////////////////////////////////////////////////////////// 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 12808718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction& rAct) 12818718d260SArmin Le Grand { 12828718d260SArmin Le Grand basegfx::B2DRange aRange(rAct.GetRect().Left(), rAct.GetRect().Top(), rAct.GetRect().Right(), rAct.GetRect().Bottom()); 12838718d260SArmin Le Grand 12848718d260SArmin Le Grand if(!aRange.isEmpty()) 12858718d260SArmin Le Grand { 12868718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 12878718d260SArmin Le Grand aRange.transform(aTransform); 12888718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 12898718d260SArmin Le Grand SdrRectObj* pRect = new SdrRectObj( 12908718d260SArmin Le Grand Rectangle( 12918718d260SArmin Le Grand floor(aRange.getMinX()), 12928718d260SArmin Le Grand floor(aRange.getMinY()), 12938718d260SArmin Le Grand ceil(aRange.getMaxX()), 12948718d260SArmin Le Grand ceil(aRange.getMaxY()))); 12958718d260SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0); 12968718d260SArmin Le Grand XGradientStyle aXGradientStyle(XGRAD_LINEAR); 12978718d260SArmin Le Grand 12988718d260SArmin Le Grand switch(rGradient.GetStyle()) 12998718d260SArmin Le Grand { 1300*9f63b866SArmin Le Grand case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break; 1301*9f63b866SArmin Le Grand case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break; 1302*9f63b866SArmin Le Grand case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break; 1303*9f63b866SArmin Le Grand case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break; 1304*9f63b866SArmin Le Grand case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break; 13058718d260SArmin Le Grand case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break; 13068718d260SArmin Le Grand } 13078718d260SArmin Le Grand 13088718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem( 13098718d260SArmin Le Grand &mpModel->GetItemPool(), 13108718d260SArmin Le Grand XGradient( 13118718d260SArmin Le Grand rGradient.GetStartColor(), 13128718d260SArmin Le Grand rGradient.GetEndColor(), 13138718d260SArmin Le Grand aXGradientStyle, 13148718d260SArmin Le Grand rGradient.GetAngle(), 13158718d260SArmin Le Grand rGradient.GetOfsX(), 13168718d260SArmin Le Grand rGradient.GetOfsY(), 13178718d260SArmin Le Grand rGradient.GetBorder(), 13188718d260SArmin Le Grand rGradient.GetStartIntensity(), 13198718d260SArmin Le Grand rGradient.GetEndIntensity(), 13208718d260SArmin Le Grand rGradient.GetSteps())); 13218718d260SArmin Le Grand 13228718d260SArmin Le Grand SetAttributes(pRect); 13238718d260SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_HATCH)); 13248718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem); 13258718d260SArmin Le Grand pRect->SetMergedItemSet(aGradientAttr); 13268718d260SArmin Le Grand 13278718d260SArmin Le Grand InsertObj(pRect, false); 13288718d260SArmin Le Grand } 13298718d260SArmin Le Grand } 13308718d260SArmin Le Grand 13318718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaWallpaperAction& rAct) 13328718d260SArmin Le Grand { 13338718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaWallpaperAction: not supported (!)"); 13348718d260SArmin Le Grand } 13358718d260SArmin Le Grand 13368718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction& rAct) 13378718d260SArmin Le Grand { 13388718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 13398718d260SArmin Le Grand 13408718d260SArmin Le Grand if(aSource.count()) 13418718d260SArmin Le Grand { 13428718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 13438718d260SArmin Le Grand aSource.transform(aTransform); 13448718d260SArmin Le Grand aSource.setClosed(true); 13458718d260SArmin Le Grand 13468718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 13478718d260SArmin Le Grand SetAttributes(pPath); 13488718d260SArmin Le Grand pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence())); 13498718d260SArmin Le Grand InsertObj(pPath, false); 13508718d260SArmin Le Grand } 13518718d260SArmin Le Grand } 13528718d260SArmin Le Grand 13538718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaEPSAction& rAct) 13548718d260SArmin Le Grand { 13558718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaEPSAction: not supported (!)"); 13568718d260SArmin Le Grand } 13578718d260SArmin Le Grand 13588718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaTextLineAction& rAct) 13598718d260SArmin Le Grand { 13608718d260SArmin Le Grand OSL_ENSURE(false, "Tried to construct SdrObject from MetaTextLineAction: not supported (!)"); 13618718d260SArmin Le Grand } 13628718d260SArmin Le Grand 13638718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction& rAct) 13648718d260SArmin Le Grand { 13658718d260SArmin Le Grand basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); 13668718d260SArmin Le Grand 13678718d260SArmin Le Grand if(aSource.count()) 13688718d260SArmin Le Grand { 13698718d260SArmin Le Grand const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); 13708718d260SArmin Le Grand aSource.transform(aTransform); 13718718d260SArmin Le Grand 13728718d260SArmin Le Grand if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) 13738718d260SArmin Le Grand { 13748718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 13758718d260SArmin Le Grand SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource); 13768718d260SArmin Le Grand SfxItemSet aGradientAttr(mpModel->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0); 13778718d260SArmin Le Grand XGradientStyle aXGradientStyle(XGRAD_LINEAR); 13788718d260SArmin Le Grand 13798718d260SArmin Le Grand switch(rGradient.GetStyle()) 13808718d260SArmin Le Grand { 1381*9f63b866SArmin Le Grand case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break; 1382*9f63b866SArmin Le Grand case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break; 1383*9f63b866SArmin Le Grand case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break; 1384*9f63b866SArmin Le Grand case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break; 1385*9f63b866SArmin Le Grand case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break; 13868718d260SArmin Le Grand case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break; 13878718d260SArmin Le Grand } 13888718d260SArmin Le Grand 13898718d260SArmin Le Grand const XFillGradientItem aXFillGradientItem( 13908718d260SArmin Le Grand &mpModel->GetItemPool(), 13918718d260SArmin Le Grand XGradient( 13928718d260SArmin Le Grand rGradient.GetStartColor(), 13938718d260SArmin Le Grand rGradient.GetEndColor(), 13948718d260SArmin Le Grand aXGradientStyle, 13958718d260SArmin Le Grand rGradient.GetAngle(), 13968718d260SArmin Le Grand rGradient.GetOfsX(), 13978718d260SArmin Le Grand rGradient.GetOfsY(), 13988718d260SArmin Le Grand rGradient.GetBorder(), 13998718d260SArmin Le Grand rGradient.GetStartIntensity(), 14008718d260SArmin Le Grand rGradient.GetEndIntensity(), 14018718d260SArmin Le Grand rGradient.GetSteps())); 14028718d260SArmin Le Grand 14038718d260SArmin Le Grand SetAttributes(pPath); 14048718d260SArmin Le Grand aGradientAttr.Put(XFillStyleItem(XFILL_HATCH)); 14058718d260SArmin Le Grand aGradientAttr.Put(aXFillGradientItem); 14068718d260SArmin Le Grand pPath->SetMergedItemSet(aGradientAttr); 14078718d260SArmin Le Grand 14088718d260SArmin Le Grand InsertObj(pPath, false); 14098718d260SArmin Le Grand } 14108718d260SArmin Le Grand } 14118718d260SArmin Le Grand } 14128718d260SArmin Le Grand 14138718d260SArmin Le Grand void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) 14148718d260SArmin Le Grand { 14158718d260SArmin Le Grand const GDIMetaFile& rMtf = rAct.GetGDIMetaFile(); 14168718d260SArmin Le Grand 14178718d260SArmin Le Grand if(rMtf.GetActionCount()) 14188718d260SArmin Le Grand { 1419*9f63b866SArmin Le Grand const Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); 1420*9f63b866SArmin Le Grand 1421*9f63b866SArmin Le Grand // convert metafile sub-content to BitmapEx 1422*9f63b866SArmin Le Grand BitmapEx aBitmapEx( 1423*9f63b866SArmin Le Grand convertMetafileToBitmapEx( 1424*9f63b866SArmin Le Grand rMtf, 1425*9f63b866SArmin Le Grand basegfx::B2DRange( 1426*9f63b866SArmin Le Grand aRect.Left(), aRect.Top(), 1427*9f63b866SArmin Le Grand aRect.Right(), aRect.Bottom()), 1428*9f63b866SArmin Le Grand 125000)); 14298718d260SArmin Le Grand 14308718d260SArmin Le Grand // handle colors 14318718d260SArmin Le Grand const Gradient& rGradient = rAct.GetGradient(); 14328718d260SArmin Le Grand basegfx::BColor aStart(rGradient.GetStartColor().getBColor()); 14338718d260SArmin Le Grand basegfx::BColor aEnd(rGradient.GetEndColor().getBColor()); 14348718d260SArmin Le Grand 14358718d260SArmin Le Grand if(100 != rGradient.GetStartIntensity()) 14368718d260SArmin Le Grand { 14378718d260SArmin Le Grand aStart *= (double)rGradient.GetStartIntensity() / 100.0; 14388718d260SArmin Le Grand } 14398718d260SArmin Le Grand 14408718d260SArmin Le Grand if(100 != rGradient.GetEndIntensity()) 14418718d260SArmin Le Grand { 14428718d260SArmin Le Grand aEnd *= (double)rGradient.GetEndIntensity() / 100.0; 14438718d260SArmin Le Grand } 14448718d260SArmin Le Grand 14458718d260SArmin Le Grand const bool bEqualColors(aStart == aEnd); 14468718d260SArmin Le Grand const bool bNoSteps(1 == rGradient.GetSteps()); 14478718d260SArmin Le Grand bool bCreateObject(true); 14488718d260SArmin Le Grand bool bHasNewMask(false); 14498718d260SArmin Le Grand AlphaMask aNewMask; 1450*9f63b866SArmin Le Grand double fTransparence(0.0); 1451*9f63b866SArmin Le Grand bool bFixedTransparence(false); 14528718d260SArmin Le Grand 14538718d260SArmin Le Grand if(bEqualColors || bNoSteps) 14548718d260SArmin Le Grand { 14558718d260SArmin Le Grand // single transparence 14568718d260SArmin Le Grand const basegfx::BColor aMedium(basegfx::average(aStart, aEnd)); 1457*9f63b866SArmin Le Grand fTransparence = aMedium.luminance(); 14588718d260SArmin Le Grand 14598718d260SArmin Le Grand if(basegfx::fTools::lessOrEqual(fTransparence, 0.0)) 14608718d260SArmin Le Grand { 14618718d260SArmin Le Grand // no transparence needed, all done 14628718d260SArmin Le Grand } 14638718d260SArmin Le Grand else if(basegfx::fTools::moreOrEqual(fTransparence, 1.0)) 14648718d260SArmin Le Grand { 14658718d260SArmin Le Grand // all transparent, no object 14668718d260SArmin Le Grand bCreateObject = false; 14678718d260SArmin Le Grand } 14688718d260SArmin Le Grand else 14698718d260SArmin Le Grand { 1470*9f63b866SArmin Le Grand // 0.0 < transparence < 1.0, apply fixed transparence 1471*9f63b866SArmin Le Grand bFixedTransparence = true; 14728718d260SArmin Le Grand } 14738718d260SArmin Le Grand } 14748718d260SArmin Le Grand else 14758718d260SArmin Le Grand { 14768718d260SArmin Le Grand // gradient transparence 14778718d260SArmin Le Grand VirtualDevice aVDev; 14788718d260SArmin Le Grand 14798718d260SArmin Le Grand aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel()); 14808718d260SArmin Le Grand aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient); 14818718d260SArmin Le Grand 14828718d260SArmin Le Grand aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel())); 14838718d260SArmin Le Grand bHasNewMask = true; 14848718d260SArmin Le Grand } 14858718d260SArmin Le Grand 14868718d260SArmin Le Grand if(bCreateObject) 14878718d260SArmin Le Grand { 1488*9f63b866SArmin Le Grand if(bHasNewMask || bFixedTransparence) 14898718d260SArmin Le Grand { 14908718d260SArmin Le Grand if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) 14918718d260SArmin Le Grand { 14928718d260SArmin Le Grand // no transparence yet, apply new one 1493*9f63b866SArmin Le Grand if(bFixedTransparence) 1494*9f63b866SArmin Le Grand { 1495*9f63b866SArmin Le Grand sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); 1496*9f63b866SArmin Le Grand 1497*9f63b866SArmin Le Grand aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); 1498*9f63b866SArmin Le Grand } 1499*9f63b866SArmin Le Grand 15008718d260SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); 15018718d260SArmin Le Grand } 15028718d260SArmin Le Grand else 15038718d260SArmin Le Grand { 15048718d260SArmin Le Grand // mix existing and new alpha mask 15058718d260SArmin Le Grand AlphaMask aOldMask; 15068718d260SArmin Le Grand 15078718d260SArmin Le Grand if(aBitmapEx.IsAlpha()) 15088718d260SArmin Le Grand { 15098718d260SArmin Le Grand aOldMask = aBitmapEx.GetAlpha(); 15108718d260SArmin Le Grand } 15118718d260SArmin Le Grand else if(TRANSPARENT_BITMAP == aBitmapEx.GetTransparentType()) 15128718d260SArmin Le Grand { 15138718d260SArmin Le Grand aOldMask = aBitmapEx.GetMask(); 15148718d260SArmin Le Grand } 15158718d260SArmin Le Grand else if(TRANSPARENT_COLOR == aBitmapEx.GetTransparentType()) 15168718d260SArmin Le Grand { 15178718d260SArmin Le Grand aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor()); 15188718d260SArmin Le Grand } 15198718d260SArmin Le Grand 1520*9f63b866SArmin Le Grand BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess(); 15218718d260SArmin Le Grand 1522*9f63b866SArmin Le Grand if(pOld) 15238718d260SArmin Le Grand { 1524*9f63b866SArmin Le Grand const double fFactor(1.0 / 255.0); 1525*9f63b866SArmin Le Grand 1526*9f63b866SArmin Le Grand if(bFixedTransparence) 15278718d260SArmin Le Grand { 1528*9f63b866SArmin Le Grand const double fOpNew(1.0 - fTransparence); 1529*9f63b866SArmin Le Grand 1530*9f63b866SArmin Le Grand for(sal_uInt32 y(0); y < pOld->Height(); y++) 15318718d260SArmin Le Grand { 1532*9f63b866SArmin Le Grand for(sal_uInt32 x(0); x < pOld->Width(); x++) 15338718d260SArmin Le Grand { 1534*9f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); 1535*9f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); 1536*9f63b866SArmin Le Grand 1537*9f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol)); 15388718d260SArmin Le Grand } 15398718d260SArmin Le Grand } 15408718d260SArmin Le Grand } 15418718d260SArmin Le Grand else 15428718d260SArmin Le Grand { 1543*9f63b866SArmin Le Grand BitmapReadAccess* pNew = aNewMask.AcquireReadAccess(); 1544*9f63b866SArmin Le Grand 1545*9f63b866SArmin Le Grand if(pNew) 1546*9f63b866SArmin Le Grand { 1547*9f63b866SArmin Le Grand if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height()) 1548*9f63b866SArmin Le Grand { 1549*9f63b866SArmin Le Grand for(sal_uInt32 y(0); y < pOld->Height(); y++) 1550*9f63b866SArmin Le Grand { 1551*9f63b866SArmin Le Grand for(sal_uInt32 x(0); x < pOld->Width(); x++) 1552*9f63b866SArmin Le Grand { 1553*9f63b866SArmin Le Grand const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); 1554*9f63b866SArmin Le Grand const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor)); 1555*9f63b866SArmin Le Grand const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); 1556*9f63b866SArmin Le Grand 1557*9f63b866SArmin Le Grand pOld->SetPixel(y, x, BitmapColor(aCol)); 1558*9f63b866SArmin Le Grand } 1559*9f63b866SArmin Le Grand } 1560*9f63b866SArmin Le Grand } 1561*9f63b866SArmin Le Grand else 1562*9f63b866SArmin Le Grand { 1563*9f63b866SArmin Le Grand OSL_ENSURE(false, "Alpha masks have different sizes (!)"); 1564*9f63b866SArmin Le Grand } 15658718d260SArmin Le Grand 1566*9f63b866SArmin Le Grand aNewMask.ReleaseAccess(pNew); 1567*9f63b866SArmin Le Grand } 1568*9f63b866SArmin Le Grand else 1569*9f63b866SArmin Le Grand { 1570*9f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to new alpha mask (!)"); 1571*9f63b866SArmin Le Grand } 1572*9f63b866SArmin Le Grand } 1573*9f63b866SArmin Le Grand 15748718d260SArmin Le Grand aOldMask.ReleaseAccess(pOld); 15758718d260SArmin Le Grand } 15768718d260SArmin Le Grand else 15778718d260SArmin Le Grand { 1578*9f63b866SArmin Le Grand OSL_ENSURE(false, "Got no access to old alpha mask (!)"); 15798718d260SArmin Le Grand } 15808718d260SArmin Le Grand 15818718d260SArmin Le Grand // apply combined bitmap as mask 1582*9f63b866SArmin Le Grand aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask); 15838718d260SArmin Le Grand } 15848718d260SArmin Le Grand } 15858718d260SArmin Le Grand 15868718d260SArmin Le Grand // create and add object 15878718d260SArmin Le Grand SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect); 15888718d260SArmin Le Grand 15898718d260SArmin Le Grand InsertObj(pGraf); 15908718d260SArmin Le Grand } 15918718d260SArmin Le Grand } 15928718d260SArmin Le Grand } 15938718d260SArmin Le Grand 1594cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 1595cdf0e10cSrcweir // eof 1596