bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / osx / DragSource.hxx
blob96a8fb48a833546d554a7b0616de5dc707c46de9
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 #pragma once
22 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
23 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <cppuhelper/compbase.hxx>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <cppuhelper/basemutex.hxx>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <osl/thread.h>
30 #include <com/sun/star/awt/MouseEvent.hpp>
32 #include <premac.h>
33 #import <Cocoa/Cocoa.h>
34 #include <postmac.h>
36 class DragSource;
37 class AquaSalFrame;
39 /* The functions declared in this protocol are actually
40 declared in vcl/inc/osx/salframe.h. Because we want
41 to avoid importing VCL headers in UNO services and
42 on the other hand want to avoid warnings caused by
43 gcc complaining about unknowness of these functions
44 we declare them in a protocol here and cast at the
45 appropriate places.
47 @protocol MouseEventListener
48 -(void)registerMouseEventListener:(id)theHandler;
49 -(void)unregisterMouseEventListener:(id)theHandler;
50 @end
52 @interface DragSourceHelper : NSObject
54 DragSource* mDragSource;
57 -(DragSourceHelper*)initWithDragSource: (DragSource*) pds;
59 -(void)mouseDown: (NSEvent*)theEvent;
60 -(void)mouseDragged: (NSEvent*)theEvent;
62 -(unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
63 -(void)draggedImage:(NSImage*)anImage beganAt:(NSPoint)aPoint;
64 -(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
65 -(void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint;
67 @end
69 class DragSource : public ::cppu::BaseMutex,
70 public ::cppu::WeakComponentImplHelper< css::datatransfer::dnd::XDragSource,
71 css::lang::XInitialization,
72 css::lang::XServiceInfo >
74 public:
75 DragSource();
76 virtual ~DragSource() override;
77 DragSource(const DragSource&) = delete;
78 DragSource& operator=(const DragSource&) = delete;
80 // XInitialization
81 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
83 // XDragSource
84 virtual sal_Bool SAL_CALL isDragImageSupported( ) override;
86 virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) override;
88 virtual void SAL_CALL startDrag( const css::datatransfer::dnd::DragGestureEvent& trigger,
89 sal_Int8 sourceActions,
90 sal_Int32 cursor,
91 sal_Int32 image,
92 const css::uno::Reference< css::datatransfer::XTransferable >& transferable,
93 const css::uno::Reference< css::datatransfer::dnd::XDragSourceListener >& listener ) override;
95 // XServiceInfo
96 virtual OUString SAL_CALL getImplementationName() override;
97 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
98 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
100 void saveMouseEvent(NSEvent* theEvent);
101 unsigned int getSupportedDragOperations(bool isLocal) const;
103 public:
104 // The context notifies the XDragSourceListeners
105 css::uno::Reference< css::datatransfer::dnd::XDragSourceContext > mXCurrentContext;
107 id mView;
108 AquaSalFrame* mpFrame;
109 NSEvent* mLastMouseEventBeforeStartDrag;
110 DragSourceHelper* mDragSourceHelper;
111 css::awt::MouseEvent mMouseEvent;
112 css::uno::Reference< css::datatransfer::XTransferable > mXTransferable;
113 css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mXDragSrcListener;
114 // The mouse button that set off the drag and drop operation
115 short m_MouseButton;
116 sal_Int8 mDragSourceActions;
118 static css::uno::Reference< css::datatransfer::XTransferable > g_XTransferable;
119 static NSView* g_DragSourceView;
120 static bool g_DropSuccessSet;
121 static bool g_DropSuccess;
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */