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