fdo#54938 Convert comphelper and vcl to cppu::supportsService
Change-Id: I391a7324bf92208fe632dac17874943343b1f65a Reviewed-on: https://gerrit.libreoffice.org/7757 Reviewed-by: Marcos Souza <marcos.souza.org@gmail.com> Tested-by: Marcos Souza <marcos.souza.org@gmail.com>
This commit is contained in:
parent
a7395942ae
commit
e17cf91032
@ -17,7 +17,6 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
|
||||
#include "comphelper_module.hxx"
|
||||
|
||||
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
|
||||
@ -27,21 +26,18 @@
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
#include <cppuhelper/implbase1.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/lang/XInitialization.hpp>
|
||||
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
||||
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
|
||||
#include <map>
|
||||
|
||||
|
||||
using namespace com::sun::star::uno;
|
||||
using namespace com::sun::star::ucb;
|
||||
using namespace com::sun::star::lang;
|
||||
using namespace com::sun::star::i18n;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
class AnyCompare : public ::cppu::WeakImplHelper1< XAnyCompare >
|
||||
{
|
||||
Reference< XCollator > m_rCollator;
|
||||
@ -57,8 +53,6 @@ public:
|
||||
virtual sal_Int16 SAL_CALL compare( const Any& any1, const Any& any2 ) throw(RuntimeException);
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
class AnyCompareFactory : public cppu::WeakImplHelper3< XAnyCompareFactory, XInitialization, XServiceInfo >
|
||||
{
|
||||
Reference< XAnyCompare > m_rAnyCompare;
|
||||
@ -87,8 +81,6 @@ public:
|
||||
static Reference< XInterface > SAL_CALL Create( const Reference< XComponentContext >& );
|
||||
};
|
||||
|
||||
//===========================================================================================
|
||||
|
||||
sal_Int16 SAL_CALL AnyCompare::compare( const Any& any1, const Any& any2 ) throw(::com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
sal_Int16 aResult = 0;
|
||||
@ -104,8 +96,6 @@ sal_Int16 SAL_CALL AnyCompare::compare( const Any& any1, const Any& any2 ) throw
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//===========================================================================================
|
||||
|
||||
Reference< XAnyCompare > SAL_CALL AnyCompareFactory::createAnyCompareByName( const OUString& aPropertyName ) throw(::com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
// for now only OUString properties compare is implemented
|
||||
@ -127,7 +117,6 @@ void SAL_CALL AnyCompareFactory::initialize( const Sequence< Any >& aArguments )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OUString SAL_CALL AnyCompareFactory::getImplementationName( ) throw( RuntimeException )
|
||||
@ -142,8 +131,7 @@ OUString SAL_CALL AnyCompareFactory::getImplementationName_static( )
|
||||
|
||||
sal_Bool SAL_CALL AnyCompareFactory::supportsService( const OUString& ServiceName ) throw(RuntimeException)
|
||||
{
|
||||
OUString aServiceName( "com.sun.star.ucb.AnyCompareFactory" );
|
||||
return aServiceName == ServiceName;
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
Sequence< OUString > SAL_CALL AnyCompareFactory::getSupportedServiceNames( ) throw(RuntimeException)
|
||||
|
@ -17,7 +17,6 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
|
||||
#include "comphelper_module.hxx"
|
||||
|
||||
#include <com/sun/star/container/XIndexContainer.hpp>
|
||||
@ -25,6 +24,7 @@
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <cppuhelper/implbase2.hxx>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -226,8 +226,7 @@ OUString SAL_CALL IndexedPropertyValuesContainer::getImplementationName_static(
|
||||
|
||||
sal_Bool SAL_CALL IndexedPropertyValuesContainer::supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
OUString aServiceName( "com.sun.star.document.IndexedPropertyValues" );
|
||||
return aServiceName == ServiceName;
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
::com::sun::star::uno::Sequence< OUString > SAL_CALL IndexedPropertyValuesContainer::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <cppuhelper/implbase2.hxx>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <map>
|
||||
|
||||
|
||||
@ -197,8 +197,7 @@ OUString SAL_CALL NamedPropertyValuesContainer::getImplementationName_static( )
|
||||
|
||||
sal_Bool SAL_CALL NamedPropertyValuesContainer::supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
OUString aServiceName( "com.sun.star.document.NamedPropertyValues" );
|
||||
return aServiceName == ServiceName;
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
::com::sun::star::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
|
||||
@ -206,7 +205,6 @@ sal_Bool SAL_CALL NamedPropertyValuesContainer::supportsService( const OUString&
|
||||
return getSupportedServiceNames_static();
|
||||
}
|
||||
|
||||
|
||||
::com::sun::star::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getSupportedServiceNames_static( )
|
||||
{
|
||||
const OUString aServiceName( "com.sun.star.document.NamedPropertyValues" );
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "rtl/ustring.hxx"
|
||||
|
||||
#include "comphelper/makesequence.hxx"
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
|
||||
#include "DragSource.hxx"
|
||||
#include "DragSourceContext.hxx"
|
||||
@ -69,7 +70,6 @@ Sequence<OUString> dragSource_getSupportedServiceNames()
|
||||
return makeSequence(OUString("com.sun.star.datatransfer.dnd.OleDragSource"));
|
||||
}
|
||||
|
||||
|
||||
@implementation DragSourceHelper;
|
||||
|
||||
-(DragSourceHelper*)initWithDragSource: (DragSource*) pds
|
||||
@ -84,25 +84,21 @@ Sequence<OUString> dragSource_getSupportedServiceNames()
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(void)mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
mDragSource->saveMouseEvent(theEvent);
|
||||
}
|
||||
|
||||
|
||||
-(void)mouseDragged: (NSEvent*)theEvent
|
||||
{
|
||||
mDragSource->saveMouseEvent(theEvent);
|
||||
}
|
||||
|
||||
|
||||
-(unsigned int)draggingSourceOperationMaskForLocal: (BOOL)isLocal
|
||||
{
|
||||
return mDragSource->getSupportedDragOperations(isLocal);
|
||||
}
|
||||
|
||||
|
||||
-(void)draggedImage:(NSImage*)anImage beganAt:(NSPoint)aPoint
|
||||
{
|
||||
(void)anImage;
|
||||
@ -116,7 +112,6 @@ Sequence<OUString> dragSource_getSupportedServiceNames()
|
||||
mDragSource->mXDragSrcListener->dragEnter(dsde);
|
||||
}
|
||||
|
||||
|
||||
-(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
|
||||
{
|
||||
(void)anImage;
|
||||
@ -137,7 +132,6 @@ Sequence<OUString> dragSource_getSupportedServiceNames()
|
||||
mDragSource->mXDragSrcListener = uno::Reference<XDragSourceListener>();
|
||||
}
|
||||
|
||||
|
||||
-(void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint
|
||||
{
|
||||
(void)draggedImage;
|
||||
@ -153,7 +147,6 @@ Sequence<OUString> dragSource_getSupportedServiceNames()
|
||||
|
||||
@end
|
||||
|
||||
|
||||
DragSource::DragSource():
|
||||
WeakComponentImplHelper3<XDragSource, XInitialization, XServiceInfo>(m_aMutex),
|
||||
mView(NULL),
|
||||
@ -163,7 +156,6 @@ DragSource::DragSource():
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DragSource::~DragSource()
|
||||
{
|
||||
if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
|
||||
@ -171,7 +163,6 @@ DragSource::~DragSource()
|
||||
[mDragSourceHelper release];
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments)
|
||||
throw(Exception)
|
||||
{
|
||||
@ -217,25 +208,18 @@ void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments)
|
||||
[(id <MouseEventListener>)mView registerMouseEventListener: mDragSourceHelper];
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// XDragSource
|
||||
//----------------------------------------------------
|
||||
|
||||
sal_Bool SAL_CALL DragSource::isDragImageSupported( )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
sal_Int32 SAL_CALL DragSource::getDefaultCursor( sal_Int8 /*dragAction*/ )
|
||||
throw( IllegalArgumentException, RuntimeException)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DragSource::startDrag(const DragGestureEvent& trigger,
|
||||
sal_Int8 sourceActions,
|
||||
sal_Int32 /*cursor*/,
|
||||
@ -303,7 +287,6 @@ void SAL_CALL DragSource::startDrag(const DragGestureEvent& trigger,
|
||||
g_DropSuccess = false;
|
||||
}
|
||||
|
||||
|
||||
// In order to initiate a D&D operation we need to
|
||||
// provide the triggering mouse event which we get
|
||||
// from the SalFrameView that is associated with
|
||||
@ -318,7 +301,6 @@ void DragSource::saveMouseEvent(NSEvent* theEvent)
|
||||
mLastMouseEventBeforeStartDrag = theEvent;
|
||||
}
|
||||
|
||||
|
||||
/* isLocal indicates whether or not the DnD operation is OOo
|
||||
internal.
|
||||
*/
|
||||
@ -344,29 +326,19 @@ unsigned int DragSource::getSupportedDragOperations(bool isLocal) const
|
||||
return srcActions;
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// XServiceInfo
|
||||
//################################
|
||||
|
||||
OUString SAL_CALL DragSource::getImplementationName( ) throw (RuntimeException)
|
||||
{
|
||||
return dragSource_getImplementationName();
|
||||
}
|
||||
|
||||
|
||||
sal_Bool SAL_CALL DragSource::supportsService( const OUString& ServiceName ) throw (RuntimeException)
|
||||
{
|
||||
return ServiceName == "com.sun.star.datatransfer.dnd.OleDragSource";
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
|
||||
Sequence< OUString > SAL_CALL DragSource::getSupportedServiceNames() throw (RuntimeException)
|
||||
{
|
||||
return dragSource_getSupportedServiceNames();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -20,25 +20,20 @@
|
||||
#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
|
||||
#include <com/sun/star/datatransfer/XTransferable.hpp>
|
||||
#include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
|
||||
|
||||
#include "comphelper/makesequence.hxx"
|
||||
#include <cppuhelper/interfacecontainer.hxx>
|
||||
|
||||
#include "clipboard.hxx"
|
||||
#include "DropTarget.hxx"
|
||||
#include "DragActionConversion.hxx"
|
||||
|
||||
#include "DragSource.hxx"
|
||||
|
||||
#include <rtl/ustring.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <premac.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <postmac.h>
|
||||
|
||||
#include <osx/salframe.h>
|
||||
#include <osx/salframeview.h>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
|
||||
using namespace cppu;
|
||||
using namespace osl;
|
||||
@ -54,26 +49,24 @@ using namespace comphelper;
|
||||
|
||||
OUString dropTarget_getImplementationName()
|
||||
{
|
||||
return OUString("com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1");
|
||||
return OUString("com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1");
|
||||
}
|
||||
|
||||
|
||||
Sequence<OUString> dropTarget_getSupportedServiceNames()
|
||||
{
|
||||
return makeSequence(OUString("com.sun.star.datatransfer.dnd.OleDropTarget"));
|
||||
return makeSequence(OUString("com.sun.star.datatransfer.dnd.OleDropTarget"));
|
||||
}
|
||||
|
||||
|
||||
namespace /* private */
|
||||
{
|
||||
// Cocoa's coordinate system has its origin lower-left, VCL's
|
||||
// coordinate system upper-left hence we need to transform
|
||||
// coordinates
|
||||
// Cocoa's coordinate system has its origin lower-left, VCL's
|
||||
// coordinate system upper-left hence we need to transform
|
||||
// coordinates
|
||||
|
||||
inline void CocoaToVCL(NSPoint& rPoint, const NSRect& bounds)
|
||||
{
|
||||
rPoint.y = bounds.size.height - rPoint.y;
|
||||
}
|
||||
inline void CocoaToVCL(NSPoint& rPoint, const NSRect& bounds)
|
||||
{
|
||||
rPoint.y = bounds.size.height - rPoint.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -82,70 +75,62 @@ namespace /* private */
|
||||
|
||||
-(DropTargetHelper*)initWithDropTarget:(DropTarget*)pdt
|
||||
{
|
||||
self = [super init];
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
if (self)
|
||||
{
|
||||
mDropTarget = pdt;
|
||||
mDropTarget = pdt;
|
||||
}
|
||||
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return mDropTarget->draggingEntered(sender);
|
||||
return mDropTarget->draggingEntered(sender);
|
||||
}
|
||||
|
||||
|
||||
-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return mDropTarget->draggingUpdated(sender);
|
||||
return mDropTarget->draggingUpdated(sender);
|
||||
}
|
||||
|
||||
|
||||
-(void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
mDropTarget->draggingExited(sender);
|
||||
mDropTarget->draggingExited(sender);
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return mDropTarget->prepareForDragOperation(sender);
|
||||
return mDropTarget->prepareForDragOperation(sender);
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return mDropTarget->performDragOperation(sender);
|
||||
return mDropTarget->performDragOperation(sender);
|
||||
}
|
||||
|
||||
|
||||
-(void)concludeDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
mDropTarget->concludeDragOperation(sender);
|
||||
mDropTarget->concludeDragOperation(sender);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
DropTarget::DropTarget() :
|
||||
WeakComponentImplHelper5<XInitialization, XDropTarget, XDropTargetDragContext, XDropTargetDropContext, XServiceInfo>(m_aMutex),
|
||||
mView(nil),
|
||||
mpFrame(NULL),
|
||||
mDropTargetHelper(nil),
|
||||
mbActive(false),
|
||||
mDragSourceSupportedActions(DNDConstants::ACTION_NONE),
|
||||
mSelectedDropAction(DNDConstants::ACTION_NONE),
|
||||
mDefaultActions(DNDConstants::ACTION_COPY_OR_MOVE | DNDConstants::ACTION_LINK | DNDConstants::ACTION_DEFAULT)
|
||||
WeakComponentImplHelper5<XInitialization, XDropTarget, XDropTargetDragContext, XDropTargetDropContext, XServiceInfo>(m_aMutex),
|
||||
mView(nil),
|
||||
mpFrame(NULL),
|
||||
mDropTargetHelper(nil),
|
||||
mbActive(false),
|
||||
mDragSourceSupportedActions(DNDConstants::ACTION_NONE),
|
||||
mSelectedDropAction(DNDConstants::ACTION_NONE),
|
||||
mDefaultActions(DNDConstants::ACTION_COPY_OR_MOVE | DNDConstants::ACTION_LINK | DNDConstants::ACTION_DEFAULT)
|
||||
{
|
||||
mDataFlavorMapper = DataFlavorMapperPtr_t(new DataFlavorMapper());
|
||||
mDataFlavorMapper = DataFlavorMapperPtr_t(new DataFlavorMapper());
|
||||
}
|
||||
|
||||
|
||||
DropTarget::~DropTarget()
|
||||
{
|
||||
if( AquaSalFrame::isAlive( mpFrame ) )
|
||||
@ -153,121 +138,118 @@ DropTarget::~DropTarget()
|
||||
[mDropTargetHelper release];
|
||||
}
|
||||
|
||||
|
||||
sal_Int8 DropTarget::determineDropAction(sal_Int8 dropActions, id sender) const
|
||||
{
|
||||
sal_Int8 dropAct = dropActions;
|
||||
bool srcAndDestEqual = false;
|
||||
sal_Int8 dropAct = dropActions;
|
||||
bool srcAndDestEqual = false;
|
||||
|
||||
if ([sender draggingSource] != nil)
|
||||
if ([sender draggingSource] != nil)
|
||||
{
|
||||
// Internal DnD
|
||||
NSView* destView = [[sender draggingDestinationWindow] contentView];
|
||||
srcAndDestEqual = (DragSource::g_DragSourceView == destView);
|
||||
// Internal DnD
|
||||
NSView* destView = [[sender draggingDestinationWindow] contentView];
|
||||
srcAndDestEqual = (DragSource::g_DragSourceView == destView);
|
||||
}
|
||||
|
||||
// If ACTION_DEFAULT is set this means NSDragOperationGeneric
|
||||
// has been set and we map this to ACTION_MOVE or ACTION_COPY
|
||||
// depending on whether or not source and dest are equal,
|
||||
// this hopefully satisfies all parties
|
||||
if( (dropActions == DNDConstants::ACTION_DEFAULT)
|
||||
|| ((dropActions == mDragSourceSupportedActions)
|
||||
&& !(~mDragSourceSupportedActions & DNDConstants::ACTION_COPY_OR_MOVE ) ) )
|
||||
// If ACTION_DEFAULT is set this means NSDragOperationGeneric
|
||||
// has been set and we map this to ACTION_MOVE or ACTION_COPY
|
||||
// depending on whether or not source and dest are equal,
|
||||
// this hopefully satisfies all parties
|
||||
if( (dropActions == DNDConstants::ACTION_DEFAULT)
|
||||
|| ((dropActions == mDragSourceSupportedActions)
|
||||
&& !(~mDragSourceSupportedActions & DNDConstants::ACTION_COPY_OR_MOVE ) ) )
|
||||
{
|
||||
dropAct = srcAndDestEqual ? DNDConstants::ACTION_MOVE :
|
||||
dropAct = srcAndDestEqual ? DNDConstants::ACTION_MOVE :
|
||||
DNDConstants::ACTION_COPY;
|
||||
}
|
||||
// if more than one drop actions have been specified
|
||||
// set ACTION_DEFAULT in order to let the drop target
|
||||
// decide which one to use
|
||||
else if (dropActions != DNDConstants::ACTION_NONE &&
|
||||
dropActions != DNDConstants::ACTION_MOVE &&
|
||||
dropActions != DNDConstants::ACTION_COPY &&
|
||||
dropActions != DNDConstants::ACTION_LINK)
|
||||
else if (dropActions != DNDConstants::ACTION_NONE &&
|
||||
dropActions != DNDConstants::ACTION_MOVE &&
|
||||
dropActions != DNDConstants::ACTION_COPY &&
|
||||
dropActions != DNDConstants::ACTION_LINK)
|
||||
{
|
||||
if (srcAndDestEqual)
|
||||
if (srcAndDestEqual)
|
||||
{
|
||||
dropAct = dropActions;
|
||||
dropAct = dropActions;
|
||||
}
|
||||
else // source and destination are different
|
||||
else // source and destination are different
|
||||
{
|
||||
if (dropActions & DNDConstants::ACTION_COPY)
|
||||
dropAct = DNDConstants::ACTION_COPY;
|
||||
else if (dropActions & DNDConstants::ACTION_MOVE)
|
||||
dropAct = DNDConstants::ACTION_MOVE;
|
||||
else if (dropActions & DNDConstants::ACTION_LINK)
|
||||
dropAct = DNDConstants::ACTION_LINK;
|
||||
if (dropActions & DNDConstants::ACTION_COPY)
|
||||
dropAct = DNDConstants::ACTION_COPY;
|
||||
else if (dropActions & DNDConstants::ACTION_MOVE)
|
||||
dropAct = DNDConstants::ACTION_MOVE;
|
||||
else if (dropActions & DNDConstants::ACTION_LINK)
|
||||
dropAct = DNDConstants::ACTION_LINK;
|
||||
}
|
||||
|
||||
dropAct |= DNDConstants::ACTION_DEFAULT;
|
||||
dropAct |= DNDConstants::ACTION_DEFAULT;
|
||||
}
|
||||
|
||||
return dropAct;
|
||||
return dropAct;
|
||||
}
|
||||
|
||||
|
||||
NSDragOperation DropTarget::draggingEntered(id sender)
|
||||
{
|
||||
// Initially when DnD will be started no modifier key can be pressed yet
|
||||
// thus we are getting all actions that the drag source supports, we save
|
||||
// this value because later the system masks the drag source actions if
|
||||
// a modifier key will be pressed
|
||||
mDragSourceSupportedActions = SystemToOfficeDragActions([sender draggingSourceOperationMask]);
|
||||
// Initially when DnD will be started no modifier key can be pressed yet
|
||||
// thus we are getting all actions that the drag source supports, we save
|
||||
// this value because later the system masks the drag source actions if
|
||||
// a modifier key will be pressed
|
||||
mDragSourceSupportedActions = SystemToOfficeDragActions([sender draggingSourceOperationMask]);
|
||||
|
||||
// Only if the drop target is really interessted in the drag actions
|
||||
// supported by the source
|
||||
if (mDragSourceSupportedActions & mDefaultActions)
|
||||
// Only if the drop target is really interessted in the drag actions
|
||||
// supported by the source
|
||||
if (mDragSourceSupportedActions & mDefaultActions)
|
||||
{
|
||||
sal_Int8 currentAction = determineDropAction(mDragSourceSupportedActions, sender);
|
||||
sal_Int8 currentAction = determineDropAction(mDragSourceSupportedActions, sender);
|
||||
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
|
||||
NSPasteboard* dragPboard = [sender draggingPasteboard];
|
||||
mXCurrentDragClipboard = new AquaClipboard(dragPboard, false);
|
||||
NSPasteboard* dragPboard = [sender draggingPasteboard];
|
||||
mXCurrentDragClipboard = new AquaClipboard(dragPboard, false);
|
||||
|
||||
uno::Reference<XTransferable> xTransferable = DragSource::g_XTransferable.is() ?
|
||||
DragSource::g_XTransferable : mXCurrentDragClipboard->getContents();
|
||||
uno::Reference<XTransferable> xTransferable = DragSource::g_XTransferable.is() ?
|
||||
DragSource::g_XTransferable : mXCurrentDragClipboard->getContents();
|
||||
|
||||
DropTargetDragEnterEvent dtdee(static_cast<OWeakObject*>(this),
|
||||
0,
|
||||
this,
|
||||
currentAction,
|
||||
posX,
|
||||
posY,
|
||||
mDragSourceSupportedActions,
|
||||
xTransferable->getTransferDataFlavors());
|
||||
DropTargetDragEnterEvent dtdee(static_cast<OWeakObject*>(this),
|
||||
0,
|
||||
this,
|
||||
currentAction,
|
||||
posX,
|
||||
posY,
|
||||
mDragSourceSupportedActions,
|
||||
xTransferable->getTransferDataFlavors());
|
||||
|
||||
fire_dragEnter(dtdee);
|
||||
fire_dragEnter(dtdee);
|
||||
}
|
||||
|
||||
return OfficeToSystemDragActions(mSelectedDropAction);
|
||||
return OfficeToSystemDragActions(mSelectedDropAction);
|
||||
}
|
||||
|
||||
|
||||
NSDragOperation DropTarget::draggingUpdated(id sender)
|
||||
{
|
||||
sal_Int8 currentDragSourceActions =
|
||||
sal_Int8 currentDragSourceActions =
|
||||
SystemToOfficeDragActions([sender draggingSourceOperationMask]);
|
||||
NSDragOperation dragOp = NSDragOperationNone;
|
||||
NSDragOperation dragOp = NSDragOperationNone;
|
||||
|
||||
if (currentDragSourceActions & mDefaultActions)
|
||||
if (currentDragSourceActions & mDefaultActions)
|
||||
{
|
||||
sal_Int8 currentAction = determineDropAction(currentDragSourceActions, sender);
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
sal_Int8 currentAction = determineDropAction(currentDragSourceActions, sender);
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
|
||||
DropTargetDragEvent dtde(static_cast<OWeakObject*>(this),
|
||||
DropTargetDragEvent dtde(static_cast<OWeakObject*>(this),
|
||||
0,
|
||||
this,
|
||||
currentAction,
|
||||
@ -275,27 +257,26 @@ NSDragOperation DropTarget::draggingUpdated(id sender)
|
||||
posY,
|
||||
mDragSourceSupportedActions);
|
||||
|
||||
fire_dragOver(dtde);
|
||||
fire_dragOver(dtde);
|
||||
|
||||
// drag over callbacks likely have rendered something
|
||||
[mView setNeedsDisplay: TRUE];
|
||||
// drag over callbacks likely have rendered something
|
||||
[mView setNeedsDisplay: TRUE];
|
||||
|
||||
dragOp = OfficeToSystemDragActions(mSelectedDropAction);
|
||||
dragOp = OfficeToSystemDragActions(mSelectedDropAction);
|
||||
|
||||
//NSLog(@"Drag update: Source actions: %x proposed action %x selected action %x", mDragSourceSupportedActions, currentAction, mSelectedDropAction);
|
||||
//NSLog(@"Drag update: Source actions: %x proposed action %x selected action %x", mDragSourceSupportedActions, currentAction, mSelectedDropAction);
|
||||
}
|
||||
|
||||
if (dragOp == NSDragOperationNone)
|
||||
[[NSCursor operationNotAllowedCursor] set];
|
||||
else if (dragOp == NSDragOperationCopy)
|
||||
[[NSCursor dragCopyCursor] set];
|
||||
else
|
||||
[[NSCursor arrowCursor] set];
|
||||
if (dragOp == NSDragOperationNone)
|
||||
[[NSCursor operationNotAllowedCursor] set];
|
||||
else if (dragOp == NSDragOperationCopy)
|
||||
[[NSCursor dragCopyCursor] set];
|
||||
else
|
||||
[[NSCursor arrowCursor] set];
|
||||
|
||||
return dragOp;
|
||||
return dragOp;
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::draggingExited(id /*sender*/)
|
||||
{
|
||||
DropTargetEvent dte(static_cast<OWeakObject*>(this), 0);
|
||||
@ -305,35 +286,33 @@ void DropTarget::draggingExited(id /*sender*/)
|
||||
[[NSCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
|
||||
BOOL DropTarget::prepareForDragOperation(id /*sender*/)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
BOOL DropTarget::performDragOperation(id sender)
|
||||
{
|
||||
bool bSuccess = false;
|
||||
bool bSuccess = false;
|
||||
|
||||
if (mSelectedDropAction != DNDConstants::ACTION_NONE)
|
||||
if (mSelectedDropAction != DNDConstants::ACTION_NONE)
|
||||
{
|
||||
uno::Reference<XTransferable> xTransferable = DragSource::g_XTransferable;
|
||||
|
||||
if (!DragSource::g_XTransferable.is())
|
||||
if (!DragSource::g_XTransferable.is())
|
||||
{
|
||||
xTransferable = mXCurrentDragClipboard->getContents();
|
||||
xTransferable = mXCurrentDragClipboard->getContents();
|
||||
}
|
||||
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
NSRect bounds = [mView bounds];
|
||||
NSPoint dragLocation = [sender draggedImageLocation];
|
||||
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
CocoaToVCL(dragLocation, bounds);
|
||||
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
|
||||
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
|
||||
|
||||
DropTargetDropEvent dtde(static_cast<OWeakObject*>(this),
|
||||
DropTargetDropEvent dtde(static_cast<OWeakObject*>(this),
|
||||
0,
|
||||
this,
|
||||
mSelectedDropAction,
|
||||
@ -342,15 +321,14 @@ BOOL DropTarget::performDragOperation(id sender)
|
||||
mDragSourceSupportedActions,
|
||||
xTransferable);
|
||||
|
||||
fire_drop(dtde);
|
||||
fire_drop(dtde);
|
||||
|
||||
bSuccess = true;
|
||||
bSuccess = true;
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::concludeDragOperation(id /*sender*/)
|
||||
{
|
||||
mDragSourceSupportedActions = DNDConstants::ACTION_NONE;
|
||||
@ -359,23 +337,21 @@ void DropTarget::concludeDragOperation(id /*sender*/)
|
||||
[[NSCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
// called from WeakComponentImplHelperX::dispose
|
||||
// WeakComponentImplHelper calls disposing before it destroys
|
||||
// itself.
|
||||
void SAL_CALL DropTarget::disposing()
|
||||
{
|
||||
}
|
||||
|
||||
// called from WeakComponentImplHelperX::dispose
|
||||
// WeakComponentImplHelper calls disposing before it destroys
|
||||
// itself.
|
||||
void SAL_CALL DropTarget::disposing()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::initialize(const Sequence< Any >& aArguments)
|
||||
void SAL_CALL DropTarget::initialize(const Sequence< Any >& aArguments)
|
||||
throw(Exception)
|
||||
{
|
||||
{
|
||||
if (aArguments.getLength() < 2)
|
||||
{
|
||||
{
|
||||
throw RuntimeException("DropTarget::initialize: Cannot install window event handler",
|
||||
static_cast<OWeakObject*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
Any pNSView = aArguments[0];
|
||||
sal_uInt64 tmp = 0;
|
||||
@ -394,193 +370,168 @@ void DropTarget::concludeDragOperation(id /*sender*/)
|
||||
unsigned int wndStyles = [wnd styleMask] & topWndStyle;
|
||||
|
||||
if (parentWnd == nil && (wndStyles == topWndStyle))
|
||||
{
|
||||
{
|
||||
[wnd registerDraggingDestinationHandler:mDropTargetHelper];
|
||||
[wnd registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::addDropTargetListener(const uno::Reference<XDropTargetListener>& dtl)
|
||||
void SAL_CALL DropTarget::addDropTargetListener(const uno::Reference<XDropTargetListener>& dtl)
|
||||
throw(RuntimeException)
|
||||
{
|
||||
{
|
||||
rBHelper.addListener(::getCppuType(&dtl), dtl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::removeDropTargetListener(const uno::Reference<XDropTargetListener>& dtl)
|
||||
void SAL_CALL DropTarget::removeDropTargetListener(const uno::Reference<XDropTargetListener>& dtl)
|
||||
throw(RuntimeException)
|
||||
{
|
||||
{
|
||||
rBHelper.removeListener(::getCppuType(&dtl), dtl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sal_Bool SAL_CALL DropTarget::isActive( ) throw(RuntimeException)
|
||||
{
|
||||
sal_Bool SAL_CALL DropTarget::isActive( ) throw(RuntimeException)
|
||||
{
|
||||
return mbActive;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::setActive(sal_Bool active) throw(RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::setActive(sal_Bool active) throw(RuntimeException)
|
||||
{
|
||||
mbActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sal_Int8 SAL_CALL DropTarget::getDefaultActions() throw(RuntimeException)
|
||||
{
|
||||
sal_Int8 SAL_CALL DropTarget::getDefaultActions() throw(RuntimeException)
|
||||
{
|
||||
return mDefaultActions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::setDefaultActions(sal_Int8 actions) throw(RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::setDefaultActions(sal_Int8 actions) throw(RuntimeException)
|
||||
{
|
||||
OSL_ENSURE( actions < 8, "No valid default actions");
|
||||
mDefaultActions= actions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XDropTargetDragContext
|
||||
|
||||
void SAL_CALL DropTarget::acceptDrag(sal_Int8 dragOperation) throw (RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::acceptDrag(sal_Int8 dragOperation) throw (RuntimeException)
|
||||
{
|
||||
mSelectedDropAction = dragOperation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::rejectDrag() throw (RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::rejectDrag() throw (RuntimeException)
|
||||
{
|
||||
mSelectedDropAction = DNDConstants::ACTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//XDropTargetDropContext
|
||||
|
||||
void SAL_CALL DropTarget::acceptDrop(sal_Int8 dropOperation) throw( RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::acceptDrop(sal_Int8 dropOperation) throw( RuntimeException)
|
||||
{
|
||||
mSelectedDropAction = dropOperation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::rejectDrop() throw (RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::rejectDrop() throw (RuntimeException)
|
||||
{
|
||||
mSelectedDropAction = DNDConstants::ACTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL DropTarget::dropComplete(sal_Bool success) throw (RuntimeException)
|
||||
{
|
||||
void SAL_CALL DropTarget::dropComplete(sal_Bool success) throw (RuntimeException)
|
||||
{
|
||||
// Reset the internal transferable used as shortcut in case this is
|
||||
// an internal D&D operation
|
||||
DragSource::g_XTransferable = uno::Reference<XTransferable>();
|
||||
DragSource::g_DropSuccessSet = true;
|
||||
DragSource::g_DropSuccess = success;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::fire_drop( const DropTargetDropEvent& dte)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
void DropTarget::fire_drop( const DropTargetDropEvent& dte)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
if( pContainer)
|
||||
{
|
||||
{
|
||||
OInterfaceIteratorHelper iter( *pContainer);
|
||||
while( iter.hasMoreElements())
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
|
||||
try { listener->drop( dte); }
|
||||
catch(RuntimeException&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::fire_dragEnter(const DropTargetDragEnterEvent& e)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
void DropTarget::fire_dragEnter(const DropTargetDragEnterEvent& e)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
if( pContainer)
|
||||
{
|
||||
{
|
||||
OInterfaceIteratorHelper iter( *pContainer);
|
||||
while( iter.hasMoreElements())
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
|
||||
try { listener->dragEnter( e); }
|
||||
catch (RuntimeException&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::fire_dragExit(const DropTargetEvent& dte)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
void DropTarget::fire_dragExit(const DropTargetEvent& dte)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
|
||||
if( pContainer)
|
||||
{
|
||||
{
|
||||
OInterfaceIteratorHelper iter( *pContainer);
|
||||
while( iter.hasMoreElements())
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
|
||||
try { listener->dragExit( dte); }
|
||||
catch (RuntimeException&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::fire_dragOver(const DropTargetDragEvent& dtde)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
void DropTarget::fire_dragOver(const DropTargetDragEvent& dtde)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
if( pContainer)
|
||||
{
|
||||
{
|
||||
OInterfaceIteratorHelper iter( *pContainer );
|
||||
while( iter.hasMoreElements())
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
|
||||
try { listener->dragOver( dtde); }
|
||||
catch (RuntimeException&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DropTarget::fire_dropActionChanged(const DropTargetDragEvent& dtde)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
void DropTarget::fire_dropActionChanged(const DropTargetDragEvent& dtde)
|
||||
{
|
||||
OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (uno::Reference<XDropTargetListener>* )0 ) );
|
||||
if( pContainer)
|
||||
{
|
||||
{
|
||||
OInterfaceIteratorHelper iter( *pContainer);
|
||||
while( iter.hasMoreElements())
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
{
|
||||
uno::Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
|
||||
|
||||
try { listener->dropActionChanged( dtde); }
|
||||
catch (RuntimeException&) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XServiceInfo
|
||||
|
||||
OUString SAL_CALL DropTarget::getImplementationName() throw (RuntimeException)
|
||||
{
|
||||
OUString SAL_CALL DropTarget::getImplementationName() throw (RuntimeException)
|
||||
{
|
||||
return dropTarget_getImplementationName();
|
||||
}
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL DropTarget::supportsService( const OUString& ServiceName ) throw (RuntimeException)
|
||||
{
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL DropTarget::supportsService( const OUString& ServiceName ) throw (RuntimeException)
|
||||
{
|
||||
return ServiceName == "com.sun.star.datatransfer.dnd.OleDropTarget";
|
||||
}
|
||||
|
||||
|
||||
Sequence< OUString > SAL_CALL DropTarget::getSupportedServiceNames( ) throw (RuntimeException)
|
||||
{
|
||||
Sequence< OUString > SAL_CALL DropTarget::getSupportedServiceNames( ) throw (RuntimeException)
|
||||
{
|
||||
return dropTarget_getSupportedServiceNames();
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <com/sun/star/datatransfer/MimeContentTypeFactory.hpp>
|
||||
#include "comphelper/makesequence.hxx"
|
||||
#include "comphelper/processfactory.hxx"
|
||||
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
using namespace com::sun::star::datatransfer;
|
||||
@ -68,7 +68,6 @@ using namespace comphelper;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
OUString clipboard_getImplementationName()
|
||||
{
|
||||
return OUString("com.sun.star.datatransfer.clipboard.AquaClipboard");
|
||||
@ -79,7 +78,6 @@ Sequence<OUString> clipboard_getSupportedServiceNames()
|
||||
return makeSequence(OUString("com.sun.star.datatransfer.clipboard.SystemClipboard"));
|
||||
}
|
||||
|
||||
|
||||
AquaClipboard::AquaClipboard(NSPasteboard* pasteboard, bool bUseSystemPasteboard) :
|
||||
WeakComponentImplHelper3<XSystemClipboard, XFlushableClipboard, XServiceInfo>(m_aMutex),
|
||||
mIsSystemPasteboard(bUseSystemPasteboard)
|
||||
@ -88,82 +86,80 @@ AquaClipboard::AquaClipboard(NSPasteboard* pasteboard, bool bUseSystemPasteboard
|
||||
|
||||
mrXMimeCntFactory = MimeContentTypeFactory::create(xContext);
|
||||
|
||||
mpDataFlavorMapper = DataFlavorMapperPtr_t(new DataFlavorMapper());
|
||||
mpDataFlavorMapper = DataFlavorMapperPtr_t(new DataFlavorMapper());
|
||||
|
||||
if (pasteboard != NULL)
|
||||
if (pasteboard != NULL)
|
||||
{
|
||||
mPasteboard = pasteboard;
|
||||
mIsSystemPasteboard = false;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
mPasteboard = bUseSystemPasteboard ? [NSPasteboard generalPasteboard] :
|
||||
[NSPasteboard pasteboardWithName: NSDragPboard];
|
||||
|
||||
if (mPasteboard == nil)
|
||||
{
|
||||
throw RuntimeException("AquaClipboard: Cannot create Cocoa pasteboard",
|
||||
throw RuntimeException("AquaClipboard: Cannot create Cocoa pasteboard",
|
||||
static_cast<XClipboardEx*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
[mPasteboard retain];
|
||||
[mPasteboard retain];
|
||||
|
||||
mEventListener = [[EventListener alloc] initWithAquaClipboard: this];
|
||||
mEventListener = [[EventListener alloc] initWithAquaClipboard: this];
|
||||
|
||||
if (mEventListener == nil)
|
||||
if (mEventListener == nil)
|
||||
{
|
||||
[mPasteboard release];
|
||||
[mPasteboard release];
|
||||
|
||||
throw RuntimeException(
|
||||
throw RuntimeException(
|
||||
OUString("AquaClipboard: Cannot create pasteboard change listener"),
|
||||
static_cast<XClipboardEx*>(this));
|
||||
}
|
||||
|
||||
if (mIsSystemPasteboard)
|
||||
if (mIsSystemPasteboard)
|
||||
{
|
||||
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[notificationCenter addObserver: mEventListener
|
||||
selector: @selector(applicationDidBecomeActive:)
|
||||
name: @"NSApplicationDidBecomeActiveNotification"
|
||||
object: [NSApplication sharedApplication]];
|
||||
[notificationCenter addObserver: mEventListener
|
||||
selector: @selector(applicationDidBecomeActive:)
|
||||
name: @"NSApplicationDidBecomeActiveNotification"
|
||||
object: [NSApplication sharedApplication]];
|
||||
}
|
||||
|
||||
mPasteboardChangeCount = [mPasteboard changeCount];
|
||||
mPasteboardChangeCount = [mPasteboard changeCount];
|
||||
}
|
||||
|
||||
|
||||
AquaClipboard::~AquaClipboard()
|
||||
{
|
||||
if (mIsSystemPasteboard)
|
||||
if (mIsSystemPasteboard)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: mEventListener];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: mEventListener];
|
||||
}
|
||||
|
||||
[mEventListener disposing];
|
||||
[mEventListener release];
|
||||
[mPasteboard release];
|
||||
[mEventListener disposing];
|
||||
[mEventListener release];
|
||||
[mPasteboard release];
|
||||
}
|
||||
|
||||
|
||||
Reference<XTransferable> SAL_CALL AquaClipboard::getContents() throw(RuntimeException)
|
||||
{
|
||||
MutexGuard aGuard(m_aMutex);
|
||||
MutexGuard aGuard(m_aMutex);
|
||||
|
||||
// Shortcut: If we are clipboard owner already we don't need
|
||||
// to drag the data through the system clipboard
|
||||
if (mXClipboardContent.is())
|
||||
// Shortcut: If we are clipboard owner already we don't need
|
||||
// to drag the data through the system clipboard
|
||||
if (mXClipboardContent.is())
|
||||
{
|
||||
return mXClipboardContent;
|
||||
return mXClipboardContent;
|
||||
}
|
||||
|
||||
return Reference<XTransferable>(new OSXTransferable(mrXMimeCntFactory,
|
||||
mpDataFlavorMapper,
|
||||
mPasteboard));
|
||||
return Reference<XTransferable>(new OSXTransferable(mrXMimeCntFactory,
|
||||
mpDataFlavorMapper,
|
||||
mPasteboard));
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL AquaClipboard::setContents(const Reference<XTransferable>& xTransferable,
|
||||
const Reference<XClipboardOwner>& xClipboardOwner)
|
||||
throw( RuntimeException )
|
||||
@ -194,19 +190,16 @@ void SAL_CALL AquaClipboard::setContents(const Reference<XTransferable>& xTransf
|
||||
fireClipboardChangedEvent();
|
||||
}
|
||||
|
||||
|
||||
OUString SAL_CALL AquaClipboard::getName() throw( RuntimeException )
|
||||
{
|
||||
return OUString();
|
||||
return OUString();
|
||||
}
|
||||
|
||||
|
||||
sal_Int8 SAL_CALL AquaClipboard::getRenderingCapabilities() throw( RuntimeException )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL AquaClipboard::addClipboardListener(const Reference< XClipboardListener >& listener)
|
||||
throw( RuntimeException )
|
||||
{
|
||||
@ -219,7 +212,6 @@ void SAL_CALL AquaClipboard::addClipboardListener(const Reference< XClipboardLis
|
||||
mClipboardListeners.push_back(listener);
|
||||
}
|
||||
|
||||
|
||||
void SAL_CALL AquaClipboard::removeClipboardListener(const Reference< XClipboardListener >& listener)
|
||||
throw( RuntimeException )
|
||||
{
|
||||
@ -232,7 +224,6 @@ void SAL_CALL AquaClipboard::removeClipboardListener(const Reference< XClipboard
|
||||
mClipboardListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
void AquaClipboard::applicationDidBecomeActive(NSNotification*)
|
||||
{
|
||||
ClearableMutexGuard aGuard(m_aMutex);
|
||||
@ -263,7 +254,6 @@ void AquaClipboard::applicationDidBecomeActive(NSNotification*)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AquaClipboard::fireClipboardChangedEvent()
|
||||
{
|
||||
ClearableMutexGuard aGuard(m_aMutex);
|
||||
@ -272,33 +262,31 @@ void AquaClipboard::fireClipboardChangedEvent()
|
||||
ClipboardEvent aEvent;
|
||||
|
||||
if (listeners.begin() != listeners.end())
|
||||
{
|
||||
{
|
||||
aEvent = ClipboardEvent(static_cast<OWeakObject*>(this), getContents());
|
||||
}
|
||||
}
|
||||
|
||||
aGuard.clear();
|
||||
|
||||
while (listeners.begin() != listeners.end())
|
||||
{
|
||||
if (listeners.front().is())
|
||||
{
|
||||
{
|
||||
try { listeners.front()->changedContents(aEvent); }
|
||||
catch (RuntimeException&) { }
|
||||
}
|
||||
}
|
||||
listeners.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AquaClipboard::fireLostClipboardOwnershipEvent(Reference<XClipboardOwner> oldOwner, Reference<XTransferable> oldContent)
|
||||
{
|
||||
BOOST_ASSERT(oldOwner.is());
|
||||
BOOST_ASSERT(oldOwner.is());
|
||||
|
||||
try { oldOwner->lostOwnership(static_cast<XClipboardEx*>(this), oldContent); }
|
||||
catch(RuntimeException&) { }
|
||||
try { oldOwner->lostOwnership(static_cast<XClipboardEx*>(this), oldContent); }
|
||||
catch(RuntimeException&) { }
|
||||
}
|
||||
|
||||
|
||||
void AquaClipboard::provideDataForType(NSPasteboard* sender, const NSString* type)
|
||||
{
|
||||
if( mXClipboardContent.is() )
|
||||
@ -314,17 +302,12 @@ void AquaClipboard::provideDataForType(NSPasteboard* sender, const NSString* typ
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// XFlushableClipboard
|
||||
//------------------------------------------------
|
||||
|
||||
void SAL_CALL AquaClipboard::flushClipboard()
|
||||
throw(RuntimeException)
|
||||
{
|
||||
if (mXClipboardContent.is())
|
||||
{
|
||||
Sequence<DataFlavor> flavorList = mXClipboardContent->getTransferDataFlavors();
|
||||
Sequence<DataFlavor> flavorList = mXClipboardContent->getTransferDataFlavors();
|
||||
sal_uInt32 nFlavors = flavorList.getLength();
|
||||
bool bInternal(false);
|
||||
|
||||
@ -341,32 +324,24 @@ void SAL_CALL AquaClipboard::flushClipboard()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSPasteboard* AquaClipboard::getPasteboard() const
|
||||
{
|
||||
return mPasteboard;
|
||||
return mPasteboard;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// XServiceInfo
|
||||
//-------------------------------------------------
|
||||
|
||||
OUString SAL_CALL AquaClipboard::getImplementationName() throw( RuntimeException )
|
||||
{
|
||||
return clipboard_getImplementationName();
|
||||
return clipboard_getImplementationName();
|
||||
}
|
||||
|
||||
|
||||
sal_Bool SAL_CALL AquaClipboard::supportsService( const OUString& /*ServiceName*/ ) throw( RuntimeException )
|
||||
{
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
|
||||
Sequence< OUString > SAL_CALL AquaClipboard::getSupportedServiceNames() throw( RuntimeException )
|
||||
{
|
||||
return clipboard_getSupportedServiceNames();
|
||||
return clipboard_getSupportedServiceNames();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Loading…
x
Reference in New Issue
Block a user