tdf#151341 Use lzfse compression instead of bzip2
[LibreOffice.git] / vcl / osx / DropTarget.hxx
blobffc53a4e17ecf883a309cc9bbca7a3b2b9234f08
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 "DataFlavorMapping.hxx"
23 #include <cppuhelper/compbase.hxx>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
27 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
28 #include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
29 #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
30 #include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <cppuhelper/basemutex.hxx>
34 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
36 #include <premac.h>
37 #import <Cocoa/Cocoa.h>
38 #include <postmac.h>
40 class DropTarget;
41 class AquaSalFrame;
43 /* The functions declared in this protocol are actually
44 declared in vcl/inc/osx/salframe.h. Because we want
45 to avoid importing VCL headers in UNO services and
46 on the other hand want to avoid warnings caused by
47 gcc complaining about unknowness of these functions
48 we declare them in a protocol here and cast at the
49 appropriate places.
51 @protocol DraggingDestinationHandler
52 -(void)registerDraggingDestinationHandler:(id)theHandler;
53 -(void)unregisterDraggingDestinationHandler:(id)theHandler;
54 @end
56 @interface DropTargetHelper : NSObject
58 DropTarget* mDropTarget;
61 -(DropTargetHelper*)initWithDropTarget:(DropTarget*)pdt;
63 -(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
64 -(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
65 -(void)draggingExited:(id <NSDraggingInfo>)sender;
66 -(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender;
67 -(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
68 -(void)concludeDragOperation:(id <NSDraggingInfo>)sender;
70 @end
72 class DropTarget: public cppu::BaseMutex,
73 public cppu::WeakComponentImplHelper< css::lang::XInitialization,
74 css::datatransfer::dnd::XDropTarget,
75 css::datatransfer::dnd::XDropTargetDragContext,
76 css::datatransfer::dnd::XDropTargetDropContext,
77 css::lang::XServiceInfo >
79 public:
80 DropTarget();
81 virtual ~DropTarget() override;
82 DropTarget(const DropTarget&) = delete;
83 DropTarget& operator=(const DropTarget&) = delete;
85 // Overrides WeakComponentImplHelper::disposing which is called by
86 // WeakComponentImplHelper::dispose
87 // Must be called.
88 virtual void SAL_CALL disposing() override;
90 // XInitialization
91 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
93 // XDropTarget
94 virtual void SAL_CALL addDropTargetListener( const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >& dtl ) override;
96 virtual void SAL_CALL removeDropTargetListener( const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >& dtl ) override;
98 // Default is not active
99 virtual sal_Bool SAL_CALL isActive() override;
100 virtual void SAL_CALL setActive(sal_Bool isActive) override;
101 virtual sal_Int8 SAL_CALL getDefaultActions() override;
102 virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override;
104 // XDropTargetDragContext
105 virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) override;
106 virtual void SAL_CALL rejectDrag() override;
108 // XDropTargetDragContext
109 virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) override;
110 virtual void SAL_CALL rejectDrop() override;
111 virtual void SAL_CALL dropComplete(sal_Bool success) override;
113 // XServiceInfo
114 virtual OUString SAL_CALL getImplementationName() override;
115 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
116 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
118 // NSDraggingDestination protocol functions
119 NSDragOperation draggingEntered(id sender);
120 NSDragOperation draggingUpdated(id sender);
121 void draggingExited(id sender);
122 static BOOL prepareForDragOperation();
123 BOOL performDragOperation();
124 void concludeDragOperation(id sender);
126 /* If multiple actions are supported by the drag source and
127 the user did not choose a specific action by pressing a
128 modifier key choose a default action to be proposed to
129 the application.
131 sal_Int8 determineDropAction(sal_Int8 dropActions, id sender) const;
133 private:
134 void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dte);
135 void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee);
136 void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte);
137 void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEvent& dtde);
138 void fire_dropActionChanged(const css::datatransfer::dnd::DropTargetDragEvent& dtde);
140 private:
141 css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext > mXCurrentDragContext;
142 css::uno::Reference< css::datatransfer::dnd::XDropTargetDropContext > mXCurrentDropContext;
143 css::uno::Reference< css::datatransfer::clipboard::XClipboard > mXCurrentDragClipboard;
144 DataFlavorMapperPtr_t mDataFlavorMapper;
145 id mView;
146 AquaSalFrame* mpFrame;
147 DropTargetHelper* mDropTargetHelper;
148 bool mbActive;
149 sal_Int8 mDragSourceSupportedActions;
150 sal_Int8 mSelectedDropAction;
151 sal_Int8 mDefaultActions;
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */