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 #define SCDRAWTRANS_TYPE_EMBOBJ 1
78 #define SCDRAWTRANS_TYPE_DRAWMODEL 2
79 #define SCDRAWTRANS_TYPE_DOCUMENT 3
83 ScDrawTransferObj::ScDrawTransferObj( SdrModel
* pClipModel
, ScDocShell
* pContainerShell
,
84 const TransferableObjectDescriptor
& rDesc
) :
91 pDragSourceView( NULL
),
92 nDragSourceFlags( 0 ),
93 bDragWasInternal( false ),
95 maShellID(SfxObjectShell::CreateShellID(pContainerShell
))
98 // check what kind of objects are contained
101 SdrPage
* pPage
= pModel
->GetPage(0);
104 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
105 SdrObject
* pObject
= aIter
.Next();
106 if (pObject
&& !aIter
.Next()) // exactly one object?
112 sal_uInt16 nSdrObjKind
= pObject
->GetObjIdentifier();
113 if (nSdrObjKind
== OBJ_OLE2
)
115 // if object has no persistence it must be copied as a part of document
118 uno::Reference
< embed::XEmbedPersist
> xPersObj( ((SdrOle2Obj
*)pObject
)->GetObjRef(), uno::UNO_QUERY
);
119 if ( xPersObj
.is() && xPersObj
->hasEntry() )
122 catch( uno::Exception
& )
124 // aOleData is initialized later
131 if (nSdrObjKind
== OBJ_GRAF
)
134 if ( ((SdrGrafObj
*)pObject
)->GetGraphic().GetType() == GRAPHIC_BITMAP
)
142 SdrUnoObj
* pUnoCtrl
= PTR_CAST(SdrUnoObj
, pObject
);
143 if (pUnoCtrl
&& FmFormInventor
== pUnoCtrl
->GetObjInventor())
145 uno::Reference
<awt::XControlModel
> xControlModel
= pUnoCtrl
->GetUnoControlModel();
146 OSL_ENSURE( xControlModel
.is(), "uno control without model" );
147 if ( xControlModel
.is() )
149 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY
);
150 uno::Reference
< beans::XPropertySetInfo
> xInfo
= xPropSet
->getPropertySetInfo();
152 OUString
sPropButtonType( "ButtonType" );
153 OUString
sPropTargetURL( "TargetURL" );
154 OUString
sPropLabel( "Label" );
156 if(xInfo
->hasPropertyByName( sPropButtonType
))
158 uno::Any aAny
= xPropSet
->getPropertyValue( sPropButtonType
);
159 form::FormButtonType eTmp
;
160 if ( (aAny
>>= eTmp
) && eTmp
== form::FormButtonType_URL
)
163 if(xInfo
->hasPropertyByName( sPropTargetURL
))
165 aAny
= xPropSet
->getPropertyValue( sPropTargetURL
);
167 if ( (aAny
>>= sTmp
) && !sTmp
.isEmpty() )
169 OUString aUrl
= sTmp
;
171 const SfxMedium
* pMedium
;
172 if (pContainerShell
&& (pMedium
= pContainerShell
->GetMedium()) != NULL
)
175 aAbs
= pMedium
->GetURLObject().smartRel2Abs( aUrl
, bWasAbs
).
176 GetMainURL(INetURLObject::NO_DECODE
);
177 // full path as stored INetBookmark must be encoded
184 if(xInfo
->hasPropertyByName( sPropLabel
))
186 aAny
= xPropSet
->getPropertyValue( sPropLabel
);
187 if ( (aAny
>>= sTmp
) && !sTmp
.isEmpty() )
192 pBookmark
= new INetBookmark( aAbs
, aLabel
);
203 // get size for object descriptor
206 // #i71538# use complete SdrViews
207 // SdrExchangeView aView(pModel);
208 SdrView
aView(pModel
);
209 SdrPageView
* pPv
= aView
.ShowSdrPage(aView
.GetModel()->GetPage(0));
210 aView
.MarkAllObj(pPv
);
211 aSrcSize
= aView
.GetAllMarkedRect().GetSize();
213 if ( bOleObj
) // single OLE object
215 SdrOle2Obj
* pObj
= GetSingleObject();
216 if ( pObj
&& pObj
->GetObjRef().is() )
217 SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc
, pObj
->GetObjRef(), pObj
->GetGraphic(), pObj
->GetAspect() );
220 aObjDesc
.maSize
= aSrcSize
;
221 PrepareOLE( aObjDesc
);
224 // remember a unique ID of the source document
226 if ( pContainerShell
)
228 ScDocument
* pDoc
= pContainerShell
->GetDocument();
231 nSourceDocID
= pDoc
->GetDocumentID();
234 ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector
, pDoc
, pPage
);
240 ScDrawTransferObj::~ScDrawTransferObj()
242 SolarMutexGuard aSolarGuard
;
244 ScModule
* pScMod
= SC_MOD();
245 if ( pScMod
->GetClipData().pDrawClipboard
== this )
247 OSL_FAIL("ScDrawTransferObj wasn't released");
248 pScMod
->SetClipObject( NULL
, NULL
);
250 if ( pScMod
->GetDragData().pDrawTransfer
== this )
252 OSL_FAIL("ScDrawTransferObj wasn't released");
253 pScMod
->ResetDragObject();
256 aOleData
= TransferableDataHelper(); // clear before releasing the mutex
257 aDocShellRef
.Clear();
260 aDrawPersistRef
.Clear(); // after the model
263 delete pDragSourceView
;
266 ScDrawTransferObj
* ScDrawTransferObj::GetOwnClipboard( Window
* )
268 ScDrawTransferObj
* pObj
= SC_MOD()->GetClipData().pDrawClipboard
;
272 static bool lcl_HasOnlyControls( SdrModel
* pModel
)
274 bool bOnlyControls
= false; // default if there are no objects
278 SdrPage
* pPage
= pModel
->GetPage(0);
281 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
282 SdrObject
* pObj
= aIter
.Next();
285 bOnlyControls
= true; // only set if there are any objects at all
288 if (!pObj
->ISA(SdrUnoObj
))
290 bOnlyControls
= false;
299 return bOnlyControls
;
302 void ScDrawTransferObj::AddSupportedFormats()
304 if ( bGrIsBit
) // single bitmap graphic
306 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
307 AddFormat( SOT_FORMATSTR_ID_SVXB
);
308 AddFormat( SOT_FORMATSTR_ID_PNG
);
309 AddFormat( SOT_FORMAT_BITMAP
);
310 AddFormat( SOT_FORMAT_GDIMETAFILE
);
312 else if ( bGraphic
) // other graphic
315 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
317 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
318 AddFormat( SOT_FORMATSTR_ID_SVXB
);
319 AddFormat( SOT_FORMAT_GDIMETAFILE
);
320 AddFormat( SOT_FORMATSTR_ID_PNG
);
321 AddFormat( SOT_FORMAT_BITMAP
);
323 else if ( pBookmark
) // url button
325 // AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
326 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
327 AddFormat( SOT_FORMATSTR_ID_SOLK
);
328 AddFormat( SOT_FORMAT_STRING
);
329 AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
);
330 AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
);
331 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
333 else if ( bOleObj
) // single OLE object
335 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
336 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
337 AddFormat( SOT_FORMAT_GDIMETAFILE
);
341 if ( aOleData
.GetTransferable().is() )
343 // get format list from object snapshot
344 // (this must be after inserting the default formats!)
346 DataFlavorExVector
aVector( aOleData
.GetDataFlavorExVector() );
347 DataFlavorExVector::iterator
aIter( aVector
.begin() ), aEnd( aVector
.end() );
349 while( aIter
!= aEnd
)
350 AddFormat( *aIter
++ );
353 else // any drawing objects
355 AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
);
356 AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
);
357 AddFormat( SOT_FORMATSTR_ID_DRAWING
);
359 // leave out bitmap and metafile if there are only controls
360 if ( !lcl_HasOnlyControls( pModel
) )
362 AddFormat( SOT_FORMATSTR_ID_PNG
);
363 AddFormat( SOT_FORMAT_BITMAP
);
364 AddFormat( SOT_FORMAT_GDIMETAFILE
);
369 // AddFormat( SOT_FORMATSTR_ID_SVIM );
372 bool ScDrawTransferObj::GetData( const css::datatransfer::DataFlavor
& rFlavor
, const OUString
& rDestDoc
)
375 sal_uInt32 nFormat
= SotExchange::GetFormat( rFlavor
);
377 if ( bOleObj
&& nFormat
!= SOT_FORMAT_GDIMETAFILE
)
381 if( aOleData
.GetTransferable().is() && aOleData
.HasFormat( rFlavor
) )
383 sal_uLong nOldSwapMode
= 0;
387 nOldSwapMode
= pModel
->GetSwapGraphicsMode();
388 pModel
->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE
);
391 bOK
= SetAny( aOleData
.GetAny(rFlavor
, rDestDoc
), rFlavor
);
394 pModel
->SetSwapGraphicsMode( nOldSwapMode
);
400 if( HasFormat( nFormat
) )
402 if ( nFormat
== SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR
|| nFormat
== SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
)
404 bOK
= SetTransferableObjectDescriptor( aObjDesc
, rFlavor
);
406 else if ( nFormat
== SOT_FORMATSTR_ID_DRAWING
)
408 bOK
= SetObject( pModel
, SCDRAWTRANS_TYPE_DRAWMODEL
, rFlavor
);
410 else if ( nFormat
== SOT_FORMAT_BITMAP
411 || nFormat
== SOT_FORMATSTR_ID_PNG
412 || nFormat
== SOT_FORMAT_GDIMETAFILE
)
414 // #i71538# use complete SdrViews
415 // SdrExchangeView aView( pModel );
416 SdrView
aView( pModel
);
417 SdrPageView
* pPv
= aView
.ShowSdrPage(aView
.GetModel()->GetPage(0));
418 OSL_ENSURE( pPv
, "pPv not there..." );
419 aView
.MarkAllObj( pPv
);
420 if ( nFormat
== SOT_FORMAT_GDIMETAFILE
)
421 bOK
= SetGDIMetaFile( aView
.GetMarkedObjMetaFile(true), rFlavor
);
423 bOK
= SetBitmapEx( aView
.GetMarkedObjBitmapEx(true), rFlavor
);
425 else if ( nFormat
== SOT_FORMATSTR_ID_SVXB
)
427 // only enabled for single graphics object
429 SdrPage
* pPage
= pModel
->GetPage(0);
432 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
433 SdrObject
* pObject
= aIter
.Next();
434 if (pObject
&& pObject
->GetObjIdentifier() == OBJ_GRAF
)
436 SdrGrafObj
* pGraphObj
= (SdrGrafObj
*) pObject
;
437 bOK
= SetGraphic( pGraphObj
->GetGraphic(), rFlavor
);
441 else if ( nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
443 if ( bOleObj
) // single OLE object
445 SdrOle2Obj
* pObj
= GetSingleObject();
446 if ( pObj
&& pObj
->GetObjRef().is() )
448 bOK
= SetObject( pObj
->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ
, rFlavor
);
451 else // create object from contents
453 //TODO/LATER: needs new Format, because now single OLE and "this" are different
454 InitDocShell(); // set aDocShellRef
456 SfxObjectShell
* pEmbObj
= aDocShellRef
;
457 bOK
= SetObject( pEmbObj
, SCDRAWTRANS_TYPE_DOCUMENT
, rFlavor
);
462 bOK
= SetINetBookmark( *pBookmark
, rFlavor
);
468 bool ScDrawTransferObj::WriteObject( SotStorageStreamRef
& rxOStm
, void* pUserObject
, sal_uInt32 nUserObjectId
,
469 const ::com::sun::star::datatransfer::DataFlavor
& /* rFlavor */ )
471 // called from SetObject, put data into stream
474 switch (nUserObjectId
)
476 case SCDRAWTRANS_TYPE_DRAWMODEL
:
478 SdrModel
* pDrawModel
= (SdrModel
*)pUserObject
;
479 rxOStm
->SetBufferSize( 0xff00 );
482 // for the changed pool defaults from drawing layer pool set those
483 // attributes as hard attributes to preserve them for saving
484 const SfxItemPool
& rItemPool
= pModel
->GetItemPool();
485 const SvxFontHeightItem
& rDefaultFontHeight
= (const SvxFontHeightItem
&)rItemPool
.GetDefaultItem(EE_CHAR_FONTHEIGHT
);
487 // SW should have no MasterPages
488 OSL_ENSURE(0L == pModel
->GetMasterPageCount(), "SW with MasterPages (!)");
490 for(sal_uInt16
a(0); a
< pModel
->GetPageCount(); a
++)
492 const SdrPage
* pPage
= pModel
->GetPage(a
);
493 SdrObjListIter
aIter(*pPage
, IM_DEEPNOGROUPS
);
495 while(aIter
.IsMore())
497 SdrObject
* pObj
= aIter
.Next();
498 const SvxFontHeightItem
& rItem
= (const SvxFontHeightItem
&)pObj
->GetMergedItem(EE_CHAR_FONTHEIGHT
);
500 if(rItem
.GetHeight() == rDefaultFontHeight
.GetHeight())
502 pObj
->SetMergedItem(rDefaultFontHeight
);
508 com::sun::star::uno::Reference
<com::sun::star::io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *rxOStm
) );
509 if( SvxDrawingLayerExport( pDrawModel
, xDocOut
) )
513 bRet
= ( rxOStm
->GetError() == ERRCODE_NONE
);
517 case SCDRAWTRANS_TYPE_EMBOBJ
:
519 // impl. for "single OLE"
520 embed::XEmbeddedObject
* pEmbObj
= (embed::XEmbeddedObject
*) pUserObject
;
522 ::utl::TempFile aTempFile
;
523 aTempFile
.EnableKillingFile();
524 uno::Reference
< embed::XStorage
> xWorkStore
=
525 ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile
.GetURL(), embed::ElementModes::READWRITE
);
527 uno::Reference
< embed::XEmbedPersist
> xPers( (embed::XVisualObject
*)pEmbObj
, uno::UNO_QUERY
);
532 uno::Sequence
< beans::PropertyValue
> aSeq
;
533 OUString
aDummyName("Dummy");
534 xPers
->storeToEntry( xWorkStore
, aDummyName
, aSeq
, aSeq
);
535 if ( xWorkStore
->isStreamElement( aDummyName
) )
537 uno::Reference
< io::XOutputStream
> xDocOut( new utl::OOutputStreamWrapper( *rxOStm
) );
538 uno::Reference
< io::XStream
> xNewStream
= xWorkStore
->openStreamElement( aDummyName
, embed::ElementModes::READ
);
539 ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream
->getInputStream(), xDocOut
);
543 uno::Reference
< io::XStream
> xDocStr( new utl::OStreamWrapper( *rxOStm
) );
544 uno::Reference
< embed::XStorage
> xDocStg
= ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr
);
545 uno::Reference
< embed::XStorage
> xNewStg
= xWorkStore
->openStorageElement( aDummyName
, embed::ElementModes::READ
);
546 xNewStg
->copyToStorage( xDocStg
);
547 uno::Reference
< embed::XTransactedObject
> xTrans( xDocStg
, uno::UNO_QUERY
);
554 catch ( uno::Exception
& )
561 case SCDRAWTRANS_TYPE_DOCUMENT
:
563 // impl. for "DocShell"
564 SfxObjectShell
* pEmbObj
= (SfxObjectShell
*) pUserObject
;
568 ::utl::TempFile aTempFile
;
569 aTempFile
.EnableKillingFile();
570 uno::Reference
< embed::XStorage
> xWorkStore
=
571 ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile
.GetURL(), embed::ElementModes::READWRITE
);
573 // write document storage
574 pEmbObj
->SetupStorage( xWorkStore
, SOFFICE_FILEFORMAT_CURRENT
, false, false );
576 // mba: no relative URLs for clipboard!
577 SfxMedium
aMedium( xWorkStore
, OUString() );
578 bRet
= pEmbObj
->DoSaveObjectAs( aMedium
, false );
579 pEmbObj
->DoSaveCompleted();
581 uno::Reference
< embed::XTransactedObject
> xTransact( xWorkStore
, uno::UNO_QUERY
);
582 if ( xTransact
.is() )
585 SvStream
* pSrcStm
= ::utl::UcbStreamHelper::CreateStream( aTempFile
.GetURL(), STREAM_READ
);
588 rxOStm
->SetBufferSize( 0xff00 );
589 rxOStm
->WriteStream( *pSrcStm
);
595 xWorkStore
->dispose();
596 xWorkStore
= uno::Reference
< embed::XStorage
>();
599 catch ( uno::Exception
& )
602 bRet
= ( rxOStm
->GetError() == ERRCODE_NONE
);
607 OSL_FAIL("unknown object id");
612 void ScDrawTransferObj::ObjectReleased()
614 ScModule
* pScMod
= SC_MOD();
615 if ( pScMod
->GetClipData().pDrawClipboard
== this )
616 pScMod
->SetClipObject( NULL
, NULL
);
618 TransferableHelper::ObjectReleased();
621 void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction
)
623 if ( nDropAction
== DND_ACTION_MOVE
&& !bDragWasInternal
&& !(nDragSourceFlags
& SC_DROP_NAVIGATOR
) )
625 // move: delete source objects
627 if ( pDragSourceView
)
628 pDragSourceView
->DeleteMarked();
631 ScModule
* pScMod
= SC_MOD();
632 if ( pScMod
->GetDragData().pDrawTransfer
== this )
633 pScMod
->ResetDragObject();
635 DELETEZ( pDragSourceView
);
637 TransferableHelper::DragFinished( nDropAction
);
640 void ScDrawTransferObj::SetDrawPersist( const SfxObjectShellRef
& rRef
)
642 aDrawPersistRef
= rRef
;
645 static void lcl_InitMarks( SdrMarkView
& rDest
, const SdrMarkView
& rSource
, SCTAB nTab
)
647 rDest
.ShowSdrPage(rDest
.GetModel()->GetPage(nTab
));
648 SdrPageView
* pDestPV
= rDest
.GetSdrPageView();
649 OSL_ENSURE(pDestPV
,"PageView ?");
651 const SdrMarkList
& rMarkList
= rSource
.GetMarkedObjectList();
652 sal_uLong nCount
= rMarkList
.GetMarkCount();
653 for (sal_uLong i
=0; i
<nCount
; i
++)
655 SdrMark
* pMark
= rMarkList
.GetMark(i
);
656 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
658 rDest
.MarkObj(pObj
, pDestPV
);
662 void ScDrawTransferObj::SetDragSource( ScDrawView
* pView
)
664 DELETEZ( pDragSourceView
);
665 pDragSourceView
= new SdrView( pView
->GetModel() );
666 lcl_InitMarks( *pDragSourceView
, *pView
, pView
->GetTab() );
668 //! add as listener with document, delete pDragSourceView if document gone
671 void ScDrawTransferObj::SetDragSourceObj( SdrObject
* pObj
, SCTAB nTab
)
673 DELETEZ( pDragSourceView
);
674 pDragSourceView
= new SdrView( pObj
->GetModel() );
675 pDragSourceView
->ShowSdrPage(pDragSourceView
->GetModel()->GetPage(nTab
));
676 SdrPageView
* pPV
= pDragSourceView
->GetSdrPageView();
677 pDragSourceView
->MarkObj(pObj
, pPV
);
679 //! add as listener with document, delete pDragSourceView if document gone
682 void ScDrawTransferObj::SetDragSourceFlags( sal_uInt16 nFlags
)
684 nDragSourceFlags
= nFlags
;
687 void ScDrawTransferObj::SetDragWasInternal()
689 bDragWasInternal
= true;
692 OUString
ScDrawTransferObj::GetShellID() const
697 SdrOle2Obj
* ScDrawTransferObj::GetSingleObject()
699 // if single OLE object was copied, get its object
701 SdrPage
* pPage
= pModel
->GetPage(0);
704 SdrObjListIter
aIter( *pPage
, IM_FLAT
);
705 SdrObject
* pObject
= aIter
.Next();
706 if (pObject
&& pObject
->GetObjIdentifier() == OBJ_OLE2
)
708 return (SdrOle2Obj
*) pObject
;
715 void ScDrawTransferObj::CreateOLEData()
717 if (aOleData
.GetTransferable().is())
721 SdrOle2Obj
* pObj
= GetSingleObject();
722 if (!pObj
|| !pObj
->GetObjRef().is())
723 // No OLE object present.
726 SvEmbedTransferHelper
* pEmbedTransfer
=
727 new SvEmbedTransferHelper(
728 pObj
->GetObjRef(), pObj
->GetGraphic(), pObj
->GetAspect());
730 pEmbedTransfer
->SetParentShellID(maShellID
);
732 aOleData
= TransferableDataHelper(pEmbedTransfer
);
736 // initialize aDocShellRef with a live document from the ClipDoc
739 void ScDrawTransferObj::InitDocShell()
741 if ( !aDocShellRef
.Is() )
743 ScDocShell
* pDocSh
= new ScDocShell
;
744 aDocShellRef
= pDocSh
; // ref must be there before InitNew
746 pDocSh
->DoInitNew(NULL
);
748 ScDocument
* pDestDoc
= pDocSh
->GetDocument();
749 pDestDoc
->InitDrawLayer( pDocSh
);
751 SdrModel
* pDestModel
= pDestDoc
->GetDrawLayer();
752 // #i71538# use complete SdrViews
753 // SdrExchangeView aDestView( pDestModel );
754 SdrView
aDestView( pDestModel
);
755 aDestView
.ShowSdrPage(aDestView
.GetModel()->GetPage(0));
758 Point(aSrcSize
.Width()/2, aSrcSize
.Height()/2),
759 NULL
, 0, OUString(), OUString());
761 // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING)
763 SdrPage
* pPage
= pDestModel
->GetPage(0);
766 SdrObjListIter
aIter( *pPage
, IM_DEEPWITHGROUPS
);
767 SdrObject
* pObject
= aIter
.Next();
770 if ( pObject
->ISA(SdrUnoObj
) )
771 pObject
->NbcSetLayer(SC_LAYER_CONTROLS
);
773 pObject
->NbcSetLayer(SC_LAYER_FRONT
);
774 pObject
= aIter
.Next();
779 Rectangle
aDestArea( aTmpPoint
, aSrcSize
);
780 pDocSh
->SetVisArea( aDestArea
);
782 ScViewOptions
aViewOpt( pDestDoc
->GetViewOptions() );
783 aViewOpt
.SetOption( VOPT_GRID
, false );
784 pDestDoc
->SetViewOptions( aViewOpt
);
786 ScViewData
aViewData( pDocSh
, NULL
);
787 aViewData
.SetTabNo( 0 );
788 aViewData
.SetScreen( aDestArea
);
789 aViewData
.SetCurX( 0 );
790 aViewData
.SetCurY( 0 );
791 pDocSh
->UpdateOle(&aViewData
, true);
797 class theScDrawTransferObjUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theScDrawTransferObjUnoTunnelId
> {};
800 const com::sun::star::uno::Sequence
< sal_Int8
>& ScDrawTransferObj::getUnoTunnelId()
802 return theScDrawTransferObjUnoTunnelId::get().getSeq();
805 sal_Int64 SAL_CALL
ScDrawTransferObj::getSomething( const com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw( com::sun::star::uno::RuntimeException
, std::exception
)
808 if( ( rId
.getLength() == 16 ) &&
809 ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
811 nRet
= reinterpret_cast< sal_Int64
>( this );
814 nRet
= TransferableHelper::getSomething(rId
);
819 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */