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