LibreOffice Module sc (master) 1
drwtrans.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 <com/sun/star/embed/XTransactedObject.hpp>
21#include <com/sun/star/embed/XEmbedPersist.hpp>
22#include <com/sun/star/embed/XEmbeddedObject.hpp>
23#include <com/sun/star/uno/Exception.hpp>
24
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/beans/XPropertySetInfo.hpp>
27#include <com/sun/star/form/FormButtonType.hpp>
29
30#include <svx/unomodel.hxx>
31#include <unotools/tempfile.hxx>
36
38#include <sot/storage.hxx>
39#include <svx/svditer.hxx>
40#include <svx/svdograf.hxx>
41#include <svx/svdoole2.hxx>
42#include <svx/svdouno.hxx>
43#include <sfx2/docfile.hxx>
44#include <svl/itempool.hxx>
45#include <svl/urlbmk.hxx>
46#include <tools/urlobj.hxx>
47#include <osl/diagnose.h>
48
49#include <drwtrans.hxx>
50#include <docsh.hxx>
51#include <drwlayer.hxx>
52#include <drawview.hxx>
53#include <utility>
54#include <viewdata.hxx>
55#include <scmod.hxx>
56#include <dragdata.hxx>
57#include <stlpool.hxx>
58#include <scresid.hxx>
59#include <globstr.hrc>
60
61#include <editeng/eeitem.hxx>
62
63#include <editeng/fhgtitem.hxx>
64#include <vcl/svapp.hxx>
65
66using namespace com::sun::star;
67
68constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ = 1;
69constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL = 2;
70constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT = 3;
71
72ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell,
74 m_pModel( std::move(pClipModel) ),
75 m_aObjDesc(std::move( aDesc )),
76 m_bGraphic( false ),
77 m_bGrIsBit( false ),
78 m_bOleObj( false ),
79 m_nDragSourceFlags( ScDragSrc::Undefined ),
80 m_bDragWasInternal( false ),
81 maShellID(SfxObjectShell::CreateShellID(pContainerShell))
82{
83
84 // check what kind of objects are contained
85
86 SdrPage* pPage = m_pModel->GetPage(0);
87 if (pPage)
88 {
89 SdrObjListIter aIter( pPage, SdrIterMode::Flat );
90 SdrObject* pObject = aIter.Next();
91 if (pObject && !aIter.Next()) // exactly one object?
92 {
93
94 // OLE object
95
96 SdrObjKind nSdrObjKind = pObject->GetObjIdentifier();
97 if (nSdrObjKind == SdrObjKind::OLE2)
98 {
99 // if object has no persistence it must be copied as a part of document
100 try
101 {
102 uno::Reference< embed::XEmbedPersist > xPersObj( static_cast<SdrOle2Obj*>(pObject)->GetObjRef(), uno::UNO_QUERY );
103 if ( xPersObj.is() && xPersObj->hasEntry() )
104 m_bOleObj = true;
105 }
106 catch( uno::Exception& )
107 {}
108 // aOleData is initialized later
109 }
110
111 // Graphic object
112
113 if (nSdrObjKind == SdrObjKind::Graphic)
114 {
115 m_bGraphic = true;
116 if ( static_cast<SdrGrafObj*>(pObject)->GetGraphic().GetType() == GraphicType::Bitmap )
117 m_bGrIsBit = true;
118 }
119
120 // URL button
121
122 SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObject );
123 if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
124 {
125 const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->GetUnoControlModel();
126 OSL_ENSURE( xControlModel.is(), "uno control without model" );
127 if ( xControlModel.is() )
128 {
129 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
130 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
131
132 OUString sPropButtonType( "ButtonType" );
133
134 if(xInfo->hasPropertyByName( sPropButtonType ))
135 {
136 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
137 form::FormButtonType eTmp;
138 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
139 {
140 // URL
141 OUString sPropTargetURL( "TargetURL" );
142 if(xInfo->hasPropertyByName( sPropTargetURL ))
143 {
144 aAny = xPropSet->getPropertyValue( sPropTargetURL );
145 OUString sTmp;
146 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
147 {
148 OUString aUrl = sTmp;
149 OUString aAbs = aUrl;
150 if (pContainerShell)
151 {
152 const SfxMedium* pMedium = pContainerShell->GetMedium();
153 if (pMedium)
154 {
155 bool bWasAbs = true;
156 aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ).
158 // full path as stored INetBookmark must be encoded
159 }
160 }
161
162 // Label
163 OUString aLabel;
164 OUString sPropLabel( "Label" );
165 if(xInfo->hasPropertyByName( sPropLabel ))
166 {
167 aAny = xPropSet->getPropertyValue( sPropLabel );
168 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
169 {
170 aLabel = sTmp;
171 }
172 }
173 m_oBookmark.emplace( aAbs, aLabel );
174 }
175 }
176 }
177 }
178 }
179 }
180 }
181 }
182
183 // get size for object descriptor
184
185 // #i71538# use complete SdrViews
186 // SdrExchangeView aView(pModel);
187 SdrView aView(*m_pModel);
188 SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel().GetPage(0));
189 aView.MarkAllObj(pPv);
191
192 if ( m_bOleObj ) // single OLE object
193 {
194 SdrOle2Obj* pObj = GetSingleObject();
195 if ( pObj && pObj->GetObjRef().is() )
197 }
198
201
202 // remember a unique ID of the source document
203
204 if ( pContainerShell )
205 {
206 ScDocument& rDoc = pContainerShell->GetDocument();
207 if ( pPage )
208 {
210 }
211 }
212}
213
215{
216 SolarMutexGuard aSolarGuard;
217
218 ScModule* pScMod = SC_MOD();
219 if (pScMod && pScMod->GetDragData().pDrawTransfer == this)
220 {
221 OSL_FAIL("ScDrawTransferObj wasn't released");
222 pScMod->ResetDragObject();
223 }
224
225 m_aOleData = TransferableDataHelper(); // clear before releasing the mutex
227
228 m_pModel.reset();
229 m_aDrawPersistRef.clear(); // after the model
230
231 m_oBookmark.reset();
232 m_pDragSourceView.reset();
233}
234
235ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard(const uno::Reference<datatransfer::XTransferable2>& xTransferable)
236{
237 return dynamic_cast<ScDrawTransferObj*>(xTransferable.get());
238}
239
240static bool lcl_HasOnlyControls( SdrModel* pModel )
241{
242 bool bOnlyControls = false; // default if there are no objects
243
244 if ( pModel )
245 {
246 SdrPage* pPage = pModel->GetPage(0);
247 if (pPage)
248 {
249 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
250 SdrObject* pObj = aIter.Next();
251 if ( pObj )
252 {
253 bOnlyControls = true; // only set if there are any objects at all
254 while ( pObj )
255 {
256 if (dynamic_cast<const SdrUnoObj*>( pObj) == nullptr)
257 {
258 bOnlyControls = false;
259 break;
260 }
261 pObj = aIter.Next();
262 }
263 }
264 }
265 }
266
267 return bOnlyControls;
268}
269
271{
272 if ( m_bGrIsBit ) // single bitmap graphic
273 {
274 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
275 AddFormat( SotClipboardFormatId::SVXB );
276 AddFormat( SotClipboardFormatId::PNG );
277 AddFormat( SotClipboardFormatId::BITMAP );
278 AddFormat( SotClipboardFormatId::GDIMETAFILE );
279 }
280 else if ( m_bGraphic ) // other graphic
281 {
282 // #i25616#
283 AddFormat( SotClipboardFormatId::DRAWING );
284
285 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
286 AddFormat( SotClipboardFormatId::SVXB );
287 AddFormat( SotClipboardFormatId::GDIMETAFILE );
288 AddFormat( SotClipboardFormatId::PNG );
289 AddFormat( SotClipboardFormatId::BITMAP );
290 }
291 else if ( m_oBookmark ) // url button
292 {
293// AddFormat( SotClipboardFormatId::EMBED_SOURCE );
294 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
295 AddFormat( SotClipboardFormatId::SOLK );
296 AddFormat( SotClipboardFormatId::STRING );
297 AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
298 AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
299 AddFormat( SotClipboardFormatId::DRAWING );
300 }
301 else if ( m_bOleObj ) // single OLE object
302 {
303 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
304 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
305 AddFormat( SotClipboardFormatId::GDIMETAFILE );
306
308
309 if ( m_aOleData.GetTransferable().is() )
310 {
311 // get format list from object snapshot
312 // (this must be after inserting the default formats!)
313
315
316 for( const auto& rItem : aVector )
317 AddFormat( rItem );
318 }
319 }
320 else // any drawing objects
321 {
322 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
323 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
324 AddFormat( SotClipboardFormatId::DRAWING );
325
326 // leave out bitmap and metafile if there are only controls
327 if ( !lcl_HasOnlyControls( m_pModel.get() ) )
328 {
329 AddFormat( SotClipboardFormatId::PNG );
330 AddFormat( SotClipboardFormatId::BITMAP );
331 AddFormat( SotClipboardFormatId::GDIMETAFILE );
332 }
333 }
334
335// if( pImageMap )
336// AddFormat( SotClipboardFormatId::SVIM );
337}
338
339bool ScDrawTransferObj::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc )
340{
341 bool bOK = false;
342 SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor );
343
344 if ( m_bOleObj && nFormat != SotClipboardFormatId::GDIMETAFILE )
345 {
347
348 if( m_aOleData.GetTransferable().is() && m_aOleData.HasFormat( rFlavor ) )
349 {
350 bOK = SetAny( m_aOleData.GetAny(rFlavor, rDestDoc) );
351
352 return bOK;
353 }
354 }
355
356 if( HasFormat( nFormat ) )
357 {
358 if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
359 {
361 }
362 else if ( nFormat == SotClipboardFormatId::DRAWING )
363 {
364 SdrView aView(*m_pModel);
365 SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel().GetPage(0));
366 aView.MarkAllObj( pPv );
367 auto pNewModel = aView.CreateMarkedObjModel();
368 bOK = SetObject( pNewModel.get(), SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor );
369 }
370 else if ( nFormat == SotClipboardFormatId::BITMAP
371 || nFormat == SotClipboardFormatId::PNG
372 || nFormat == SotClipboardFormatId::GDIMETAFILE )
373 {
374 // #i71538# use complete SdrViews
375 // SdrExchangeView aView( pModel );
376 SdrView aView(*m_pModel);
377 SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel().GetPage(0));
378 OSL_ENSURE( pPv, "pPv not there..." );
379 aView.MarkAllObj( pPv );
380 if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
381 bOK = SetGDIMetaFile( aView.GetMarkedObjMetaFile(true) );
382 else
383 bOK = SetBitmapEx( aView.GetMarkedObjBitmapEx(true), rFlavor );
384 }
385 else if ( nFormat == SotClipboardFormatId::SVXB )
386 {
387 // only enabled for single graphics object
388
389 SdrPage* pPage = m_pModel->GetPage(0);
390 if (pPage)
391 {
392 SdrObjListIter aIter( pPage, SdrIterMode::Flat );
393 SdrObject* pObject = aIter.Next();
394 if (pObject && pObject->GetObjIdentifier() == SdrObjKind::Graphic)
395 {
396 SdrGrafObj* pGraphObj = static_cast<SdrGrafObj*>(pObject);
397 bOK = SetGraphic( pGraphObj->GetGraphic() );
398 }
399 }
400 }
401 else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
402 {
403 if ( m_bOleObj ) // single OLE object
404 {
405 SdrOle2Obj* pObj = GetSingleObject();
406 if ( pObj && pObj->GetObjRef().is() )
407 {
408 bOK = SetObject( pObj->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ, rFlavor );
409 }
410 }
411 else // create object from contents
412 {
413 //TODO/LATER: needs new Format, because now single OLE and "this" are different
414 InitDocShell(); // set aDocShellRef
415
416 SfxObjectShell* pEmbObj = m_aDocShellRef.get();
417 bOK = SetObject( pEmbObj, SCDRAWTRANS_TYPE_DOCUMENT, rFlavor );
418 }
419 }
420 else if( m_oBookmark )
421 {
422 bOK = SetINetBookmark( *m_oBookmark, rFlavor );
423 }
424 }
425 return bOK;
426}
427
428bool ScDrawTransferObj::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
429 const css::datatransfer::DataFlavor& /* rFlavor */ )
430{
431 // called from SetObject, put data into stream
432
433 bool bRet = false;
434 switch (nUserObjectId)
435 {
437 {
438 SdrModel* pDrawModel = static_cast<SdrModel*>(pUserObject);
439 pDrawModel->BurnInStyleSheetAttributes();
440 rxOStm->SetBufferSize( 0xff00 );
441
442 // for the changed pool defaults from drawing layer pool set those
443 // attributes as hard attributes to preserve them for saving
444 const SfxItemPool& rItemPool = pDrawModel->GetItemPool();
445 const SvxFontHeightItem& rDefaultFontHeight = rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
446
447 // SW should have no MasterPages
448 OSL_ENSURE(0 == pDrawModel->GetMasterPageCount(), "SW with MasterPages (!)");
449
450 for(sal_uInt16 a(0); a < pDrawModel->GetPageCount(); a++)
451 {
452 const SdrPage* pPage(pDrawModel->GetPage(a));
453 SdrObjListIter aIter(pPage, SdrIterMode::DeepNoGroups);
454
455 while(aIter.IsMore())
456 {
457 SdrObject* pObj = aIter.Next();
459
460 if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
461 {
462 pObj->SetMergedItem(rDefaultFontHeight);
463 }
464 }
465 }
466
467 {
468 css::uno::Reference<css::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
469 SvxDrawingLayerExport( pDrawModel, xDocOut );
470 }
471
472 bRet = ( rxOStm->GetError() == ERRCODE_NONE );
473 }
474 break;
475
477 {
478 // impl. for "single OLE"
479 embed::XEmbeddedObject* pEmbObj = static_cast<embed::XEmbeddedObject*>(pUserObject);
480
481 ::utl::TempFileFast aTempFile;
482 SvStream* pTempStream = aTempFile.GetStream(StreamMode::READWRITE);
483 uno::Reference< embed::XStorage > xWorkStore =
485
486 uno::Reference < embed::XEmbedPersist > xPers( static_cast<embed::XVisualObject*>(pEmbObj), uno::UNO_QUERY );
487 if ( xPers.is() )
488 {
489 try
490 {
491 uno::Sequence < beans::PropertyValue > aSeq;
492 OUString aDummyName("Dummy");
493 xPers->storeToEntry( xWorkStore, aDummyName, aSeq, aSeq );
494 if ( xWorkStore->isStreamElement( aDummyName ) )
495 {
496 uno::Reference < io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
497 uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ );
498 ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream->getInputStream(), xDocOut );
499 }
500 else
501 {
502 uno::Reference < io::XStream > xDocStr( new utl::OStreamWrapper( *rxOStm ) );
503 uno::Reference< embed::XStorage > xDocStg = ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr );
504 uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ );
505 xNewStg->copyToStorage( xDocStg );
506 uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY );
507 if ( xTrans.is() )
508 xTrans->commit();
509 }
510 }
511 catch ( uno::Exception& )
512 {
513 }
514 }
515
516 break;
517 }
519 {
520 // impl. for "DocShell"
521 SfxObjectShell* pEmbObj = static_cast<SfxObjectShell*>(pUserObject);
522
523 try
524 {
525 ::utl::TempFileFast aTempFile;
526 SvStream* pTempStream = aTempFile.GetStream(StreamMode::READWRITE);
527 uno::Reference< embed::XStorage > xWorkStore =
529
530 // write document storage
531 pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
532
533 // mba: no relative URLs for clipboard!
534 SfxMedium aMedium( xWorkStore, OUString() );
535 pEmbObj->DoSaveObjectAs( aMedium, false );
536 pEmbObj->DoSaveCompleted();
537
538 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
539 if ( xTransact.is() )
540 xTransact->commit();
541
542 rxOStm->SetBufferSize( 0xff00 );
543 rxOStm->WriteStream( *pTempStream );
544
545 xWorkStore->dispose();
546 xWorkStore.clear();
547 }
548 catch ( uno::Exception& )
549 {}
550
551 bRet = ( rxOStm->GetError() == ERRCODE_NONE );
552 }
553 break;
554
555 default:
556 OSL_FAIL("unknown object id");
557 }
558 return bRet;
559}
560
562{
564 {
565 // move: delete source objects
566
567 if ( m_pDragSourceView )
568 m_pDragSourceView->DeleteMarked();
569 }
570
571 ScModule* pScMod = SC_MOD();
572 if ( pScMod->GetDragData().pDrawTransfer == this )
573 pScMod->ResetDragObject();
574
575 m_pDragSourceView.reset();
576
578}
579
581{
582 m_aDrawPersistRef = rRef;
583}
584
585static void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, SCTAB nTab )
586{
587 rDest.ShowSdrPage(rDest.GetModel().GetPage(nTab));
588 SdrPageView* pDestPV = rDest.GetSdrPageView();
589 OSL_ENSURE(pDestPV,"PageView ?");
590
591 const SdrMarkList& rMarkList = rSource.GetMarkedObjectList();
592 const size_t nCount = rMarkList.GetMarkCount();
593 for (size_t i=0; i<nCount; ++i)
594 {
595 SdrMark* pMark = rMarkList.GetMark(i);
596 SdrObject* pObj = pMark->GetMarkedSdrObj();
597
598 rDest.MarkObj(pObj, pDestPV);
599 }
600}
601
603{
604 m_pDragSourceView.reset(new SdrView(pView->getSdrModelFromSdrView())); // TTTT pView should be reference
605 lcl_InitMarks( *m_pDragSourceView, *pView, pView->GetTab() );
606
608}
609
611{
613 m_pDragSourceView->ShowSdrPage(m_pDragSourceView->GetModel().GetPage(nTab));
614 SdrPageView* pPV = m_pDragSourceView->GetSdrPageView();
615 m_pDragSourceView->MarkObj(&rObj, pPV); // TTTT MarkObj should take SdrObject&
616
618}
619
621{
622 m_nDragSourceFlags = nFlags;
623}
624
626{
627 m_bDragWasInternal = true;
628}
629
630const OUString& ScDrawTransferObj::GetShellID() const
631{
632 return maShellID;
633}
634
636{
637 // if single OLE object was copied, get its object
638
639 SdrPage* pPage = m_pModel->GetPage(0);
640 if (pPage)
641 {
642 SdrObjListIter aIter( pPage, SdrIterMode::Flat );
643 SdrObject* pObject = aIter.Next();
644 if (pObject && pObject->GetObjIdentifier() == SdrObjKind::OLE2)
645 {
646 return static_cast<SdrOle2Obj*>(pObject);
647 }
648 }
649
650 return nullptr;
651}
652
654{
655 if (m_aOleData.GetTransferable().is())
656 // Already created.
657 return;
658
659 SdrOle2Obj* pObj = GetSingleObject();
660 if (!pObj || !pObj->GetObjRef().is())
661 // No OLE object present.
662 return;
663
666 pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect());
667
668 pEmbedTransfer->SetParentShellID(maShellID);
669
670 m_aOleData = TransferableDataHelper(pEmbedTransfer);
671}
672
673// initialize aDocShellRef with a live document from the ClipDoc
674
676{
677 if ( m_aDocShellRef.is() )
678 return;
679
680 ScDocShell* pDocSh = new ScDocShell;
681 m_aDocShellRef = pDocSh; // ref must be there before InitNew
682
683 pDocSh->DoInitNew();
684
685 ScDocument& rDestDoc = pDocSh->GetDocument();
686 rDestDoc.InitDrawLayer( pDocSh );
687
688 auto pPool = rDestDoc.GetStyleSheetPool();
689 pPool->CopyStyleFrom(m_pModel->GetStyleSheetPool(), ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Frame);
690 pPool->CopyUsedGraphicStylesFrom(m_pModel->GetStyleSheetPool());
691
692 SdrModel* pDestModel = rDestDoc.GetDrawLayer();
693 // #i71538# use complete SdrViews
694 // SdrExchangeView aDestView( pDestModel );
695 SdrView aDestView(*pDestModel);
696 aDestView.ShowSdrPage(aDestView.GetModel().GetPage(0));
697 aDestView.Paste(
698 *m_pModel,
700 nullptr, SdrInsertFlags::NONE);
701
702 // put objects to right layer (see ScViewFunc::PasteDataFormat for SotClipboardFormatId::DRAWING)
703
704 SdrPage* pPage = pDestModel->GetPage(0);
705 if (pPage)
706 {
707 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
708 SdrObject* pObject = aIter.Next();
709 while (pObject)
710 {
711 if ( dynamic_cast<const SdrUnoObj*>( pObject) != nullptr )
712 pObject->NbcSetLayer(SC_LAYER_CONTROLS);
713 else
714 pObject->NbcSetLayer(SC_LAYER_FRONT);
715 pObject = aIter.Next();
716 }
717 }
718
719 tools::Rectangle aDestArea( Point(), m_aSrcSize );
720 pDocSh->SetVisArea( aDestArea );
721
722 ScViewOptions aViewOpt( rDestDoc.GetViewOptions() );
723 aViewOpt.SetOption( VOPT_GRID, false );
724 rDestDoc.SetViewOptions( aViewOpt );
725
726 ScViewData aViewData( *pDocSh, nullptr );
727 aViewData.SetTabNo( 0 );
728 aViewData.SetScreen( aDestArea );
729 aViewData.SetCurX( 0 );
730 aViewData.SetCurY( 0 );
731 pDocSh->UpdateOle(aViewData, true);
732}
733
734/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
static void FillProtectedChartRangesVector(ScRangeListVector &rRangesVector, const ScDocument &rDocument, const SdrPage *pPage)
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
Definition: docsh6.cxx:152
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
Definition: docsh6.cxx:57
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:105
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
Definition: documen3.cxx:1951
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1957
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
Definition: drwtrans.cxx:428
virtual ~ScDrawTransferObj() override
Definition: drwtrans.cxx:214
ScDragSrc m_nDragSourceFlags
Definition: drwtrans.hxx:55
void SetDrawPersist(const SfxObjectShellRef &rRef)
Definition: drwtrans.cxx:580
virtual void AddSupportedFormats() override
Definition: drwtrans.cxx:270
ScRangeListVector m_aProtectedChartRangesVector
Definition: drwtrans.hxx:58
OUString maShellID
Definition: drwtrans.hxx:60
void SetDragSource(const ScDrawView *pView)
Definition: drwtrans.cxx:602
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: drwtrans.cxx:235
void SetDragWasInternal()
Definition: drwtrans.cxx:625
void CreateOLEData()
Definition: drwtrans.cxx:653
ScDrawTransferObj(std::unique_ptr< SdrModel > pClipModel, ScDocShell *pContainerShell, TransferableObjectDescriptor aDesc)
Definition: drwtrans.cxx:72
SdrOle2Obj * GetSingleObject()
Definition: drwtrans.cxx:635
TransferableDataHelper m_aOleData
Definition: drwtrans.hxx:41
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: drwtrans.cxx:561
void SetDragSourceFlags(ScDragSrc nFlags)
Definition: drwtrans.cxx:620
SfxObjectShellRef m_aDocShellRef
Definition: drwtrans.hxx:43
std::unique_ptr< SdrModel > m_pModel
Definition: drwtrans.hxx:40
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: drwtrans.cxx:339
void SetDragSourceObj(SdrObject &rObj, SCTAB nTab)
Definition: drwtrans.cxx:610
TransferableObjectDescriptor m_aObjDesc
Definition: drwtrans.hxx:42
std::unique_ptr< SdrView > m_pDragSourceView
Definition: drwtrans.hxx:54
bool m_bDragWasInternal
Definition: drwtrans.hxx:56
SfxObjectShellRef m_aDrawPersistRef
Definition: drwtrans.hxx:44
const OUString & GetShellID() const
Definition: drwtrans.cxx:630
std::optional< INetBookmark > m_oBookmark
Definition: drwtrans.hxx:48
SCTAB GetTab() const
Definition: drawview.hxx:100
const ScDragData & GetDragData() const
Definition: scmod.cxx:623
void ResetDragObject()
Definition: scmod.cxx:602
void CopyStyleFrom(SfxStyleSheetBasePool *pSrcPool, const OUString &rName, SfxStyleFamily eFamily, bool bNewStyleHierarchy=false)
Definition: stlpool.cxx:128
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: viewdata.cxx:3033
void SetTabNo(SCTAB nNewTab)
Definition: viewdata.cxx:2319
void SetCurX(SCCOL nNewCurX)
Definition: viewdata.hxx:431
void SetCurY(SCROW nNewCurY)
Definition: viewdata.hxx:432
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:85
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt) const
const Graphic & GetGraphic() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
void MarkAllObj(SdrPageView *pPV=nullptr)
const tools::Rectangle & GetAllMarkedRect() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
sal_uInt16 GetMasterPageCount() const
const SfxItemPool & GetItemPool() const
void BurnInStyleSheetAttributes()
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
SdrPageView * ShowSdrPage(SdrPage *pPage) override
SdrObject * Next()
bool IsMore() const
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
virtual SdrInventor GetObjInventor() const
SdrModel & getSdrModelFromSdrObject() const
void SetMergedItem(const SfxPoolItem &rItem)
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const Graphic * GetGraphic() const
virtual SdrPageView * ShowSdrPage(SdrPage *pPage)
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const INetURLObject & GetURLObject() const
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
SfxMedium * GetMedium() const
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
sal_uInt32 GetHeight() const
virtual void DragFinished(sal_Int8 nDropAction) override
const DataFlavorExVector & GetDataFlavorExVector() const
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool SetGraphic(const Graphic &rGraphic)
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
bool SetAny(const css::uno::Any &rAny)
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
bool SetINetBookmark(const INetBookmark &rBmk, const css::datatransfer::DataFlavor &rFlavor)
bool HasFormat(SotClipboardFormatId nFormat)
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
void AddFormat(SotClipboardFormatId nFormat)
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
static css::uno::Reference< css::embed::XStorage > GetStorageFromStream(const css::uno::Reference< css::io::XStream > &xStream, sal_Int32 nStorageMode=css::embed::ElementModes::READWRITE, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
constexpr Size GetSize() const
T * get() const
bool is() const
SvStream * GetStream(StreamMode eMode)
int nCount
static void lcl_InitMarks(SdrMarkView &rDest, const SdrMarkView &rSource, SCTAB nTab)
Definition: drwtrans.cxx:585
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL
Definition: drwtrans.cxx:69
constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ
Definition: drwtrans.cxx:68
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT
Definition: drwtrans.cxx:70
static bool lcl_HasOnlyControls(SdrModel *pModel)
Definition: drwtrans.cxx:240
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
EmbeddedObjectRef * pObject
#define ERRCODE_NONE
::std::vector< DataFlavorEx > DataFlavorExVector
#define SOFFICE_FILEFORMAT_CURRENT
SotClipboardFormatId
constexpr SdrLayerID SC_LAYER_FRONT(0)
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
uno_Any a
Sequence< sal_Int8 > aSeq
int i
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
#define SC_MOD()
Definition: scmod.hxx:247
ScDrawTransferObj * pDrawTransfer
Definition: dragdata.hxx:21
SdrObjKind
#define DND_ACTION_MOVE
signed char sal_Int8
sal_Int16 SCTAB
Definition: types.hxx:22
OUString aLabel
SVXCORE_DLLPUBLIC bool SvxDrawingLayerExport(SdrModel *pModel, const css::uno::Reference< css::io::XOutputStream > &xOut)
ScDragSrc
Definition: viewdata.hxx:91
@ VOPT_GRID
Definition: viewopti.hxx:42