xref: /aoo41x/main/sc/source/ui/app/drwtrans.cxx (revision a206ee71)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
31cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedPersist.hpp>
32cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
36cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
37cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
38cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <svx/unomodel.hxx>
41cdf0e10cSrcweir #include <unotools/tempfile.hxx>
42cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
43cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <svtools/embedtransfer.hxx>
46cdf0e10cSrcweir #include <sot/storage.hxx>
47cdf0e10cSrcweir #include <vcl/virdev.hxx>
48cdf0e10cSrcweir #include <svx/fmglob.hxx>
49cdf0e10cSrcweir #include <svx/svditer.hxx>
50cdf0e10cSrcweir #include <svx/svdograf.hxx>
51cdf0e10cSrcweir #include <svx/svdoole2.hxx>
52cdf0e10cSrcweir #include <svx/svdouno.hxx>
53cdf0e10cSrcweir #include <svx/svdpage.hxx>
54cdf0e10cSrcweir #include <svx/svdxcgv.hxx>
55cdf0e10cSrcweir #include <sfx2/docfile.hxx>
56cdf0e10cSrcweir #include <svl/itempool.hxx>
57cdf0e10cSrcweir #include <svl/urlbmk.hxx>
58cdf0e10cSrcweir #include <tools/urlobj.hxx>
59cdf0e10cSrcweir #include <vos/mutex.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include "drwtrans.hxx"
62cdf0e10cSrcweir #include "docsh.hxx"
63cdf0e10cSrcweir #include "drwlayer.hxx"
64cdf0e10cSrcweir #include "drawview.hxx"
65cdf0e10cSrcweir #include "viewdata.hxx"
66cdf0e10cSrcweir #include "scmod.hxx"
67cdf0e10cSrcweir #include "chartlis.hxx"
68cdf0e10cSrcweir #include "rangeutl.hxx"
69cdf0e10cSrcweir #include "formula/grammar.hxx"
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // #108584#
72cdf0e10cSrcweir #include "scitems.hxx"
73cdf0e10cSrcweir 
74cdf0e10cSrcweir // #108584#
75cdf0e10cSrcweir #include <editeng/eeitem.hxx>
76cdf0e10cSrcweir 
77cdf0e10cSrcweir // #108584#
78cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
79cdf0e10cSrcweir #include <vcl/svapp.hxx>
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir using namespace com::sun::star;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // -----------------------------------------------------------------------
85cdf0e10cSrcweir 
86cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_EMBOBJ         1
87cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_DRAWMODEL      2
88cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_DOCUMENT       3
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // -----------------------------------------------------------------------
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // -----------------------------------------------------------------------
93cdf0e10cSrcweir 
ScDrawTransferObj(SdrModel * pClipModel,ScDocShell * pContainerShell,const TransferableObjectDescriptor & rDesc)94cdf0e10cSrcweir ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell,
95cdf0e10cSrcweir                                         const TransferableObjectDescriptor& rDesc ) :
96cdf0e10cSrcweir     pModel( pClipModel ),
97cdf0e10cSrcweir     aObjDesc( rDesc ),
98cdf0e10cSrcweir     pBookmark( NULL ),
99cdf0e10cSrcweir     bGraphic( sal_False ),
100cdf0e10cSrcweir     bGrIsBit( sal_False ),
101cdf0e10cSrcweir     bOleObj( sal_False ),
102cdf0e10cSrcweir     pDragSourceView( NULL ),
103cdf0e10cSrcweir     nDragSourceFlags( 0 ),
104cdf0e10cSrcweir     bDragWasInternal( sal_False ),
105cdf0e10cSrcweir     nSourceDocID( 0 )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     //
108cdf0e10cSrcweir     //  check what kind of objects are contained
109cdf0e10cSrcweir     //
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     SdrPage* pPage = pModel->GetPage(0);
112cdf0e10cSrcweir     if (pPage)
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         SdrObjListIter aIter( *pPage, IM_FLAT );
115cdf0e10cSrcweir         SdrObject* pObject = aIter.Next();
116cdf0e10cSrcweir         if (pObject && !aIter.Next())               // exactly one object?
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir             //
119cdf0e10cSrcweir             //  OLE object
120cdf0e10cSrcweir             //
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             sal_uInt16 nSdrObjKind = pObject->GetObjIdentifier();
123cdf0e10cSrcweir             if (nSdrObjKind == OBJ_OLE2)
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir 				// if object has no persistence it must be copied as a part of document
126cdf0e10cSrcweir 				try
127cdf0e10cSrcweir 				{
128cdf0e10cSrcweir 					uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObject)->GetObjRef(), uno::UNO_QUERY );
129cdf0e10cSrcweir 					if ( xPersObj.is() && xPersObj->hasEntry() )
130cdf0e10cSrcweir                 		bOleObj = sal_True;
131cdf0e10cSrcweir 				}
132cdf0e10cSrcweir 				catch( uno::Exception& )
133cdf0e10cSrcweir 				{}
134cdf0e10cSrcweir                 // aOleData is initialized later
135cdf0e10cSrcweir             }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir             //
138cdf0e10cSrcweir             //  Graphic object
139cdf0e10cSrcweir             //
140cdf0e10cSrcweir 
141cdf0e10cSrcweir             if (nSdrObjKind == OBJ_GRAF)
142cdf0e10cSrcweir             {
143cdf0e10cSrcweir                 bGraphic = sal_True;
144cdf0e10cSrcweir                 if ( ((SdrGrafObj*)pObject)->GetGraphic().GetType() == GRAPHIC_BITMAP )
145cdf0e10cSrcweir                     bGrIsBit = sal_True;
146cdf0e10cSrcweir             }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir             //
149cdf0e10cSrcweir             //  URL button
150cdf0e10cSrcweir             //
151cdf0e10cSrcweir 
152cdf0e10cSrcweir             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObject);
153cdf0e10cSrcweir             if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
154cdf0e10cSrcweir             {
155cdf0e10cSrcweir                 uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
156cdf0e10cSrcweir                 DBG_ASSERT( xControlModel.is(), "uno control without model" );
157cdf0e10cSrcweir                 if ( xControlModel.is() )
158cdf0e10cSrcweir                 {
159cdf0e10cSrcweir                     uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
160cdf0e10cSrcweir                     uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir                     rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" );
163cdf0e10cSrcweir                     rtl::OUString sPropTargetURL  = rtl::OUString::createFromAscii( "TargetURL" );
164cdf0e10cSrcweir                     rtl::OUString sPropLabel      = rtl::OUString::createFromAscii( "Label" );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir                     if(xInfo->hasPropertyByName( sPropButtonType ))
167cdf0e10cSrcweir                     {
168cdf0e10cSrcweir                         uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
169cdf0e10cSrcweir                         form::FormButtonType eTmp;
170cdf0e10cSrcweir                         if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
171cdf0e10cSrcweir                         {
172cdf0e10cSrcweir                             // URL
173cdf0e10cSrcweir                             if(xInfo->hasPropertyByName( sPropTargetURL ))
174cdf0e10cSrcweir                             {
175cdf0e10cSrcweir                                 aAny = xPropSet->getPropertyValue( sPropTargetURL );
176cdf0e10cSrcweir                                 rtl::OUString sTmp;
177cdf0e10cSrcweir                                 if ( (aAny >>= sTmp) && sTmp.getLength() )
178cdf0e10cSrcweir                                 {
179cdf0e10cSrcweir                                     String aUrl = sTmp;
180cdf0e10cSrcweir                                     String aAbs;
181cdf0e10cSrcweir                                     const SfxMedium* pMedium;
182cdf0e10cSrcweir                                     if (pContainerShell && (pMedium = pContainerShell->GetMedium()) != NULL)
183cdf0e10cSrcweir                                     {
184cdf0e10cSrcweir                                         bool bWasAbs = true;
185cdf0e10cSrcweir                                         aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ).
186cdf0e10cSrcweir                                         			GetMainURL(INetURLObject::NO_DECODE);
187cdf0e10cSrcweir 										// full path as stored INetBookmark must be encoded
188cdf0e10cSrcweir                                     }
189cdf0e10cSrcweir                                     else
190cdf0e10cSrcweir                                         aAbs = aUrl;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir                                     // Label
193cdf0e10cSrcweir                                     String aLabel;
194cdf0e10cSrcweir                                     if(xInfo->hasPropertyByName( sPropLabel ))
195cdf0e10cSrcweir                                     {
196cdf0e10cSrcweir                                         aAny = xPropSet->getPropertyValue( sPropLabel );
197cdf0e10cSrcweir                                         if ( (aAny >>= sTmp) && sTmp.getLength() )
198cdf0e10cSrcweir                                         {
199cdf0e10cSrcweir                                             aLabel = String(sTmp);
200cdf0e10cSrcweir                                         }
201cdf0e10cSrcweir                                     }
202cdf0e10cSrcweir                                     pBookmark = new INetBookmark( aAbs, aLabel );
203cdf0e10cSrcweir                                 }
204cdf0e10cSrcweir                             }
205cdf0e10cSrcweir                         }
206cdf0e10cSrcweir                     }
207cdf0e10cSrcweir                 }
208cdf0e10cSrcweir             }
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir     }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     //
213cdf0e10cSrcweir     //  get size for object descriptor
214cdf0e10cSrcweir     //
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	// #i71538# use complete SdrViews
217cdf0e10cSrcweir     // SdrExchangeView aView(pModel);
218cdf0e10cSrcweir     SdrView aView(pModel);
219cdf0e10cSrcweir     SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
220cdf0e10cSrcweir     aView.MarkAllObj(pPv);
221cdf0e10cSrcweir     aSrcSize = aView.GetAllMarkedRect().GetSize();
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     if ( bOleObj )              // single OLE object
224cdf0e10cSrcweir     {
225cdf0e10cSrcweir 		SdrOle2Obj* pObj = GetSingleObject();
226cdf0e10cSrcweir     	if ( pObj && pObj->GetObjRef().is() )
227cdf0e10cSrcweir             SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() );
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     aObjDesc.maSize = aSrcSize;
231cdf0e10cSrcweir     PrepareOLE( aObjDesc );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     //
234cdf0e10cSrcweir     // remember a unique ID of the source document
235cdf0e10cSrcweir     //
236cdf0e10cSrcweir     if ( pContainerShell )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         ScDocument* pDoc = pContainerShell->GetDocument();
239cdf0e10cSrcweir         if ( pDoc )
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             nSourceDocID = pDoc->GetDocumentID();
242cdf0e10cSrcweir             if ( pPage )
243cdf0e10cSrcweir             {
244cdf0e10cSrcweir                 ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector, pDoc, pPage );
245cdf0e10cSrcweir             }
246cdf0e10cSrcweir         }
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir }
249cdf0e10cSrcweir 
~ScDrawTransferObj()250cdf0e10cSrcweir ScDrawTransferObj::~ScDrawTransferObj()
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     Application::GetSolarMutex().acquire();     //! ???
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
255cdf0e10cSrcweir     if ( pScMod->GetClipData().pDrawClipboard == this )
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         DBG_ERROR("ScDrawTransferObj wasn't released");
258cdf0e10cSrcweir         pScMod->SetClipObject( NULL, NULL );
259cdf0e10cSrcweir     }
260cdf0e10cSrcweir     if ( pScMod->GetDragData().pDrawTransfer == this )
261cdf0e10cSrcweir     {
262cdf0e10cSrcweir         DBG_ERROR("ScDrawTransferObj wasn't released");
263cdf0e10cSrcweir         pScMod->ResetDragObject();
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     aOleData = TransferableDataHelper();        // clear before releasing the mutex
267cdf0e10cSrcweir     aDocShellRef.Clear();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir     delete pModel;
270cdf0e10cSrcweir     aDrawPersistRef.Clear();                    // after the model
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     delete pBookmark;
273cdf0e10cSrcweir     delete pDragSourceView;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     Application::GetSolarMutex().release();     //! ???
276cdf0e10cSrcweir }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir // static
GetOwnClipboard(Window *)279cdf0e10cSrcweir ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( Window* )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     ScDrawTransferObj* pObj = SC_MOD()->GetClipData().pDrawClipboard;
282cdf0e10cSrcweir     return pObj;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
lcl_HasOnlyControls(SdrModel * pModel)285cdf0e10cSrcweir sal_Bool lcl_HasOnlyControls( SdrModel* pModel )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     sal_Bool bOnlyControls = sal_False;         // default if there are no objects
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     if ( pModel )
290cdf0e10cSrcweir     {
291cdf0e10cSrcweir         SdrPage* pPage = pModel->GetPage(0);
292cdf0e10cSrcweir         if (pPage)
293cdf0e10cSrcweir         {
294cdf0e10cSrcweir             SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
295cdf0e10cSrcweir             SdrObject* pObj = aIter.Next();
296cdf0e10cSrcweir             if ( pObj )
297cdf0e10cSrcweir             {
298cdf0e10cSrcweir                 bOnlyControls = sal_True;   // only set if there are any objects at all
299cdf0e10cSrcweir                 while ( pObj )
300cdf0e10cSrcweir                 {
301cdf0e10cSrcweir                     if (!pObj->ISA(SdrUnoObj))
302cdf0e10cSrcweir                     {
303cdf0e10cSrcweir                         bOnlyControls = sal_False;
304cdf0e10cSrcweir                         break;
305cdf0e10cSrcweir                     }
306cdf0e10cSrcweir                     pObj = aIter.Next();
307cdf0e10cSrcweir                 }
308cdf0e10cSrcweir             }
309cdf0e10cSrcweir         }
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir     return bOnlyControls;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
AddSupportedFormats()315cdf0e10cSrcweir void ScDrawTransferObj::AddSupportedFormats()
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     if ( bGrIsBit )             // single bitmap graphic
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
320cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_SVXB );
321*a206ee71SArmin Le Grand         AddFormat( SOT_FORMATSTR_ID_PNG );
322cdf0e10cSrcweir         AddFormat( SOT_FORMAT_BITMAP );
323cdf0e10cSrcweir         AddFormat( SOT_FORMAT_GDIMETAFILE );
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir     else if ( bGraphic )        // other graphic
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir 		// #i25616#
328cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_DRAWING );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
331cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_SVXB );
332cdf0e10cSrcweir         AddFormat( SOT_FORMAT_GDIMETAFILE );
333*a206ee71SArmin Le Grand         AddFormat( SOT_FORMATSTR_ID_PNG );
334cdf0e10cSrcweir         AddFormat( SOT_FORMAT_BITMAP );
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir     else if ( pBookmark )       // url button
337cdf0e10cSrcweir     {
338cdf0e10cSrcweir //      AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
339cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
340cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_SOLK );
341cdf0e10cSrcweir         AddFormat( SOT_FORMAT_STRING );
342cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
343cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
344cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_DRAWING );
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir     else if ( bOleObj )         // single OLE object
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
349cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
350cdf0e10cSrcweir         AddFormat( SOT_FORMAT_GDIMETAFILE );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         if ( !aOleData.GetTransferable().is() )
353cdf0e10cSrcweir         {
354cdf0e10cSrcweir 			SdrOle2Obj* pObj = GetSingleObject();
355cdf0e10cSrcweir             if ( pObj && pObj->GetObjRef().is() )
356cdf0e10cSrcweir                 aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ;
357cdf0e10cSrcweir         }
358cdf0e10cSrcweir         if ( aOleData.GetTransferable().is() )
359cdf0e10cSrcweir         {
360cdf0e10cSrcweir             //  get format list from object snapshot
361cdf0e10cSrcweir             //  (this must be after inserting the default formats!)
362cdf0e10cSrcweir 
363cdf0e10cSrcweir             DataFlavorExVector              aVector( aOleData.GetDataFlavorExVector() );
364cdf0e10cSrcweir             DataFlavorExVector::iterator    aIter( aVector.begin() ), aEnd( aVector.end() );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir             while( aIter != aEnd )
367cdf0e10cSrcweir                 AddFormat( *aIter++ );
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     else                        // any drawing objects
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
373cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
374cdf0e10cSrcweir         AddFormat( SOT_FORMATSTR_ID_DRAWING );
375cdf0e10cSrcweir 
376cdf0e10cSrcweir         // #103556# leave out bitmap and metafile if there are only controls
377cdf0e10cSrcweir         if ( !lcl_HasOnlyControls( pModel ) )
378cdf0e10cSrcweir         {
379*a206ee71SArmin Le Grand             AddFormat( SOT_FORMATSTR_ID_PNG );
380cdf0e10cSrcweir             AddFormat( SOT_FORMAT_BITMAP );
381cdf0e10cSrcweir             AddFormat( SOT_FORMAT_GDIMETAFILE );
382cdf0e10cSrcweir         }
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir //  if( pImageMap )
386cdf0e10cSrcweir //      AddFormat( SOT_FORMATSTR_ID_SVIM );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
GetData(const::com::sun::star::datatransfer::DataFlavor & rFlavor)389cdf0e10cSrcweir sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir     sal_Bool bOK = sal_False;
392cdf0e10cSrcweir     sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     if ( bOleObj && nFormat != SOT_FORMAT_GDIMETAFILE )
395cdf0e10cSrcweir     {
396cdf0e10cSrcweir         if ( !aOleData.GetTransferable().is() )
397cdf0e10cSrcweir         {
398cdf0e10cSrcweir 			SdrOle2Obj* pObj = GetSingleObject();
399cdf0e10cSrcweir             if ( pObj && pObj->GetObjRef().is() )
400cdf0e10cSrcweir                 aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ;
401cdf0e10cSrcweir         }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         if( aOleData.GetTransferable().is() && aOleData.HasFormat( rFlavor ) )
404cdf0e10cSrcweir         {
405cdf0e10cSrcweir             sal_uLong nOldSwapMode = 0;
406cdf0e10cSrcweir 
407cdf0e10cSrcweir             if( pModel )
408cdf0e10cSrcweir             {
409cdf0e10cSrcweir                 nOldSwapMode = pModel->GetSwapGraphicsMode();
410cdf0e10cSrcweir                 pModel->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
411cdf0e10cSrcweir             }
412cdf0e10cSrcweir 
413cdf0e10cSrcweir             bOK = SetAny( aOleData.GetAny( rFlavor ), rFlavor );
414cdf0e10cSrcweir 
415cdf0e10cSrcweir             if( pModel )
416cdf0e10cSrcweir                 pModel->SetSwapGraphicsMode( nOldSwapMode );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir             return bOK;
419cdf0e10cSrcweir         }
420cdf0e10cSrcweir     }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir     if( HasFormat( nFormat ) )
423cdf0e10cSrcweir     {
424cdf0e10cSrcweir         if ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
425cdf0e10cSrcweir         {
426cdf0e10cSrcweir             bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
427cdf0e10cSrcweir         }
428cdf0e10cSrcweir         else if ( nFormat == SOT_FORMATSTR_ID_DRAWING )
429cdf0e10cSrcweir         {
430cdf0e10cSrcweir             bOK = SetObject( pModel, SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor );
431cdf0e10cSrcweir         }
432*a206ee71SArmin Le Grand         else if ( nFormat == SOT_FORMAT_BITMAP
433*a206ee71SArmin Le Grand             || nFormat == SOT_FORMATSTR_ID_PNG
434*a206ee71SArmin Le Grand             || nFormat == SOT_FORMAT_GDIMETAFILE )
435cdf0e10cSrcweir         {
436cdf0e10cSrcweir 			// #i71538# use complete SdrViews
437cdf0e10cSrcweir             // SdrExchangeView aView( pModel );
438cdf0e10cSrcweir             SdrView aView( pModel );
439cdf0e10cSrcweir             SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
440cdf0e10cSrcweir             DBG_ASSERT( pPv, "pPv not there..." );
441cdf0e10cSrcweir             aView.MarkAllObj( pPv );
442cdf0e10cSrcweir             if ( nFormat == SOT_FORMAT_GDIMETAFILE )
443bb18ee55SArmin Le Grand                 bOK = SetGDIMetaFile( aView.GetMarkedObjMetaFile(true), rFlavor );
444cdf0e10cSrcweir             else
44545fd3b9aSArmin Le Grand                 bOK = SetBitmapEx( aView.GetMarkedObjBitmapEx(true), rFlavor );
446cdf0e10cSrcweir         }
447cdf0e10cSrcweir         else if ( nFormat == SOT_FORMATSTR_ID_SVXB )
448cdf0e10cSrcweir         {
449cdf0e10cSrcweir             // only enabled for single graphics object
450cdf0e10cSrcweir 
451cdf0e10cSrcweir             SdrPage* pPage = pModel->GetPage(0);
452cdf0e10cSrcweir             if (pPage)
453cdf0e10cSrcweir             {
454cdf0e10cSrcweir                 SdrObjListIter aIter( *pPage, IM_FLAT );
455cdf0e10cSrcweir                 SdrObject* pObject = aIter.Next();
456cdf0e10cSrcweir                 if (pObject && pObject->GetObjIdentifier() == OBJ_GRAF)
457cdf0e10cSrcweir                 {
458cdf0e10cSrcweir                     SdrGrafObj* pGraphObj = (SdrGrafObj*) pObject;
459cdf0e10cSrcweir                     bOK = SetGraphic( pGraphObj->GetGraphic(), rFlavor );
460cdf0e10cSrcweir                 }
461cdf0e10cSrcweir             }
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         else if ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
464cdf0e10cSrcweir         {
465cdf0e10cSrcweir             if ( bOleObj )              // single OLE object
466cdf0e10cSrcweir             {
467cdf0e10cSrcweir 				SdrOle2Obj* pObj = GetSingleObject();
468cdf0e10cSrcweir             	if ( pObj && pObj->GetObjRef().is() )
469cdf0e10cSrcweir                 {
470cdf0e10cSrcweir                     bOK = SetObject( pObj->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ, rFlavor );
471cdf0e10cSrcweir                 }
472cdf0e10cSrcweir             }
473cdf0e10cSrcweir             else                        // create object from contents
474cdf0e10cSrcweir             {
475cdf0e10cSrcweir                 //TODO/LATER: needs new Format, because now single OLE and "this" are different
476cdf0e10cSrcweir                 InitDocShell();         // set aDocShellRef
477cdf0e10cSrcweir 
478cdf0e10cSrcweir                 SfxObjectShell* pEmbObj = aDocShellRef;
479cdf0e10cSrcweir                 bOK = SetObject( pEmbObj, SCDRAWTRANS_TYPE_DOCUMENT, rFlavor );
480cdf0e10cSrcweir             }
481cdf0e10cSrcweir         }
482cdf0e10cSrcweir         else if( pBookmark )
483cdf0e10cSrcweir         {
484cdf0e10cSrcweir             bOK = SetINetBookmark( *pBookmark, rFlavor );
485cdf0e10cSrcweir         }
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir     return bOK;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
WriteObject(SotStorageStreamRef & rxOStm,void * pUserObject,sal_uInt32 nUserObjectId,const::com::sun::star::datatransfer::DataFlavor &)490cdf0e10cSrcweir sal_Bool ScDrawTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
491cdf0e10cSrcweir                                         const ::com::sun::star::datatransfer::DataFlavor& /* rFlavor */ )
492cdf0e10cSrcweir {
493cdf0e10cSrcweir     // called from SetObject, put data into stream
494cdf0e10cSrcweir 
495cdf0e10cSrcweir     sal_Bool bRet = sal_False;
496cdf0e10cSrcweir     switch (nUserObjectId)
497cdf0e10cSrcweir     {
498cdf0e10cSrcweir         case SCDRAWTRANS_TYPE_DRAWMODEL:
499cdf0e10cSrcweir             {
500cdf0e10cSrcweir                 SdrModel* pDrawModel = (SdrModel*)pUserObject;
501cdf0e10cSrcweir                 rxOStm->SetBufferSize( 0xff00 );
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 				// #108584#
504cdf0e10cSrcweir 				// for the changed pool defaults from drawing layer pool set those
505cdf0e10cSrcweir 				// attributes as hard attributes to preserve them for saving
506cdf0e10cSrcweir 				const SfxItemPool& rItemPool = pModel->GetItemPool();
507cdf0e10cSrcweir 				const SvxFontHeightItem& rDefaultFontHeight = (const SvxFontHeightItem&)rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 				// SW should have no MasterPages
510cdf0e10cSrcweir 				DBG_ASSERT(0L == pModel->GetMasterPageCount(), "SW with MasterPages (!)");
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 				for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++)
513cdf0e10cSrcweir 				{
514cdf0e10cSrcweir 					const SdrPage* pPage = pModel->GetPage(a);
515cdf0e10cSrcweir 					SdrObjListIter aIter(*pPage, IM_DEEPNOGROUPS);
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 					while(aIter.IsMore())
518cdf0e10cSrcweir 					{
519cdf0e10cSrcweir 						SdrObject* pObj = aIter.Next();
520cdf0e10cSrcweir 						const SvxFontHeightItem& rItem = (const SvxFontHeightItem&)pObj->GetMergedItem(EE_CHAR_FONTHEIGHT);
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 						if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
523cdf0e10cSrcweir 						{
524cdf0e10cSrcweir 							pObj->SetMergedItem(rDefaultFontHeight);
525cdf0e10cSrcweir 						}
526cdf0e10cSrcweir 					}
527cdf0e10cSrcweir 				}
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 				{
530cdf0e10cSrcweir 					com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
531cdf0e10cSrcweir 					if( SvxDrawingLayerExport( pDrawModel, xDocOut ) )
532cdf0e10cSrcweir 						rxOStm->Commit();
533cdf0e10cSrcweir 				}
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 				bRet = ( rxOStm->GetError() == ERRCODE_NONE );
536cdf0e10cSrcweir             }
537cdf0e10cSrcweir             break;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir         case SCDRAWTRANS_TYPE_EMBOBJ:
540cdf0e10cSrcweir             {
541cdf0e10cSrcweir                 // impl. for "single OLE"
542cdf0e10cSrcweir                 embed::XEmbeddedObject* pEmbObj = (embed::XEmbeddedObject*) pUserObject;
543cdf0e10cSrcweir 
544cdf0e10cSrcweir                 ::utl::TempFile     aTempFile;
545cdf0e10cSrcweir                 aTempFile.EnableKillingFile();
546cdf0e10cSrcweir                 uno::Reference< embed::XStorage > xWorkStore =
547cdf0e10cSrcweir                     ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
548cdf0e10cSrcweir 
549cdf0e10cSrcweir                 uno::Reference < embed::XEmbedPersist > xPers( (embed::XVisualObject*)pEmbObj, uno::UNO_QUERY );
550cdf0e10cSrcweir                 if ( xPers.is() )
551cdf0e10cSrcweir                 {
552cdf0e10cSrcweir                     try
553cdf0e10cSrcweir                     {
554cdf0e10cSrcweir                         uno::Sequence < beans::PropertyValue > aSeq;
555cdf0e10cSrcweir                         ::rtl::OUString aDummyName = ::rtl::OUString::createFromAscii("Dummy");
556cdf0e10cSrcweir                         xPers->storeToEntry( xWorkStore, aDummyName, aSeq, aSeq );
557cdf0e10cSrcweir                         if ( xWorkStore->isStreamElement( aDummyName ) )
558cdf0e10cSrcweir                         {
559cdf0e10cSrcweir                             uno::Reference < io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
560cdf0e10cSrcweir                             uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ );
561cdf0e10cSrcweir                             ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream->getInputStream(), xDocOut );
562cdf0e10cSrcweir                         }
563cdf0e10cSrcweir                         else
564cdf0e10cSrcweir                         {
565cdf0e10cSrcweir                             uno::Reference < io::XStream > xDocStr( new utl::OStreamWrapper( *rxOStm ) );
566cdf0e10cSrcweir                             uno::Reference< embed::XStorage > xDocStg = ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr );
567cdf0e10cSrcweir                             uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ );
568cdf0e10cSrcweir                             xNewStg->copyToStorage( xDocStg );
569cdf0e10cSrcweir                             uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY );
570cdf0e10cSrcweir                             if ( xTrans.is() )
571cdf0e10cSrcweir                                 xTrans->commit();
572cdf0e10cSrcweir                         }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir                         rxOStm->Commit();
575cdf0e10cSrcweir                     }
576cdf0e10cSrcweir                     catch ( uno::Exception& )
577cdf0e10cSrcweir                     {
578cdf0e10cSrcweir                     }
579cdf0e10cSrcweir                 }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir                 break;
582cdf0e10cSrcweir             }
583cdf0e10cSrcweir         case SCDRAWTRANS_TYPE_DOCUMENT:
584cdf0e10cSrcweir             {
585cdf0e10cSrcweir                 // impl. for "DocShell"
586cdf0e10cSrcweir                 SfxObjectShell*   pEmbObj = (SfxObjectShell*) pUserObject;
587cdf0e10cSrcweir 
588cdf0e10cSrcweir                 try
589cdf0e10cSrcweir                 {
590cdf0e10cSrcweir                     ::utl::TempFile     aTempFile;
591cdf0e10cSrcweir                     aTempFile.EnableKillingFile();
592cdf0e10cSrcweir                     uno::Reference< embed::XStorage > xWorkStore =
593cdf0e10cSrcweir                         ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
594cdf0e10cSrcweir 
595cdf0e10cSrcweir                     // write document storage
596cdf0e10cSrcweir                     pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
597cdf0e10cSrcweir 
598cdf0e10cSrcweir                     // mba: no relative ULRs for clipboard!
599cdf0e10cSrcweir                     SfxMedium aMedium( xWorkStore, String() );
600cdf0e10cSrcweir                     bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False );
601cdf0e10cSrcweir                     pEmbObj->DoSaveCompleted();
602cdf0e10cSrcweir 
603cdf0e10cSrcweir                     uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
604cdf0e10cSrcweir                     if ( xTransact.is() )
605cdf0e10cSrcweir                         xTransact->commit();
606cdf0e10cSrcweir 
607cdf0e10cSrcweir                     SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
608cdf0e10cSrcweir                     if( pSrcStm )
609cdf0e10cSrcweir                     {
610cdf0e10cSrcweir                         rxOStm->SetBufferSize( 0xff00 );
611cdf0e10cSrcweir                         *rxOStm << *pSrcStm;
612cdf0e10cSrcweir                         delete pSrcStm;
613cdf0e10cSrcweir                     }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir                     bRet = sal_True;
616cdf0e10cSrcweir 
617cdf0e10cSrcweir                     xWorkStore->dispose();
618cdf0e10cSrcweir                     xWorkStore = uno::Reference < embed::XStorage >();
619cdf0e10cSrcweir                     rxOStm->Commit();
620cdf0e10cSrcweir                 }
621cdf0e10cSrcweir                 catch ( uno::Exception& )
622cdf0e10cSrcweir                 {}
623cdf0e10cSrcweir 
624cdf0e10cSrcweir                 bRet = ( rxOStm->GetError() == ERRCODE_NONE );
625cdf0e10cSrcweir             }
626cdf0e10cSrcweir             break;
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         default:
629cdf0e10cSrcweir             DBG_ERROR("unknown object id");
630cdf0e10cSrcweir     }
631cdf0e10cSrcweir     return bRet;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
ObjectReleased()634cdf0e10cSrcweir void ScDrawTransferObj::ObjectReleased()
635cdf0e10cSrcweir {
636cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
637cdf0e10cSrcweir     if ( pScMod->GetClipData().pDrawClipboard == this )
638cdf0e10cSrcweir         pScMod->SetClipObject( NULL, NULL );
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     TransferableHelper::ObjectReleased();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
DragFinished(sal_Int8 nDropAction)643cdf0e10cSrcweir void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction )
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
646cdf0e10cSrcweir     {
647cdf0e10cSrcweir         //  move: delete source objects
648cdf0e10cSrcweir 
649cdf0e10cSrcweir         if ( pDragSourceView )
650cdf0e10cSrcweir             pDragSourceView->DeleteMarked();
651cdf0e10cSrcweir     }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
654cdf0e10cSrcweir     if ( pScMod->GetDragData().pDrawTransfer == this )
655cdf0e10cSrcweir         pScMod->ResetDragObject();
656cdf0e10cSrcweir 
657cdf0e10cSrcweir     DELETEZ( pDragSourceView );
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     TransferableHelper::DragFinished( nDropAction );
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
SetDrawPersist(const SfxObjectShellRef & rRef)662cdf0e10cSrcweir void ScDrawTransferObj::SetDrawPersist( const SfxObjectShellRef& rRef )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir     aDrawPersistRef = rRef;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
lcl_InitMarks(SdrMarkView & rDest,const SdrMarkView & rSource,SCTAB nTab)667cdf0e10cSrcweir void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, SCTAB nTab )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir     rDest.ShowSdrPage(rDest.GetModel()->GetPage(nTab));
670cdf0e10cSrcweir     SdrPageView* pDestPV = rDest.GetSdrPageView();
671cdf0e10cSrcweir     DBG_ASSERT(pDestPV,"PageView ?");
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     const SdrMarkList& rMarkList = rSource.GetMarkedObjectList();
674cdf0e10cSrcweir     sal_uLong nCount = rMarkList.GetMarkCount();
675cdf0e10cSrcweir     for (sal_uLong i=0; i<nCount; i++)
676cdf0e10cSrcweir     {
677cdf0e10cSrcweir         SdrMark* pMark = rMarkList.GetMark(i);
678cdf0e10cSrcweir         SdrObject* pObj = pMark->GetMarkedSdrObj();
679cdf0e10cSrcweir 
680cdf0e10cSrcweir         rDest.MarkObj(pObj, pDestPV);
681cdf0e10cSrcweir     }
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
SetDragSource(ScDrawView * pView)684cdf0e10cSrcweir void ScDrawTransferObj::SetDragSource( ScDrawView* pView )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     DELETEZ( pDragSourceView );
687cdf0e10cSrcweir     pDragSourceView = new SdrView( pView->GetModel() );
688cdf0e10cSrcweir     lcl_InitMarks( *pDragSourceView, *pView, pView->GetTab() );
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     //! add as listener with document, delete pDragSourceView if document gone
691cdf0e10cSrcweir }
692cdf0e10cSrcweir 
SetDragSourceObj(SdrObject * pObj,SCTAB nTab)693cdf0e10cSrcweir void ScDrawTransferObj::SetDragSourceObj( SdrObject* pObj, SCTAB nTab )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir     DELETEZ( pDragSourceView );
696cdf0e10cSrcweir     pDragSourceView = new SdrView( pObj->GetModel() );
697cdf0e10cSrcweir     pDragSourceView->ShowSdrPage(pDragSourceView->GetModel()->GetPage(nTab));
698cdf0e10cSrcweir     SdrPageView* pPV = pDragSourceView->GetSdrPageView();
699cdf0e10cSrcweir     pDragSourceView->MarkObj(pObj, pPV);
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     //! add as listener with document, delete pDragSourceView if document gone
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
SetDragSourceFlags(sal_uInt16 nFlags)704cdf0e10cSrcweir void ScDrawTransferObj::SetDragSourceFlags( sal_uInt16 nFlags )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir     nDragSourceFlags = nFlags;
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
SetDragWasInternal()709cdf0e10cSrcweir void ScDrawTransferObj::SetDragWasInternal()
710cdf0e10cSrcweir {
711cdf0e10cSrcweir     bDragWasInternal = sal_True;
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
GetSingleObject()714cdf0e10cSrcweir SdrOle2Obj* ScDrawTransferObj::GetSingleObject()
715cdf0e10cSrcweir {
716cdf0e10cSrcweir     //  if single OLE object was copied, get its object
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     SdrPage* pPage = pModel->GetPage(0);
719cdf0e10cSrcweir     if (pPage)
720cdf0e10cSrcweir     {
721cdf0e10cSrcweir         SdrObjListIter aIter( *pPage, IM_FLAT );
722cdf0e10cSrcweir         SdrObject* pObject = aIter.Next();
723cdf0e10cSrcweir         if (pObject && pObject->GetObjIdentifier() == OBJ_OLE2)
724cdf0e10cSrcweir         {
725cdf0e10cSrcweir             return (SdrOle2Obj*) pObject;
726cdf0e10cSrcweir         }
727cdf0e10cSrcweir     }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     return NULL;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir //
733cdf0e10cSrcweir //  initialize aDocShellRef with a live document from the ClipDoc
734cdf0e10cSrcweir //
735cdf0e10cSrcweir 
InitDocShell()736cdf0e10cSrcweir void ScDrawTransferObj::InitDocShell()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir     if ( !aDocShellRef.Is() )
739cdf0e10cSrcweir     {
740cdf0e10cSrcweir         ScDocShell* pDocSh = new ScDocShell;
741cdf0e10cSrcweir         aDocShellRef = pDocSh;      // ref must be there before InitNew
742cdf0e10cSrcweir 
743cdf0e10cSrcweir         pDocSh->DoInitNew(NULL);
744cdf0e10cSrcweir 
745cdf0e10cSrcweir         ScDocument* pDestDoc = pDocSh->GetDocument();
746cdf0e10cSrcweir         pDestDoc->InitDrawLayer( pDocSh );
747cdf0e10cSrcweir 
748cdf0e10cSrcweir         SdrModel* pDestModel = pDestDoc->GetDrawLayer();
749cdf0e10cSrcweir 		// #i71538# use complete SdrViews
750cdf0e10cSrcweir         // SdrExchangeView aDestView( pDestModel );
751cdf0e10cSrcweir         SdrView aDestView( pDestModel );
752cdf0e10cSrcweir         aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0));
753cdf0e10cSrcweir         aDestView.Paste( *pModel, Point( aSrcSize.Width()/2, aSrcSize.Height()/2 ) );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir         // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING)
756cdf0e10cSrcweir 
757cdf0e10cSrcweir         SdrPage* pPage = pDestModel->GetPage(0);
758cdf0e10cSrcweir         if (pPage)
759cdf0e10cSrcweir         {
760cdf0e10cSrcweir             SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
761cdf0e10cSrcweir             SdrObject* pObject = aIter.Next();
762cdf0e10cSrcweir             while (pObject)
763cdf0e10cSrcweir             {
764cdf0e10cSrcweir                 if ( pObject->ISA(SdrUnoObj) )
765cdf0e10cSrcweir                     pObject->NbcSetLayer(SC_LAYER_CONTROLS);
766cdf0e10cSrcweir                 else
767cdf0e10cSrcweir                     pObject->NbcSetLayer(SC_LAYER_FRONT);
768cdf0e10cSrcweir                 pObject = aIter.Next();
769cdf0e10cSrcweir             }
770cdf0e10cSrcweir         }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir         Point aTmpPoint;
773cdf0e10cSrcweir         Rectangle aDestArea( aTmpPoint, aSrcSize );
774cdf0e10cSrcweir         pDocSh->SetVisArea( aDestArea );
775cdf0e10cSrcweir 
776cdf0e10cSrcweir         ScViewOptions aViewOpt( pDestDoc->GetViewOptions() );
777cdf0e10cSrcweir         aViewOpt.SetOption( VOPT_GRID, sal_False );
778cdf0e10cSrcweir         pDestDoc->SetViewOptions( aViewOpt );
779cdf0e10cSrcweir 
780cdf0e10cSrcweir         ScViewData aViewData( pDocSh, NULL );
781cdf0e10cSrcweir         aViewData.SetTabNo( 0 );
782cdf0e10cSrcweir         aViewData.SetScreen( aDestArea );
783cdf0e10cSrcweir         aViewData.SetCurX( 0 );
784cdf0e10cSrcweir         aViewData.SetCurY( 0 );
785cdf0e10cSrcweir         pDocSh->UpdateOle(&aViewData, sal_True);
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
getUnoTunnelId()789cdf0e10cSrcweir const com::sun::star::uno::Sequence< sal_Int8 >& ScDrawTransferObj::getUnoTunnelId()
790cdf0e10cSrcweir {
791cdf0e10cSrcweir     static com::sun::star::uno::Sequence< sal_Int8 > aSeq;
792cdf0e10cSrcweir     if( !aSeq.getLength() )
793cdf0e10cSrcweir     {
794cdf0e10cSrcweir         static osl::Mutex           aCreateMutex;
795cdf0e10cSrcweir         osl::Guard< osl::Mutex >    aGuard( aCreateMutex );
796cdf0e10cSrcweir         aSeq.realloc( 16 );
797cdf0e10cSrcweir         rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
798cdf0e10cSrcweir     }
799cdf0e10cSrcweir     return aSeq;
800cdf0e10cSrcweir }
801cdf0e10cSrcweir 
getSomething(const com::sun::star::uno::Sequence<sal_Int8> & rId)802cdf0e10cSrcweir sal_Int64 SAL_CALL ScDrawTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException )
803cdf0e10cSrcweir {
804cdf0e10cSrcweir     sal_Int64 nRet;
805cdf0e10cSrcweir     if( ( rId.getLength() == 16 ) &&
806cdf0e10cSrcweir         ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
807cdf0e10cSrcweir     {
808cdf0e10cSrcweir         nRet = reinterpret_cast< sal_Int64 >( this );
809cdf0e10cSrcweir     }
810cdf0e10cSrcweir     else
811cdf0e10cSrcweir         nRet = TransferableHelper::getSomething(rId);
812cdf0e10cSrcweir     return nRet;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 
816