Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _TRANSFER_HXX
21 : #define _TRANSFER_HXX
22 :
23 : #include "svtools/svtdllapi.h"
24 : #include <tools/globname.hxx>
25 : #include <tools/gen.hxx>
26 : #include <sot/formats.hxx>
27 : #include <cppuhelper/implbase1.hxx>
28 : #include <cppuhelper/implbase4.hxx>
29 : #include <com/sun/star/frame/XTerminateListener.hpp>
30 : #include <com/sun/star/lang/XUnoTunnel.hpp>
31 : #include <com/sun/star/datatransfer/XTransferable.hpp>
32 : #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
33 : #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
34 : #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
35 : #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
36 : #include <com/sun/star/datatransfer/dnd/DropTargetDragEvent.hpp>
37 : #include <com/sun/star/datatransfer/dnd/DropTargetDropEvent.hpp>
38 : #include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp>
39 : #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
40 : #include <com/sun/star/io/XInputStream.hpp>
41 :
42 : // ------------------------
43 : // - Forward declarations -
44 : // ------------------------
45 :
46 : class Bitmap;
47 : class GDIMetaFile;
48 : class Graphic;
49 : class ImageMap;
50 : class SotStorageStreamRef;
51 : class INetBookmark;
52 : class INetImage;
53 : class FileList;
54 : class Window;
55 : class Link;
56 :
57 : // ---------------------
58 : // - Drag&Drop defines -
59 : // ---------------------
60 :
61 : #define DND_ACTION_NONE ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_NONE
62 : #define DND_ACTION_COPY ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_COPY
63 : #define DND_ACTION_MOVE ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_MOVE
64 : #define DND_ACTION_COPYMOVE ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE
65 : #define DND_ACTION_LINK ::com::sun::star::datatransfer::dnd::DNDConstants::ACTION_LINK
66 :
67 : #define DND_POINTER_NONE 0
68 : #define DND_IMAGE_NONE 0
69 :
70 : // --------------------------------
71 : // - TransferableObjectDescriptor -
72 : // --------------------------------
73 :
74 0 : struct TransferableObjectDescriptor
75 : {
76 : SvGlobalName maClassName;
77 : sal_uInt16 mnViewAspect;
78 : Point maDragStartPos;
79 : Size maSize;
80 : sal_uInt32 mnOle2Misc;
81 : String maTypeName;
82 : String maDisplayName;
83 : sal_Bool mbCanLink;
84 :
85 : SVT_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStm, TransferableObjectDescriptor& rObjDesc );
86 : SVT_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjDesc );
87 : };
88 :
89 : // -------------------
90 : // - AcceptDragEvent -
91 : // -------------------
92 :
93 0 : struct AcceptDropEvent
94 : {
95 : sal_Int8 mnAction;
96 : Point maPosPixel;
97 : const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent maDragEvent;
98 : sal_Bool mbLeaving;
99 : sal_Bool mbDefault;
100 :
101 0 : AcceptDropEvent() :
102 : mnAction( DND_ACTION_NONE ),
103 : mbLeaving( sal_False ),
104 0 : mbDefault( sal_False ) {}
105 :
106 0 : AcceptDropEvent( sal_Int8 nAction,
107 : const Point& rPosPixel,
108 : const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& rDragEvent,
109 : sal_Bool bLeaving = sal_False ) :
110 : mnAction( nAction ),
111 : maPosPixel( rPosPixel ),
112 : maDragEvent( rDragEvent ),
113 : mbLeaving( bLeaving ),
114 0 : mbDefault( sal_False ) {}
115 : };
116 :
117 : // --------------------
118 : // - ExecuteDropEvent -
119 : // --------------------
120 :
121 0 : struct ExecuteDropEvent
122 : {
123 : sal_Int8 mnAction;
124 : Point maPosPixel;
125 : const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent maDropEvent;
126 : sal_Bool mbDefault;
127 :
128 : ExecuteDropEvent() :
129 : mnAction( DND_ACTION_NONE ),
130 : mbDefault( sal_False ) {}
131 :
132 0 : ExecuteDropEvent( sal_Int8 nAction,
133 : const Point& rPosPixel,
134 : const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& rDropEvent ) :
135 : mnAction( nAction ),
136 : maPosPixel( rPosPixel ),
137 : maDropEvent( rDropEvent ),
138 0 : mbDefault( sal_False ) {}
139 : };
140 :
141 : // ----------------------
142 : // - TransferableHelper -
143 : // ----------------------
144 :
145 : class SVT_DLLPUBLIC TransferableHelper : public ::cppu::WeakImplHelper4< ::com::sun::star::datatransfer::XTransferable,
146 : ::com::sun::star::datatransfer::clipboard::XClipboardOwner,
147 : ::com::sun::star::datatransfer::dnd::XDragSourceListener,
148 : ::com::sun::star::lang::XUnoTunnel >
149 : {
150 : private:
151 :
152 : // nested class to implement the XTerminateListener interface
153 : class TerminateListener : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XTerminateListener >
154 : {
155 : private:
156 :
157 : TransferableHelper& mrParent;
158 :
159 : private:
160 :
161 : // XEventListener
162 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException );
163 :
164 : // XTerminateListener
165 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
166 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
167 :
168 : public:
169 :
170 : TerminateListener( TransferableHelper& rDropTargetHelper );
171 : virtual ~TerminateListener();
172 : };
173 :
174 : friend class TransferableHelper::TerminateListener;
175 :
176 : private:
177 :
178 : ::com::sun::star::uno::Any maAny;
179 : ::rtl::OUString maLastFormat;
180 : mutable ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxClipboard;
181 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener > mxTerminateListener;
182 : DataFlavorExVector* mpFormats;
183 : TransferableObjectDescriptor* mpObjDesc;
184 :
185 : protected:
186 : inline const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >&
187 0 : getOwnClipboard() const { return mxClipboard; }
188 :
189 : private:
190 :
191 : // XTransferable
192 : virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) throw(::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
193 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() throw(::com::sun::star::uno::RuntimeException);
194 : virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) throw(::com::sun::star::uno::RuntimeException);
195 :
196 : // XEventListener
197 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
198 :
199 : // XDragSourceListener
200 : virtual void SAL_CALL dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw(::com::sun::star::uno::RuntimeException);
201 : virtual void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw(::com::sun::star::uno::RuntimeException);
202 : virtual void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DragSourceEvent& dse ) throw(::com::sun::star::uno::RuntimeException);
203 : virtual void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw(::com::sun::star::uno::RuntimeException);
204 : virtual void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw(::com::sun::star::uno::RuntimeException);
205 :
206 : private:
207 :
208 : // XClipboardOwner
209 : virtual void SAL_CALL lostOwnership( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& xClipboard, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw(::com::sun::star::uno::RuntimeException);
210 :
211 : protected:
212 : // derivees need to access lostOwnership in case hey override it
213 : // on windows, changing the access rights to a method gives unresolved externals, so we introduce
214 : // this impl-method here 'til the next incompatible update
215 0 : inline void implCallOwnLostOwnership(
216 : const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& _rxClipboard,
217 : const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTrans
218 : )
219 : {
220 0 : TransferableHelper::lostOwnership( _rxClipboard, _rxTrans );
221 0 : }
222 :
223 :
224 : private:
225 :
226 : SVT_DLLPRIVATE void ImplFlush();
227 :
228 : protected:
229 :
230 : virtual ~TransferableHelper();
231 :
232 : void AddFormat( SotFormatStringId nFormat );
233 : void AddFormat( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
234 : void RemoveFormat( SotFormatStringId nFormat );
235 : void RemoveFormat( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
236 : sal_Bool HasFormat( SotFormatStringId nFormat );
237 : inline sal_Bool HasFormat( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) { return isDataFlavorSupported( rFlavor ); }
238 : void ClearFormats();
239 :
240 : sal_Bool SetAny( const ::com::sun::star::uno::Any& rAny, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
241 : sal_Bool SetString( const ::rtl::OUString& rString, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
242 : sal_Bool SetBitmap( const Bitmap& rBitmap, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
243 : sal_Bool SetGDIMetaFile( const GDIMetaFile& rMtf, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
244 : sal_Bool SetGraphic( const Graphic& rGraphic, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
245 : sal_Bool SetImageMap( const ImageMap& rIMap, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
246 : sal_Bool SetTransferableObjectDescriptor( const TransferableObjectDescriptor& rDesc, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
247 : sal_Bool SetINetBookmark( const INetBookmark& rBmk, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
248 : sal_Bool SetINetImage( const INetImage& rINtImg, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
249 : sal_Bool SetObject( void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
250 :
251 : protected:
252 :
253 : virtual void AddSupportedFormats() = 0;
254 : virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) = 0;
255 : virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
256 : virtual void DragFinished( sal_Int8 nDropAction );
257 : virtual void ObjectReleased();
258 :
259 : public:
260 :
261 : TransferableHelper();
262 :
263 : void PrepareOLE( const TransferableObjectDescriptor& rObjDesc );
264 :
265 : void CopyToClipboard( Window *pWindow ) const;
266 : void CopyToSelection( Window *pWindow ) const;
267 : void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
268 : sal_Int32 nDragPointer = DND_POINTER_NONE,
269 : sal_Int32 nDragImage = DND_IMAGE_NONE );
270 :
271 : static void ClearSelection( Window *pWindow );
272 :
273 : static ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > GetSystemClipboard();
274 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
275 :
276 : public:
277 :
278 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
279 : };
280 :
281 : // --------------------------
282 : // - TransferableDataHelper -
283 : // --------------------------
284 :
285 : struct TransferableDataHelper_Impl;
286 :
287 : class SVT_DLLPUBLIC TransferableDataHelper
288 : {
289 : friend class DropTargetHelper;
290 :
291 : private:
292 :
293 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > mxTransfer;
294 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxClipboard;
295 : DataFlavorExVector* mpFormats;
296 : TransferableObjectDescriptor* mpObjDesc;
297 : TransferableDataHelper_Impl* mpImpl;
298 :
299 : protected:
300 : void InitFormats();
301 :
302 : public:
303 :
304 : static void FillDataFlavorExVector( const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& rDataFlavorSeq,
305 : DataFlavorExVector& rDataFlavorExVector );
306 :
307 : TransferableDataHelper();
308 : TransferableDataHelper( const TransferableDataHelper& rDataHelper );
309 : TransferableDataHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
310 : ~TransferableDataHelper();
311 :
312 : TransferableDataHelper& operator=( const TransferableDataHelper& rDataHelper );
313 :
314 0 : const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& GetTransferable() const { return mxTransfer; }
315 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > GetXTransferable() const;
316 :
317 : sal_Bool HasFormat( SotFormatStringId nFormat ) const;
318 : sal_Bool HasFormat( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) const;
319 :
320 : sal_uInt32 GetFormatCount() const;
321 :
322 : SotFormatStringId GetFormat( sal_uInt32 nFormat ) const;
323 : ::com::sun::star::datatransfer::DataFlavor GetFormatDataFlavor( sal_uInt32 nFormat ) const;
324 :
325 0 : DataFlavorExVector& GetDataFlavorExVector() const {return *mpFormats; }
326 :
327 : sal_Bool StartClipboardListening( );
328 : void StopClipboardListening( );
329 :
330 : void Rebind( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxNewData );
331 :
332 : public:
333 :
334 : ::com::sun::star::uno::Any GetAny( SotFormatStringId nFormat ) const;
335 : ::com::sun::star::uno::Any GetAny( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) const;
336 :
337 : sal_Bool GetString( SotFormatStringId nFormat, String& rStr );
338 : sal_Bool GetString( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, String& rStr );
339 :
340 : sal_Bool GetString( SotFormatStringId nFormat, ::rtl::OUString& rStr );
341 : sal_Bool GetString( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ::rtl::OUString& rStr );
342 :
343 : sal_Bool GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp );
344 : sal_Bool GetBitmap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Bitmap& rBmp );
345 :
346 : sal_Bool GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf );
347 : sal_Bool GetGDIMetaFile( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf );
348 :
349 : sal_Bool GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic );
350 : sal_Bool GetGraphic( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Graphic& rGraphic );
351 :
352 : sal_Bool GetImageMap( SotFormatStringId nFormat, ImageMap& rIMap );
353 : sal_Bool GetImageMap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ImageMap& rImap );
354 :
355 : sal_Bool GetTransferableObjectDescriptor( SotFormatStringId nFormat, TransferableObjectDescriptor& rDesc );
356 : sal_Bool GetTransferableObjectDescriptor( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, TransferableObjectDescriptor& rDesc );
357 :
358 : sal_Bool GetINetBookmark( SotFormatStringId nFormat, INetBookmark& rBmk );
359 : sal_Bool GetINetBookmark( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, INetBookmark& rBmk );
360 :
361 : sal_Bool GetINetImage( SotFormatStringId nFormat, INetImage& rINtImg );
362 : sal_Bool GetINetImage( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, INetImage& rINtImg );
363 :
364 : sal_Bool GetFileList( SotFormatStringId nFormat, FileList& rFileList );
365 : sal_Bool GetFileList( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, FileList& rFileList );
366 :
367 : sal_Bool GetSequence( SotFormatStringId nFormat, ::com::sun::star::uno::Sequence< sal_Int8 >& rSeq );
368 : sal_Bool GetSequence( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ::com::sun::star::uno::Sequence< sal_Int8 >& rSeq );
369 :
370 : sal_Bool GetSotStorageStream( SotFormatStringId nFormat, SotStorageStreamRef& rStreamRef );
371 : sal_Bool GetSotStorageStream( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, SotStorageStreamRef& rStreamRef );
372 :
373 : sal_Bool GetInputStream( SotFormatStringId nFormat, ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xStream );
374 : sal_Bool GetInputStream( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xStream );
375 :
376 : sal_Bool GetInterface( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rIf );
377 :
378 : public:
379 :
380 : static TransferableDataHelper CreateFromSystemClipboard( Window * pWindow );
381 : static TransferableDataHelper CreateFromSelection( Window * pWindow );
382 : static sal_Bool IsEqual( const ::com::sun::star::datatransfer::DataFlavor& rInternalFlavor,
383 : const ::com::sun::star::datatransfer::DataFlavor& rRequestFlavor,
384 : sal_Bool bCompareParameters = sal_False );
385 : };
386 :
387 : // --------------------
388 : // - DragSourceHelper -
389 : // --------------------
390 :
391 : class SVT_DLLPUBLIC DragSourceHelper
392 : {
393 : private:
394 :
395 : // nested class to implement the XDragGestureListener interface
396 : class DragGestureListener : public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::dnd::XDragGestureListener >
397 : {
398 : private:
399 :
400 : DragSourceHelper& mrParent;
401 :
402 : private:
403 :
404 : // XEventListener
405 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
406 :
407 : // XDragGestureListener
408 : virtual void SAL_CALL dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& rDGE ) throw( ::com::sun::star::uno::RuntimeException );
409 :
410 : public:
411 :
412 : DragGestureListener( DragSourceHelper& rDragSourceHelper );
413 : ~DragGestureListener();
414 : };
415 :
416 : friend class DragSourceHelper::DragGestureListener;
417 :
418 : private:
419 :
420 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > mxDragGestureRecognizer;
421 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureListener > mxDragGestureListener;
422 :
423 : // not available
424 : DragSourceHelper();
425 : DragSourceHelper& operator=( const DragSourceHelper& rDragSourceHelper );
426 : sal_Bool operator==( const DragSourceHelper& rDragSourceHelper ) const;
427 :
428 : public:
429 :
430 : // to be overridden by the application
431 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
432 :
433 : DragSourceHelper( Window* pWindow );
434 : virtual ~DragSourceHelper();
435 : };
436 :
437 : // --------------------
438 : // - DropTargetHelper -
439 : // --------------------
440 :
441 : class SVT_DLLPUBLIC DropTargetHelper
442 : {
443 : private:
444 :
445 : // nested class to implement the XDropTargetListener interface
446 : class DropTargetListener : public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::dnd::XDropTargetListener >
447 : {
448 : private:
449 :
450 : DropTargetHelper& mrParent;
451 : AcceptDropEvent* mpLastDragOverEvent;
452 :
453 : private:
454 :
455 : // XEventListener
456 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
457 :
458 : // XDropTargetListener
459 : virtual void SAL_CALL drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw(::com::sun::star::uno::RuntimeException);
460 : virtual void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw(::com::sun::star::uno::RuntimeException);
461 : virtual void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw(::com::sun::star::uno::RuntimeException);
462 : virtual void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException);
463 : virtual void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException);
464 :
465 : public:
466 :
467 : DropTargetListener( DropTargetHelper& rDropTargetHelper );
468 : ~DropTargetListener();
469 : };
470 :
471 : friend class DropTargetHelper::DropTargetListener;
472 :
473 : private:
474 :
475 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > mxDropTarget;
476 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener > mxDropTargetListener;
477 : DataFlavorExVector* mpFormats;
478 :
479 : // not available
480 : DropTargetHelper();
481 : DropTargetHelper& operator=( const DropTargetHelper& rDropTargetHelper );
482 : sal_Bool operator==( const DropTargetHelper& rDropTargetHelper ) const;
483 :
484 : void ImplConstruct();
485 :
486 : // called by our own implementation of XDropTargetListener (DropTargetListener instance)
487 : void ImplBeginDrag( const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& rSupportedDataFlavors );
488 : void ImplEndDrag();
489 :
490 : public:
491 :
492 : // to be overridden by the application
493 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
494 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
495 :
496 : DropTargetHelper( Window* pWindow );
497 : DropTargetHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >& rxDropTarget );
498 :
499 : virtual ~DropTargetHelper();
500 :
501 : // typically called by the application in ::AcceptDrop and ::ExecuteDrop and (see above)
502 : sal_Bool IsDropFormatSupported( SotFormatStringId nFormat );
503 : sal_Bool IsDropFormatSupported( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
504 :
505 0 : DataFlavorExVector& GetDataFlavorExVector() const {return *mpFormats; }
506 :
507 : };
508 :
509 :
510 : //------------------------
511 : // TransferDataContainer
512 : //------------------------
513 :
514 : struct TransferDataContainer_Impl;
515 :
516 : class SVT_DLLPUBLIC TransferDataContainer : public TransferableHelper
517 : {
518 : TransferDataContainer_Impl* pImpl;
519 :
520 : protected:
521 :
522 : virtual void AddSupportedFormats();
523 : virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
524 : virtual void DragFinished( sal_Int8 nDropAction );
525 :
526 : public:
527 :
528 : TransferDataContainer();
529 : ~TransferDataContainer();
530 :
531 : void CopyINetBookmark( const INetBookmark& rBkmk );
532 : void CopyINetImage( const INetImage& rINtImg );
533 : void CopyImageMap( const ImageMap& rImgMap );
534 : void CopyGraphic( const Graphic& rGrf );
535 : void CopyString( const String& rStr );
536 : void CopyString( sal_uInt16 nFmt, const String& rStr );
537 : void CopyAny( sal_uInt16 nFmt, const ::com::sun::star::uno::Any& rAny );
538 :
539 : void CopyByteString( sal_uLong nFormatId, const rtl::OString& rStr );
540 : void CopyAnyData( sal_uLong nFormatId, const sal_Char* pData, sal_uLong nLen );
541 :
542 : sal_Bool HasAnyData() const;
543 :
544 : using TransferableHelper::StartDrag;
545 : void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
546 : const Link& rCallbck,
547 : sal_Int32 nDragPointer = DND_POINTER_NONE,
548 : sal_Int32 nDragImage = DND_IMAGE_NONE );
549 : };
550 :
551 : #endif
552 :
553 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|