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