Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/mutex.hxx>
30 : : #include <unotools/ucbstreamhelper.hxx>
31 : : #include <sot/exchange.hxx>
32 : : #include <sot/storage.hxx>
33 : : #include <vcl/bitmap.hxx>
34 : : #include <vcl/gdimtf.hxx>
35 : : #include <vcl/graph.hxx>
36 : : #include <vcl/svapp.hxx>
37 : : #include <vcl/window.hxx>
38 : : #include <comphelper/processfactory.hxx>
39 : : #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
40 : : #include "svl/urlbmk.hxx"
41 : : #include <svtools/inetimg.hxx>
42 : : #include <svtools/imap.hxx>
43 : : #include <svtools/transfer.hxx>
44 : :
45 : : // --------------
46 : : // - Namespaces -
47 : : // --------------
48 : :
49 : : using namespace ::com::sun::star::uno;
50 : : using namespace ::com::sun::star::lang;
51 : : using namespace ::com::sun::star::io;
52 : : using namespace ::com::sun::star::datatransfer;
53 : : using namespace ::com::sun::star::datatransfer::clipboard;
54 : : using namespace ::com::sun::star::datatransfer::dnd;
55 : :
56 : : // -----------------------------------------
57 : : // - DragSourceHelper::DragGestureListener -
58 : : // -----------------------------------------
59 : :
60 : 2392 : DragSourceHelper::DragGestureListener::DragGestureListener( DragSourceHelper& rDragSourceHelper ) :
61 : 2392 : mrParent( rDragSourceHelper )
62 : : {
63 : 2392 : }
64 : :
65 : : // -----------------------------------------------------------------------------
66 : :
67 : 2293 : DragSourceHelper::DragGestureListener::~DragGestureListener()
68 : : {
69 [ - + ]: 4586 : }
70 : :
71 : : // -----------------------------------------------------------------------------
72 : :
73 : 0 : void SAL_CALL DragSourceHelper::DragGestureListener::disposing( const EventObject& ) throw( RuntimeException )
74 : : {
75 : 0 : }
76 : :
77 : : // -----------------------------------------------------------------------------
78 : :
79 : 0 : void SAL_CALL DragSourceHelper::DragGestureListener::dragGestureRecognized( const DragGestureEvent& rDGE ) throw( RuntimeException )
80 : : {
81 [ # # ]: 0 : const SolarMutexGuard aGuard;
82 : :
83 : 0 : const Point aPtPixel( rDGE.DragOriginX, rDGE.DragOriginY );
84 [ # # ][ # # ]: 0 : mrParent.StartDrag( rDGE.DragAction, aPtPixel );
85 : 0 : }
86 : :
87 : : // --------------------
88 : : // - DragSourceHelper -
89 : : // --------------------
90 : :
91 : 2392 : DragSourceHelper::DragSourceHelper( Window* pWindow ) :
92 : 2392 : mxDragGestureRecognizer( pWindow->GetDragGestureRecognizer() )
93 : : {
94 [ + - ]: 2392 : if( mxDragGestureRecognizer.is() )
95 : : {
96 [ + - ][ + - ]: 2392 : mxDragGestureListener = new DragSourceHelper::DragGestureListener( *this );
[ + - ]
97 [ + - ][ + - ]: 2392 : mxDragGestureRecognizer->addDragGestureListener( mxDragGestureListener );
98 : : }
99 : 2392 : }
100 : :
101 : : // -----------------------------------------------------------------------------
102 : :
103 : 2293 : DragSourceHelper::~DragSourceHelper()
104 : : {
105 [ + - ]: 2293 : if( mxDragGestureRecognizer.is() )
106 [ + - ][ + - ]: 2293 : mxDragGestureRecognizer->removeDragGestureListener( mxDragGestureListener );
107 [ - + ]: 2293 : }
108 : :
109 : : // -----------------------------------------------------------------------------
110 : :
111 : 0 : void DragSourceHelper::StartDrag( sal_Int8, const Point& )
112 : : {
113 : 0 : }
114 : :
115 : : // ----------------------------------------
116 : : // - DropTargetHelper::DropTargetListener -
117 : : // ----------------------------------------
118 : :
119 : 2741 : DropTargetHelper::DropTargetListener::DropTargetListener( DropTargetHelper& rDropTargetHelper ) :
120 : : mrParent( rDropTargetHelper ),
121 : 2741 : mpLastDragOverEvent( NULL )
122 : : {
123 : 2741 : }
124 : :
125 : : // -----------------------------------------------------------------------------
126 : :
127 : 2646 : DropTargetHelper::DropTargetListener::~DropTargetListener()
128 : : {
129 [ - + ][ # # ]: 2646 : delete mpLastDragOverEvent;
130 [ - + ]: 5292 : }
131 : :
132 : : // -----------------------------------------------------------------------------
133 : :
134 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::disposing( const EventObject& ) throw( RuntimeException )
135 : : {
136 : 0 : }
137 : :
138 : : // -----------------------------------------------------------------------------
139 : :
140 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::drop( const DropTargetDropEvent& rDTDE ) throw( RuntimeException )
141 : : {
142 [ # # ]: 0 : const SolarMutexGuard aGuard;
143 : :
144 : : try
145 : : {
146 [ # # ]: 0 : AcceptDropEvent aAcceptEvent;
147 [ # # ]: 0 : ExecuteDropEvent aExecuteEvt( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
148 : 0 : sal_Int8 nRet = DNDConstants::ACTION_NONE;
149 : :
150 : 0 : aExecuteEvt.mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
151 : :
152 : : // in case of a default action, call ::AcceptDrop first and use the returned
153 : : // accepted action as the execute action in the call to ::ExecuteDrop
154 : 0 : aAcceptEvent.mnAction = aExecuteEvt.mnAction;
155 : 0 : aAcceptEvent.maPosPixel = aExecuteEvt.maPosPixel;
156 [ # # ]: 0 : (DropTargetEvent&)( aAcceptEvent.maDragEvent ) = (DropTargetEvent&) rDTDE;
157 : 0 : ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).DropAction = rDTDE.DropAction;
158 : 0 : ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationX = rDTDE.LocationX;
159 : 0 : ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationY = rDTDE.LocationY;
160 : 0 : ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).SourceActions = rDTDE.SourceActions;
161 : 0 : aAcceptEvent.mbLeaving = sal_False;
162 : 0 : aAcceptEvent.mbDefault = aExecuteEvt.mbDefault;
163 : :
164 [ # # ]: 0 : nRet = mrParent.AcceptDrop( aAcceptEvent );
165 : :
166 [ # # ]: 0 : if( DNDConstants::ACTION_NONE != nRet )
167 : : {
168 [ # # ][ # # ]: 0 : rDTDE.Context->acceptDrop( nRet );
169 : :
170 [ # # ]: 0 : if( aExecuteEvt.mbDefault )
171 : 0 : aExecuteEvt.mnAction = nRet;
172 : :
173 [ # # ]: 0 : nRet = mrParent.ExecuteDrop( aExecuteEvt );
174 : : }
175 : :
176 [ # # ][ # # ]: 0 : rDTDE.Context->dropComplete( DNDConstants::ACTION_NONE != nRet );
177 : :
178 [ # # ]: 0 : if( mpLastDragOverEvent )
179 : : {
180 [ # # ][ # # ]: 0 : delete mpLastDragOverEvent;
181 : 0 : mpLastDragOverEvent = NULL;
182 [ # # ][ # # ]: 0 : }
[ # # ]
183 : : }
184 [ # # ]: 0 : catch( const ::com::sun::star::uno::Exception& )
185 : : {
186 [ # # ]: 0 : }
187 : 0 : }
188 : :
189 : : // -----------------------------------------------------------------------------
190 : :
191 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragEnter( const DropTargetDragEnterEvent& rDTDEE ) throw( RuntimeException )
192 : : {
193 [ # # ]: 0 : const SolarMutexGuard aGuard;
194 : :
195 : : try
196 : : {
197 [ # # ]: 0 : mrParent.ImplBeginDrag( rDTDEE.SupportedDataFlavors );
198 : : }
199 [ # # ]: 0 : catch( const ::com::sun::star::uno::Exception& )
200 : : {
201 : : }
202 : :
203 [ # # ][ # # ]: 0 : dragOver( rDTDEE );
204 [ # # ]: 0 : }
205 : :
206 : : // -----------------------------------------------------------------------------
207 : :
208 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragOver( const DropTargetDragEvent& rDTDE ) throw( RuntimeException )
209 : : {
210 [ # # ]: 0 : const SolarMutexGuard aGuard;
211 : :
212 : : try
213 : : {
214 [ # # ]: 0 : if( mpLastDragOverEvent )
215 [ # # ][ # # ]: 0 : delete mpLastDragOverEvent;
216 : :
217 [ # # ]: 0 : mpLastDragOverEvent = new AcceptDropEvent( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
[ # # # # ]
218 : 0 : mpLastDragOverEvent->mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
219 : :
220 [ # # ]: 0 : const sal_Int8 nRet = mrParent.AcceptDrop( *mpLastDragOverEvent );
221 : :
222 [ # # ]: 0 : if( DNDConstants::ACTION_NONE == nRet )
223 [ # # ][ # # ]: 0 : rDTDE.Context->rejectDrag();
224 : : else
225 [ # # ][ # # ]: 0 : rDTDE.Context->acceptDrag( nRet );
226 : : }
227 [ # # ]: 0 : catch( const ::com::sun::star::uno::Exception& )
228 : : {
229 [ # # ]: 0 : }
230 : 0 : }
231 : :
232 : : // -----------------------------------------------------------------------------
233 : :
234 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragExit( const DropTargetEvent& ) throw( RuntimeException )
235 : : {
236 [ # # ]: 0 : const SolarMutexGuard aGuard;
237 : :
238 : : try
239 : : {
240 [ # # ]: 0 : if( mpLastDragOverEvent )
241 : : {
242 : 0 : mpLastDragOverEvent->mbLeaving = sal_True;
243 [ # # ]: 0 : mrParent.AcceptDrop( *mpLastDragOverEvent );
244 [ # # ][ # # ]: 0 : delete mpLastDragOverEvent;
245 : 0 : mpLastDragOverEvent = NULL;
246 : : }
247 : :
248 [ # # ]: 0 : mrParent.ImplEndDrag();
249 : : }
250 [ # # ]: 0 : catch( const ::com::sun::star::uno::Exception& )
251 : : {
252 [ # # ]: 0 : }
253 [ # # ]: 0 : }
254 : :
255 : :
256 : : // -----------------------------------------------------------------------------
257 : :
258 : 0 : void SAL_CALL DropTargetHelper::DropTargetListener::dropActionChanged( const DropTargetDragEvent& ) throw( RuntimeException )
259 : : {
260 : 0 : }
261 : :
262 : : // --------------------
263 : : // - DropTargetHelper -
264 : : // --------------------
265 : :
266 : 2707 : DropTargetHelper::DropTargetHelper( Window* pWindow ) :
267 : 2707 : mxDropTarget( pWindow->GetDropTarget() ),
268 [ + - ][ + - ]: 2707 : mpFormats( new DataFlavorExVector )
[ + - ]
269 : : {
270 [ + - ]: 2707 : ImplConstruct();
271 : 2707 : }
272 : :
273 : : // -----------------------------------------------------------------------------
274 : :
275 : 34 : DropTargetHelper::DropTargetHelper( const Reference< XDropTarget >& rxDropTarget ) :
276 : : mxDropTarget( rxDropTarget ),
277 [ + - ][ + - ]: 34 : mpFormats( new DataFlavorExVector )
278 : : {
279 [ + - ]: 34 : ImplConstruct();
280 : 34 : }
281 : :
282 : : // -----------------------------------------------------------------------------
283 : :
284 : 2646 : DropTargetHelper::~DropTargetHelper()
285 : : {
286 [ + - ]: 2646 : if( mxDropTarget.is() )
287 [ + - ][ + - ]: 2646 : mxDropTarget->removeDropTargetListener( mxDropTargetListener );
288 : :
289 [ + - ]: 2646 : delete mpFormats;
290 [ - + ]: 2646 : }
291 : :
292 : : // -----------------------------------------------------------------------------
293 : :
294 : 2741 : void DropTargetHelper::ImplConstruct()
295 : : {
296 [ + - ]: 2741 : if( mxDropTarget.is() )
297 : : {
298 [ + - ][ + - ]: 2741 : mxDropTargetListener = new DropTargetHelper::DropTargetListener( *this );
299 : 2741 : mxDropTarget->addDropTargetListener( mxDropTargetListener );
300 : 2741 : mxDropTarget->setActive( sal_True );
301 : : }
302 : 2741 : }
303 : :
304 : : // -----------------------------------------------------------------------------
305 : :
306 : 0 : void DropTargetHelper::ImplBeginDrag( const Sequence< DataFlavor >& rSupportedDataFlavors )
307 : : {
308 : 0 : mpFormats->clear();
309 : 0 : TransferableDataHelper::FillDataFlavorExVector( rSupportedDataFlavors, *mpFormats );
310 : 0 : }
311 : :
312 : : // -----------------------------------------------------------------------------
313 : :
314 : 0 : void DropTargetHelper::ImplEndDrag()
315 : : {
316 : 0 : mpFormats->clear();
317 : 0 : }
318 : :
319 : : // -----------------------------------------------------------------------------
320 : :
321 : 0 : sal_Int8 DropTargetHelper::AcceptDrop( const AcceptDropEvent& )
322 : : {
323 : 0 : return( DNDConstants::ACTION_NONE );
324 : : }
325 : :
326 : : // -----------------------------------------------------------------------------
327 : :
328 : 0 : sal_Int8 DropTargetHelper::ExecuteDrop( const ExecuteDropEvent& )
329 : : {
330 : 0 : return( DNDConstants::ACTION_NONE );
331 : : }
332 : :
333 : : // -----------------------------------------------------------------------------
334 : :
335 : 0 : sal_Bool DropTargetHelper::IsDropFormatSupported( SotFormatStringId nFormat )
336 : : {
337 : 0 : DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
338 : 0 : sal_Bool bRet = sal_False;
339 : :
340 [ # # ][ # # ]: 0 : while( aIter != aEnd )
341 : : {
342 [ # # ][ # # ]: 0 : if( nFormat == (*aIter++).mnSotId )
343 : : {
344 : 0 : bRet = sal_True;
345 : 0 : aIter = aEnd;
346 : : }
347 : : }
348 : :
349 : 0 : return bRet;
350 : : }
351 : :
352 : : // -----------------------------------------------------------------------------
353 : :
354 : 0 : sal_Bool DropTargetHelper::IsDropFormatSupported( const DataFlavor& rFlavor )
355 : : {
356 : 0 : DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
357 : 0 : sal_Bool bRet = sal_False;
358 : :
359 [ # # ][ # # ]: 0 : while( aIter != aEnd )
360 : : {
361 [ # # ][ # # ]: 0 : if( TransferableDataHelper::IsEqual( rFlavor, *aIter++ ) )
[ # # ]
362 : : {
363 : 0 : bRet = sal_True;
364 : 0 : aIter = aEnd;
365 : : }
366 : : }
367 : :
368 : 0 : return bRet;
369 : : }
370 : :
371 : : // -----------------------------------------------------------------------------
372 : : // TransferDataContainer
373 : : // -----------------------------------------------------------------------------
374 : :
375 : 0 : struct TDataCntnrEntry_Impl
376 : : {
377 : : ::com::sun::star::uno::Any aAny;
378 : : SotFormatStringId nId;
379 : : };
380 : :
381 : : // -----------------------------------------------------------------------------
382 : :
383 : : typedef ::std::list< TDataCntnrEntry_Impl > TDataCntnrEntryList;
384 : :
385 : : // -----------------------------------------------------------------------------
386 : :
387 : : struct TransferDataContainer_Impl
388 : : {
389 : : TDataCntnrEntryList aFmtList;
390 : : Link aFinshedLnk;
391 : : INetBookmark* pBookmk;
392 : : Graphic* pGrf;
393 : :
394 : 0 : TransferDataContainer_Impl()
395 [ # # ]: 0 : : pBookmk( 0 ), pGrf( 0 )
396 : : {
397 : 0 : }
398 : :
399 : 0 : ~TransferDataContainer_Impl()
400 : 0 : {
401 [ # # ][ # # ]: 0 : delete pBookmk;
402 [ # # ][ # # ]: 0 : delete pGrf;
403 : 0 : }
404 : : };
405 : :
406 : : // -----------------------------------------------------------------------------
407 : :
408 : 0 : TransferDataContainer::TransferDataContainer()
409 [ # # ][ # # ]: 0 : : pImpl( new TransferDataContainer_Impl )
410 : : {
411 : 0 : }
412 : :
413 : : // -----------------------------------------------------------------------------
414 : :
415 : 0 : TransferDataContainer::~TransferDataContainer()
416 : : {
417 [ # # ][ # # ]: 0 : delete pImpl;
418 [ # # ]: 0 : }
419 : :
420 : : // -----------------------------------------------------------------------------
421 : :
422 : 0 : void TransferDataContainer::AddSupportedFormats()
423 : : {
424 : 0 : }
425 : :
426 : : // -----------------------------------------------------------------------------
427 : :
428 : 0 : sal_Bool TransferDataContainer::GetData( const
429 : : ::com::sun::star::datatransfer::DataFlavor& rFlavor )
430 : : {
431 : 0 : TDataCntnrEntryList::iterator aIter( pImpl->aFmtList.begin() ),
432 : 0 : aEnd( pImpl->aFmtList.end() );
433 : 0 : sal_Bool bFnd = sal_False;
434 [ # # ]: 0 : sal_uLong nFmtId = SotExchange::GetFormat( rFlavor );
435 : :
436 : : // test first the list
437 [ # # ]: 0 : for( ; aIter != aEnd; ++aIter )
438 : : {
439 : 0 : TDataCntnrEntry_Impl& rEntry = (TDataCntnrEntry_Impl&)*aIter;
440 [ # # ]: 0 : if( nFmtId == rEntry.nId )
441 : : {
442 [ # # ]: 0 : bFnd = SetAny( rEntry.aAny, rFlavor );
443 : 0 : break;
444 : : }
445 : : }
446 : :
447 : : // test second the bookmark pointer
448 [ # # ]: 0 : if( !bFnd )
449 [ # # # ]: 0 : switch( nFmtId )
450 : : {
451 : : case SOT_FORMAT_STRING:
452 : : case SOT_FORMATSTR_ID_SOLK:
453 : : case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
454 : : case SOT_FORMATSTR_ID_FILECONTENT:
455 : : case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
456 : : case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
457 [ # # ]: 0 : if( pImpl->pBookmk )
458 [ # # ]: 0 : bFnd = SetINetBookmark( *pImpl->pBookmk, rFlavor );
459 : 0 : break;
460 : :
461 : : case SOT_FORMATSTR_ID_SVXB:
462 : : case SOT_FORMAT_BITMAP:
463 : : case SOT_FORMAT_GDIMETAFILE:
464 [ # # ]: 0 : if( pImpl->pGrf )
465 [ # # ]: 0 : bFnd = SetGraphic( *pImpl->pGrf, rFlavor );
466 : 0 : break;
467 : : }
468 : :
469 : 0 : return bFnd;
470 : : }
471 : :
472 : : // -----------------------------------------------------------------------------
473 : :
474 : 0 : void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk )
475 : : {
476 [ # # ]: 0 : if( !pImpl->pBookmk )
477 [ # # ]: 0 : pImpl->pBookmk = new INetBookmark( rBkmk );
478 : : else
479 : 0 : *pImpl->pBookmk = rBkmk;
480 : :
481 : 0 : AddFormat( SOT_FORMAT_STRING );
482 : 0 : AddFormat( SOT_FORMATSTR_ID_SOLK );
483 : 0 : AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
484 : 0 : AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
485 : 0 : AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
486 : 0 : AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
487 : 0 : }
488 : :
489 : : // -----------------------------------------------------------------------------
490 : :
491 : 0 : void TransferDataContainer::CopyAnyData( sal_uLong nFormatId,
492 : : const sal_Char* pData, sal_uLong nLen )
493 : : {
494 [ # # ]: 0 : if( nLen )
495 : : {
496 : 0 : TDataCntnrEntry_Impl aEntry;
497 : 0 : aEntry.nId = nFormatId;
498 : :
499 [ # # ]: 0 : Sequence< sal_Int8 > aSeq( nLen );
500 [ # # ]: 0 : memcpy( aSeq.getArray(), pData, nLen );
501 [ # # ]: 0 : aEntry.aAny <<= aSeq;
502 [ # # ]: 0 : pImpl->aFmtList.push_back( aEntry );
503 [ # # ][ # # ]: 0 : AddFormat( nFormatId );
504 : : }
505 : 0 : }
506 : :
507 : : // -----------------------------------------------------------------------------
508 : :
509 : 0 : void TransferDataContainer::CopyByteString( sal_uLong nFormatId,
510 : : const rtl::OString& rStr )
511 : : {
512 : 0 : CopyAnyData( nFormatId, rStr.getStr(), rStr.getLength() );
513 : 0 : }
514 : :
515 : : // -----------------------------------------------------------------------------
516 : :
517 : 0 : void TransferDataContainer::CopyINetImage( const INetImage& rINtImg )
518 : : {
519 [ # # ]: 0 : SvMemoryStream aMemStm( 1024, 1024 );
520 : 0 : aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
521 [ # # ]: 0 : rINtImg.Write( aMemStm, SOT_FORMATSTR_ID_INET_IMAGE );
522 [ # # ]: 0 : CopyAnyData( SOT_FORMATSTR_ID_INET_IMAGE, (sal_Char*)aMemStm.GetData(),
523 [ # # ][ # # ]: 0 : aMemStm.Seek( STREAM_SEEK_TO_END ) );
[ # # ]
524 : 0 : }
525 : :
526 : : // -----------------------------------------------------------------------------
527 : :
528 : 0 : void TransferDataContainer::CopyImageMap( const ImageMap& rImgMap )
529 : : {
530 [ # # ]: 0 : SvMemoryStream aMemStm( 8192, 8192 );
531 : 0 : aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
532 [ # # ][ # # ]: 0 : rImgMap.Write( aMemStm, String() );
[ # # ]
533 [ # # ]: 0 : CopyAnyData( SOT_FORMATSTR_ID_SVIM, (sal_Char*)aMemStm.GetData(),
534 [ # # ][ # # ]: 0 : aMemStm.Seek( STREAM_SEEK_TO_END ) );
[ # # ]
535 : 0 : }
536 : :
537 : : // -----------------------------------------------------------------------------
538 : :
539 : 0 : void TransferDataContainer::CopyGraphic( const Graphic& rGrf )
540 : : {
541 : 0 : GraphicType nType = rGrf.GetType();
542 [ # # ]: 0 : if( GRAPHIC_NONE != nType )
543 : : {
544 [ # # ]: 0 : if( !pImpl->pGrf )
545 [ # # ]: 0 : pImpl->pGrf = new Graphic( rGrf );
546 : : else
547 : 0 : *pImpl->pGrf = rGrf;
548 : :
549 : 0 : AddFormat( SOT_FORMATSTR_ID_SVXB );
550 [ # # ]: 0 : if( GRAPHIC_BITMAP == nType )
551 : 0 : AddFormat( SOT_FORMAT_BITMAP );
552 [ # # ]: 0 : else if( GRAPHIC_GDIMETAFILE == nType )
553 : 0 : AddFormat( SOT_FORMAT_GDIMETAFILE );
554 : : }
555 : 0 : }
556 : :
557 : : // -----------------------------------------------------------------------------
558 : :
559 : 0 : void TransferDataContainer::CopyString( sal_uInt16 nFmt, const String& rStr )
560 : : {
561 [ # # ]: 0 : if( rStr.Len() )
562 : : {
563 : 0 : TDataCntnrEntry_Impl aEntry;
564 : 0 : aEntry.nId = nFmt;
565 [ # # ]: 0 : rtl::OUString aStr( rStr );
566 [ # # ]: 0 : aEntry.aAny <<= aStr;
567 [ # # ]: 0 : pImpl->aFmtList.push_back( aEntry );
568 [ # # ]: 0 : AddFormat( aEntry.nId );
569 : : }
570 : 0 : }
571 : :
572 : : // -----------------------------------------------------------------------------
573 : :
574 : 0 : void TransferDataContainer::CopyString( const String& rStr )
575 : : {
576 : 0 : CopyString( SOT_FORMAT_STRING, rStr );
577 : 0 : }
578 : :
579 : : // -----------------------------------------------------------------------------
580 : :
581 : 0 : void TransferDataContainer::CopyAny( sal_uInt16 nFmt,
582 : : const ::com::sun::star::uno::Any& rAny )
583 : : {
584 : 0 : TDataCntnrEntry_Impl aEntry;
585 : 0 : aEntry.nId = nFmt;
586 : 0 : aEntry.aAny = rAny;
587 [ # # ]: 0 : pImpl->aFmtList.push_back( aEntry );
588 [ # # ]: 0 : AddFormat( aEntry.nId );
589 : 0 : }
590 : :
591 : : // -----------------------------------------------------------------------------
592 : :
593 : 0 : sal_Bool TransferDataContainer::HasAnyData() const
594 : : {
595 [ # # ][ # # ]: 0 : return pImpl->aFmtList.begin() != pImpl->aFmtList.end() ||
596 [ # # ][ # # ]: 0 : 0 != pImpl->pBookmk;
597 : : }
598 : :
599 : : // -----------------------------------------------------------------------------
600 : :
601 : 0 : void TransferDataContainer::StartDrag(
602 : : Window* pWindow, sal_Int8 nDragSourceActions,
603 : : const Link& rLnk, sal_Int32 nDragPointer, sal_Int32 nDragImage )
604 : : {
605 : 0 : pImpl->aFinshedLnk = rLnk;
606 : : TransferableHelper::StartDrag( pWindow, nDragSourceActions,
607 : 0 : nDragPointer, nDragImage );
608 : 0 : }
609 : :
610 : : // -----------------------------------------------------------------------------
611 : :
612 : 0 : void TransferDataContainer::DragFinished( sal_Int8 nDropAction )
613 : : {
614 [ # # ]: 0 : if( pImpl->aFinshedLnk.IsSet() )
615 : 0 : pImpl->aFinshedLnk.Call( &nDropAction );
616 : 0 : }
617 : :
618 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|