1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/embed/XTransactedObject.hpp>
21 #include <com/sun/star/embed/XEmbedPersist.hpp>
22 #include <com/sun/star/uno/Exception.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/beans/XPropertySetInfo.hpp>
26 #include <com/sun/star/form/FormButtonType.hpp>
27 #include <toolkit/helper/vclunohelper.hxx>
28 #include <unotools/streamwrap.hxx>
30 #include <svx/unomodel.hxx>
31 #include <unotools/tempfile.hxx>
32 #include <unotools/ucbstreamhelper.hxx>
33 #include <comphelper/storagehelper.hxx>
34 #include <comphelper/servicehelper.hxx>
36 #include <svtools/embedtransfer.hxx>
37 #include <sot/storage.hxx>
38 #include <vcl/virdev.hxx>
39 #include <svx/fmglob.hxx>
40 #include <svx/svditer.hxx>
41 #include <svx/svdograf.hxx>
42 #include <svx/svdoole2.hxx>
43 #include <svx/svdouno.hxx>
44 #include <svx/svdpage.hxx>
45 #include <svx/svdxcgv.hxx>
46 #include <sfx2/docfile.hxx>
47 #include <svl/itempool.hxx>
48 #include <svl/urlbmk.hxx>
49 #include <tools/urlobj.hxx>
50 #include <osl/mutex.hxx>
52 #include "drwtrans.hxx"
54 #include "drwlayer.hxx"
55 #include "drawview.hxx"
56 #include "viewdata.hxx"
58 #include "chartlis.hxx"
59 #include "rangeutl.hxx"
60 #include "formula/grammar.hxx"
61 #include "dragdata.hxx"
62 #include "clipdata.hxx"
65 #include "scitems.hxx"
68 #include <editeng/eeitem.hxx>
71 #include <editeng/fhgtitem.hxx>
72 #include <vcl/svapp.hxx>
75 using namespace com::sun::star
;
77 // -----------------------------------------------------------------------
79 #define SCDRAWTRANS_TYPE_EMBOBJ 1
80 #define SCDRAWTRANS_TYPE_DRAWMODEL 2
81 #define SCDRAWTRANS_TYPE_DOCUMENT 3
83 // -----------------------------------------------------------------------
85 // -----------------------------------------------------------------------
87 ScDrawTransferObj::ScDrawTransferObj( SdrModel
* pClipModel
, ScDocShell
* pContainerShell
,
88 const TransferableObjectDescriptor
& rDesc
) :
95 pDragSourceView( NULL
),
96 nDragSourceFlags( 0 ),
97 bDragWasInternal( false ),
101 // check what kind of objects are contained
104 SdrPage
* pPage
= pModel
->GetPage(0);
107 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
108 SdrObject
* pObject
= aIter
.Next();
109 if (pObject
&& !aIter
.Next()) // exactly one object?
115 sal_uInt16 nSdrObjKind
= pObject
->GetObjIdentifier();
116 if (nSdrObjKind
== OBJ_OLE2
)
118 // if object has no persistence it must be copied as a part of document
121 uno::Reference
< embed::XEmbedPersist
> xPersObj( ((SdrOle2Obj
*)pObject
)->GetObjRef(), uno::UNO_QUERY
);
122 if ( xPersObj
.is() && xPersObj
->hasEntry() )
125 catch( uno::Exception
& )
127 // aOleData is initialized later
134 if (nSdrObjKind
== OBJ_GRAF
)
137 if ( ((SdrGrafObj
*)pObject
)->GetGraphic().GetType() == GRAPHIC_BITMAP
)
145 SdrUnoObj
* pUnoCtrl
= PTR_CAST(SdrUnoObj
, pObject
);
146 if (pUnoCtrl
&& FmFormInventor
== pUnoCtrl
->GetObjInventor())
148 uno::Reference
<awt::XControlModel
> xControlModel
= pUnoCtrl
->GetUnoControlModel();
149 OSL_ENSURE( xControlModel
.is(), "uno control without model" );
150 if ( xControlModel
.is() )
152 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY
);
153 uno::Reference
< beans::XPropertySetInfo
> xInfo
= xPropSet
->getPropertySetInfo();
155 OUString
sPropButtonType( "ButtonType" );
156 OUString
sPropTargetURL( "TargetURL" );
157 OUString
sPropLabel( "Label" );
159 if(xInfo
->hasPropertyByName( sPropButtonType
))
161 uno::Any aAny
= xPropSet
->getPropertyValue( sPropButtonType
);
162 form::FormButtonType eTmp
;
163 if ( (aAny
>>= eTmp
) && eTmp
== form::FormButtonType_URL
)
166 if(xInfo
->hasPropertyByName( sPropTargetURL
))
168 aAny
= xPropSet
->getPropertyValue( sPropTargetURL
);
170 if ( (aAny
>>= sTmp
) && !sTmp
.isEmpty() )
172 OUString aUrl
= sTmp
;
174 const SfxMedium
* pMedium
;
175 if (pContainerShell
&& (pMedium
= pContainerShell
->GetMedium()) != NULL
)
178 aAbs
= pMedium
->GetURLObject().smartRel2Abs( aUrl
, bWasAbs
).
179 GetMainURL(INetURLObject::NO_DECODE
);
180 // full path as stored INetBookmark must be encoded
187 if(xInfo
->hasPropertyByName( sPropLabel
))
189 aAny
= xPropSet
->getPropertyValue( sPropLabel
);
190 if ( (aAny
>>= sTmp
) && !sTmp
.isEmpty() )
195 pBookmark
= new INetBookmark( aAbs
, aLabel
);
206 // get size for object descriptor
209 // #i71538# use complete SdrViews
210 // SdrExchangeView aView(pModel);
211 SdrView
aView(pModel
);
212 SdrPageView
* pPv
= aView
.ShowSdrPage(aView
.GetModel()->GetPage(0));
213 aView
.MarkAllObj(pPv
);
214 aSrcSize
= aView
.GetAllMarkedRect().GetSize();
216 if ( bOleObj
) // single OLE object
218 SdrOle2Obj
* pObj
= GetSingleObject();
219 if ( pObj
&& pObj
->GetObjRef().is() )
220 SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc
, pObj
->GetObjRef(), pObj
->GetGraphic(), pObj
->GetAspect() );
223 aObjDesc
.maSize
= aSrcSize
;
224 PrepareOLE( aObjDesc
);
227 // remember a unique ID of the source document
229 if ( pContainerShell
)
231 ScDocument
* pDoc
= pContainerShell
->GetDocument();
234 nSourceDocID
= pDoc
->GetDocumentID();
237 ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector
, pDoc
, pPage
);
243 ScDrawTransferObj::~ScDrawTransferObj()
245 SolarMutexGuard aSolarGuard
;
247 ScModule
* pScMod
= SC_MOD();
248 if ( pScMod
->GetClipData().pDrawClipboard
== this )
250 OSL_FAIL("ScDrawTransferObj wasn't released");
251 pScMod
->SetClipObject( NULL
, NULL
);
253 if ( pScMod
->GetDragData().pDrawTransfer
== this )
255 OSL_FAIL("ScDrawTransferObj wasn't released");
256 pScMod
->ResetDragObject();
259 aOleData
= TransferableDataHelper(); // clear before releasing the mutex
260 aDocShellRef
.Clear();
263 aDrawPersistRef
.Clear(); // after the model
266 delete pDragSourceView
;
269 ScDrawTransferObj
* ScDrawTransferObj::GetOwnClipboard( Window
* )
271 ScDrawTransferObj
* pObj
= SC_MOD()->GetClipData().pDrawClipboard
;
275 static sal_Bool
lcl_HasOnlyControls( SdrModel
* pModel
)
277 sal_Bool bOnlyControls
= false; // default if there are no objects
281 SdrPage
* pPage
= pModel
->GetPage(0);
284 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
285 SdrObject
* pObj
= aIter
.Next();
288 bOnlyControls
= sal_True
; // only set if there are any objects at all
291 if (!pObj
->ISA(SdrUnoObj
))
293 bOnlyControls
= false;
302 return bOnlyControls
;
305 void ScDrawTransferObj::AddSupportedFormats()
307 if ( bGrIsBit
) // single bitmap graphic
309 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
310 AddFormat( SOT_FORMATSTR_ID_SVXB
);
311 AddFormat( SOT_FORMAT_BITMAP
);
312 AddFormat( SOT_FORMAT_GDIMETAFILE
);
314 else if ( bGraphic
) // other graphic
317 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
319 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
320 AddFormat( SOT_FORMATSTR_ID_SVXB
);
321 AddFormat( SOT_FORMAT_GDIMETAFILE
);
322 AddFormat( SOT_FORMAT_BITMAP
);
324 else if ( pBookmark
) // url button
326 // AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
327 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
328 AddFormat( SOT_FORMATSTR_ID_SOLK
);
329 AddFormat( SOT_FORMAT_STRING
);
330 AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
);
331 AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
332 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
334 else if ( bOleObj
) // single OLE object
336 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
337 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
338 AddFormat( SOT_FORMAT_GDIMETAFILE
);
340 if ( !aOleData
.GetTransferable().is() )
342 SdrOle2Obj
* pObj
= GetSingleObject();
343 if ( pObj
&& pObj
->GetObjRef().is() )
344 aOleData
= TransferableDataHelper( new SvEmbedTransferHelper( pObj
->GetObjRef(), pObj
->GetGraphic(), pObj
->GetAspect() ) ) ;
346 if ( aOleData
.GetTransferable().is() )
348 // get format list from object snapshot
349 // (this must be after inserting the default formats!)
351 DataFlavorExVector
aVector( aOleData
.GetDataFlavorExVector() );
352 DataFlavorExVector::iterator
aIter( aVector
.begin() ), aEnd( aVector
.end() );
354 while( aIter
!= aEnd
)
355 AddFormat( *aIter
++ );
358 else // any drawing objects
360 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
361 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
362 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
364 // leave out bitmap and metafile if there are only controls
365 if ( !lcl_HasOnlyControls( pModel
) )
367 AddFormat( SOT_FORMAT_BITMAP
);
368 AddFormat( SOT_FORMAT_GDIMETAFILE
);
373 // AddFormat( SOT_FORMATSTR_ID_SVIM );
376 sal_Bool
ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor
& rFlavor
)
378 sal_Bool bOK
= false;
379 sal_uInt32 nFormat
= SotExchange::GetFormat( rFlavor
);
381 if ( bOleObj
&& nFormat
!= SOT_FORMAT_GDIMETAFILE
)
383 if ( !aOleData
.GetTransferable().is() )
385 SdrOle2Obj
* pObj
= GetSingleObject();
386 if ( pObj
&& pObj
->GetObjRef().is() )
387 aOleData
= TransferableDataHelper( new SvEmbedTransferHelper( pObj
->GetObjRef(), pObj
->GetGraphic(), pObj
->GetAspect() ) ) ;
390 if( aOleData
.GetTransferable().is() && aOleData
.HasFormat( rFlavor
) )
392 sal_uLong nOldSwapMode
= 0;
396 nOldSwapMode
= pModel
->GetSwapGraphicsMode();
397 pModel
->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE
);
400 bOK
= SetAny( aOleData
.GetAny( rFlavor
), rFlavor
);
403 pModel
->SetSwapGraphicsMode( nOldSwapMode
);
409 if( HasFormat( nFormat
) )
411 if ( nFormat
== SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR
|| nFormat
== SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
)
413 bOK
= SetTransferableObjectDescriptor( aObjDesc
, rFlavor
);
415 else if ( nFormat
== SOT_FORMATSTR_ID_DRAWING
)
417 bOK
= SetObject( pModel
, SCDRAWTRANS_TYPE_DRAWMODEL
, rFlavor
);
419 else if ( nFormat
== SOT_FORMAT_BITMAP
|| nFormat
== SOT_FORMAT_GDIMETAFILE
)
421 // #i71538# use complete SdrViews
422 // SdrExchangeView aView( pModel );
423 SdrView
aView( pModel
);
424 SdrPageView
* pPv
= aView
.ShowSdrPage(aView
.GetModel()->GetPage(0));
425 OSL_ENSURE( pPv
, "pPv not there..." );
426 aView
.MarkAllObj( pPv
);
427 if ( nFormat
== SOT_FORMAT_GDIMETAFILE
)
428 bOK
= SetGDIMetaFile( aView
.GetMarkedObjMetaFile(true), rFlavor
);
430 bOK
= SetBitmapEx( aView
.GetMarkedObjBitmapEx(true), rFlavor
);
432 else if ( nFormat
== SOT_FORMATSTR_ID_SVXB
)
434 // only enabled for single graphics object
436 SdrPage
* pPage
= pModel
->GetPage(0);
439 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
440 SdrObject
* pObject
= aIter
.Next();
441 if (pObject
&& pObject
->GetObjIdentifier() == OBJ_GRAF
)
443 SdrGrafObj
* pGraphObj
= (SdrGrafObj
*) pObject
;
444 bOK
= SetGraphic( pGraphObj
->GetGraphic(), rFlavor
);
448 else if ( nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
450 if ( bOleObj
) // single OLE object
452 SdrOle2Obj
* pObj
= GetSingleObject();
453 if ( pObj
&& pObj
->GetObjRef().is() )
455 bOK
= SetObject( pObj
->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ
, rFlavor
);
458 else // create object from contents
460 //TODO/LATER: needs new Format, because now single OLE and "this" are different
461 InitDocShell(); // set aDocShellRef
463 SfxObjectShell
* pEmbObj
= aDocShellRef
;
464 bOK
= SetObject( pEmbObj
, SCDRAWTRANS_TYPE_DOCUMENT
, rFlavor
);
469 bOK
= SetINetBookmark( *pBookmark
, rFlavor
);
475 sal_Bool
ScDrawTransferObj::WriteObject( SotStorageStreamRef
& rxOStm
, void* pUserObject
, sal_uInt32 nUserObjectId
,
476 const ::com::sun::star::datatransfer::DataFlavor
& /* rFlavor */ )
478 // called from SetObject, put data into stream
480 sal_Bool bRet
= false;
481 switch (nUserObjectId
)
483 case SCDRAWTRANS_TYPE_DRAWMODEL
:
485 SdrModel
* pDrawModel
= (SdrModel
*)pUserObject
;
486 rxOStm
->SetBufferSize( 0xff00 );
489 // for the changed pool defaults from drawing layer pool set those
490 // attributes as hard attributes to preserve them for saving
491 const SfxItemPool
& rItemPool
= pModel
->GetItemPool();
492 const SvxFontHeightItem
& rDefaultFontHeight
= (const SvxFontHeightItem
&)rItemPool
.GetDefaultItem(EE_CHAR_FONTHEIGHT
);
494 // SW should have no MasterPages
495 OSL_ENSURE(0L == pModel
->GetMasterPageCount(), "SW with MasterPages (!)");
497 for(sal_uInt16
a(0); a
< pModel
->GetPageCount(); a
++)
499 const SdrPage
* pPage
= pModel
->GetPage(a
);
500 SdrObjListIter
aIter(*pPage
, IM_DEEPNOGROUPS
);
502 while(aIter
.IsMore())
504 SdrObject
* pObj
= aIter
.Next();
505 const SvxFontHeightItem
& rItem
= (const SvxFontHeightItem
&)pObj
->GetMergedItem(EE_CHAR_FONTHEIGHT
);
507 if(rItem
.GetHeight() == rDefaultFontHeight
.GetHeight())
509 pObj
->SetMergedItem(rDefaultFontHeight
);
515 com::sun::star::uno::Reference
<com::sun::star::io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *rxOStm
) );
516 if( SvxDrawingLayerExport( pDrawModel
, xDocOut
) )
520 bRet
= ( rxOStm
->GetError() == ERRCODE_NONE
);
524 case SCDRAWTRANS_TYPE_EMBOBJ
:
526 // impl. for "single OLE"
527 embed::XEmbeddedObject
* pEmbObj
= (embed::XEmbeddedObject
*) pUserObject
;
529 ::utl::TempFile aTempFile
;
530 aTempFile
.EnableKillingFile();
531 uno::Reference
< embed::XStorage
> xWorkStore
=
532 ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile
.GetURL(), embed::ElementModes::READWRITE
);
534 uno::Reference
< embed::XEmbedPersist
> xPers( (embed::XVisualObject
*)pEmbObj
, uno::UNO_QUERY
);
539 uno::Sequence
< beans::PropertyValue
> aSeq
;
540 OUString
aDummyName("Dummy");
541 xPers
->storeToEntry( xWorkStore
, aDummyName
, aSeq
, aSeq
);
542 if ( xWorkStore
->isStreamElement( aDummyName
) )
544 uno::Reference
< io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *rxOStm
) );
545 uno::Reference
< io::XStream
> xNewStream
= xWorkStore
->openStreamElement( aDummyName
, embed::ElementModes::READ
);
546 ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream
->getInputStream(), xDocOut
);
550 uno::Reference
< io::XStream
> xDocStr( new utl::OStreamWrapper( *rxOStm
) );
551 uno::Reference
< embed::XStorage
> xDocStg
= ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr
);
552 uno::Reference
< embed::XStorage
> xNewStg
= xWorkStore
->openStorageElement( aDummyName
, embed::ElementModes::READ
);
553 xNewStg
->copyToStorage( xDocStg
);
554 uno::Reference
< embed::XTransactedObject
> xTrans( xDocStg
, uno::UNO_QUERY
);
561 catch ( uno::Exception
& )
568 case SCDRAWTRANS_TYPE_DOCUMENT
:
570 // impl. for "DocShell"
571 SfxObjectShell
* pEmbObj
= (SfxObjectShell
*) pUserObject
;
575 ::utl::TempFile aTempFile
;
576 aTempFile
.EnableKillingFile();
577 uno::Reference
< embed::XStorage
> xWorkStore
=
578 ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile
.GetURL(), embed::ElementModes::READWRITE
);
580 // write document storage
581 pEmbObj
->SetupStorage( xWorkStore
, SOFFICE_FILEFORMAT_CURRENT
, false, false );
583 // mba: no relative ULRs for clipboard!
584 SfxMedium
aMedium( xWorkStore
, OUString() );
585 bRet
= pEmbObj
->DoSaveObjectAs( aMedium
, false );
586 pEmbObj
->DoSaveCompleted();
588 uno::Reference
< embed::XTransactedObject
> xTransact( xWorkStore
, uno::UNO_QUERY
);
589 if ( xTransact
.is() )
592 SvStream
* pSrcStm
= ::utl::UcbStreamHelper::CreateStream( aTempFile
.GetURL(), STREAM_READ
);
595 rxOStm
->SetBufferSize( 0xff00 );
602 xWorkStore
->dispose();
603 xWorkStore
= uno::Reference
< embed::XStorage
>();
606 catch ( uno::Exception
& )
609 bRet
= ( rxOStm
->GetError() == ERRCODE_NONE
);
614 OSL_FAIL("unknown object id");
619 void ScDrawTransferObj::ObjectReleased()
621 ScModule
* pScMod
= SC_MOD();
622 if ( pScMod
->GetClipData().pDrawClipboard
== this )
623 pScMod
->SetClipObject( NULL
, NULL
);
625 TransferableHelper::ObjectReleased();
628 void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction
)
630 if ( nDropAction
== DND_ACTION_MOVE
&& !bDragWasInternal
&& !(nDragSourceFlags
& SC_DROP_NAVIGATOR
) )
632 // move: delete source objects
634 if ( pDragSourceView
)
635 pDragSourceView
->DeleteMarked();
638 ScModule
* pScMod
= SC_MOD();
639 if ( pScMod
->GetDragData().pDrawTransfer
== this )
640 pScMod
->ResetDragObject();
642 DELETEZ( pDragSourceView
);
644 TransferableHelper::DragFinished( nDropAction
);
647 void ScDrawTransferObj::SetDrawPersist( const SfxObjectShellRef
& rRef
)
649 aDrawPersistRef
= rRef
;
652 static void lcl_InitMarks( SdrMarkView
& rDest
, const SdrMarkView
& rSource
, SCTAB nTab
)
654 rDest
.ShowSdrPage(rDest
.GetModel()->GetPage(nTab
));
655 SdrPageView
* pDestPV
= rDest
.GetSdrPageView();
656 OSL_ENSURE(pDestPV
,"PageView ?");
658 const SdrMarkList
& rMarkList
= rSource
.GetMarkedObjectList();
659 sal_uLong nCount
= rMarkList
.GetMarkCount();
660 for (sal_uLong i
=0; i
<nCount
; i
++)
662 SdrMark
* pMark
= rMarkList
.GetMark(i
);
663 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
665 rDest
.MarkObj(pObj
, pDestPV
);
669 void ScDrawTransferObj::SetDragSource( ScDrawView
* pView
)
671 DELETEZ( pDragSourceView
);
672 pDragSourceView
= new SdrView( pView
->GetModel() );
673 lcl_InitMarks( *pDragSourceView
, *pView
, pView
->GetTab() );
675 //! add as listener with document, delete pDragSourceView if document gone
678 void ScDrawTransferObj::SetDragSourceObj( SdrObject
* pObj
, SCTAB nTab
)
680 DELETEZ( pDragSourceView
);
681 pDragSourceView
= new SdrView( pObj
->GetModel() );
682 pDragSourceView
->ShowSdrPage(pDragSourceView
->GetModel()->GetPage(nTab
));
683 SdrPageView
* pPV
= pDragSourceView
->GetSdrPageView();
684 pDragSourceView
->MarkObj(pObj
, pPV
);
686 //! add as listener with document, delete pDragSourceView if document gone
689 void ScDrawTransferObj::SetDragSourceFlags( sal_uInt16 nFlags
)
691 nDragSourceFlags
= nFlags
;
694 void ScDrawTransferObj::SetDragWasInternal()
696 bDragWasInternal
= sal_True
;
699 SdrOle2Obj
* ScDrawTransferObj::GetSingleObject()
701 // if single OLE object was copied, get its object
703 SdrPage
* pPage
= pModel
->GetPage(0);
706 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
707 SdrObject
* pObject
= aIter
.Next();
708 if (pObject
&& pObject
->GetObjIdentifier() == OBJ_OLE2
)
710 return (SdrOle2Obj
*) pObject
;
718 // initialize aDocShellRef with a live document from the ClipDoc
721 void ScDrawTransferObj::InitDocShell()
723 if ( !aDocShellRef
.Is() )
725 ScDocShell
* pDocSh
= new ScDocShell
;
726 aDocShellRef
= pDocSh
; // ref must be there before InitNew
728 pDocSh
->DoInitNew(NULL
);
730 ScDocument
* pDestDoc
= pDocSh
->GetDocument();
731 pDestDoc
->InitDrawLayer( pDocSh
);
733 SdrModel
* pDestModel
= pDestDoc
->GetDrawLayer();
734 // #i71538# use complete SdrViews
735 // SdrExchangeView aDestView( pDestModel );
736 SdrView
aDestView( pDestModel
);
737 aDestView
.ShowSdrPage(aDestView
.GetModel()->GetPage(0));
738 aDestView
.Paste( *pModel
, Point( aSrcSize
.Width()/2, aSrcSize
.Height()/2 ) );
740 // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING)
742 SdrPage
* pPage
= pDestModel
->GetPage(0);
745 SdrObjListIter
aIter( *pPage
, IM_DEEPWITHGROUPS
);
746 SdrObject
* pObject
= aIter
.Next();
749 if ( pObject
->ISA(SdrUnoObj
) )
750 pObject
->NbcSetLayer(SC_LAYER_CONTROLS
);
752 pObject
->NbcSetLayer(SC_LAYER_FRONT
);
753 pObject
= aIter
.Next();
758 Rectangle
aDestArea( aTmpPoint
, aSrcSize
);
759 pDocSh
->SetVisArea( aDestArea
);
761 ScViewOptions
aViewOpt( pDestDoc
->GetViewOptions() );
762 aViewOpt
.SetOption( VOPT_GRID
, false );
763 pDestDoc
->SetViewOptions( aViewOpt
);
765 ScViewData
aViewData( pDocSh
, NULL
);
766 aViewData
.SetTabNo( 0 );
767 aViewData
.SetScreen( aDestArea
);
768 aViewData
.SetCurX( 0 );
769 aViewData
.SetCurY( 0 );
770 pDocSh
->UpdateOle(&aViewData
, sal_True
);
776 class theScDrawTransferObjUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theScDrawTransferObjUnoTunnelId
> {};
779 const com::sun::star::uno::Sequence
< sal_Int8
>& ScDrawTransferObj::getUnoTunnelId()
781 return theScDrawTransferObjUnoTunnelId::get().getSeq();
784 sal_Int64 SAL_CALL
ScDrawTransferObj::getSomething( const com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw( com::sun::star::uno::RuntimeException
)
787 if( ( rId
.getLength() == 16 ) &&
788 ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
790 nRet
= reinterpret_cast< sal_Int64
>( this );
793 nRet
= TransferableHelper::getSomething(rId
);
798 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */