merge the formfield patch from ooo-build
[ooovba.git] / vcl / aqua / source / dtrans / DropTarget.hxx
blobdb850f66eefefc882b2cedc8cd2e6efe6384bf59
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: DropTarget.hxx,v $
10 * $Revision: 1.3 $
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 _DROPTARGET_HXX_
32 #define _DROPTARGET_HXX_
34 #include "DataFlavorMapping.hxx"
35 #include <cppuhelper/compbase5.hxx>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
39 #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETLISTENR_HPP_
40 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
41 #endif
42 #include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
43 #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
44 #include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
45 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <cppuhelper/basemutex.hxx>
48 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
50 #include <boost/utility.hpp>
52 #include <premac.h>
53 #import <Cocoa/Cocoa.h>
54 #include <postmac.h>
56 class DropTarget;
58 /* The functions declared in this protocol are actually
59 declared in vcl/aqua/inc/salframe.h. Because we want
60 to avoid importing VCL headers in UNO services and
61 on the other hand want to avoid warnings caused by
62 gcc complaining about unknowness of these functions
63 we declare them in a protocol here and cast at the
64 appropriate places.
66 @protocol DraggingDestinationHandler
67 -(void)registerDraggingDestinationHandler:(id)theHandler;
68 -(void)unregisterDraggingDestinationHandler:(id)theHandler;
69 @end
72 @interface DropTargetHelper : NSObject
74 DropTarget* mDropTarget;
77 -(DropTargetHelper*)initWithDropTarget:(DropTarget*)pdt;
79 -(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
80 -(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
81 -(void)draggingExited:(id <NSDraggingInfo>)sender;
82 -(MacOSBOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender;
83 -(MacOSBOOL)performDragOperation:(id <NSDraggingInfo>)sender;
84 -(void)concludeDragOperation:(id <NSDraggingInfo>)sender;
86 @end
89 class DropTarget: public cppu::BaseMutex,
90 public cppu::WeakComponentImplHelper5< com::sun::star::lang::XInitialization,
91 com::sun::star::datatransfer::dnd::XDropTarget,
92 com::sun::star::datatransfer::dnd::XDropTargetDragContext,
93 com::sun::star::datatransfer::dnd::XDropTargetDropContext,
94 com::sun::star::lang::XServiceInfo >,
95 private boost::noncopyable
97 public:
98 DropTarget();
99 virtual ~DropTarget();
101 // Overrides WeakComponentImplHelper::disposing which is called by
102 // WeakComponentImplHelper::dispose
103 // Must be called.
104 virtual void SAL_CALL disposing();
106 // XInitialization
107 virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
108 throw(com::sun::star::uno::Exception);
110 // XDropTarget
111 virtual void SAL_CALL addDropTargetListener( const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl )
112 throw(com::sun::star::uno::RuntimeException);
114 virtual void SAL_CALL removeDropTargetListener( const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl )
115 throw(com::sun::star::uno::RuntimeException);
117 // Default is not active
118 virtual sal_Bool SAL_CALL isActive() throw(com::sun::star::uno::RuntimeException);
119 virtual void SAL_CALL setActive(sal_Bool isActive) throw(com::sun::star::uno::RuntimeException);
120 virtual sal_Int8 SAL_CALL getDefaultActions() throw(com::sun::star::uno::RuntimeException);
121 virtual void SAL_CALL setDefaultActions(sal_Int8 actions) throw(com::sun::star::uno::RuntimeException);
123 // XDropTargetDragContext
124 virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) throw(com::sun::star::uno::RuntimeException);
125 virtual void SAL_CALL rejectDrag() throw(com::sun::star::uno::RuntimeException);
127 // XDropTargetDragContext
128 virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) throw (com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL rejectDrop() throw (com::sun::star::uno::RuntimeException);
130 virtual void SAL_CALL dropComplete(sal_Bool success) throw (com::sun::star::uno::RuntimeException);
132 // XServiceInfo
133 virtual rtl::OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException);
134 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw (com::sun::star::uno::RuntimeException);
135 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
137 // NSDraggingDestination protocol functions
138 virtual NSDragOperation draggingEntered(id sender);
139 virtual NSDragOperation draggingUpdated(id sender);
140 virtual void draggingExited(id sender);
141 virtual MacOSBOOL prepareForDragOperation(id sender);
142 virtual MacOSBOOL performDragOperation(id sender);
143 virtual void concludeDragOperation(id sender);
145 /* If multiple actions are supported by the drag source and
146 the user did not choose a specific action by pressing a
147 modifier key choose a default action to be proposed to
148 the application.
150 sal_Int8 determineDropAction(sal_Int8 dropActions, id sender) const;
152 private:
153 void fire_drop(const com::sun::star::datatransfer::dnd::DropTargetDropEvent& dte);
154 void fire_dragEnter(const com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee);
155 void fire_dragExit(const com::sun::star::datatransfer::dnd::DropTargetEvent& dte);
156 void fire_dragOver(const com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde);
157 void fire_dropActionChanged(const com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde);
159 private:
160 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetDragContext > mXCurrentDragContext;
161 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetDropContext > mXCurrentDropContext;
162 com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboard > mXCurrentDragClipboard;
163 DataFlavorMapperPtr_t mDataFlavorMapper;
164 id mView;
165 DropTargetHelper* mDropTargetHelper;
166 bool mbActive;
167 sal_Int8 mDragSourceSupportedActions;
168 sal_Int8 mSelectedDropAction;
169 sal_Int8 mDefaultActions;
172 #endif