LibreOffice Module svx (master)  1
svdxcgv.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <vector>
21 #include <unordered_set>
22 #include <editeng/editdata.hxx>
23 #include <editeng/editeng.hxx>
24 #include <rtl/strbuf.hxx>
25 #include <svx/xfillit0.hxx>
26 #include <svx/xflclit.hxx>
27 #include <svx/xlineit0.hxx>
28 #include <svx/svdxcgv.hxx>
29 #include <svx/svdoutl.hxx>
30 #include <svx/svdetc.hxx>
31 #include <svx/svdundo.hxx>
32 #include <svx/svdograf.hxx>
33 #include <svx/svdoole2.hxx>
34 #include <svx/svdorect.hxx>
35 #include <svx/svdoedge.hxx>
36 #include <svx/svdopage.hxx>
37 #include <svx/svdpage.hxx>
38 #include <svx/svdpagv.hxx>
39 #include <svx/svdtrans.hxx>
40 #include <svx/strings.hrc>
41 #include <svx/dialmgr.hxx>
42 #include <svx/xoutbmp.hxx>
43 #include <vcl/metaact.hxx>
44 #include <svl/poolitem.hxx>
45 #include <svl/itempool.hxx>
46 #include <tools/bigint.hxx>
47 #include <sot/formats.hxx>
48 #include <clonelist.hxx>
49 #include <vcl/virdev.hxx>
50 #include <svl/style.hxx>
51 #include <fmobj.hxx>
59 #include <svx/svdotable.hxx>
60 
61 using namespace com::sun::star;
62 
64  SdrModel& rSdrModel,
65  OutputDevice* pOut)
66 : SdrObjEditView(rSdrModel, pOut)
67 {
68 }
69 
71 {
72  bool bRet(false);
73 
74  if(!maMaxWorkArea.IsEmpty())
75  {
76  if(rPt.X()<maMaxWorkArea.Left())
77  {
78  rPt.setX( maMaxWorkArea.Left() );
79  bRet = true;
80  }
81 
82  if(rPt.X()>maMaxWorkArea.Right())
83  {
84  rPt.setX( maMaxWorkArea.Right() );
85  bRet = true;
86  }
87 
88  if(rPt.Y()<maMaxWorkArea.Top())
89  {
90  rPt.setY( maMaxWorkArea.Top() );
91  bRet = true;
92  }
93 
94  if(rPt.Y()>maMaxWorkArea.Bottom())
95  {
96  rPt.setY( maMaxWorkArea.Bottom() );
97  bRet = true;
98  }
99  }
100  return bRet;
101 }
102 
104 {
105  if (rpLst==nullptr)
106  {
107  SdrPageView* pPV = GetSdrPageView();
108 
109  if (pPV!=nullptr) {
110  rpLst=pPV->GetObjList();
111  }
112  }
113 }
114 
115 bool SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const
116 {
117  bool bRet=false;
118  rLayer=SdrLayerID(0);
119  if (pObjList!=nullptr) {
120  const SdrPage* pPg=pObjList->getSdrPageFromSdrObjList();
121  if (pPg!=nullptr) {
122  rLayer=pPg->GetLayerAdmin().GetLayerID(maActualLayer);
123  if (rLayer==SDRLAYER_NOTFOUND) rLayer=SdrLayerID(0);
124  SdrPageView* pPV = GetSdrPageView();
125  if (pPV!=nullptr) {
126  bRet=!pPV->GetLockedLayers().IsSet(rLayer) && pPV->GetVisibleLayers().IsSet(rLayer);
127  }
128  }
129  }
130  return bRet;
131 }
132 
133 bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions)
134 {
135  if (rStr.isEmpty())
136  return false;
137 
138  Point aPos(rPos);
139  ImpGetPasteObjList(aPos,pLst);
140  ImpLimitToWorkArea( aPos );
141  if (pLst==nullptr) return false;
142  SdrLayerID nLayer;
143  if (!ImpGetPasteLayer(pLst,nLayer)) return false;
145  if (bUnmark) UnmarkAllObj();
146  tools::Rectangle aTextRect(0,0,500,500);
147  SdrPage* pPage=pLst->getSdrPageFromSdrObjList();
148  if (pPage!=nullptr) {
149  aTextRect.SetSize(pPage->GetSize());
150  }
151  SdrRectObj* pObj = new SdrRectObj(
153  OBJ_TEXT,
154  aTextRect);
155 
156  pObj->SetLayer(nLayer);
157  pObj->NbcSetText(rStr); // SetText before SetAttr, else SetAttr doesn't work!
158  if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
159 
161 
162  SfxItemSet aTempAttr(mpModel->GetItemPool()); // no fill, no line
163  aTempAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
164  aTempAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
165 
166  pObj->SetMergedItemSet(aTempAttr);
167 
168  pObj->FitFrameToTextSize();
169  Size aSiz(pObj->GetLogicRect().GetSize());
170  MapUnit eMap=mpModel->GetScaleUnit();
172  ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
173  return true;
174 }
175 
176 bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions)
177 {
178  Point aPos(rPos);
179  ImpGetPasteObjList(aPos,pLst);
180  ImpLimitToWorkArea( aPos );
181  if (pLst==nullptr) return false;
182  SdrLayerID nLayer;
183  if (!ImpGetPasteLayer(pLst,nLayer)) return false;
185  if (bUnmark) UnmarkAllObj();
186  tools::Rectangle aTextRect(0,0,500,500);
187  SdrPage* pPage=pLst->getSdrPageFromSdrObjList();
188  if (pPage!=nullptr) {
189  aTextRect.SetSize(pPage->GetSize());
190  }
191  SdrRectObj* pObj = new SdrRectObj(
193  OBJ_TEXT,
194  aTextRect);
195 
196  pObj->SetLayer(nLayer);
197  if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
198 
200 
201  SfxItemSet aTempAttr(mpModel->GetItemPool()); // no fill, no line
202  aTempAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
203  aTempAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
204 
205  pObj->SetMergedItemSet(aTempAttr);
206 
207  pObj->NbcSetText(rInput,OUString(),eFormat);
208  pObj->FitFrameToTextSize();
209  Size aSiz(pObj->GetLogicRect().GetSize());
210  MapUnit eMap=mpModel->GetScaleUnit();
212  ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
213 
214  // b4967543
215  if(pObj->GetOutlinerParaObject())
216  {
218  rOutliner.SetText(*pObj->GetOutlinerParaObject());
219 
220  if(1 == rOutliner.GetParagraphCount())
221  {
222  SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0);
223 
224  if(pCandidate)
225  {
226  if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == pCandidate->GetPool())
227  {
228  pObj->NbcSetStyleSheet(pCandidate, true);
229  }
230  }
231  }
232  }
233 
234  return true;
235 }
236 
238  const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions)
239 {
240  const SdrModel* pSrcMod=&rMod;
241  if (pSrcMod==mpModel)
242  return false; // this can't work, right?
243 
244  const bool bUndo = IsUndoEnabled();
245 
246  if( bUndo )
247  BegUndo(SvxResId(STR_ExchangePaste));
248 
249  if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) )
250  {
251  if( bUndo )
252  EndUndo();
253  return true;
254  }
255 
256  Point aPos(rPos);
257  ImpGetPasteObjList(aPos,pLst);
258  SdrPageView* pMarkPV=nullptr;
259  SdrPageView* pPV = GetSdrPageView();
260 
261  if(pPV && pPV->GetObjList() == pLst )
262  pMarkPV=pPV;
263 
264  ImpLimitToWorkArea( aPos );
265  if (pLst==nullptr)
266  return false;
267 
269  if (bUnmark)
270  UnmarkAllObj();
271 
272  // Rescale, if the Model uses a different MapUnit.
273  // Calculate the necessary factors first.
274  MapUnit eSrcUnit=pSrcMod->GetScaleUnit();
275  MapUnit eDstUnit=mpModel->GetScaleUnit();
276  bool bResize=eSrcUnit!=eDstUnit;
277  Fraction aXResize,aYResize;
278  Point aPt0;
279  if (bResize)
280  {
281  FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit));
282  aXResize=aResize.X();
283  aYResize=aResize.Y();
284  }
285  SdrObjList* pDstLst=pLst;
286  sal_uInt16 nPg,nPgCount=pSrcMod->GetPageCount();
287  for (nPg=0; nPg<nPgCount; nPg++)
288  {
289  const SdrPage* pSrcPg=pSrcMod->GetPage(nPg);
290 
291  // Use SnapRect, not BoundRect here
292  tools::Rectangle aR=pSrcPg->GetAllObjSnapRect();
293 
294  if (bResize)
295  ResizeRect(aR,aPt0,aXResize,aYResize);
296  Point aDist(aPos-aR.Center());
297  Size aSiz(aDist.X(),aDist.Y());
298  size_t nCloneErrCnt = 0;
299  const size_t nObjCount = pSrcPg->GetObjCount();
300  bool bMark = pMarkPV!=nullptr && !IsTextEdit() && (nOptions&SdrInsertFlags::DONTMARK)==SdrInsertFlags::NONE;
301 
302  // #i13033#
303  // New mechanism to re-create the connections of cloned connectors
304  CloneList aCloneList;
305  std::unordered_set<rtl::OUString> aNameSet;
306  for (size_t nOb=0; nOb<nObjCount; ++nOb)
307  {
308  const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
309 
310  SdrObject* pNewObj(pSrcOb->CloneSdrObject(*mpModel));
311 
312  if (pNewObj!=nullptr)
313  {
314  if(bResize)
315  {
316  pNewObj->getSdrModelFromSdrObject().SetPasteResize(true);
317  pNewObj->NbcResize(aPt0,aXResize,aYResize);
318  pNewObj->getSdrModelFromSdrObject().SetPasteResize(false);
319  }
320 
321  // #i39861#
322  pNewObj->NbcMove(aSiz);
323 
324  const SdrPage* pPg = pDstLst->getSdrPageFromSdrObjList();
325 
326  if(pPg)
327  {
328  // #i72535#
329  const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
330  SdrLayerID nLayer(0);
331 
332  if(dynamic_cast<const FmFormObj*>( pNewObj) != nullptr)
333  {
334  // for FormControls, force to form layer
335  nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
336  }
337  else
338  {
339  nLayer = rAd.GetLayerID(maActualLayer);
340  }
341 
342  if(SDRLAYER_NOTFOUND == nLayer)
343  {
344  nLayer = SdrLayerID(0);
345  }
346 
347  pNewObj->SetLayer(nLayer);
348  }
349 
350  pDstLst->InsertObjectThenMakeNameUnique(pNewObj, aNameSet);
351 
352  if( bUndo )
353  AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
354 
355  if (bMark) {
356  // Don't already set Markhandles!
357  // That is instead being done by ModelHasChanged in MarkView.
358  MarkObj(pNewObj,pMarkPV,false,true);
359  }
360 
361  // #i13033#
362  aCloneList.AddPair(pSrcOb, pNewObj);
363  }
364  else
365  {
366  nCloneErrCnt++;
367  }
368  }
369 
370  // #i13033#
371  // New mechanism to re-create the connections of cloned connectors
372  aCloneList.CopyConnections();
373 
374  if(0L != nCloneErrCnt)
375  {
376 #ifdef DBG_UTIL
377  OStringBuffer aStr("SdrExchangeView::Paste(): Error when cloning ");
378 
379  if(nCloneErrCnt == 1)
380  {
381  aStr.append("a drawing object.");
382  }
383  else
384  {
385  aStr.append(static_cast<sal_Int32>(nCloneErrCnt));
386  aStr.append(" drawing objects.");
387  }
388 
389  aStr.append(" Not copying object connectors.");
390 
391  OSL_FAIL(aStr.getStr());
392 #endif
393  }
394  }
395 
396  if( bUndo )
397  EndUndo();
398 
399  return true;
400 }
401 
402 void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, SdrInsertFlags nOptions)
403 {
404  BigInt nSizX(rSiz.Width());
405  BigInt nSizY(rSiz.Height());
406  MapUnit eSrcMU=rMap.GetMapUnit();
407  MapUnit eDstMU=mpModel->GetScaleUnit();
408  FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
409  Fraction aDstFr(mpModel->GetScaleFraction());
410  nSizX *= double(aMapFact.X() * rMap.GetScaleX() * aDstFr);
411  nSizX *= aDstFr.GetDenominator();
412  nSizY *= double(aMapFact.Y() * rMap.GetScaleY());
413  nSizY /= aDstFr.GetNumerator();
414  long xs=nSizX;
415  long ys=nSizY;
416  Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2);
417  tools::Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys);
418  pObj->SetLogicRect(aR);
419  rLst.InsertObject(pObj, SAL_MAX_SIZE);
420 
421  if( IsUndoEnabled() )
422  AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pObj));
423 
424  SdrPageView* pMarkPV=nullptr;
425  SdrPageView* pPV = GetSdrPageView();
426 
427  if(pPV && pPV->GetObjList()==&rLst)
428  pMarkPV=pPV;
429 
430  bool bMark = pMarkPV!=nullptr && !IsTextEdit() && (nOptions&SdrInsertFlags::DONTMARK)==SdrInsertFlags::NONE;
431  if (bMark)
432  { // select object the first PageView we found
433  MarkObj(pObj,pMarkPV);
434  }
435 }
436 
437 BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
438 {
439  BitmapEx aBmp;
440 
441  if( AreObjectsMarked() )
442  {
443  if(1 == GetMarkedObjectCount())
444  {
445  if(bNoVDevIfOneBmpMarked)
446  {
447  SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
448  SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>( pGrafObjTmp );
449 
450  if( pGrafObj && ( pGrafObj->GetGraphicType() == GraphicType::Bitmap ) )
451  {
452  aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx();
453  }
454  }
455  else
456  {
457  const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0));
458 
459  if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData())
460  {
461  aBmp = pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement();
462  }
463  }
464  }
465 
466  if( !aBmp )
467  {
468  // choose conversion directly using primitives to bitmap to avoid
469  // rendering errors with tiled bitmap fills (these will be tiled in a
470  // in-between metafile, but tend to show 'gaps' since the target is *no*
471  // bitmap rendering)
472  ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
473  const sal_uInt32 nCount(aSdrObjects.size());
474 
475  if(nCount)
476  {
477  // collect sub-primitives as group objects, thus no expensive append
478  // to existing sequence is needed
480 
481  for(sal_uInt32 a(0); a < nCount; a++)
482  {
483  SdrObject* pCandidate = aSdrObjects[a];
484  SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pCandidate);
485 
486  if(pSdrGrafObj)
487  {
488  // #122753# To ensure existence of graphic content, force swap in
489  pSdrGrafObj->ForceSwapIn();
490  }
491 
494  }
495 
496  // get logic range
497  const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
498  const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D));
499 
500  if(!aRange.isEmpty())
501  {
502  // if we have geometry and it has a range, convert to BitmapEx using
503  // common tooling
505  xPrimitives,
506  aRange);
507  }
508  }
509  }
510  }
511 
512  return aBmp;
513 }
514 
515 
516 GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) const
517 {
518  GDIMetaFile aMtf;
519 
520  if( AreObjectsMarked() )
521  {
523  Size aBoundSize( aBound.GetWidth(), aBound.GetHeight() );
525 
526  if( bNoVDevIfOneMtfMarked )
527  {
528  SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
529  SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? dynamic_cast<SdrGrafObj*>( pGrafObjTmp ) : nullptr;
530 
531  if( pGrafObj )
532  {
533  Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
534 
535  // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
536  aMtf = aGraphic.GetGDIMetaFile();
537  }
538  }
539 
540  if( !aMtf.GetActionSize() )
541  {
543  const Size aDummySize(2, 2);
544 
545  pOut->SetOutputSizePixel(aDummySize);
546  pOut->EnableOutput(false);
547  pOut->SetMapMode(aMap);
548  aMtf.Clear();
549  aMtf.Record(pOut);
550 
551  DrawMarkedObj(*pOut);
552 
553  aMtf.Stop();
554  aMtf.WindStart();
555 
556  // moving the result is more reliable then setting a relative MapMode at the VDev (used
557  // before), also see #i99268# in GetObjGraphic() below. Some draw actions at
558  // the OutDev are simply not handled correctly when a MapMode is set at the
559  // target device, e.g. MetaFloatTransparentAction. Even the Move for this action
560  // was missing the manipulation of the embedded Metafile
561  aMtf.Move(-aBound.Left(), -aBound.Top());
562 
563  aMtf.SetPrefMapMode( aMap );
564 
565  // removed PrefSize extension. It is principally wrong to set a reduced size at
566  // the created MetaFile. The mentioned errors occur at output time since the integer
567  // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
568  // primitives (and may later be done in breaking up a MetaFile to primitives)
569  aMtf.SetPrefSize(aBoundSize);
570  }
571  }
572 
573  return aMtf;
574 }
575 
576 
578 {
579  Graphic aRet;
580 
581  if( AreObjectsMarked() )
582  {
583  if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
585  else
586  aRet = GetMarkedObjMetaFile();
587  }
588 
589  return aRet;
590 }
591 
592 
594 {
595  Graphic aRet;
596 
597  // try to get a graphic from the object first
598  const SdrGrafObj* pSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&rSdrObject));
599  const SdrOle2Obj* pSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&rSdrObject));
600 
601  if(pSdrGrafObj)
602  {
603  if(pSdrGrafObj->isEmbeddedVectorGraphicData())
604  {
605  // get Metafile for Svg content
606  aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
607  }
608  else
609  {
610  // Make behaviour coherent with metafile
611  // recording below (which of course also takes
612  // view-transformed objects)
613  aRet = pSdrGrafObj->GetTransformedGraphic();
614  }
615  }
616  else if(pSdrOle2Obj)
617  {
618  if(pSdrOle2Obj->GetGraphic())
619  {
620  aRet = *pSdrOle2Obj->GetGraphic();
621  }
622  }
623 
624  // if graphic could not be retrieved => go the hard way and create a MetaFile
625  if((GraphicType::NONE == aRet.GetType()) || (GraphicType::Default == aRet.GetType()))
626  {
628  GDIMetaFile aMtf;
629  const tools::Rectangle aBoundRect(rSdrObject.GetCurrentBoundRect());
630  const MapMode aMap(rSdrObject.getSdrModelFromSdrObject().GetScaleUnit(),
631  Point(),
634 
635  pOut->EnableOutput(false);
636  pOut->SetMapMode(aMap);
637  aMtf.Record(pOut);
638  rSdrObject.SingleObjectPainter(*pOut);
639  aMtf.Stop();
640  aMtf.WindStart();
641 
642  // #i99268# replace the original offset from using XOutDev's SetOffset
643  // NOT (as tried with #i92760#) with another MapMode which gets recorded
644  // by the Metafile itself (what always leads to problems), but by
645  // moving the result directly
646  aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
647  aMtf.SetPrefMapMode(aMap);
648  aMtf.SetPrefSize(aBoundRect.GetSize());
649 
650  if(aMtf.GetActionSize())
651  {
652  aRet = aMtf;
653  }
654  }
655 
656  return aRet;
657 }
658 
659 
660 ::std::vector< SdrObject* > SdrExchangeView::GetMarkedObjects() const
661 {
663  ::std::vector< SdrObject* > aRetval;
664 
665  ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 );
666  ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ];
667  ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ];
668  const SdrLayerAdmin& rLayerAdmin = mpModel->GetLayerAdmin();
669  const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName() );
670 
671  for( size_t n = 0, nCount = GetMarkedObjectCount(); n < nCount; ++n )
672  {
673  SdrMark* pMark = GetSdrMarkByIndex( n );
674 
675  // paint objects on control layer on top of all other objects
676  if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
677  rObjVector2.push_back( pMark );
678  else
679  rObjVector1.push_back( pMark );
680  }
681 
682  for(const std::vector<SdrMark*> & rObjVector : aObjVectors)
683  {
684  for(SdrMark* pMark : rObjVector)
685  {
686  aRetval.push_back(pMark->GetMarkedSdrObj());
687  }
688  }
689 
690  return aRetval;
691 }
692 
693 
695 {
696  ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
697 
698  if(!aSdrObjects.empty())
699  {
700  sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aSdrObjects, aSdrObjects[0]->getSdrPageFromSdrObject());
701  sdr::contact::DisplayInfo aDisplayInfo;
702 
703  // do processing
704  aPainter.ProcessDisplay(aDisplayInfo);
705  }
706 }
707 
708 std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
709 {
710  // Sorting the MarkList here might be problematic in the future, so
711  // use a copy.
713  std::unique_ptr<SdrModel> pNewModel(mpModel->AllocModel());
714  SdrPage* pNewPage(pNewModel->AllocPage(false));
715  pNewModel->InsertPage(pNewPage);
716  ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
717 
718  // #i13033#
719  // New mechanism to re-create the connections of cloned connectors
720  CloneList aCloneList;
721 
722  for(SdrObject* pObj : aSdrObjects)
723  {
724  SdrObject* pNewObj(nullptr);
725 
726  if(nullptr != dynamic_cast< const SdrPageObj* >(pObj))
727  {
728  // convert SdrPageObj's to a graphic representation, because
729  // virtual connection to referenced page gets lost in new model
730  pNewObj = new SdrGrafObj(
731  *pNewModel,
732  GetObjGraphic(*pObj),
733  pObj->GetLogicRect());
734  }
735  else if(nullptr != dynamic_cast< const sdr::table::SdrTableObj* >(pObj))
736  {
737  // check if we have a valid selection *different* from whole table
738  // being selected
739  if(mxSelectionController.is())
740  {
741  pNewObj = mxSelectionController->GetMarkedSdrObjClone(*pNewModel);
742  }
743  }
744 
745  if(nullptr == pNewObj)
746  {
747  // not cloned yet
748  if (pObj->GetObjIdentifier() == OBJ_OLE2)
749  {
750  // tdf#125520
751  pNewObj = pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject());
752  }
753  else
754  {
755  // use default way
756  pNewObj = pObj->CloneSdrObject(*pNewModel);
757  }
758  }
759 
760  if(pNewObj)
761  {
762  pNewPage->InsertObject(pNewObj, SAL_MAX_SIZE);
763 
764  // #i13033#
765  aCloneList.AddPair(pObj, pNewObj);
766  }
767  }
768 
769  // #i13033#
770  // New mechanism to re-create the connections of cloned connectors
771  aCloneList.CopyConnections();
772 
773  return pNewModel;
774 }
775 
776 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrExchangeView(SdrModel &rSdrModel, OutputDevice *pOut)
Definition: svdxcgv.cxx:63
const Fraction & GetScaleX() const
long Width() const
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
Definition: svdmrkv.cxx:2297
void FitFrameToTextSize()
Definition: svdotext.cxx:182
long GetWidth() const
GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const
Definition: svdograf.cxx:858
const VectorGraphicDataPtr & getVectorGraphicData() const
long GetHeight() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:881
void ImpGetPasteObjList(Point &rPos, SdrObjList *&rpLst)
Definition: svdxcgv.cxx:103
foreign graphic (StarView Graphic)
Definition: svdobj.hxx:137
void SortMarkedObjects() const
Definition: svdmrkv.hxx:250
Graphic GetAllMarkedGraphic() const
Definition: svdxcgv.cxx:577
long Height() const
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
Definition: svdxcgv.cxx:237
const Fraction & GetScaleFraction() const
Definition: svdmodel.hxx:369
periodic cubic Spline (ni)
Definition: svdobj.hxx:133
bool AreObjectsMarked() const
Definition: svdmrkv.hxx:251
bool IsUndoEnabled() const
Definition: svdedtv.cxx:1031
sal_Int64 n
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:773
size_t GetObjCount() const
Definition: svdpage.cxx:767
SfxStyleSheet * GetStyleSheet(sal_Int32 nPara)
void SetPrefSize(const Size &rSize)
void Clear()
void BegUndo()
Definition: svdedtv.hxx:179
tools::Rectangle maMaxWorkArea
Definition: svdpntv.hxx:148
sal_Int32 GetParagraphCount() const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:358
GraphicType GetGraphicType() const
Definition: svdograf.cxx:365
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:271
EETextFormat
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
bool IsEmpty() const
SdrModel * mpModel
Definition: svdpntv.hxx:132
HashMap_OWString_Interface aMap
MapUnit GetScaleUnit() const
Definition: svdmodel.hxx:367
long Right() const
void Record(OutputDevice *pOutDev)
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false) const
Definition: svdxcgv.cxx:437
static Graphic GetObjGraphic(const SdrObject &rSdrObject)
Generate a Graphic for the given draw object.
Definition: svdxcgv.cxx:593
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void setX(long nX)
const Fraction & GetScaleY() const
void ForceSwapIn() const
Definition: svdograf.cxx:467
int nCount
oslFileHandle & pOut
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: svdobj.cxx:1936
long Top() const
constexpr SdrLayerID SDRLAYER_NOTFOUND(0xff)
void setY(long nY)
o3tl::strong_int< sal_uInt8, struct SdrLayerIDTag > SdrLayerID
Definition: svdtypes.hxx:59
void EndUndo()
Definition: svdedtv.cxx:278
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
Definition: svdxcgv.cxx:516
SdrOutliner & GetHitTestOutliner() const
Definition: svdmodel.hxx:319
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
bool ImpLimitToWorkArea(Point &rPt) const
Definition: svdxcgv.cxx:70
SdrObjList * GetObjList() const
Return current List.
Definition: svdpagv.hxx:176
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:67
SfxStyleSheetBasePool * GetPool()
Everything a View needs to know about a selected object.
Definition: svdmark.hxx:43
SfxStyleSheet * mpDefaultStyleSheet
Definition: svdpntv.hxx:135
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:217
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdedtv.hxx:183
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
Definition: svdtrans.cxx:36
virtual void SetLayer(SdrLayerID nLayer)
Definition: svdobj.cxx:626
const OUString & GetControlLayerName() const
Definition: svdlayer.hxx:151
void ImpPasteObject(SdrObject *pObj, SdrObjList &rLst, const Point &rCenter, const Size &rSiz, const MapMode &rMap, SdrInsertFlags nOptions)
Definition: svdxcgv.cxx:402
Graphic GetTransformedGraphic(SdrGrafObjTransformsAttrs nTransformFlags=SdrGrafObjTransformsAttrs::ALL) const
Definition: svdograf.cxx:349
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const
Definition: svdxcgv.cxx:708
void SetText(const OutlinerParaObject &)
uno_Any a
GraphicType GetType() const
const Fraction & Y() const
Definition: svdtrans.hxx:246
void SingleObjectPainter(OutputDevice &rOut) const
Definition: svdobj.cxx:978
size_t GetMarkedObjectCount() const
Definition: svdmrkv.hxx:249
const Graphic & GetGraphic() const
Definition: svdograf.cxx:344
Size GetSize() const
Definition: svdpage.cxx:1386
void SetSize(const Size &rSize)
const Fraction & X() const
Definition: svdtrans.hxx:245
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1917
void CopyConnections() const
Definition: clonelist.cxx:70
long Bottom() const
friend class SdrGrafObj
Definition: svdpntv.hxx:125
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:299
const SdrLayerAdmin & GetLayerAdmin() const
changing the layers does not set the modified-flag!
Definition: svdpage.cxx:1648
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1658
OUString maActualLayer
Definition: svdpntv.hxx:137
MapUnit GetMapUnit() const
void InsertObjectThenMakeNameUnique(SdrObject *pObj)
Definition: svdpage.cxx:332
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
void WindStart()
tools::Rectangle GetMarkedObjBoundRect() const
Definition: svdmrkv.cxx:2351
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:79
Abstract DrawObject.
Definition: svdobj.hxx:312
long X() const
SdrInsertFlags
Definition: svdedtv.hxx:58
Size GetSize() const
virtual SdrLayerID GetLayer() const
Definition: svdobj.cxx:604
void SetPasteResize(bool bOn)
Definition: svdmodel.hxx:270
const SdrLayerIDSet & GetLockedLayers() const
Definition: svdpagv.hxx:221
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:66
FrPair GetMapFactor(MapUnit eS, MapUnit eD)
Definition: svdtrans.cxx:632
drawinglayer::primitive2d::Primitive2DContainer const & getViewIndependentPrimitive2DContainer() const
virtual bool IsTextEdit() const final override
Definition: svdedxv.cxx:1664
sal_Int32 GetDenominator() const
bool ImpGetPasteLayer(const SdrObjList *pObjList, SdrLayerID &rLayer) const
Definition: svdxcgv.cxx:115
virtual SdrModel * AllocModel() const
Definition: svdmodel.cxx:642
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotext.cxx:1362
void Move(long nX, long nY)
SfxStyleSheetBasePool * GetStyleSheetPool() const
Definition: svdmodel.hxx:538
virtual void DrawMarkedObj(OutputDevice &rOut) const
Definition: svdxcgv.cxx:694
void NbcSetText(const OUString &rStr)
Definition: svdotext.cxx:207
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
Definition: svdobj.cxx:1001
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:146
size_t GetActionSize() const
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
Definition: svdmrkv.hxx:248
long Left() const
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
MapUnit
BitmapEx convertPrimitive2DSequenceToBitmapEx(const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > &rSequence, const basegfx::B2DRange &rTargetRange, const sal_uInt32 nMaximumQuadraticPixels)
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:268
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:314
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1673
SdrMark * GetSdrMarkByIndex(size_t nNum) const
Definition: svdmrkv.hxx:247
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
::std::vector< SdrObject * > GetMarkedObjects() const
Definition: svdxcgv.cxx:660
virtual void NbcSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
Definition: svdobj.cxx:2180
const SdrLayerAdmin & GetLayerAdmin() const
Definition: svdmodel.hxx:311
rtl::Reference< sdr::SelectionController > mxSelectionController
Definition: svdedxv.hxx:102
SdrLayerID GetLayerID(const OUString &rName) const
Definition: svdlayer.cxx:230
const tools::Rectangle & GetAllObjSnapRect() const
Definition: svdpage.cxx:694
bool isEmbeddedVectorGraphicData() const
Definition: svdograf.cxx:853
SfxItemSet maDefaultAttr
Definition: svdpntv.hxx:149
aStr
Point Center() const
long Y() const
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1929
const Graphic * GetGraphic() const
Definition: svdoole2.cxx:1660
void SetPrefMapMode(const MapMode &rMapMode)
virtual const tools::Rectangle & GetLogicRect() const override
Definition: svdotxtr.cxx:73
void AddPair(const SdrObject *pOriginal, SdrObject *pClone)
Definition: clonelist.cxx:28