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(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(static_cast<sal_Int32>(nCloneErrCnt));
379 aStr.append(" 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
598{
599 Graphic aRet;
600
601 // try to get a graphic from the object first
602 const SdrGrafObj* pSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&rSdrObject));
603 const SdrOle2Obj* pSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&rSdrObject));
604
605 if(pSdrGrafObj)
606 {
607 if(pSdrGrafObj->isEmbeddedVectorGraphicData())
608 {
609 // get Metafile for Svg content
610 aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
611 }
612 else
613 {
614 // Make behaviour coherent with metafile
615 // recording below (which of course also takes
616 // view-transformed objects)
617 aRet = pSdrGrafObj->GetTransformedGraphic();
618 }
619 }
620 else if(pSdrOle2Obj)
621 {
622 if(pSdrOle2Obj->GetGraphic())
623 {
624 aRet = *pSdrOle2Obj->GetGraphic();
625 }
626 }
627 else
628 {
629 // Support extracting a snapshot from video media, if possible.
630 const SdrMediaObj* pSdrMediaObj = dynamic_cast<const SdrMediaObj*>(&rSdrObject);
631 if (pSdrMediaObj)
632 {
633 const css::uno::Reference<css::graphic::XGraphic>& xGraphic
634 = pSdrMediaObj->getSnapshot();
635 if (xGraphic.is())
636 aRet = Graphic(xGraphic);
637 }
638 }
639
640 // if graphic could not be retrieved => go the hard way and create a MetaFile
641 if((GraphicType::NONE == aRet.GetType()) || (GraphicType::Default == aRet.GetType()))
642 {
644 GDIMetaFile aMtf;
645 const tools::Rectangle aBoundRect(rSdrObject.GetCurrentBoundRect());
647
648 pOut->EnableOutput(false);
649 pOut->SetMapMode(aMap);
650 aMtf.Record(pOut);
651 rSdrObject.SingleObjectPainter(*pOut);
652 aMtf.Stop();
653 aMtf.WindStart();
654
655 // #i99268# replace the original offset from using XOutDev's SetOffset
656 // NOT (as tried with #i92760#) with another MapMode which gets recorded
657 // by the Metafile itself (what always leads to problems), but by
658 // moving the result directly
659 aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
660 aMtf.SetPrefMapMode(aMap);
661 aMtf.SetPrefSize(aBoundRect.GetSize());
662
663 if(aMtf.GetActionSize())
664 {
665 aRet = aMtf;
666 }
667 }
668
669 return aRet;
670}
671
672
673::std::vector< SdrObject* > SdrExchangeView::GetMarkedObjects() const
674{
676 ::std::vector< SdrObject* > aRetval;
677
678 ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 );
679 ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ];
680 ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ];
681 const SdrLayerAdmin& rLayerAdmin = GetModel().GetLayerAdmin();
682 const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName() );
683
684 for( size_t n = 0, nCount = GetMarkedObjectCount(); n < nCount; ++n )
685 {
686 SdrMark* pMark = GetSdrMarkByIndex( n );
687
688 // paint objects on control layer on top of all other objects
689 if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
690 rObjVector2.push_back( pMark );
691 else
692 rObjVector1.push_back( pMark );
693 }
694
695 for(const std::vector<SdrMark*> & rObjVector : aObjVectors)
696 {
697 for(SdrMark* pMark : rObjVector)
698 {
699 aRetval.push_back(pMark->GetMarkedSdrObj());
700 }
701 }
702
703 return aRetval;
704}
705
706
708{
709 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
710
711 if(!aSdrObjects.empty())
712 {
713 sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, std::move(aSdrObjects), aSdrObjects[0]->getSdrPageFromSdrObject());
714 sdr::contact::DisplayInfo aDisplayInfo;
715
716 // do processing
717 aPainter.ProcessDisplay(aDisplayInfo);
718 }
719}
720
721std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
722{
723 // Sorting the MarkList here might be problematic in the future, so
724 // use a copy.
726 std::unique_ptr<SdrModel> pNewModel(GetModel().AllocModel());
727 rtl::Reference<SdrPage> pNewPage = pNewModel->AllocPage(false);
728 pNewModel->InsertPage(pNewPage.get());
729 ::std::vector< SdrObject* > aSdrObjects(GetMarkedObjects());
730
731 // #i13033#
732 // New mechanism to re-create the connections of cloned connectors
733 CloneList aCloneList;
734
735 for(SdrObject* pObj : aSdrObjects)
736 {
738
739 if(nullptr != dynamic_cast< const SdrPageObj* >(pObj))
740 {
741 // convert SdrPageObj's to a graphic representation, because
742 // virtual connection to referenced page gets lost in new model
743 pNewObj = new SdrGrafObj(
744 *pNewModel,
745 GetObjGraphic(*pObj),
746 pObj->GetLogicRect());
747 }
748 else if(nullptr != dynamic_cast< const sdr::table::SdrTableObj* >(pObj))
749 {
750 // check if we have a valid selection *different* from whole table
751 // being selected
752 if(mxSelectionController.is())
753 {
754 pNewObj = mxSelectionController->GetMarkedSdrObjClone(*pNewModel);
755 }
756 }
757
758 if(!pNewObj)
759 {
760 // not cloned yet
761 if(pObj->GetObjIdentifier() == SdrObjKind::OLE2 && nullptr == GetModel().GetPersist())
762 {
763 // tdf#125520 - former fix was wrong, the SdrModel
764 // has to have a GetPersist() already, see task.
765 // We can still warn here when this is not the case
766 SAL_WARN( "svx", "OLE gets cloned Persist, EmbeddedObjectContainer will not be copied" );
767 }
768
769 // use default way
770 pNewObj = pObj->CloneSdrObject(*pNewModel);
771 }
772
773 if(pNewObj)
774 {
775 pNewPage->InsertObject(pNewObj.get(), SAL_MAX_SIZE);
776
777 // #i13033#
778 aCloneList.AddPair(pObj, pNewObj.get());
779 }
780 }
781
782 // #i13033#
783 // New mechanism to re-create the connections of cloned connectors
784 aCloneList.CopyConnections();
785
786 return pNewModel;
787}
788
789/* 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 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: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
static Graphic GetObjGraphic(const SdrObject &rSdrObject)
Generate a Graphic for the given draw object.
Definition: svdxcgv.cxx:597
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:673
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
Definition: svdxcgv.cxx:520
virtual void DrawMarkedObj(OutputDevice &rOut) const
Definition: svdxcgv.cxx:707
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:721
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:860
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:855
void ForceSwapIn() const
Definition: svdograf.cxx:500
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
MapUnit GetScaleUnit() const
Definition: svdmodel.hxx:371
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1870
const SdrLayerAdmin & GetLayerAdmin() const
Definition: svdmodel.hxx:315
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1880
rtl::Reference< sdr::SelectionController > mxSelectionController
Definition: svdedxv.hxx:108
virtual bool IsTextEdit() const final override
Definition: svdedxv.cxx:1834
void InsertObjectThenMakeNameUnique(SdrObject *pObj)
Definition: svdpage.cxx:308
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:124
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:334
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:824
size_t GetObjCount() const
Definition: svdpage.cxx:818
const tools::Rectangle & GetAllObjSnapRect() const
Definition: svdpage.cxx:733
Abstract DrawObject.
Definition: svdobj.hxx:260
void SingleObjectPainter(OutputDevice &rOut) const
Definition: svdobj.cxx:1028
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:1660
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:1634
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:1751
Size GetSize() const
Definition: svdpage.cxx:1475
SfxItemSet maDefaultAttr
Definition: svdpntv.hxx:141
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:257
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:300
SdrModel & GetModel() const
Definition: svdpntv.hxx:259
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