Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / svdraw / svdxcgv.cxx
blob0ec6046e85846944f6c8b1640a88db3c2b8db14b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vector>
21 #include <editeng/editdata.hxx>
22 #include <editeng/editeng.hxx>
23 #include <rtl/strbuf.hxx>
24 #include <svx/xexch.hxx>
25 #include <svx/xflclit.hxx>
26 #include <svx/svdxcgv.hxx>
27 #include <svx/svdoutl.hxx>
28 #include <svx/svdetc.hxx>
29 #include <svx/svdundo.hxx>
30 #include <svx/svdograf.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <svx/svdorect.hxx>
33 #include <svx/svdoedge.hxx>
34 #include <svx/svdopage.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/svdpagv.hxx>
37 #include <svx/svdtrans.hxx>
38 #include "svx/svdstr.hrc"
39 #include "svdglob.hxx"
40 #include "svx/xoutbmp.hxx"
41 #include <vcl/metaact.hxx>
42 #include <svl/poolitem.hxx>
43 #include <svl/itempool.hxx>
44 #include <tools/bigint.hxx>
45 #include <sot/formats.hxx>
46 #include <clonelist.hxx>
47 #include <vcl/virdev.hxx>
48 #include <svl/style.hxx>
49 #include <fmobj.hxx>
50 #include <vcl/svgdata.hxx>
51 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
52 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
53 #include <drawinglayer/geometry/viewinformation2d.hxx>
54 #include <svx/sdr/contact/viewcontact.hxx>
55 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
56 #include <svx/sdr/contact/displayinfo.hxx>
60 SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut):
61 SdrObjEditView(pModel1,pOut)
65 bool SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const
67 bool bRet(false);
69 if(!aMaxWorkArea.IsEmpty())
71 if(rPt.X()<aMaxWorkArea.Left())
73 rPt.X() = aMaxWorkArea.Left();
74 bRet = true;
77 if(rPt.X()>aMaxWorkArea.Right())
79 rPt.X() = aMaxWorkArea.Right();
80 bRet = true;
83 if(rPt.Y()<aMaxWorkArea.Top())
85 rPt.Y() = aMaxWorkArea.Top();
86 bRet = true;
89 if(rPt.Y()>aMaxWorkArea.Bottom())
91 rPt.Y() = aMaxWorkArea.Bottom();
92 bRet = true;
95 return bRet;
98 void SdrExchangeView::ImpGetPasteObjList(Point& /*rPos*/, SdrObjList*& rpLst)
100 if (rpLst==NULL)
102 SdrPageView* pPV = GetSdrPageView();
104 if (pPV!=NULL) {
105 rpLst=pPV->GetObjList();
110 bool SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const
112 bool bRet=false;
113 rLayer=0;
114 if (pObjList!=NULL) {
115 const SdrPage* pPg=pObjList->GetPage();
116 if (pPg!=NULL) {
117 rLayer=pPg->GetLayerAdmin().GetLayerID(aAktLayer,true);
118 if (rLayer==SDRLAYER_NOTFOUND) rLayer=0;
119 SdrPageView* pPV = GetSdrPageView();
120 if (pPV!=NULL) {
121 bRet=!pPV->GetLockedLayers().IsSet(rLayer) && pPV->GetVisibleLayers().IsSet(rLayer);
125 return bRet;
128 bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
130 if (rStr.isEmpty())
131 return false;
133 Point aPos(rPos);
134 ImpGetPasteObjList(aPos,pLst);
135 ImpLimitToWorkArea( aPos );
136 if (pLst==NULL) return false;
137 SdrLayerID nLayer;
138 if (!ImpGetPasteLayer(pLst,nLayer)) return false;
139 bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
140 if (bUnmark) UnmarkAllObj();
141 Rectangle aTextRect(0,0,500,500);
142 SdrPage* pPage=pLst->GetPage();
143 if (pPage!=NULL) {
144 aTextRect.SetSize(pPage->GetSize());
146 SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
147 pObj->SetModel(pMod);
148 pObj->SetLayer(nLayer);
149 pObj->NbcSetText(rStr); // SetText before SetAttr, else SetAttr doesn't work!
150 if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, false);
152 pObj->SetMergedItemSet(aDefaultAttr);
154 SfxItemSet aTempAttr(pMod->GetItemPool()); // no fill, no line
155 aTempAttr.Put(XLineStyleItem(XLINE_NONE));
156 aTempAttr.Put(XFillStyleItem(XFILL_NONE));
158 pObj->SetMergedItemSet(aTempAttr);
160 pObj->FitFrameToTextSize();
161 Size aSiz(pObj->GetLogicRect().GetSize());
162 MapUnit eMap=pMod->GetScaleUnit();
163 Fraction aMap=pMod->GetScaleFraction();
164 ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
165 return true;
168 bool SdrExchangeView::Paste(SvStream& rInput, const OUString& rBaseURL, sal_uInt16 eFormat, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
170 Point aPos(rPos);
171 ImpGetPasteObjList(aPos,pLst);
172 ImpLimitToWorkArea( aPos );
173 if (pLst==NULL) return false;
174 SdrLayerID nLayer;
175 if (!ImpGetPasteLayer(pLst,nLayer)) return false;
176 bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
177 if (bUnmark) UnmarkAllObj();
178 Rectangle aTextRect(0,0,500,500);
179 SdrPage* pPage=pLst->GetPage();
180 if (pPage!=NULL) {
181 aTextRect.SetSize(pPage->GetSize());
183 SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
184 pObj->SetModel(pMod);
185 pObj->SetLayer(nLayer);
186 if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, false);
188 pObj->SetMergedItemSet(aDefaultAttr);
190 SfxItemSet aTempAttr(pMod->GetItemPool()); // no fill, no line
191 aTempAttr.Put(XLineStyleItem(XLINE_NONE));
192 aTempAttr.Put(XFillStyleItem(XFILL_NONE));
194 pObj->SetMergedItemSet(aTempAttr);
196 pObj->NbcSetText(rInput,rBaseURL,eFormat);
197 pObj->FitFrameToTextSize();
198 Size aSiz(pObj->GetLogicRect().GetSize());
199 MapUnit eMap=pMod->GetScaleUnit();
200 Fraction aMap=pMod->GetScaleFraction();
201 ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
203 // b4967543
204 if(pObj->GetModel() && pObj->GetOutlinerParaObject())
206 SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner();
207 rOutliner.SetText(*pObj->GetOutlinerParaObject());
209 if(1L == rOutliner.GetParagraphCount())
211 SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0L);
213 if(pCandidate)
215 if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool())
217 pObj->NbcSetStyleSheet(pCandidate, true);
223 return true;
226 bool SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
228 const SdrModel* pSrcMod=&rMod;
229 if (pSrcMod==pMod)
230 return false; // this can't work, right?
232 const bool bUndo = IsUndoEnabled();
234 if( bUndo )
235 BegUndo(ImpGetResStr(STR_ExchangePaste));
237 if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) )
239 if( bUndo )
240 EndUndo();
241 return true;
244 Point aPos(rPos);
245 ImpGetPasteObjList(aPos,pLst);
246 SdrPageView* pMarkPV=NULL;
247 SdrPageView* pPV = GetSdrPageView();
249 if(pPV)
251 if ( pPV->GetObjList() == pLst )
252 pMarkPV=pPV;
255 ImpLimitToWorkArea( aPos );
256 if (pLst==NULL)
257 return false;
259 bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
260 if (bUnmark)
261 UnmarkAllObj();
263 // Rescale, if the Model uses a different MapUnit.
264 // Calculate the necessary factors first.
265 MapUnit eSrcUnit=pSrcMod->GetScaleUnit();
266 MapUnit eDstUnit=pMod->GetScaleUnit();
267 bool bResize=eSrcUnit!=eDstUnit;
268 Fraction xResize,yResize;
269 Point aPt0;
270 if (bResize)
272 FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit));
273 xResize=aResize.X();
274 yResize=aResize.Y();
276 SdrObjList* pDstLst=pLst;
277 sal_uInt16 nPg,nPgAnz=pSrcMod->GetPageCount();
278 for (nPg=0; nPg<nPgAnz; nPg++)
280 const SdrPage* pSrcPg=pSrcMod->GetPage(nPg);
282 // Use SnapRect, not BoundRect here
283 Rectangle aR=pSrcPg->GetAllObjSnapRect();
285 if (bResize)
286 ResizeRect(aR,aPt0,xResize,yResize);
287 Point aDist(aPos-aR.Center());
288 Size aSiz(aDist.X(),aDist.Y());
289 sal_uIntPtr nCloneErrCnt=0;
290 sal_uIntPtr nOb,nObAnz=pSrcPg->GetObjCount();
291 bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
293 // #i13033#
294 // New mechanism to re-create the connections of cloned connectors
295 CloneList aCloneList;
297 for (nOb=0; nOb<nObAnz; nOb++)
299 const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
301 SdrObject* pNeuObj = pSrcOb->Clone();
303 if (pNeuObj!=NULL)
305 if(bResize)
307 pNeuObj->GetModel()->SetPasteResize(true);
308 pNeuObj->NbcResize(aPt0,xResize,yResize);
309 pNeuObj->GetModel()->SetPasteResize(false);
312 // #i39861#
313 pNeuObj->SetModel(pDstLst->GetModel());
314 pNeuObj->SetPage(pDstLst->GetPage());
316 pNeuObj->NbcMove(aSiz);
318 const SdrPage* pPg = pDstLst->GetPage();
320 if(pPg)
322 // #i72535#
323 const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
324 SdrLayerID nLayer(0);
326 if(pNeuObj->ISA(FmFormObj))
328 // for FormControls, force to form layer
329 nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
331 else
333 nLayer = rAd.GetLayerID(aAktLayer, true);
336 if(SDRLAYER_NOTFOUND == nLayer)
338 nLayer = 0;
341 pNeuObj->SetLayer(nLayer);
344 SdrInsertReason aReason(SDRREASON_VIEWCALL);
345 pDstLst->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
347 if( bUndo )
348 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj));
350 if (bMark) {
351 // Don't already set Markhandles!
352 // That is instead being done by ModelHasChanged in MarkView.
353 MarkObj(pNeuObj,pMarkPV,false,true);
356 // #i13033#
357 aCloneList.AddPair(pSrcOb, pNeuObj);
359 else
361 nCloneErrCnt++;
365 // #i13033#
366 // New mechanism to re-create the connections of cloned connectors
367 aCloneList.CopyConnections();
369 if(0L != nCloneErrCnt)
371 #ifdef DBG_UTIL
372 OStringBuffer aStr("SdrExchangeView::Paste(): Error when cloning ");
374 if(nCloneErrCnt == 1)
376 aStr.append("a drawing object.");
378 else
380 aStr.append(static_cast<sal_Int32>(nCloneErrCnt));
381 aStr.append(" drawing objects.");
384 aStr.append(" Not copying object connectors.");
386 OSL_FAIL(aStr.getStr());
387 #endif
391 if( bUndo )
392 EndUndo();
394 return true;
397 void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, sal_uInt32 nOptions)
399 BigInt nSizX(rSiz.Width());
400 BigInt nSizY(rSiz.Height());
401 MapUnit eSrcMU=rMap.GetMapUnit();
402 MapUnit eDstMU=pMod->GetScaleUnit();
403 FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
404 Fraction aDstFr(pMod->GetScaleFraction());
405 nSizX*=aMapFact.X().GetNumerator();
406 nSizX*=rMap.GetScaleX().GetNumerator();
407 nSizX*=aDstFr.GetDenominator();
408 nSizX/=aMapFact.X().GetDenominator();
409 nSizX/=rMap.GetScaleX().GetDenominator();
410 nSizX/=aDstFr.GetNumerator();
411 nSizY*=aMapFact.Y().GetNumerator();
412 nSizY*=rMap.GetScaleY().GetNumerator();
413 nSizX*=aDstFr.GetDenominator();
414 nSizY/=aMapFact.Y().GetDenominator();
415 nSizY/=rMap.GetScaleY().GetDenominator();
416 nSizY/=aDstFr.GetNumerator();
417 long xs=nSizX;
418 long ys=nSizY;
419 Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2);
420 Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys);
421 pObj->SetLogicRect(aR);
422 SdrInsertReason aReason(SDRREASON_VIEWCALL);
423 rLst.InsertObject(pObj,CONTAINER_APPEND,&aReason);
425 if( IsUndoEnabled() )
426 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
428 SdrPageView* pMarkPV=NULL;
429 SdrPageView* pPV = GetSdrPageView();
431 if(pPV)
433 if (pPV->GetObjList()==&rLst)
434 pMarkPV=pPV;
437 bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
438 if (bMark)
439 { // select object the first PageView we found
440 MarkObj(pObj,pMarkPV);
444 BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
446 BitmapEx aBmp;
448 if( AreObjectsMarked() )
450 if(1 == GetMarkedObjectCount())
452 if(bNoVDevIfOneBmpMarked)
454 SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
455 SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() == 1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
457 if( pGrafObj && ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP ) )
459 aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx();
462 else
464 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0));
466 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg())
468 aBmp = pSdrGrafObj->GetGraphic().getSvgData()->getReplacement();
473 if( !aBmp )
475 // choose conversion directly using primitives to bitmap to avoid
476 // rendering errors with tiled bitmap fills (these will be tiled in a
477 // in-between metafile, but tend to show 'gaps' since the target is *no*
478 // bitmap rendering)
479 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
480 const sal_uInt32 nCount(aSdrObjects.size());
482 if(nCount)
484 // collect sub-primitives as group objects, thus no expensive append
485 // to existing sequence is needed
486 drawinglayer::primitive2d::Primitive2DSequence xPrimitives(nCount);
488 for(sal_uInt32 a(0); a < nCount; a++)
490 SdrObject* pCandidate = aSdrObjects[a];
491 SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pCandidate);
493 if(pSdrGrafObj)
495 // #122753# To ensure existence of graphic content, force swap in
496 pSdrGrafObj->ForceSwapIn();
499 xPrimitives[a] = new drawinglayer::primitive2d::GroupPrimitive2D(
500 pCandidate->GetViewContact().getViewIndependentPrimitive2DSequence());
503 // get logic range
504 const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
505 const basegfx::B2DRange aRange(
506 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
507 xPrimitives,
508 aViewInformation2D));
510 if(!aRange.isEmpty())
512 // if we have geometry and it has a range, convert to BitmapEx using
513 // common tooling
514 aBmp = convertPrimitive2DSequenceToBitmapEx(
515 xPrimitives,
516 aRange,
517 500000);
523 return aBmp;
528 GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) const
530 GDIMetaFile aMtf;
532 if( AreObjectsMarked() )
534 Rectangle aBound( GetMarkedObjBoundRect() );
535 Size aBoundSize( aBound.GetWidth(), aBound.GetHeight() );
536 MapMode aMap( pMod->GetScaleUnit(), Point(), pMod->GetScaleFraction(), pMod->GetScaleFraction() );
538 if( bNoVDevIfOneMtfMarked )
540 SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
541 SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
543 if( pGrafObj )
545 Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
547 // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
548 aMtf = aGraphic.GetGDIMetaFile();
552 if( !aMtf.GetActionSize() )
554 VirtualDevice aOut;
555 const Size aDummySize(2, 2);
557 aOut.SetOutputSizePixel(aDummySize);
558 aOut.EnableOutput(false);
559 aOut.SetMapMode(aMap);
560 aMtf.Clear();
561 aMtf.Record(&aOut);
563 DrawMarkedObj(aOut);
565 aMtf.Stop();
566 aMtf.WindStart();
568 // moving the result is more reliable then setting a relative MapMode at the VDev (used
569 // before), also see #i99268# in GetObjGraphic() below. Some draw actions at
570 // the OutDev are simply not handled correctly when a MapMode is set at the
571 // target devive, e.g. MetaFloatTransparentAction. Even the Move for this action
572 // was missing the manipulation of the embedded Metafile
573 aMtf.Move(-aBound.Left(), -aBound.Top());
575 aMtf.SetPrefMapMode( aMap );
577 // removed PrefSize extension. It is principally wrong to set a reduced size at
578 // the created MetaFile. The mentioned errors occur at output time since the integer
579 // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
580 // primitives (and may later be done in breaking up a MetaFile to primitives)
581 aMtf.SetPrefSize(aBoundSize);
585 return aMtf;
590 Graphic SdrExchangeView::GetAllMarkedGraphic() const
592 Graphic aRet;
594 if( AreObjectsMarked() )
596 if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
597 aRet = SdrExchangeView::GetObjGraphic( pMod, GetMarkedObjectByIndex( 0 ) );
598 else
599 aRet = GetMarkedObjMetaFile(false);
602 return aRet;
607 Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj )
609 Graphic aRet;
611 if( pModel && pObj )
613 // try to get a graphic from the object first
614 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
615 const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
617 if(pSdrGrafObj)
619 if(pSdrGrafObj->isEmbeddedSvg())
621 // get Metafile for Svg content
622 aRet = pSdrGrafObj->getMetafileFromEmbeddedSvg();
624 else
626 // Make behaviour coherent with metafile
627 // recording below (which of course also takes
628 // view-transformed objects)
629 aRet = pSdrGrafObj->GetTransformedGraphic();
632 else if(pSdrOle2Obj)
634 if ( pSdrOle2Obj->GetGraphic() )
635 aRet = *pSdrOle2Obj->GetGraphic();
638 // if graphic could not be retrieved => go the hard way and create a MetaFile
639 if( ( GRAPHIC_NONE == aRet.GetType() ) || ( GRAPHIC_DEFAULT == aRet.GetType() ) )
641 VirtualDevice aOut;
642 GDIMetaFile aMtf;
643 const Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
644 const MapMode aMap( pModel->GetScaleUnit(),
645 Point(),
646 pModel->GetScaleFraction(),
647 pModel->GetScaleFraction() );
649 aOut.EnableOutput( false );
650 aOut.SetMapMode( aMap );
651 aMtf.Record( &aOut );
652 pObj->SingleObjectPainter( aOut );
653 aMtf.Stop();
654 aMtf.WindStart();
656 // #i99268# replace the original offset from using XOutDev's SetOffset
657 // NOT (as tried with #i92760#) with another MapMode which gets recorded
658 // by the Metafile itself (what always leads to problems), but by
659 // moving the result directly
660 aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
662 aMtf.SetPrefMapMode( aMap );
663 aMtf.SetPrefSize( aBoundRect.GetSize() );
665 if( aMtf.GetActionSize() )
666 aRet = aMtf;
670 return aRet;
675 ::std::vector< SdrObject* > SdrExchangeView::GetMarkedObjects() const
677 SortMarkedObjects();
678 ::std::vector< SdrObject* > aRetval;
680 ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 );
681 ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ];
682 ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ];
683 const SdrLayerAdmin& rLayerAdmin = pMod->GetLayerAdmin();
684 const sal_uInt32 nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), false );
685 sal_uInt32 n, nCount;
687 for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ )
689 SdrMark* pMark = GetSdrMarkByIndex( n );
691 // paint objects on control layer on top of all other objects
692 if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
693 rObjVector2.push_back( pMark );
694 else
695 rObjVector1.push_back( pMark );
698 for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ )
700 ::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ];
702 for( sal_uInt32 i = 0; i < rObjVector.size(); i++ )
704 SdrMark* pMark = rObjVector[ i ];
705 aRetval.push_back(pMark->GetMarkedSdrObj());
709 return aRetval;
714 void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const
716 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
718 if(aSdrObjects.size())
720 sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aSdrObjects, aSdrObjects[0]->GetPage());
721 sdr::contact::DisplayInfo aDisplayInfo;
723 // do processing
724 aPainter.ProcessDisplay(aDisplayInfo);
730 SdrModel* SdrExchangeView::GetMarkedObjModel() const
732 // Sorting the MarkList here might be problematic in the future, so
733 // use a copy.
734 SortMarkedObjects();
735 SdrModel* pNeuMod=pMod->AllocModel();
736 SdrPage* pNeuPag=pNeuMod->AllocPage(false);
737 pNeuMod->InsertPage(pNeuPag);
739 if( !mxSelectionController.is() || !mxSelectionController->GetMarkedObjModel( pNeuPag ) )
741 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
743 // #i13033#
744 // New mechanism to re-create the connections of cloned connectors
745 CloneList aCloneList;
747 for( sal_uInt32 i(0); i < aSdrObjects.size(); i++ )
749 const SdrObject* pObj = aSdrObjects[i];
750 SdrObject* pNeuObj;
752 if( pObj->ISA( SdrPageObj ) )
754 // convert SdrPageObj's to a graphic representation, because
755 // virtual connection to referenced page gets lost in new model
756 pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, pObj ), pObj->GetLogicRect() );
757 pNeuObj->SetPage( pNeuPag );
758 pNeuObj->SetModel( pNeuMod );
760 else
762 pNeuObj = pObj->Clone();
763 pNeuObj->SetPage( pNeuPag );
764 pNeuObj->SetModel( pNeuMod );
767 SdrInsertReason aReason(SDRREASON_VIEWCALL);
768 pNeuPag->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
770 // #i13033#
771 aCloneList.AddPair(pObj, pNeuObj);
774 // #i13033#
775 // New mechanism to re-create the connections of cloned connectors
776 aCloneList.CopyConnections();
778 return pNeuMod;
783 bool SdrExchangeView::Cut( sal_uIntPtr /*nFormat */)
785 OSL_FAIL( "SdrExchangeView::Cut: Not supported any more." );
786 return false;
791 bool SdrExchangeView::Yank(sal_uIntPtr /*nFormat*/)
793 OSL_FAIL( "SdrExchangeView::Yank: Not supported any more." );
794 return false;
799 bool SdrExchangeView::Paste(Window* /*pWin*/, sal_uIntPtr /*nFormat*/)
801 OSL_FAIL( "SdrExchangeView::Paste: Not supported any more." );
802 return false;
805 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */