bump product version to 4.2.0.1
[LibreOffice.git] / vcl / aqua / source / dtrans / DropTarget.hxx
blob9318d80b9b46e7d50fbc91dbc5fcee4c95800ff4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_AQUA_SOURCE_DTRANS_DROPTARGET_HXX
21 #define INCLUDED_VCL_AQUA_SOURCE_DTRANS_DROPTARGET_HXX
23 #include "DataFlavorMapping.hxx"
24 #include <cppuhelper/compbase5.hxx>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
28 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
29 #include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
30 #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
31 #include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <cppuhelper/basemutex.hxx>
35 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
37 #include <boost/utility.hpp>
39 #include <premac.h>
40 #import <Cocoa/Cocoa.h>
41 #include <postmac.h>
43 class DropTarget;
44 class AquaSalFrame;
46 /* The functions declared in this protocol are actually
47 declared in vcl/aqua/inc/salframe.h. Because we want
48 to avoid importing VCL headers in UNO services and
49 on the other hand want to avoid warnings caused by
50 gcc complaining about unknowness of these functions
51 we declare them in a protocol here and cast at the
52 appropriate places.
54 @protocol DraggingDestinationHandler
55 -(void)registerDraggingDestinationHandler:(id)theHandler;
56 -(void)unregisterDraggingDestinationHandler:(id)theHandler;
57 @end
60 @interface DropTargetHelper : NSObject
62 DropTarget* mDropTarget;
65 -(DropTargetHelper*)initWithDropTarget:(DropTarget*)pdt;
67 -(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
68 -(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
69 -(void)draggingExited:(id <NSDraggingInfo>)sender;
70 -(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender;
71 -(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
72 -(void)concludeDragOperation:(id <NSDraggingInfo>)sender;
74 @end
77 class DropTarget: public cppu::BaseMutex,
78 public cppu::WeakComponentImplHelper5< com::sun::star::lang::XInitialization,
79 com::sun::star::datatransfer::dnd::XDropTarget,
80 com::sun::star::datatransfer::dnd::XDropTargetDragContext,
81 com::sun::star::datatransfer::dnd::XDropTargetDropContext,
82 com::sun::star::lang::XServiceInfo >,
83 private boost::noncopyable
85 public:
86 DropTarget();
87 virtual ~DropTarget();
89 // Overrides WeakComponentImplHelper::disposing which is called by
90 // WeakComponentImplHelper::dispose
91 // Must be called.
92 virtual void SAL_CALL disposing();
94 // XInitialization
95 virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
96 throw(com::sun::star::uno::Exception);
98 // XDropTarget
99 virtual void SAL_CALL addDropTargetListener( const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl )
100 throw(com::sun::star::uno::RuntimeException);
102 virtual void SAL_CALL removeDropTargetListener( const com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl )
103 throw(com::sun::star::uno::RuntimeException);
105 // Default is not active
106 virtual sal_Bool SAL_CALL isActive() throw(com::sun::star::uno::RuntimeException);
107 virtual void SAL_CALL setActive(sal_Bool isActive) throw(com::sun::star::uno::RuntimeException);
108 virtual sal_Int8 SAL_CALL getDefaultActions() throw(com::sun::star::uno::RuntimeException);
109 virtual void SAL_CALL setDefaultActions(sal_Int8 actions) throw(com::sun::star::uno::RuntimeException);
111 // XDropTargetDragContext
112 virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) throw(com::sun::star::uno::RuntimeException);
113 virtual void SAL_CALL rejectDrag() throw(com::sun::star::uno::RuntimeException);
115 // XDropTargetDragContext
116 virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) throw (com::sun::star::uno::RuntimeException);
117 virtual void SAL_CALL rejectDrop() throw (com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL dropComplete(sal_Bool success) throw (com::sun::star::uno::RuntimeException);
120 // XServiceInfo
121 virtual OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException);
122 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (com::sun::star::uno::RuntimeException);
123 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
125 // NSDraggingDestination protocol functions
126 virtual NSDragOperation draggingEntered(id sender);
127 virtual NSDragOperation draggingUpdated(id sender);
128 virtual void draggingExited(id sender);
129 virtual BOOL prepareForDragOperation(id sender);
130 virtual BOOL performDragOperation(id sender);
131 virtual void concludeDragOperation(id sender);
133 /* If multiple actions are supported by the drag source and
134 the user did not choose a specific action by pressing a
135 modifier key choose a default action to be proposed to
136 the application.
138 sal_Int8 determineDropAction(sal_Int8 dropActions, id sender) const;
140 private:
141 void fire_drop(const com::sun::star::datatransfer::dnd::DropTargetDropEvent& dte);
142 void fire_dragEnter(const com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee);
143 void fire_dragExit(const com::sun::star::datatransfer::dnd::DropTargetEvent& dte);
144 void fire_dragOver(const com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde);
145 void fire_dropActionChanged(const com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde);
147 private:
148 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetDragContext > mXCurrentDragContext;
149 com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetDropContext > mXCurrentDropContext;
150 com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboard > mXCurrentDragClipboard;
151 DataFlavorMapperPtr_t mDataFlavorMapper;
152 id mView;
153 AquaSalFrame* mpFrame;
154 DropTargetHelper* mDropTargetHelper;
155 bool mbActive;
156 sal_Int8 mDragSourceSupportedActions;
157 sal_Int8 mSelectedDropAction;
158 sal_Int8 mDefaultActions;
161 #endif
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */