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
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(GetModel().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());
165 MapUnit eMap = GetModel().GetScaleUnit();
166 ImpPasteObject(pObj.get(), *pLst, aPos, aSiz, MapMode(eMap), nOptions);
167 return true;
168}
169
170bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions)
171{
172 Point aPos(rPos);
173 ImpGetPasteObjList(aPos,pLst);
174 ImpLimitToWorkArea( aPos );
175 if (pLst==nullptr) return false;
176 SdrLayerID nLayer;
177 if (!ImpGetPasteLayer(pLst,nLayer)) return false;
179 if (bUnmark) UnmarkAllObj();
180 tools::Rectangle aTextRect(0,0,500,500);
181 SdrPage* pPage=pLst->getSdrPageFromSdrObjList();
182 if (pPage!=nullptr) {
183 aTextRect.SetSize(pPage->GetSize());
184 }
188 aTextRect);
189
190 pObj->SetLayer(nLayer);
191 if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
192
193 pObj->SetMergedItemSet(maDefaultAttr);
194
195 SfxItemSet aTempAttr(GetModel().GetItemPool()); // no fill, no line
196 aTempAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
197 aTempAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
198
199 pObj->SetMergedItemSet(aTempAttr);
200
201 pObj->NbcSetText(rInput,OUString(),eFormat);
202 pObj->FitFrameToTextSize();
203 Size aSiz(pObj->GetLogicRect().GetSize());
204 MapUnit eMap = GetModel().GetScaleUnit();
205 ImpPasteObject(pObj.get(), *pLst, aPos, aSiz, MapMode(eMap), nOptions);
206
207 // b4967543
208 if(pObj->GetOutlinerParaObject())
209 {
210 SdrOutliner& rOutliner = pObj->getSdrModelFromSdrObject().GetHitTestOutliner();
211 rOutliner.SetText(*pObj->GetOutlinerParaObject());
212
213 if(1 == rOutliner.GetParagraphCount())
214 {
215 SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0);
216
217 if(pCandidate)
218 {
219 if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == pCandidate->GetPool())
220 {
221 pObj->NbcSetStyleSheet(pCandidate, true);
222 }
223 }
224 }
225 }
226
227 return true;
228}
229
231 const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions)
232{
233 const SdrModel* pSrcMod=&rMod;
234 if (pSrcMod == &GetModel())
235 return false; // this can't work, right?
236
237 const bool bUndo = IsUndoEnabled();
238
239 if( bUndo )
240 BegUndo(SvxResId(STR_ExchangePaste));
241
242 if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) )
243 {
244 if( bUndo )
245 EndUndo();
246 return true;
247 }
248
249 Point aPos(rPos);
250 ImpGetPasteObjList(aPos,pLst);
251 SdrPageView* pMarkPV=nullptr;
253
254 if(pPV && pPV->GetObjList() == pLst )
255 pMarkPV=pPV;
256
257 ImpLimitToWorkArea( aPos );
258 if (pLst==nullptr)
259 return false;
260
262 if (bUnmark)
263 UnmarkAllObj();
264
265 // Rescale, if the Model uses a different MapUnit.
266 // Calculate the necessary factors first.
267 MapUnit eSrcUnit = pSrcMod->GetScaleUnit();
268 MapUnit eDstUnit = GetModel().GetScaleUnit();
269 bool bResize=eSrcUnit!=eDstUnit;
270 Fraction aXResize,aYResize;
271 Point aPt0;
272 if (bResize)
273 {
274 FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit));
275 aXResize=aResize.X();
276 aYResize=aResize.Y();
277 }
278 SdrObjList* pDstLst=pLst;
279 sal_uInt16 nPg,nPgCount=pSrcMod->GetPageCount();
280 for (nPg=0; nPg<nPgCount; nPg++)
281 {
282 const SdrPage* pSrcPg=pSrcMod->GetPage(nPg);
283
284 // Use SnapRect, not BoundRect here
286
287 if (bResize)
288 ResizeRect(aR,aPt0,aXResize,aYResize);
289 Point aDist(aPos-aR.Center());
290 Size aSiz(aDist.X(),aDist.Y());
291 size_t nCloneErrCnt = 0;
292 const size_t nObjCount = pSrcPg->GetObjCount();
293 bool bMark = pMarkPV!=nullptr && !IsTextEdit() && (nOptions&SdrInsertFlags::DONTMARK)==SdrInsertFlags::NONE;
294
295 // #i13033#
296 // New mechanism to re-create the connections of cloned connectors
297 CloneList aCloneList;
298 std::unordered_set<rtl::OUString> aNameSet;
299 for (size_t nOb=0; nOb<nObjCount; ++nOb)
300 {
301 const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
302
304
305 if (pNewObj!=nullptr)
306 {
307 if(bResize)
308 {
309 pNewObj->getSdrModelFromSdrObject().SetPasteResize(true);
310 pNewObj->NbcResize(aPt0,aXResize,aYResize);
311 pNewObj->getSdrModelFromSdrObject().SetPasteResize(false);
312 }
313
314 // #i39861#
315 pNewObj->NbcMove(aSiz);
316
317 const SdrPage* pPg = pDstLst->getSdrPageFromSdrObjList();
318
319 if(pPg)
320 {
321 // #i72535#
322 const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
323 SdrLayerID nLayer(0);
324
325 if(dynamic_cast<const FmFormObj*>( pNewObj.get()) != nullptr)
326 {
327 // for FormControls, force to form layer
328 nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
329 }
330 else
331 {
332 nLayer = rAd.GetLayerID(maActualLayer);
333 }
334
335 if(SDRLAYER_NOTFOUND == nLayer)
336 {
337 nLayer = SdrLayerID(0);
338 }
339
340 pNewObj->SetLayer(nLayer);
341 }
342
343 pDstLst->InsertObjectThenMakeNameUnique(pNewObj.get(), aNameSet);
344
345 if( bUndo )
346 AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
347
348 if (bMark) {
349 // Don't already set Markhandles!
350 // That is instead being done by ModelHasChanged in MarkView.
351 MarkObj(pNewObj.get(),pMarkPV,false,true);
352 }
353
354 // #i13033#
355 aCloneList.AddPair(pSrcOb, pNewObj.get());
356 }
357 else
358 {
359 nCloneErrCnt++;
360 }
361 }
362
363 // #i13033#
364 // New mechanism to re-create the connections of cloned connectors
365 aCloneList.CopyConnections();
366
367 if(0 != nCloneErrCnt)
368 {
369#ifdef DBG_UTIL
370 OStringBuffer aStr("SdrExchangeView::Paste(): Error when cloning ");
371
372 if(nCloneErrCnt == 1)
373 {
374 aStr.append("a drawing object.");
375 }
376 else
377 {
378 aStr.append(OString::number(static_cast<sal_Int32>(nCloneErrCnt))
379 + " drawing objects.");
380 }
381
382 aStr.append(" Not copying object connectors.");
383
384 OSL_FAIL(aStr.getStr());
385#endif
386 }
387 }
388
389 if( bUndo )
390 EndUndo();
391
392 return true;
393}
394
395void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, SdrInsertFlags nOptions)
396{
397 BigInt nSizX(rSiz.Width());
398 BigInt nSizY(rSiz.Height());
399 MapUnit eSrcMU=rMap.GetMapUnit();
400 MapUnit eDstMU = GetModel().GetScaleUnit();
401 FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
402 nSizX *= double(aMapFact.X() * rMap.GetScaleX());
403 nSizY *= double(aMapFact.Y() * rMap.GetScaleY());
404 tools::Long xs=nSizX;
405 tools::Long ys=nSizY;
406 // set the pos to 0, 0 for online case
408 Point aPos(isLOK ? 0 : rCenter.X()-xs/2, isLOK ? 0 : rCenter.Y()-ys/2);
409 tools::Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys);
410 pObj->SetLogicRect(aR);
411 rLst.InsertObject(pObj, SAL_MAX_SIZE);
412
413 if( IsUndoEnabled() )
414 AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pObj));
415
416 SdrPageView* pMarkPV=nullptr;
418
419 if(pPV && pPV->GetObjList()==&rLst)
420 pMarkPV=pPV;
421
422 bool bMark = pMarkPV!=nullptr && !IsTextEdit() && (nOptions&SdrInsertFlags::DONTMARK)==SdrInsertFlags::NONE;
423 if (bMark)
424 { // select object the first PageView we found
425 MarkObj(pObj,pMarkPV);
426 }
427}
428
429BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const sal_uInt32 nMaximumQuadraticPixels, const std::optional<Size>& rTargetDPI) const
430{
431 BitmapEx aBmp;
432
433 if( AreObjectsMarked() )
434 {
435 if(1 == GetMarkedObjectCount())
436 {
437 if(bNoVDevIfOneBmpMarked)
438 {
439 SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
440 SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>( pGrafObjTmp );
441
442 if( pGrafObj && ( pGrafObj->GetGraphicType() == GraphicType::Bitmap ) )
443 {
444 aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx();
445 }
446 }
447 else
448 {
449 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0));
450
451 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData())
452 {
453 aBmp = pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement();
454 }
455 }
456 }
457
458 if( aBmp.IsEmpty() )
459 {
460 // choose conversion directly using primitives to bitmap to avoid
461 // rendering errors with tiled bitmap fills (these will be tiled in a
462 // in-between metafile, but tend to show 'gaps' since the target is *no*
463 // bitmap rendering)
464 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
465 const sal_uInt32 nCount(aSdrObjects.size());
466
467 if(nCount)
468 {
469 // collect sub-primitives as group objects, thus no expensive append
470 // to existing sequence is needed
472
473 for(sal_uInt32 a(0); a < nCount; a++)
474 {
475 SdrObject* pCandidate = aSdrObjects[a];
476 SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pCandidate);
477
478 if(pSdrGrafObj)
479 {
480 // #122753# To ensure existence of graphic content, force swap in
481 pSdrGrafObj->ForceSwapIn();
482 }
483
487 std::move(xRetval));
488 }
489
490 // get logic range
491 const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
492 const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D));
493
494 if(!aRange.isEmpty())
495 {
497
498 if (GetModel().IsWriter())
499 {
500 eRangeUnit = o3tl::Length::twip;
501 }
502
503 // if we have geometry and it has a range, convert to BitmapEx using
504 // common tooling
506 std::move(xPrimitives),
507 aRange,
508 nMaximumQuadraticPixels,
509 eRangeUnit,
510 rTargetDPI);
511 }
512 }
513 }
514 }
515
516 return aBmp;
517}
518
519
520GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) const
521{
522 GDIMetaFile aMtf;
523
524 if( AreObjectsMarked() )
525 {
527 Size aBoundSize( aBound.GetWidth(), aBound.GetHeight() );
528 MapMode aMap(GetModel().GetScaleUnit());
529
530 if( bNoVDevIfOneMtfMarked )
531 {
532 SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
533 SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? dynamic_cast<SdrGrafObj*>( pGrafObjTmp ) : nullptr;
534
535 if( pGrafObj )
536 {
537 Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
538
539 // #119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
540 aMtf = aGraphic.GetGDIMetaFile();
541 }
542 }
543
544 if( !aMtf.GetActionSize() )
545 {
547 const Size aDummySize(2, 2);
548
549 pOut->SetOutputSizePixel(aDummySize);
550 pOut->EnableOutput(false);
551 pOut->SetMapMode(aMap);
552 aMtf.Clear();
553 aMtf.Record(pOut);
554
556
557 aMtf.Stop();
558 aMtf.WindStart();
559
560 // moving the result is more reliable then setting a relative MapMode at the VDev (used
561 // before), also see #i99268# in GetObjGraphic() below. Some draw actions at
562 // the OutDev are simply not handled correctly when a MapMode is set at the
563 // target device, e.g. MetaFloatTransparentAction. Even the Move for this action
564 // was missing the manipulation of the embedded Metafile
565 aMtf.Move(-aBound.Left(), -aBound.Top());
566
567 aMtf.SetPrefMapMode( aMap );
568
569 // removed PrefSize extension. It is principally wrong to set a reduced size at
570 // the created MetaFile. The mentioned errors occur at output time since the integer
571 // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
572 // primitives (and may later be done in breaking up a MetaFile to primitives)
573 aMtf.SetPrefSize(aBoundSize);
574 }
575 }
576
577 return aMtf;
578}
579
580
582{
583 Graphic aRet;
584
585 if( AreObjectsMarked() )
586 {
587 if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
589 else
590 aRet = GetMarkedObjMetaFile();
591 }
592
593 return aRet;
594}
595
596
597// tdf#155479 bSVG: need to know it's SVG export, default is false
599{
600 Graphic aRet;
601
602 // try to get a graphic from the object first
603 const SdrGrafObj* pSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&rSdrObject));
604 const SdrOle2Obj* pSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&rSdrObject));
605
606 if(pSdrGrafObj)
607 {
608 if(pSdrGrafObj->isEmbeddedVectorGraphicData())
609 {
610 // get Metafile for Svg content
611 aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
612 }
613 else
614 {
615 // Make behaviour coherent with metafile
616 // recording below (which of course also takes
617 // view-transformed objects)
618 aRet = pSdrGrafObj->GetTransformedGraphic();
619 }
620 }
621 else if(pSdrOle2Obj)
622 {
623 if(pSdrOle2Obj->GetGraphic())
624 {
625 aRet = *pSdrOle2Obj->GetGraphic();
626 }
627 }
628 else
629 {
630 // Support extracting a snapshot from video media, if possible.
631 const SdrMediaObj* pSdrMediaObj = dynamic_cast<const SdrMediaObj*>(&rSdrObject);
632 if (pSdrMediaObj)
633 {
634 const css::uno::Reference<css::graphic::XGraphic>& xGraphic
635 = pSdrMediaObj->getSnapshot();
636 if (xGraphic.is())
637 aRet = Graphic(xGraphic);
638 }
639 }
640
641 // if graphic could not be retrieved => go the hard way and create a MetaFile
642 if((GraphicType::NONE == aRet.GetType()) || (GraphicType::Default == aRet.GetType()))
643 {
645 GDIMetaFile aMtf;
646 const tools::Rectangle aBoundRect(rSdrObject.GetCurrentBoundRect());
648
649 pOut->EnableOutput(false);
650 pOut->SetMapMode(aMap);
651 aMtf.Record(pOut);
652 aMtf.setSVG(bSVG);
653 rSdrObject.SingleObjectPainter(*pOut);
654 aMtf.Stop();
655 aMtf.WindStart();
656
657 // #i99268# replace the original offset from using XOutDev's SetOffset
658 // NOT (as tried with #i92760#) with another MapMode which gets recorded
659 // by the Metafile itself (what always leads to problems), but by
660 // moving the result directly
661 aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
662 aMtf.SetPrefMapMode(aMap);
663 aMtf.SetPrefSize(aBoundRect.GetSize());
664
665 if(aMtf.GetActionSize())
666 {
667 aRet = aMtf;
668 }
669 }
670
671 return aRet;
672}
673
674
675::std::vector< SdrObject* > SdrExchangeView::GetMarkedObjects() const
676{
678 ::std::vector< SdrObject* > aRetval;
679
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 = GetModel().GetLayerAdmin();
684 const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName() );
685
686 for( size_t n = 0, nCount = GetMarkedObjectCount(); n < nCount; ++n )
687 {
688 SdrMark* pMark = GetSdrMarkByIndex( n );
689
690 // paint objects on control layer on top of all other objects
691 if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
692 rObjVector2.push_back( pMark );
693 else
694 rObjVector1.push_back( pMark );
695 }
696
697 for(const std::vector<SdrMark*> & rObjVector : aObjVectors)
698 {
699 for(SdrMark* pMark : rObjVector)
700 {
701 aRetval.push_back(pMark->GetMarkedSdrObj());
702 }
703 }
704
705 return aRetval;
706}
707
708
710{
711 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
712
713 if(!aSdrObjects.empty())
714 {
715 sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, std::move(aSdrObjects), aSdrObjects[0]->getSdrPageFromSdrObject());
716 sdr::contact::DisplayInfo aDisplayInfo;
717
718 // do processing
719 aPainter.ProcessDisplay(aDisplayInfo);
720 }
721}
722
723std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
724{
725 // Sorting the MarkList here might be problematic in the future, so
726 // use a copy.
728 std::unique_ptr<SdrModel> pNewModel(GetModel().AllocModel());
729 rtl::Reference<SdrPage> pNewPage = pNewModel->AllocPage(false);
730 pNewModel->InsertPage(pNewPage.get());
731 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
732
733 // #i13033#
734 // New mechanism to re-create the connections of cloned connectors
735 CloneList aCloneList;
736
737 for(SdrObject* pObj : aSdrObjects)
738 {
740
741 if(nullptr != dynamic_cast< const SdrPageObj* >(pObj))
742 {
743 // convert SdrPageObj's to a graphic representation, because
744 // virtual connection to referenced page gets lost in new model
745 pNewObj = new SdrGrafObj(
746 *pNewModel,
747 GetObjGraphic(*pObj),
748 pObj->GetLogicRect());
749 }
750 else if(nullptr != dynamic_cast< const sdr::table::SdrTableObj* >(pObj))
751 {
752 // check if we have a valid selection *different* from whole table
753 // being selected
754 if(mxSelectionController.is())
755 {
756 pNewObj = mxSelectionController->GetMarkedSdrObjClone(*pNewModel);
757 }
758 }
759
760 if(!pNewObj)
761 {
762 // not cloned yet
763 if(pObj->GetObjIdentifier() == SdrObjKind::OLE2 && nullptr == GetModel().GetPersist())
764 {
765 // tdf#125520 - former fix was wrong, the SdrModel
766 // has to have a GetPersist() already, see task.
767 // We can still warn here when this is not the case
768 SAL_WARN( "svx", "OLE gets cloned Persist, EmbeddedObjectContainer will not be copied" );
769 }
770
771 // use default way
772 pNewObj = pObj->CloneSdrObject(*pNewModel);
773 }
774
775 if(pNewObj)
776 {
777 pNewPage->InsertObject(pNewObj.get(), SAL_MAX_SIZE);
778
779 // #i13033#
780 aCloneList.AddPair(pObj, pNewObj.get());
781 }
782 }
783
784 // #i13033#
785 // New mechanism to re-create the connections of cloned connectors
786 aCloneList.CopyConnections();
787
788 return pNewModel;
789}
790
791/* 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:236
const Fraction & Y() const
Definition: svdtrans.hxx:237
size_t GetActionSize() const
void Move(tools::Long nX, tools::Long nY)
void WindStart()
void setSVG(bool bNew)
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
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
bool IsUndoEnabled() const
Definition: svdedtv.cxx:1056
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdedtv.hxx:196
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
bool ImpGetPasteLayer(const SdrObjList *pObjList, SdrLayerID &rLayer) const
Definition: svdxcgv.cxx:110
Graphic GetAllMarkedGraphic() const
Definition: svdxcgv.cxx:581
::std::vector< SdrObject * > GetMarkedObjects() const
Definition: svdxcgv.cxx:675
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
Definition: svdxcgv.cxx:520
static Graphic GetObjGraphic(const SdrObject &rSdrObject, bool bSVG=false)
Generate a Graphic for the given draw object.
Definition: svdxcgv.cxx:598
virtual void DrawMarkedObj(OutputDevice &rOut) const
Definition: svdxcgv.cxx:709
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
Definition: svdxcgv.cxx:230
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:395
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const
Definition: svdxcgv.cxx:723
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt) const
Definition: svdxcgv.cxx:429
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:68
GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const
Definition: svdograf.cxx:854
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:398
bool isEmbeddedVectorGraphicData() const
Definition: svdograf.cxx:849
void ForceSwapIn() const
Definition: svdograf.cxx:498
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:2622
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:2567
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1941
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
MapUnit GetScaleUnit() const
Definition: svdmodel.hxx:371
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1860
const SdrLayerAdmin & GetLayerAdmin() const
Definition: svdmodel.hxx:315
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1870
rtl::Reference< sdr::SelectionController > mxSelectionController
Definition: svdedxv.hxx:108
virtual bool IsTextEdit() const final override
Definition: svdedxv.cxx:1833
void InsertObjectThenMakeNameUnique(SdrObject *pObj)
Definition: svdpage.cxx:269
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:122
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:295
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:785
size_t GetObjCount() const
Definition: svdpage.cxx:779
const tools::Rectangle & GetAllObjSnapRect() const
Definition: svdpage.cxx:694
Abstract DrawObject.
Definition: svdobj.hxx:260
void SingleObjectPainter(OutputDevice &rOut) const
Definition: svdobj.cxx:1064
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:962
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1696
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:261
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const =0
virtual SdrLayerID GetLayer() const
Definition: svdobj.cxx:645
const Graphic * GetGraphic() const
Definition: svdoole2.cxx:1700
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:379
const SdrLayerAdmin & GetLayerAdmin() const
changing the layers does not set the modified-flag!
Definition: svdpage.cxx:1726
Size GetSize() const
Definition: svdpage.cxx:1450
SfxItemSet maDefaultAttr
Definition: svdpntv.hxx:141
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:280
tools::Rectangle maMaxWorkArea
Definition: svdpntv.hxx:140
friend class SdrGrafObj
Definition: svdpntv.hxx:118
SfxStyleSheet * mpDefaultStyleSheet
Definition: svdpntv.hxx:127
OUString maActualLayer
Definition: svdpntv.hxx:129
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:323
SdrModel & GetModel() const
Definition: svdpntv.hxx:282
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:618
o3tl::strong_int< sal_Int16, struct SdrLayerIDTag > SdrLayerID
Definition: svdtypes.hxx:56
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)
oslFileHandle & pOut