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