1*0d63794cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0d63794cSAndrew Rist * distributed with this work for additional information 6*0d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0d63794cSAndrew Rist * "License"); you may not use this file except in compliance 9*0d63794cSAndrew Rist * with the License. You may obtain a copy of the License at 10*0d63794cSAndrew Rist * 11*0d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*0d63794cSAndrew Rist * 13*0d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0d63794cSAndrew Rist * software distributed under the License is distributed on an 15*0d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0d63794cSAndrew Rist * KIND, either express or implied. See the License for the 17*0d63794cSAndrew Rist * specific language governing permissions and limitations 18*0d63794cSAndrew Rist * under the License. 19*0d63794cSAndrew Rist * 20*0d63794cSAndrew Rist *************************************************************/ 21*0d63794cSAndrew Rist 22*0d63794cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DRAGSOURCE_HXX_ 25cdf0e10cSrcweir #define _DRAGSOURCE_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> 28cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 30cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 32cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 33cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 34cdf0e10cSrcweir #include <osl/thread.h> 35cdf0e10cSrcweir #include <com/sun/star/awt/MouseEvent.hpp> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <boost/utility.hpp> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <premac.h> 40cdf0e10cSrcweir #import <Cocoa/Cocoa.h> 41cdf0e10cSrcweir #include <postmac.h> 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir class DragSource; 45cdf0e10cSrcweir class AquaSalFrame; 46cdf0e10cSrcweir 47cdf0e10cSrcweir /* The functions declared in this protocol are actually 48cdf0e10cSrcweir declared in vcl/aqua/inc/salframe.h. Because we want 49cdf0e10cSrcweir to avoid importing VCL headers in UNO services and 50cdf0e10cSrcweir on the other hand want to avoid warnings caused by 51cdf0e10cSrcweir gcc complaining about unknowness of these functions 52cdf0e10cSrcweir we declare them in a protocol here and cast at the 53cdf0e10cSrcweir appropriate places. 54cdf0e10cSrcweir */ 55cdf0e10cSrcweir @protocol MouseEventListener 56cdf0e10cSrcweir -(void)registerMouseEventListener:(id)theHandler; 57cdf0e10cSrcweir -(void)unregisterMouseEventListener:(id)theHandler; 58cdf0e10cSrcweir @end 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir @interface DragSourceHelper : NSObject 62cdf0e10cSrcweir { 63cdf0e10cSrcweir DragSource* mDragSource; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir -(DragSourceHelper*)initWithDragSource: (DragSource*) pds; 67cdf0e10cSrcweir 68cdf0e10cSrcweir -(void)mouseDown: (NSEvent*)theEvent; 69cdf0e10cSrcweir -(void)mouseDragged: (NSEvent*)theEvent; 70cdf0e10cSrcweir 71cdf0e10cSrcweir -(unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal; 72cdf0e10cSrcweir -(void)draggedImage:(NSImage*)anImage beganAt:(NSPoint)aPoint; 73cdf0e10cSrcweir -(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation; 74cdf0e10cSrcweir -(void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint; 75cdf0e10cSrcweir 76cdf0e10cSrcweir @end 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir class DragSource : public ::cppu::BaseMutex, 80cdf0e10cSrcweir public ::cppu::WeakComponentImplHelper3< com::sun::star::datatransfer::dnd::XDragSource, 81cdf0e10cSrcweir com::sun::star::lang::XInitialization, 82cdf0e10cSrcweir com::sun::star::lang::XServiceInfo >, 83cdf0e10cSrcweir private ::boost::noncopyable 84cdf0e10cSrcweir { 85cdf0e10cSrcweir public: 86cdf0e10cSrcweir DragSource(); 87cdf0e10cSrcweir virtual ~DragSource(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir // XInitialization 90cdf0e10cSrcweir virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) 91cdf0e10cSrcweir throw(com::sun::star::uno::Exception/*, com::sun::star::uno::RuntimeException*/); 92cdf0e10cSrcweir 93cdf0e10cSrcweir // XDragSource 94cdf0e10cSrcweir virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir 96cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) 97cdf0e10cSrcweir throw(com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir 99cdf0e10cSrcweir virtual void SAL_CALL startDrag( const com::sun::star::datatransfer::dnd::DragGestureEvent& trigger, 100cdf0e10cSrcweir sal_Int8 sourceActions, 101cdf0e10cSrcweir sal_Int32 cursor, 102cdf0e10cSrcweir sal_Int32 image, 103cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& transferable, 104cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceListener >& listener ) 105cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XServiceInfo 108cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw (com::sun::star::uno::RuntimeException); 110cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void saveMouseEvent(NSEvent* theEvent); 113cdf0e10cSrcweir virtual unsigned int getSupportedDragOperations(bool isLocal) const; 114cdf0e10cSrcweir 115cdf0e10cSrcweir public: 116cdf0e10cSrcweir // The context notifies the XDragSourceListeners 117cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceContext > mXCurrentContext; 118cdf0e10cSrcweir 119cdf0e10cSrcweir id mView; 120cdf0e10cSrcweir AquaSalFrame* mpFrame; 121cdf0e10cSrcweir NSEvent* mLastMouseEventBeforeStartDrag; 122cdf0e10cSrcweir DragSourceHelper* mDragSourceHelper; 123cdf0e10cSrcweir com::sun::star::awt::MouseEvent mMouseEvent; 124cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > mXTransferable; 125cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDragSourceListener > mXDragSrcListener; 126cdf0e10cSrcweir // The mouse button that set off the drag and drop operation 127cdf0e10cSrcweir short m_MouseButton; 128cdf0e10cSrcweir sal_Int8 mDragSourceActions; 129cdf0e10cSrcweir 130cdf0e10cSrcweir static com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > g_XTransferable; 131cdf0e10cSrcweir static NSView* g_DragSourceView; 132cdf0e10cSrcweir static bool g_DropSuccessSet; 133cdf0e10cSrcweir static bool g_DropSuccess; 134cdf0e10cSrcweir 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138cdf0e10cSrcweir #endif 139