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