2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2008-02-18 13:47:11 +00:00
|
|
|
|
2013-12-05 22:01:05 +02:00
|
|
|
#ifndef INCLUDED_VCL_OSX_DRAGSOURCE_HXX
|
|
|
|
#define INCLUDED_VCL_OSX_DRAGSOURCE_HXX
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
|
|
|
|
#include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
|
|
|
|
#include <com/sun/star/lang/XInitialization.hpp>
|
2015-09-11 10:37:30 +09:00
|
|
|
#include <cppuhelper/compbase.hxx>
|
2008-02-18 13:47:11 +00:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <cppuhelper/basemutex.hxx>
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
#include <osl/thread.h>
|
|
|
|
#include <com/sun/star/awt/MouseEvent.hpp>
|
|
|
|
|
|
|
|
#include <premac.h>
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#include <postmac.h>
|
|
|
|
|
|
|
|
class DragSource;
|
2010-07-23 17:19:53 +02:00
|
|
|
class AquaSalFrame;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
/* The functions declared in this protocol are actually
|
2013-12-05 22:01:05 +02:00
|
|
|
declared in vcl/inc/osx/salframe.h. Because we want
|
2008-02-18 13:47:11 +00:00
|
|
|
to avoid importing VCL headers in UNO services and
|
|
|
|
on the other hand want to avoid warnings caused by
|
|
|
|
gcc complaining about unknowness of these functions
|
|
|
|
we declare them in a protocol here and cast at the
|
|
|
|
appropriate places.
|
|
|
|
*/
|
|
|
|
@protocol MouseEventListener
|
|
|
|
-(void)registerMouseEventListener:(id)theHandler;
|
|
|
|
-(void)unregisterMouseEventListener:(id)theHandler;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface DragSourceHelper : NSObject
|
|
|
|
{
|
|
|
|
DragSource* mDragSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(DragSourceHelper*)initWithDragSource: (DragSource*) pds;
|
|
|
|
|
|
|
|
-(void)mouseDown: (NSEvent*)theEvent;
|
|
|
|
-(void)mouseDragged: (NSEvent*)theEvent;
|
|
|
|
|
2011-01-19 15:42:25 +01:00
|
|
|
-(unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
|
2008-02-18 13:47:11 +00:00
|
|
|
-(void)draggedImage:(NSImage*)anImage beganAt:(NSPoint)aPoint;
|
|
|
|
-(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
|
|
|
|
-(void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
class DragSource : public ::cppu::BaseMutex,
|
2015-11-18 10:11:06 +02:00
|
|
|
public ::cppu::WeakComponentImplHelper< css::datatransfer::dnd::XDragSource,
|
|
|
|
css::lang::XInitialization,
|
2016-04-13 10:11:37 +02:00
|
|
|
css::lang::XServiceInfo >
|
2008-02-18 13:47:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-18 11:54:06 +00:00
|
|
|
DragSource();
|
2008-02-18 13:47:11 +00:00
|
|
|
virtual ~DragSource();
|
2016-04-13 10:11:37 +02:00
|
|
|
DragSource(const DragSource&) = delete;
|
|
|
|
DragSource& operator=(const DragSource&) = delete;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
// XInitialization
|
2015-11-18 10:11:06 +02:00
|
|
|
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
|
|
|
|
throw(css::uno::Exception, std::exception/*, css::uno::RuntimeException*/) override;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
// XDragSource
|
2015-11-18 10:11:06 +02:00
|
|
|
virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(css::uno::RuntimeException, std::exception) override;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction)
|
2015-11-18 10:11:06 +02:00
|
|
|
throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
2015-11-18 10:11:06 +02:00
|
|
|
virtual void SAL_CALL startDrag( const css::datatransfer::dnd::DragGestureEvent& trigger,
|
2008-02-18 13:47:11 +00:00
|
|
|
sal_Int8 sourceActions,
|
|
|
|
sal_Int32 cursor,
|
|
|
|
sal_Int32 image,
|
2015-11-18 10:11:06 +02:00
|
|
|
const css::uno::Reference< css::datatransfer::XTransferable >& transferable,
|
|
|
|
const css::uno::Reference< css::datatransfer::dnd::XDragSourceListener >& listener )
|
|
|
|
throw(css::uno::RuntimeException, std::exception) override;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
// XServiceInfo
|
2015-11-18 10:11:06 +02:00
|
|
|
virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) override;
|
|
|
|
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (css::uno::RuntimeException, std::exception) override;
|
|
|
|
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) override;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
void saveMouseEvent(NSEvent* theEvent);
|
|
|
|
unsigned int getSupportedDragOperations(bool isLocal) const;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// The context notifies the XDragSourceListeners
|
2015-11-18 10:11:06 +02:00
|
|
|
css::uno::Reference< css::datatransfer::dnd::XDragSourceContext > mXCurrentContext;
|
2008-02-18 13:47:11 +00:00
|
|
|
|
|
|
|
id mView;
|
2010-07-23 17:19:53 +02:00
|
|
|
AquaSalFrame* mpFrame;
|
2008-02-18 13:47:11 +00:00
|
|
|
NSEvent* mLastMouseEventBeforeStartDrag;
|
|
|
|
DragSourceHelper* mDragSourceHelper;
|
2015-11-18 10:11:06 +02:00
|
|
|
css::awt::MouseEvent mMouseEvent;
|
|
|
|
css::uno::Reference< css::datatransfer::XTransferable > mXTransferable;
|
|
|
|
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mXDragSrcListener;
|
2008-02-18 13:47:11 +00:00
|
|
|
// The mouse button that set off the drag and drop operation
|
|
|
|
short m_MouseButton;
|
|
|
|
sal_Int8 mDragSourceActions;
|
2008-07-01 22:01:39 +00:00
|
|
|
|
2015-11-18 10:11:06 +02:00
|
|
|
static css::uno::Reference< css::datatransfer::XTransferable > g_XTransferable;
|
2008-07-01 22:01:39 +00:00
|
|
|
static NSView* g_DragSourceView;
|
|
|
|
static bool g_DropSuccessSet;
|
|
|
|
static bool g_DropSuccess;
|
|
|
|
|
2008-02-18 13:47:11 +00:00
|
|
|
};
|
|
|
|
|
2013-12-05 22:01:05 +02:00
|
|
|
#endif // INCLUDED_VCL_OSX_DRAGSOURCE_HXX
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|