update dev300-m58
[ooovba.git] / dtrans / source / aqua / DragSource.hxx
blob4c06f327582bc9ba6812ed8ab34d8957d5c558f6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DragSource.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DRAGSOURCE_HXX_
32 #define _DRAGSOURCE_HXX_
34 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
35 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <cppuhelper/compbase3.hxx>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <cppuhelper/basemutex.hxx>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #include <osl/thread.h>
42 #include <com/sun/star/awt/MouseEvent.hpp>
44 #include <boost/utility.hpp>
46 #include <premac.h>
47 #import <Cocoa/Cocoa.h>
48 #include <postmac.h>
51 class DragSource;
53 /* The functions declared in this protocol are actually
54 declared in vcl/aqua/inc/salframe.h. Because we want
55 to avoid importing VCL headers in UNO services and
56 on the other hand want to avoid warnings caused by
57 gcc complaining about unknowness of these functions
58 we declare them in a protocol here and cast at the
59 appropriate places.
61 @protocol MouseEventListener
62 -(void)registerMouseEventListener:(id)theHandler;
63 -(void)unregisterMouseEventListener:(id)theHandler;
64 @end
67 @interface DragSourceHelper : NSObject
69 DragSource* mDragSource;
72 -(DragSourceHelper*)initWithDragSource: (DragSource*) pds;
74 -(void)mouseDown: (NSEvent*)theEvent;
75 -(void)mouseDragged: (NSEvent*)theEvent;
77 -(unsigned int)draggingSourceOperationMaskForLocal:(MacOSBOOL)isLocal;
78 -(void)draggedImage:(NSImage*)anImage beganAt:(NSPoint)aPoint;
79 -(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
80 -(void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint;
82 @end
85 class DragSource : public ::cppu::BaseMutex,
86 public ::cppu::WeakComponentImplHelper3< com::sun::star::datatransfer::dnd::XDragSource,
87 com::sun::star::lang::XInitialization,
88 com::sun::star::lang::XServiceInfo >,
89 private ::boost::noncopyable
91 public:
92 DragSource(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext>& context);
93 virtual ~DragSource();
95 // XInitialization
96 virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
97 throw(com::sun::star::uno::Exception/*, com::sun::star::uno::RuntimeException*/);
99 // XDragSource
100 virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(com::sun::star::uno::RuntimeException);
102 virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction)
103 throw(com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
105 virtual void SAL_CALL startDrag( const com::sun::star::datatransfer::dnd::DragGestureEvent& trigger,
106 sal_Int8 sourceActions,
107 sal_Int32 cursor,
108 sal_Int32 image,
109 const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& transferable,
110 const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceListener >& listener )
111 throw(com::sun::star::uno::RuntimeException);
113 // XServiceInfo
114 virtual rtl::OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException);
115 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw (com::sun::star::uno::RuntimeException);
116 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
118 virtual void saveMouseEvent(NSEvent* theEvent);
119 virtual unsigned int getSupportedDragOperations(bool isLocal) const;
121 public:
122 com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> mXComponentContext;
124 // The context notifies the XDragSourceListeners
125 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceContext > mXCurrentContext;
127 id mView;
128 NSEvent* mLastMouseEventBeforeStartDrag;
129 DragSourceHelper* mDragSourceHelper;
130 com::sun::star::awt::MouseEvent mMouseEvent;
131 com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > mXTransferable;
132 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceListener > mXDragSrcListener;
133 // The mouse button that set off the drag and drop operation
134 short m_MouseButton;
135 sal_Int8 mDragSourceActions;
137 static com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > g_XTransferable;
138 static NSView* g_DragSourceView;
139 static bool g_DropSuccessSet;
140 static bool g_DropSuccess;
145 #endif