1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vector> 28cdf0e10cSrcweir #include <editeng/editeng.hxx> 299f63b866SArmin Le Grand #include <svx/xexch.hxx> 30cdf0e10cSrcweir #include <svx/xflclit.hxx> 31cdf0e10cSrcweir #include <svx/svdxcgv.hxx> 32cdf0e10cSrcweir #include <svx/svdoutl.hxx> 339f63b866SArmin Le Grand #include <svx/svditext.hxx> 34cdf0e10cSrcweir #include <svx/svdetc.hxx> 35cdf0e10cSrcweir #include <svx/svdundo.hxx> 36cdf0e10cSrcweir #include <svx/svdograf.hxx> 37cdf0e10cSrcweir #include <svx/svdoole2.hxx> // fuer kein OLE im SdrClipboardFormat 38cdf0e10cSrcweir #include <svx/svdorect.hxx> 39cdf0e10cSrcweir #include <svx/svdoedge.hxx> // fuer Konnektoren uebers Clipboard 40cdf0e10cSrcweir #include <svx/svdopage.hxx> // fuer Konnektoren uebers Clipboard 41cdf0e10cSrcweir #include <svx/svdpage.hxx> 42cdf0e10cSrcweir #include <svx/svdpagv.hxx> 43cdf0e10cSrcweir #include <svx/svdtrans.hxx> // Fuer GetMapFactor zum umskalieren bei PasteModel 44cdf0e10cSrcweir #include "svx/svdstr.hrc" // Namen aus der Resource 45cdf0e10cSrcweir #include "svx/svdglob.hxx" // StringCache 46cdf0e10cSrcweir #include "svx/xoutbmp.hxx" 47cdf0e10cSrcweir #include <vcl/metaact.hxx> 48cdf0e10cSrcweir #include <svl/poolitem.hxx> 49cdf0e10cSrcweir #include <svl/itempool.hxx> 50cdf0e10cSrcweir #include <tools/bigint.hxx> 51cdf0e10cSrcweir #include <sot/formats.hxx> 52cdf0e10cSrcweir #include <clonelist.hxx> 53cdf0e10cSrcweir #include <vcl/virdev.hxx> 54cdf0e10cSrcweir #include <svl/style.hxx> 559f63b866SArmin Le Grand #include <fmobj.hxx> 569f63b866SArmin Le Grand #include <vcl/svgdata.hxx> 57*958da553SArmin Le Grand #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 58*958da553SArmin Le Grand #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 59*958da553SArmin Le Grand #include <drawinglayer/geometry/viewinformation2d.hxx> 60*958da553SArmin Le Grand #include <svx/sdr/contact/viewcontact.hxx> 61*958da553SArmin Le Grand #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> 62*958da553SArmin Le Grand #include <svx/sdr/contact/displayinfo.hxx> 63cdf0e10cSrcweir 64cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 65cdf0e10cSrcweir 66cdf0e10cSrcweir SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut): 67cdf0e10cSrcweir SdrObjEditView(pModel1,pOut) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 72cdf0e10cSrcweir 73cdf0e10cSrcweir Point SdrExchangeView::GetViewCenter(const OutputDevice* pOut) const 74cdf0e10cSrcweir { 75cdf0e10cSrcweir Point aCenter; 76cdf0e10cSrcweir if (pOut==NULL) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir pOut = GetFirstOutputDevice(); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir if (pOut!=NULL) { 81cdf0e10cSrcweir Point aOfs=pOut->GetMapMode().GetOrigin(); 82cdf0e10cSrcweir Size aOutSiz=pOut->GetOutputSize(); 83cdf0e10cSrcweir aOutSiz.Width()/=2; 84cdf0e10cSrcweir aOutSiz.Height()/=2; 85cdf0e10cSrcweir aCenter.X()=aOutSiz.Width() -aOfs.X(); 86cdf0e10cSrcweir aCenter.Y()=aOutSiz.Height()-aOfs.Y(); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir return aCenter; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir Point SdrExchangeView::GetPastePos(SdrObjList* pLst, OutputDevice* pOut) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir Point aP(GetViewCenter(pOut)); 94cdf0e10cSrcweir SdrPage* pPg=NULL; 95cdf0e10cSrcweir if (pLst!=NULL) pPg=pLst->GetPage(); 96cdf0e10cSrcweir if (pPg!=NULL) { 97cdf0e10cSrcweir Size aSiz(pPg->GetSize()); 98cdf0e10cSrcweir aP.X()=aSiz.Width()/2; 99cdf0e10cSrcweir aP.Y()=aSiz.Height()/2; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir return aP; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir sal_Bool SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const 105cdf0e10cSrcweir { 106cdf0e10cSrcweir sal_Bool bRet(sal_False); 107cdf0e10cSrcweir 108cdf0e10cSrcweir if(!aMaxWorkArea.IsEmpty()) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir if(rPt.X()<aMaxWorkArea.Left()) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir rPt.X() = aMaxWorkArea.Left(); 113cdf0e10cSrcweir bRet = sal_True; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir if(rPt.X()>aMaxWorkArea.Right()) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir rPt.X() = aMaxWorkArea.Right(); 119cdf0e10cSrcweir bRet = sal_True; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir if(rPt.Y()<aMaxWorkArea.Top()) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir rPt.Y() = aMaxWorkArea.Top(); 125cdf0e10cSrcweir bRet = sal_True; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir if(rPt.Y()>aMaxWorkArea.Bottom()) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir rPt.Y() = aMaxWorkArea.Bottom(); 131cdf0e10cSrcweir bRet = sal_True; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir return bRet; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir void SdrExchangeView::ImpGetPasteObjList(Point& /*rPos*/, SdrObjList*& rpLst) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir if (rpLst==NULL) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 142cdf0e10cSrcweir 143cdf0e10cSrcweir if (pPV!=NULL) { 144cdf0e10cSrcweir rpLst=pPV->GetObjList(); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir sal_Bool SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const 150cdf0e10cSrcweir { 151cdf0e10cSrcweir sal_Bool bRet=sal_False; 152cdf0e10cSrcweir rLayer=0; 153cdf0e10cSrcweir if (pObjList!=NULL) { 154cdf0e10cSrcweir const SdrPage* pPg=pObjList->GetPage(); 155cdf0e10cSrcweir if (pPg!=NULL) { 156cdf0e10cSrcweir rLayer=pPg->GetLayerAdmin().GetLayerID(aAktLayer,sal_True); 157cdf0e10cSrcweir if (rLayer==SDRLAYER_NOTFOUND) rLayer=0; 158cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 159cdf0e10cSrcweir if (pPV!=NULL) { 160cdf0e10cSrcweir bRet=!pPV->GetLockedLayers().IsSet(rLayer) && pPV->GetVisibleLayers().IsSet(rLayer); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir } 163cdf0e10cSrcweir } 164cdf0e10cSrcweir return bRet; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 168cdf0e10cSrcweir 169cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const GDIMetaFile& rMtf, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir Point aPos(rPos); 172cdf0e10cSrcweir ImpGetPasteObjList(aPos,pLst); 173cdf0e10cSrcweir ImpLimitToWorkArea( aPos ); 174cdf0e10cSrcweir if (pLst==NULL) return sal_False; 175cdf0e10cSrcweir SdrLayerID nLayer; 176cdf0e10cSrcweir if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; 177cdf0e10cSrcweir sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); 178cdf0e10cSrcweir if (bUnmark) UnmarkAllObj(); 179cdf0e10cSrcweir SdrGrafObj* pObj=new SdrGrafObj(Graphic(rMtf)); 180cdf0e10cSrcweir pObj->SetLayer(nLayer); 181cdf0e10cSrcweir ImpPasteObject(pObj,*pLst,aPos,rMtf.GetPrefSize(),rMtf.GetPrefMapMode(),nOptions); 182cdf0e10cSrcweir return sal_True; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const Bitmap& rBmp, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir Point aPos(rPos); 188cdf0e10cSrcweir ImpGetPasteObjList(aPos,pLst); 189cdf0e10cSrcweir ImpLimitToWorkArea( aPos ); 190cdf0e10cSrcweir if (pLst==NULL) return sal_False; 191cdf0e10cSrcweir SdrLayerID nLayer; 192cdf0e10cSrcweir if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; 193cdf0e10cSrcweir sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); 194cdf0e10cSrcweir if (bUnmark) UnmarkAllObj(); 195cdf0e10cSrcweir SdrGrafObj* pObj=new SdrGrafObj(Graphic(rBmp)); 196cdf0e10cSrcweir pObj->SetLayer(nLayer); 197cdf0e10cSrcweir ImpPasteObject(pObj,*pLst,aPos,rBmp.GetSizePixel(),MapMode(MAP_PIXEL),nOptions); 198cdf0e10cSrcweir return sal_True; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const XubString& rStr, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir if(!rStr.Len()) 204cdf0e10cSrcweir return sal_False; 205cdf0e10cSrcweir 206cdf0e10cSrcweir Point aPos(rPos); 207cdf0e10cSrcweir ImpGetPasteObjList(aPos,pLst); 208cdf0e10cSrcweir ImpLimitToWorkArea( aPos ); 209cdf0e10cSrcweir if (pLst==NULL) return sal_False; 210cdf0e10cSrcweir SdrLayerID nLayer; 211cdf0e10cSrcweir if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; 212cdf0e10cSrcweir sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); 213cdf0e10cSrcweir if (bUnmark) UnmarkAllObj(); 214cdf0e10cSrcweir Rectangle aTextRect(0,0,500,500); 215cdf0e10cSrcweir SdrPage* pPage=pLst->GetPage(); 216cdf0e10cSrcweir if (pPage!=NULL) { 217cdf0e10cSrcweir aTextRect.SetSize(pPage->GetSize()); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect); 220cdf0e10cSrcweir pObj->SetModel(pMod); 221cdf0e10cSrcweir pObj->SetLayer(nLayer); 222cdf0e10cSrcweir pObj->NbcSetText(rStr); // #32424# SetText vor SetAttr, weil SetAttr sonst unwirksam! 223cdf0e10cSrcweir if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False); 224cdf0e10cSrcweir 225cdf0e10cSrcweir pObj->SetMergedItemSet(aDefaultAttr); 226cdf0e10cSrcweir 227cdf0e10cSrcweir SfxItemSet aTempAttr(pMod->GetItemPool()); // Keine Fuellung oder Linie 228cdf0e10cSrcweir aTempAttr.Put(XLineStyleItem(XLINE_NONE)); 229cdf0e10cSrcweir aTempAttr.Put(XFillStyleItem(XFILL_NONE)); 230cdf0e10cSrcweir 231cdf0e10cSrcweir pObj->SetMergedItemSet(aTempAttr); 232cdf0e10cSrcweir 233cdf0e10cSrcweir pObj->FitFrameToTextSize(); 234cdf0e10cSrcweir Size aSiz(pObj->GetLogicRect().GetSize()); 235cdf0e10cSrcweir MapUnit eMap=pMod->GetScaleUnit(); 236cdf0e10cSrcweir Fraction aMap=pMod->GetScaleFraction(); 237cdf0e10cSrcweir ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions); 238cdf0e10cSrcweir return sal_True; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir Point aPos(rPos); 244cdf0e10cSrcweir ImpGetPasteObjList(aPos,pLst); 245cdf0e10cSrcweir ImpLimitToWorkArea( aPos ); 246cdf0e10cSrcweir if (pLst==NULL) return sal_False; 247cdf0e10cSrcweir SdrLayerID nLayer; 248cdf0e10cSrcweir if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False; 249cdf0e10cSrcweir sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); 250cdf0e10cSrcweir if (bUnmark) UnmarkAllObj(); 251cdf0e10cSrcweir Rectangle aTextRect(0,0,500,500); 252cdf0e10cSrcweir SdrPage* pPage=pLst->GetPage(); 253cdf0e10cSrcweir if (pPage!=NULL) { 254cdf0e10cSrcweir aTextRect.SetSize(pPage->GetSize()); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect); 257cdf0e10cSrcweir pObj->SetModel(pMod); 258cdf0e10cSrcweir pObj->SetLayer(nLayer); 259cdf0e10cSrcweir if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False); 260cdf0e10cSrcweir 261cdf0e10cSrcweir pObj->SetMergedItemSet(aDefaultAttr); 262cdf0e10cSrcweir 263cdf0e10cSrcweir SfxItemSet aTempAttr(pMod->GetItemPool()); // Keine Fuellung oder Linie 264cdf0e10cSrcweir aTempAttr.Put(XLineStyleItem(XLINE_NONE)); 265cdf0e10cSrcweir aTempAttr.Put(XFillStyleItem(XFILL_NONE)); 266cdf0e10cSrcweir 267cdf0e10cSrcweir pObj->SetMergedItemSet(aTempAttr); 268cdf0e10cSrcweir 269cdf0e10cSrcweir pObj->NbcSetText(rInput,rBaseURL,eFormat); 270cdf0e10cSrcweir pObj->FitFrameToTextSize(); 271cdf0e10cSrcweir Size aSiz(pObj->GetLogicRect().GetSize()); 272cdf0e10cSrcweir MapUnit eMap=pMod->GetScaleUnit(); 273cdf0e10cSrcweir Fraction aMap=pMod->GetScaleFraction(); 274cdf0e10cSrcweir ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions); 275cdf0e10cSrcweir 276cdf0e10cSrcweir // b4967543 277cdf0e10cSrcweir if(pObj && pObj->GetModel() && pObj->GetOutlinerParaObject()) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner(); 280cdf0e10cSrcweir rOutliner.SetText(*pObj->GetOutlinerParaObject()); 281cdf0e10cSrcweir 282cdf0e10cSrcweir if(1L == rOutliner.GetParagraphCount()) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0L); 285cdf0e10cSrcweir 286cdf0e10cSrcweir if(pCandidate) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool()) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir pObj->NbcSetStyleSheet(pCandidate, sal_True); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir return sal_True; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir const SdrModel* pSrcMod=&rMod; 302cdf0e10cSrcweir if (pSrcMod==pMod) 303cdf0e10cSrcweir return sal_False; // na so geht's ja nun nicht 304cdf0e10cSrcweir 305cdf0e10cSrcweir const bool bUndo = IsUndoEnabled(); 306cdf0e10cSrcweir 307cdf0e10cSrcweir if( bUndo ) 308cdf0e10cSrcweir BegUndo(ImpGetResStr(STR_ExchangePaste)); 309cdf0e10cSrcweir 310cdf0e10cSrcweir if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir if( bUndo ) 313cdf0e10cSrcweir EndUndo(); 314cdf0e10cSrcweir return sal_True; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir Point aPos(rPos); 318cdf0e10cSrcweir ImpGetPasteObjList(aPos,pLst); 319cdf0e10cSrcweir SdrPageView* pMarkPV=NULL; 320cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir if(pPV) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir if ( pPV->GetObjList() == pLst ) 325cdf0e10cSrcweir pMarkPV=pPV; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir ImpLimitToWorkArea( aPos ); 329cdf0e10cSrcweir if (pLst==NULL) 330cdf0e10cSrcweir return sal_False; 331cdf0e10cSrcweir 332cdf0e10cSrcweir sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); 333cdf0e10cSrcweir if (bUnmark) 334cdf0e10cSrcweir UnmarkAllObj(); 335cdf0e10cSrcweir 336cdf0e10cSrcweir // evtl. umskalieren bei unterschiedlicher MapUnit am Model 337cdf0e10cSrcweir // Dafuer erstmal die Faktoren berechnen 338cdf0e10cSrcweir MapUnit eSrcUnit=pSrcMod->GetScaleUnit(); 339cdf0e10cSrcweir MapUnit eDstUnit=pMod->GetScaleUnit(); 340cdf0e10cSrcweir sal_Bool bResize=eSrcUnit!=eDstUnit; 341cdf0e10cSrcweir Fraction xResize,yResize; 342cdf0e10cSrcweir Point aPt0; 343cdf0e10cSrcweir if (bResize) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit)); 346cdf0e10cSrcweir xResize=aResize.X(); 347cdf0e10cSrcweir yResize=aResize.Y(); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir SdrObjList* pDstLst=pLst; 350cdf0e10cSrcweir sal_uInt16 nPg,nPgAnz=pSrcMod->GetPageCount(); 351cdf0e10cSrcweir for (nPg=0; nPg<nPgAnz; nPg++) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir const SdrPage* pSrcPg=pSrcMod->GetPage(nPg); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // #104148# Use SnapRect, not BoundRect here 356cdf0e10cSrcweir Rectangle aR=pSrcPg->GetAllObjSnapRect(); 357cdf0e10cSrcweir 358cdf0e10cSrcweir if (bResize) 359cdf0e10cSrcweir ResizeRect(aR,aPt0,xResize,yResize); 360cdf0e10cSrcweir Point aDist(aPos-aR.Center()); 361cdf0e10cSrcweir Size aSiz(aDist.X(),aDist.Y()); 362cdf0e10cSrcweir //sal_uIntPtr nDstObjAnz0=pDstLst->GetObjCount(); 363cdf0e10cSrcweir sal_uIntPtr nCloneErrCnt=0; 364cdf0e10cSrcweir sal_uIntPtr nOb,nObAnz=pSrcPg->GetObjCount(); 365cdf0e10cSrcweir sal_Bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0; 366cdf0e10cSrcweir 367cdf0e10cSrcweir // #i13033# 368cdf0e10cSrcweir // New mechanism to re-create the connections of cloned connectors 369cdf0e10cSrcweir CloneList aCloneList; 370cdf0e10cSrcweir 371cdf0e10cSrcweir for (nOb=0; nOb<nObAnz; nOb++) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir const SdrObject* pSrcOb=pSrcPg->GetObj(nOb); 374cdf0e10cSrcweir 375cdf0e10cSrcweir // #116235# 376cdf0e10cSrcweir SdrObject* pNeuObj = pSrcOb->Clone(); 377cdf0e10cSrcweir 378cdf0e10cSrcweir if (pNeuObj!=NULL) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if(bResize) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir pNeuObj->GetModel()->SetPasteResize(sal_True); // #51139# 383cdf0e10cSrcweir pNeuObj->NbcResize(aPt0,xResize,yResize); 384cdf0e10cSrcweir pNeuObj->GetModel()->SetPasteResize(sal_False); // #51139# 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir // #i39861# 388cdf0e10cSrcweir pNeuObj->SetModel(pDstLst->GetModel()); 389cdf0e10cSrcweir pNeuObj->SetPage(pDstLst->GetPage()); 390cdf0e10cSrcweir 391cdf0e10cSrcweir pNeuObj->NbcMove(aSiz); 392cdf0e10cSrcweir 393cdf0e10cSrcweir const SdrPage* pPg = pDstLst->GetPage(); 394cdf0e10cSrcweir 395cdf0e10cSrcweir if(pPg) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir // #i72535# 398cdf0e10cSrcweir const SdrLayerAdmin& rAd = pPg->GetLayerAdmin(); 399cdf0e10cSrcweir SdrLayerID nLayer(0); 400cdf0e10cSrcweir 401cdf0e10cSrcweir if(pNeuObj->ISA(FmFormObj)) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir // for FormControls, force to form layer 404cdf0e10cSrcweir nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir else 407cdf0e10cSrcweir { 408cdf0e10cSrcweir nLayer = rAd.GetLayerID(aAktLayer, sal_True); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir if(SDRLAYER_NOTFOUND == nLayer) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir nLayer = 0; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir pNeuObj->SetLayer(nLayer); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir SdrInsertReason aReason(SDRREASON_VIEWCALL); 420cdf0e10cSrcweir pDstLst->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason); 421cdf0e10cSrcweir 422cdf0e10cSrcweir if( bUndo ) 423cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj)); 424cdf0e10cSrcweir 425cdf0e10cSrcweir if (bMark) { 426cdf0e10cSrcweir // Markhandles noch nicht sofort setzen! 427cdf0e10cSrcweir // Das erledigt das ModelHasChanged der MarkView. 428cdf0e10cSrcweir MarkObj(pNeuObj,pMarkPV,sal_False,sal_True); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir // #i13033# 432cdf0e10cSrcweir aCloneList.AddPair(pSrcOb, pNeuObj); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir else 435cdf0e10cSrcweir { 436cdf0e10cSrcweir nCloneErrCnt++; 437cdf0e10cSrcweir } 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir // #i13033# 441cdf0e10cSrcweir // New mechanism to re-create the connections of cloned connectors 442cdf0e10cSrcweir aCloneList.CopyConnections(); 443cdf0e10cSrcweir 444cdf0e10cSrcweir if(0L != nCloneErrCnt) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir #ifdef DBG_UTIL 447cdf0e10cSrcweir ByteString aStr("SdrExchangeView::Paste(): Fehler beim Clonen "); 448cdf0e10cSrcweir 449cdf0e10cSrcweir if(nCloneErrCnt == 1) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir aStr += "eines Zeichenobjekts."; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir else 454cdf0e10cSrcweir { 455cdf0e10cSrcweir aStr += "von "; 456cdf0e10cSrcweir aStr += ByteString::CreateFromInt32( nCloneErrCnt ); 457cdf0e10cSrcweir aStr += " Zeichenobjekten."; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir aStr += " Objektverbindungen werden nicht mitkopiert."; 461cdf0e10cSrcweir 462cdf0e10cSrcweir DBG_ERROR(aStr.GetBuffer()); 463cdf0e10cSrcweir #endif 464cdf0e10cSrcweir } 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir if( bUndo ) 468cdf0e10cSrcweir EndUndo(); 469cdf0e10cSrcweir 470cdf0e10cSrcweir return sal_True; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir sal_Bool SdrExchangeView::IsExchangeFormatSupported(sal_uIntPtr nFormat) const 474cdf0e10cSrcweir { 475cdf0e10cSrcweir return( FORMAT_PRIVATE == nFormat || 476cdf0e10cSrcweir FORMAT_GDIMETAFILE == nFormat || 477cdf0e10cSrcweir FORMAT_BITMAP == nFormat || 478cdf0e10cSrcweir FORMAT_RTF == nFormat || 479cdf0e10cSrcweir FORMAT_STRING == nFormat || 480cdf0e10cSrcweir SOT_FORMATSTR_ID_DRAWING == nFormat || 481cdf0e10cSrcweir SOT_FORMATSTR_ID_EDITENGINE == nFormat ); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, sal_uInt32 nOptions) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir BigInt nSizX(rSiz.Width()); 487cdf0e10cSrcweir BigInt nSizY(rSiz.Height()); 488cdf0e10cSrcweir MapUnit eSrcMU=rMap.GetMapUnit(); 489cdf0e10cSrcweir MapUnit eDstMU=pMod->GetScaleUnit(); 490cdf0e10cSrcweir FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU)); 491cdf0e10cSrcweir Fraction aDstFr(pMod->GetScaleFraction()); 492cdf0e10cSrcweir nSizX*=aMapFact.X().GetNumerator(); 493cdf0e10cSrcweir nSizX*=rMap.GetScaleX().GetNumerator(); 494cdf0e10cSrcweir nSizX*=aDstFr.GetDenominator(); 495cdf0e10cSrcweir nSizX/=aMapFact.X().GetDenominator(); 496cdf0e10cSrcweir nSizX/=rMap.GetScaleX().GetDenominator(); 497cdf0e10cSrcweir nSizX/=aDstFr.GetNumerator(); 498cdf0e10cSrcweir nSizY*=aMapFact.Y().GetNumerator(); 499cdf0e10cSrcweir nSizY*=rMap.GetScaleY().GetNumerator(); 500cdf0e10cSrcweir nSizX*=aDstFr.GetDenominator(); 501cdf0e10cSrcweir nSizY/=aMapFact.Y().GetDenominator(); 502cdf0e10cSrcweir nSizY/=rMap.GetScaleY().GetDenominator(); 503cdf0e10cSrcweir nSizY/=aDstFr.GetNumerator(); 504cdf0e10cSrcweir long xs=nSizX; 505cdf0e10cSrcweir long ys=nSizY; 506cdf0e10cSrcweir Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2); 507cdf0e10cSrcweir Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys); 508cdf0e10cSrcweir pObj->SetLogicRect(aR); 509cdf0e10cSrcweir SdrInsertReason aReason(SDRREASON_VIEWCALL); 510cdf0e10cSrcweir rLst.InsertObject(pObj,CONTAINER_APPEND,&aReason); 511cdf0e10cSrcweir 512cdf0e10cSrcweir if( IsUndoEnabled() ) 513cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); 514cdf0e10cSrcweir 515cdf0e10cSrcweir SdrPageView* pMarkPV=NULL; 516cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 517cdf0e10cSrcweir 518cdf0e10cSrcweir if(pPV) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir if (pPV->GetObjList()==&rLst) 521cdf0e10cSrcweir pMarkPV=pPV; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir sal_Bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0; 525cdf0e10cSrcweir if (bMark) 526cdf0e10cSrcweir { // Obj in der ersten gefundenen PageView markieren 527cdf0e10cSrcweir MarkObj(pObj,pMarkPV); 528cdf0e10cSrcweir } 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531bb18ee55SArmin Le Grand BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const 532cdf0e10cSrcweir { 533ddde725dSArmin Le Grand BitmapEx aBmp; 534cdf0e10cSrcweir 535cdf0e10cSrcweir if( AreObjectsMarked() ) 536cdf0e10cSrcweir { 537ddde725dSArmin Le Grand if(1 == GetMarkedObjectCount()) 538ddde725dSArmin Le Grand { 539cdf0e10cSrcweir if(bNoVDevIfOneBmpMarked) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 ); 542cdf0e10cSrcweir SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() == 1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL; 543cdf0e10cSrcweir 544cdf0e10cSrcweir if( pGrafObj && ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP ) ) 545ddde725dSArmin Le Grand { 546ddde725dSArmin Le Grand aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx(); 547ddde725dSArmin Le Grand } 548ddde725dSArmin Le Grand } 549ddde725dSArmin Le Grand else 550ddde725dSArmin Le Grand { 551ddde725dSArmin Le Grand const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0)); 552ddde725dSArmin Le Grand 553ddde725dSArmin Le Grand if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg()) 554ddde725dSArmin Le Grand { 555ddde725dSArmin Le Grand aBmp = pSdrGrafObj->GetGraphic().getSvgData()->getReplacement(); 556ddde725dSArmin Le Grand } 557ddde725dSArmin Le Grand } 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir if( !aBmp ) 561cdf0e10cSrcweir { 562*958da553SArmin Le Grand // choose conversion directly using primitives to bitmap to avoid 563*958da553SArmin Le Grand // rendering errors with tiled bitmap fills (these will be tiled in a 564*958da553SArmin Le Grand // in-between metafile, but tend to show 'gaps' since the target is *no* 565*958da553SArmin Le Grand // bitmap rendering) 566*958da553SArmin Le Grand ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects()); 567*958da553SArmin Le Grand const sal_uInt32 nCount(aSdrObjects.size()); 568cdf0e10cSrcweir 569*958da553SArmin Le Grand if(nCount) 570*958da553SArmin Le Grand { 571*958da553SArmin Le Grand // collect sub-primitives as group objects, thus no expensive append 572*958da553SArmin Le Grand // to existing sequence is needed 573*958da553SArmin Le Grand drawinglayer::primitive2d::Primitive2DSequence xPrimitives(nCount); 574*958da553SArmin Le Grand 575*958da553SArmin Le Grand for(sal_uInt32 a(0); a < nCount; a++) 576*958da553SArmin Le Grand { 577*958da553SArmin Le Grand xPrimitives[a] = new drawinglayer::primitive2d::GroupPrimitive2D( 578*958da553SArmin Le Grand aSdrObjects[a]->GetViewContact().getViewIndependentPrimitive2DSequence()); 579*958da553SArmin Le Grand } 580*958da553SArmin Le Grand 581*958da553SArmin Le Grand // get logic range 582*958da553SArmin Le Grand const drawinglayer::geometry::ViewInformation2D aViewInformation2D; 583*958da553SArmin Le Grand const basegfx::B2DRange aRange( 584*958da553SArmin Le Grand drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence( 585*958da553SArmin Le Grand xPrimitives, 586*958da553SArmin Le Grand aViewInformation2D)); 587*958da553SArmin Le Grand 588*958da553SArmin Le Grand if(!aRange.isEmpty()) 589*958da553SArmin Le Grand { 590*958da553SArmin Le Grand // if we have geometry and it has a range, convert to BitmapEx using 591*958da553SArmin Le Grand // common tooling 592*958da553SArmin Le Grand aBmp = convertPrimitive2DSequenceToBitmapEx( 593*958da553SArmin Le Grand xPrimitives, 594*958da553SArmin Le Grand aRange, 595*958da553SArmin Le Grand 500000); 596*958da553SArmin Le Grand } 597*958da553SArmin Le Grand } 598cdf0e10cSrcweir } 599cdf0e10cSrcweir } 600cdf0e10cSrcweir 601cdf0e10cSrcweir return aBmp; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir // ----------------------------------------------------------------------------- 605cdf0e10cSrcweir 606bb18ee55SArmin Le Grand GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) const 607cdf0e10cSrcweir { 608cdf0e10cSrcweir GDIMetaFile aMtf; 609cdf0e10cSrcweir 610cdf0e10cSrcweir if( AreObjectsMarked() ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir Rectangle aBound( GetMarkedObjBoundRect() ); 613cdf0e10cSrcweir Size aBoundSize( aBound.GetWidth(), aBound.GetHeight() ); 614cdf0e10cSrcweir MapMode aMap( pMod->GetScaleUnit(), Point(), pMod->GetScaleFraction(), pMod->GetScaleFraction() ); 615cdf0e10cSrcweir 616cdf0e10cSrcweir if( bNoVDevIfOneMtfMarked ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 ); 619cdf0e10cSrcweir SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL; 620cdf0e10cSrcweir 621cdf0e10cSrcweir if( pGrafObj ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir Graphic aGraphic( pGrafObj->GetTransformedGraphic() ); 624cdf0e10cSrcweir 625cb0a2370SArmin Le Grand // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically 626cdf0e10cSrcweir aMtf = aGraphic.GetGDIMetaFile(); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir if( !aMtf.GetActionCount() ) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir VirtualDevice aOut; 63347a7c0c1SArmin Le Grand const Size aDummySize(2, 2); 634cdf0e10cSrcweir 635cdf0e10cSrcweir aOut.SetOutputSizePixel(aDummySize); 63647a7c0c1SArmin Le Grand aOut.EnableOutput(false); 637cdf0e10cSrcweir aOut.SetMapMode(aMap); 638cdf0e10cSrcweir aMtf.Clear(); 639cdf0e10cSrcweir aMtf.Record(&aOut); 640cdf0e10cSrcweir 641cdf0e10cSrcweir DrawMarkedObj(aOut); 642cdf0e10cSrcweir 643cdf0e10cSrcweir aMtf.Stop(); 644cdf0e10cSrcweir aMtf.WindStart(); 64547a7c0c1SArmin Le Grand 64647a7c0c1SArmin Le Grand // moving the result is more reliable then setting a relative MapMode at the VDev (used 64747a7c0c1SArmin Le Grand // before), also see #i99268# in GetObjGraphic() below. Some draw actions at 64847a7c0c1SArmin Le Grand // the OutDev are simply not handled correctly when a MapMode is set at the 64947a7c0c1SArmin Le Grand // target devive, e.g. MetaFloatTransparentAction. Even the Move for this action 65047a7c0c1SArmin Le Grand // was missing the manipulation of the embedded Metafile 65147a7c0c1SArmin Le Grand aMtf.Move(-aBound.Left(), -aBound.Top()); 65247a7c0c1SArmin Le Grand 653cdf0e10cSrcweir aMtf.SetPrefMapMode( aMap ); 654cdf0e10cSrcweir 655cdf0e10cSrcweir // removed PrefSize extension. It is principially wrong to set a reduced size at 656cdf0e10cSrcweir // the created MetaFile. The mentioned errors occurr at output time since the integer 657cdf0e10cSrcweir // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for 658cdf0e10cSrcweir // primitives (and may later be done in breaking up a MetaFile to primitives) 659cdf0e10cSrcweir aMtf.SetPrefSize(aBoundSize); 660cdf0e10cSrcweir } 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir return aMtf; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir 666cdf0e10cSrcweir // ----------------------------------------------------------------------------- 667cdf0e10cSrcweir 668cdf0e10cSrcweir Graphic SdrExchangeView::GetAllMarkedGraphic() const 669cdf0e10cSrcweir { 670cdf0e10cSrcweir Graphic aRet; 671cdf0e10cSrcweir 672cdf0e10cSrcweir if( AreObjectsMarked() ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) ) 675cdf0e10cSrcweir aRet = SdrExchangeView::GetObjGraphic( pMod, GetMarkedObjectByIndex( 0 ) ); 676cdf0e10cSrcweir else 677bb18ee55SArmin Le Grand aRet = GetMarkedObjMetaFile(false); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir return aRet; 681cdf0e10cSrcweir } 682cdf0e10cSrcweir 683cdf0e10cSrcweir // ----------------------------------------------------------------------------- 684cdf0e10cSrcweir 685cdf0e10cSrcweir Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir Graphic aRet; 688cdf0e10cSrcweir 689cdf0e10cSrcweir if( pModel && pObj ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir // try to get a graphic from the object first 692cdf0e10cSrcweir const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); 693cdf0e10cSrcweir const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); 694cdf0e10cSrcweir 695cdf0e10cSrcweir if(pSdrGrafObj) 696cdf0e10cSrcweir { 697ddde725dSArmin Le Grand if(pSdrGrafObj->isEmbeddedSvg()) 698ddde725dSArmin Le Grand { 699ddde725dSArmin Le Grand // get Metafile for Svg content 700ddde725dSArmin Le Grand aRet = pSdrGrafObj->getMetafileFromEmbeddedSvg(); 701ddde725dSArmin Le Grand } 702ddde725dSArmin Le Grand else 703ddde725dSArmin Le Grand { 704cdf0e10cSrcweir // #110981# Make behaviour coherent with metafile 705cdf0e10cSrcweir // recording below (which of course also takes 706cdf0e10cSrcweir // view-transformed objects) 707cdf0e10cSrcweir aRet = pSdrGrafObj->GetTransformedGraphic(); 708cdf0e10cSrcweir } 709ddde725dSArmin Le Grand } 710cdf0e10cSrcweir else if(pSdrOle2Obj) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir if ( pSdrOle2Obj->GetGraphic() ) 713cdf0e10cSrcweir aRet = *pSdrOle2Obj->GetGraphic(); 714cdf0e10cSrcweir } 715cdf0e10cSrcweir 716cdf0e10cSrcweir // if graphic could not be retrieved => go the hard way and create a MetaFile 717cdf0e10cSrcweir if( ( GRAPHIC_NONE == aRet.GetType() ) || ( GRAPHIC_DEFAULT == aRet.GetType() ) ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir VirtualDevice aOut; 720cdf0e10cSrcweir GDIMetaFile aMtf; 721cdf0e10cSrcweir const Rectangle aBoundRect( pObj->GetCurrentBoundRect() ); 722cdf0e10cSrcweir const MapMode aMap( pModel->GetScaleUnit(), 723cdf0e10cSrcweir Point(), 724cdf0e10cSrcweir pModel->GetScaleFraction(), 725cdf0e10cSrcweir pModel->GetScaleFraction() ); 726cdf0e10cSrcweir 727cdf0e10cSrcweir aOut.EnableOutput( sal_False ); 728cdf0e10cSrcweir aOut.SetMapMode( aMap ); 729cdf0e10cSrcweir aMtf.Record( &aOut ); 730cdf0e10cSrcweir pObj->SingleObjectPainter( aOut ); // #110094#-17 731cdf0e10cSrcweir aMtf.Stop(); 732cdf0e10cSrcweir aMtf.WindStart(); 733cdf0e10cSrcweir 734cdf0e10cSrcweir // #i99268# replace the original offset from using XOutDev's SetOffset 735cdf0e10cSrcweir // NOT (as tried with #i92760#) with another MapMode which gets recorded 73647a7c0c1SArmin Le Grand // by the Metafile itself (what always leads to problems), but by 73747a7c0c1SArmin Le Grand // moving the result directly 738cdf0e10cSrcweir aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top()); 739cdf0e10cSrcweir 740cdf0e10cSrcweir aMtf.SetPrefMapMode( aMap ); 741cdf0e10cSrcweir aMtf.SetPrefSize( aBoundRect.GetSize() ); 742cdf0e10cSrcweir 743cdf0e10cSrcweir if( aMtf.GetActionCount() ) 744cdf0e10cSrcweir aRet = aMtf; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir 748cdf0e10cSrcweir return aRet; 749cdf0e10cSrcweir } 750cdf0e10cSrcweir 751cdf0e10cSrcweir // ----------------------------------------------------------------------------- 752cdf0e10cSrcweir 753*958da553SArmin Le Grand ::std::vector< SdrObject* > SdrExchangeView::GetMarkedObjects() const 754cdf0e10cSrcweir { 755cdf0e10cSrcweir SortMarkedObjects(); 756*958da553SArmin Le Grand ::std::vector< SdrObject* > aRetval; 757cdf0e10cSrcweir 758cdf0e10cSrcweir ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 ); 759cdf0e10cSrcweir ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ]; 760cdf0e10cSrcweir ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ]; 761cdf0e10cSrcweir const SdrLayerAdmin& rLayerAdmin = pMod->GetLayerAdmin(); 762cdf0e10cSrcweir const sal_uInt32 nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False ); 763cdf0e10cSrcweir sal_uInt32 n, nCount; 764cdf0e10cSrcweir 765cdf0e10cSrcweir for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir SdrMark* pMark = GetSdrMarkByIndex( n ); 768cdf0e10cSrcweir 769cdf0e10cSrcweir // paint objects on control layer on top of all otherobjects 770cdf0e10cSrcweir if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() ) 771cdf0e10cSrcweir rObjVector2.push_back( pMark ); 772cdf0e10cSrcweir else 773cdf0e10cSrcweir rObjVector1.push_back( pMark ); 774cdf0e10cSrcweir } 775cdf0e10cSrcweir 776cdf0e10cSrcweir for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ ) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir ::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ]; 779cdf0e10cSrcweir 780cdf0e10cSrcweir for( sal_uInt32 i = 0; i < rObjVector.size(); i++ ) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir SdrMark* pMark = rObjVector[ i ]; 783*958da553SArmin Le Grand aRetval.push_back(pMark->GetMarkedSdrObj()); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir } 786*958da553SArmin Le Grand 787*958da553SArmin Le Grand return aRetval; 788*958da553SArmin Le Grand } 789*958da553SArmin Le Grand 790*958da553SArmin Le Grand // ----------------------------------------------------------------------------- 791*958da553SArmin Le Grand 792*958da553SArmin Le Grand void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const 793*958da553SArmin Le Grand { 794*958da553SArmin Le Grand ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects()); 795*958da553SArmin Le Grand 796*958da553SArmin Le Grand if(aSdrObjects.size()) 797*958da553SArmin Le Grand { 798*958da553SArmin Le Grand sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aSdrObjects, aSdrObjects[0]->GetPage()); 799*958da553SArmin Le Grand sdr::contact::DisplayInfo aDisplayInfo; 800*958da553SArmin Le Grand 801*958da553SArmin Le Grand // do processing 802*958da553SArmin Le Grand aPainter.ProcessDisplay(aDisplayInfo); 803*958da553SArmin Le Grand } 804cdf0e10cSrcweir } 805cdf0e10cSrcweir 806cdf0e10cSrcweir // ----------------------------------------------------------------------------- 807cdf0e10cSrcweir 808cdf0e10cSrcweir SdrModel* SdrExchangeView::GetMarkedObjModel() const 809cdf0e10cSrcweir { 810cdf0e10cSrcweir // Wenn das sortieren der MarkList mal stoeren sollte, 811cdf0e10cSrcweir // werde ich sie mir wohl kopieren muessen. 812cdf0e10cSrcweir SortMarkedObjects(); 813cdf0e10cSrcweir SdrModel* pNeuMod=pMod->AllocModel(); 814cdf0e10cSrcweir SdrPage* pNeuPag=pNeuMod->AllocPage(sal_False); 815cdf0e10cSrcweir pNeuMod->InsertPage(pNeuPag); 816cdf0e10cSrcweir 817cdf0e10cSrcweir if( !mxSelectionController.is() || !mxSelectionController->GetMarkedObjModel( pNeuPag ) ) 818cdf0e10cSrcweir { 819*958da553SArmin Le Grand ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects()); 820cdf0e10cSrcweir 821cdf0e10cSrcweir // #i13033# 822cdf0e10cSrcweir // New mechanism to re-create the connections of cloned connectors 823cdf0e10cSrcweir CloneList aCloneList; 824*958da553SArmin Le Grand sal_uInt32 nCloneErrCnt(0); 825cdf0e10cSrcweir 826*958da553SArmin Le Grand for( sal_uInt32 i(0); i < aSdrObjects.size(); i++ ) 827cdf0e10cSrcweir { 828*958da553SArmin Le Grand const SdrObject* pObj = aSdrObjects[i]; 829cdf0e10cSrcweir SdrObject* pNeuObj; 830cdf0e10cSrcweir 831cdf0e10cSrcweir if( pObj->ISA( SdrPageObj ) ) 832cdf0e10cSrcweir { 833cdf0e10cSrcweir // convert SdrPageObj's to a graphic representation, because 834cdf0e10cSrcweir // virtual connection to referenced page gets lost in new model 835cdf0e10cSrcweir pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, pObj ), pObj->GetLogicRect() ); 836cdf0e10cSrcweir pNeuObj->SetPage( pNeuPag ); 837cdf0e10cSrcweir pNeuObj->SetModel( pNeuMod ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir else 840cdf0e10cSrcweir { 841cdf0e10cSrcweir // #116235# 842cdf0e10cSrcweir // pNeuObj = pObj->Clone( pNeuPag, pNeuMod ); 843cdf0e10cSrcweir pNeuObj = pObj->Clone(); 844cdf0e10cSrcweir pNeuObj->SetPage( pNeuPag ); 845cdf0e10cSrcweir pNeuObj->SetModel( pNeuMod ); 846cdf0e10cSrcweir } 847cdf0e10cSrcweir 848cdf0e10cSrcweir if( pNeuObj ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir SdrInsertReason aReason(SDRREASON_VIEWCALL); 851cdf0e10cSrcweir pNeuPag->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason); 852cdf0e10cSrcweir 853cdf0e10cSrcweir // #i13033# 854cdf0e10cSrcweir aCloneList.AddPair(pObj, pNeuObj); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir else 857cdf0e10cSrcweir nCloneErrCnt++; 858cdf0e10cSrcweir } 859cdf0e10cSrcweir 860cdf0e10cSrcweir // #i13033# 861cdf0e10cSrcweir // New mechanism to re-create the connections of cloned connectors 862cdf0e10cSrcweir aCloneList.CopyConnections(); 863cdf0e10cSrcweir 864cdf0e10cSrcweir if(0L != nCloneErrCnt) 865cdf0e10cSrcweir { 866cdf0e10cSrcweir #ifdef DBG_UTIL 867cdf0e10cSrcweir ByteString aStr("SdrExchangeView::GetMarkedObjModel(): Fehler beim Clonen "); 868cdf0e10cSrcweir 869cdf0e10cSrcweir if(nCloneErrCnt == 1) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir aStr += "eines Zeichenobjekts."; 872cdf0e10cSrcweir } 873cdf0e10cSrcweir else 874cdf0e10cSrcweir { 875cdf0e10cSrcweir aStr += "von "; 876cdf0e10cSrcweir aStr += ByteString::CreateFromInt32( nCloneErrCnt ); 877cdf0e10cSrcweir aStr += " Zeichenobjekten."; 878cdf0e10cSrcweir } 879cdf0e10cSrcweir 880cdf0e10cSrcweir aStr += " Objektverbindungen werden nicht mitkopiert."; 881cdf0e10cSrcweir 882cdf0e10cSrcweir DBG_ERROR(aStr.GetBuffer()); 883cdf0e10cSrcweir #endif 884cdf0e10cSrcweir } 885cdf0e10cSrcweir } 886cdf0e10cSrcweir return pNeuMod; 887cdf0e10cSrcweir } 888cdf0e10cSrcweir 889cdf0e10cSrcweir // ----------------------------------------------------------------------------- 890cdf0e10cSrcweir 891cdf0e10cSrcweir sal_Bool SdrExchangeView::Cut( sal_uIntPtr /*nFormat */) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir DBG_ERROR( "SdrExchangeView::Cut: Not supported anymore" ); 894cdf0e10cSrcweir return sal_False; 895cdf0e10cSrcweir } 896cdf0e10cSrcweir 897cdf0e10cSrcweir // ----------------------------------------------------------------------------- 898cdf0e10cSrcweir 899cdf0e10cSrcweir void SdrExchangeView::CutMarked( sal_uIntPtr /*nFormat */) 900cdf0e10cSrcweir { 901cdf0e10cSrcweir DBG_ERROR( "SdrExchangeView::CutMarked: Not supported anymore" ); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir 904cdf0e10cSrcweir // ----------------------------------------------------------------------------- 905cdf0e10cSrcweir 906cdf0e10cSrcweir sal_Bool SdrExchangeView::Yank(sal_uIntPtr /*nFormat*/) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir DBG_ERROR( "SdrExchangeView::Yank: Not supported anymore" ); 909cdf0e10cSrcweir return sal_False; 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir // ----------------------------------------------------------------------------- 913cdf0e10cSrcweir 914cdf0e10cSrcweir void SdrExchangeView::YankMarked(sal_uIntPtr /*nFormat*/) 915cdf0e10cSrcweir { 916cdf0e10cSrcweir DBG_ERROR( "YankMarked: Not supported anymore" ); 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir // ----------------------------------------------------------------------------- 920cdf0e10cSrcweir 921cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(Window* /*pWin*/, sal_uIntPtr /*nFormat*/) 922cdf0e10cSrcweir { 923cdf0e10cSrcweir DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" ); 924cdf0e10cSrcweir return sal_False; 925cdf0e10cSrcweir } 9269f63b866SArmin Le Grand 9279f63b866SArmin Le Grand // eof 928