Files
libreoffice/vcl/source/window/dndlcon.cxx

501 lines
16 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Pedro Giffuni: Avoid some uses of non portable #!/bin/bash in shell scripts. http://svn.apache.org/viewvc?view=revision&revision=1235297 Reduce the dependencies on non standard GNU copy. http://svn.apache.org/viewvc?view=revision&revision=1238684 Correct /usr/bin/env path. http://svn.apache.org/viewvc?view=revision&revision=1235619 Complex Toolbar Controls Extension from the SDK Patches contributed by Ariel Constenla-Haile http://svn.apache.org/viewvc?view=revision&revision=1190390 i118615 - make epm more verbose http://svn.apache.org/viewvc?view=revision&revision=1204288 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 Patches contributed by Juergen Schmidt: jsc341: i117327: take care if no dependency node in current description exists, create one http://svn.apache.org/viewvc?view=revision&revision=1172101 jsc341: i117327: add extra extension dependency check http://svn.apache.org/viewvc?view=revision&revision=1172098 make initial branding changes http://svn.apache.org/viewvc?view=revision&revision=1231878 Patches contributed by Ingo Schmidt native373: #i117733# no linux jre installation on 64 bit systems http://svn.apache.org/viewvc?view=revision&revision=1167536 native373: ##164464# improve debian support http://svn.apache.org/viewvc?view=revision&revision=1167537 Patch contribtued by Armin Le-Grand: Changed various aspects concerning usages of old vendor names http://svn.apache.org/viewvc?view=revision&revision=1293313 fix for neon webdav, remove coinmp bits, improve odk script, cleanup & remove OS/2 conditionals, system ucpp fixes, remove OS/2 conditionals, restore our license filenames.
2012-11-06 12:12:33 +00: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 .
*/
2001-02-05 08:45:05 +00:00
#include <dndlcon.hxx>
2001-02-05 08:45:05 +00:00
using namespace ::cppu;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::datatransfer;
using namespace ::com::sun::star::datatransfer::dnd;
DNDListenerContainer::DNDListenerContainer( sal_Int8 nDefaultActions )
: WeakComponentImplHelper4< XDragGestureRecognizer, XDropTargetDragContext, XDropTargetDropContext, XDropTarget >(GetMutex())
2001-02-05 08:45:05 +00:00
{
m_bActive = true;
2001-02-09 14:59:18 +00:00
m_nDefaultActions = nDefaultActions;
2001-02-05 08:45:05 +00:00
}
DNDListenerContainer::~DNDListenerContainer()
{
}
// DNDListenerContainer::addDragGestureListener
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::addDragGestureListener( const Reference< XDragGestureListener >& dgl )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
rBHelper.addListener( cppu::UnoType<XDragGestureListener>::get(), dgl );
2001-02-05 08:45:05 +00:00
}
// DNDListenerContainer::removeDragGestureListener
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::removeDragGestureListener( const Reference< XDragGestureListener >& dgl )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
rBHelper.removeListener( cppu::UnoType<XDragGestureListener>::get(), dgl );
2001-02-05 08:45:05 +00:00
}
// DNDListenerContainer::resetRecognizer
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::resetRecognizer( )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
}
// DNDListenerContainer::addDropTargetListener
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::addDropTargetListener( const Reference< XDropTargetListener >& dtl )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
rBHelper.addListener( cppu::UnoType<XDropTargetListener>::get(), dtl );
2001-02-05 08:45:05 +00:00
}
// DNDListenerContainer::removeDropTargetListener
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::removeDropTargetListener( const Reference< XDropTargetListener >& dtl )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
rBHelper.removeListener( cppu::UnoType<XDropTargetListener>::get(), dtl );
2001-02-05 08:45:05 +00:00
}
// DNDListenerContainer::isActive
2001-02-05 08:45:05 +00:00
sal_Bool SAL_CALL DNDListenerContainer::isActive( )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
return m_bActive;
}
// DNDListenerContainer::setActive
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::setActive( sal_Bool active )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
m_bActive = active;
}
// DNDListenerContainer::getDefaultActions
2001-02-05 08:45:05 +00:00
sal_Int8 SAL_CALL DNDListenerContainer::getDefaultActions( )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
return m_nDefaultActions;
}
// DNDListenerContainer::setDefaultActions
2001-02-05 08:45:05 +00:00
void SAL_CALL DNDListenerContainer::setDefaultActions( sal_Int8 actions )
throw(RuntimeException, std::exception)
2001-02-05 08:45:05 +00:00
{
m_nDefaultActions = actions;
}
// DNDListenerContainer::fireDropEvent
2001-02-05 08:45:05 +00:00
sal_uInt32 DNDListenerContainer::fireDropEvent( const Reference< XDropTargetDropContext >& context,
2001-02-20 10:17:45 +00:00
sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions,
2001-02-05 08:45:05 +00:00
const Reference< XTransferable >& transferable )
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDropTargetListener>::get());
2001-02-05 08:45:05 +00:00
2001-02-14 15:37:54 +00:00
if( pContainer && m_bActive )
2001-02-05 08:45:05 +00:00
{
OInterfaceIteratorHelper aIterator( *pContainer );
// remember context to use in own context methods
m_xDropTargetDropContext = context;
2001-02-20 10:17:45 +00:00
// do not construct the event before you are sure at least one listener is registered
DropTargetDropEvent aEvent( static_cast < XDropTarget * > (this), 0,
static_cast < XDropTargetDropContext * > (this), dropAction,
2001-02-20 10:17:45 +00:00
locationX, locationY, sourceActions, transferable );
2001-02-05 08:45:05 +00:00
while (aIterator.hasMoreElements())
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDropTargetListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
// fire drop until the first one has accepted
if( m_xDropTargetDropContext.is() )
xListener->drop( aEvent );
else
{
DropTargetEvent aDTEvent( static_cast < XDropTarget * > (this), 0 );
xListener->dragExit( aDTEvent );
}
2001-02-05 08:45:05 +00:00
nRet++;
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
// if context still valid, then reject drop
if( m_xDropTargetDropContext.is() )
{
m_xDropTargetDropContext.clear();
try
{
context->rejectDrop();
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
{
}
}
2001-02-05 08:45:05 +00:00
}
return nRet;
}
// DNDListenerContainer::fireDragExitEvent
2001-02-05 08:45:05 +00:00
sal_uInt32 DNDListenerContainer::fireDragExitEvent()
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDropTargetListener>::get());
2001-02-05 08:45:05 +00:00
2001-02-14 15:37:54 +00:00
if( pContainer && m_bActive )
2001-02-05 08:45:05 +00:00
{
2001-02-20 10:17:45 +00:00
OInterfaceIteratorHelper aIterator( *pContainer );
2001-02-05 08:45:05 +00:00
// do not construct the event before you are sure at least one listener is registered
DropTargetEvent aEvent( static_cast < XDropTarget * > (this), 0 );
while (aIterator.hasMoreElements())
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDropTargetListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
xListener->dragExit( aEvent );
2001-02-05 08:45:05 +00:00
nRet++;
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
}
return nRet;
}
// DNDListenerContainer::fireDragOverEvent
2001-02-05 08:45:05 +00:00
sal_uInt32 DNDListenerContainer::fireDragOverEvent( const Reference< XDropTargetDragContext >& context,
2001-02-20 10:17:45 +00:00
sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions )
2001-02-05 08:45:05 +00:00
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDropTargetListener>::get());
2001-02-05 08:45:05 +00:00
2001-02-14 15:37:54 +00:00
if( pContainer && m_bActive )
2001-02-05 08:45:05 +00:00
{
OInterfaceIteratorHelper aIterator( *pContainer );
// remember context to use in own context methods
m_xDropTargetDragContext = context;
2001-02-20 10:17:45 +00:00
// do not construct the event before you are sure at least one listener is registered
DropTargetDragEvent aEvent( static_cast < XDropTarget * > (this), 0,
static_cast < XDropTargetDragContext * > (this),
dropAction, locationX, locationY, sourceActions );
2001-02-20 10:17:45 +00:00
2001-02-05 08:45:05 +00:00
while (aIterator.hasMoreElements())
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDropTargetListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
if( m_xDropTargetDragContext.is() )
xListener->dragOver( aEvent );
nRet++;
2001-02-05 08:45:05 +00:00
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
// if context still valid, then reject drag
if( m_xDropTargetDragContext.is() )
{
m_xDropTargetDragContext.clear();
try
{
context->rejectDrag();
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
{
}
}
2001-02-05 08:45:05 +00:00
}
return nRet;
}
// DNDListenerContainer::fireDragEnterEvent
2001-02-05 08:45:05 +00:00
sal_uInt32 DNDListenerContainer::fireDragEnterEvent( const Reference< XDropTargetDragContext >& context,
2001-02-20 10:17:45 +00:00
sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions,
const Sequence< DataFlavor >& dataFlavors )
2001-02-05 08:45:05 +00:00
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDropTargetListener>::get());
2001-02-05 08:45:05 +00:00
2001-02-14 15:37:54 +00:00
if( pContainer && m_bActive )
2001-02-05 08:45:05 +00:00
{
OInterfaceIteratorHelper aIterator( *pContainer );
// remember context to use in own context methods
m_xDropTargetDragContext = context;
2001-02-20 10:17:45 +00:00
// do not construct the event before you are sure at least one listener is registered
DropTargetDragEnterEvent aEvent( static_cast < XDropTarget * > (this), 0,
static_cast < XDropTargetDragContext * > (this),
dropAction, locationX, locationY, sourceActions, dataFlavors );
2001-02-20 10:17:45 +00:00
2001-02-05 08:45:05 +00:00
while (aIterator.hasMoreElements())
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDropTargetListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
if( m_xDropTargetDragContext.is() )
xListener->dragEnter( aEvent );
2001-02-05 08:45:05 +00:00
nRet++;
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
// if context still valid, then reject drag
if( m_xDropTargetDragContext.is() )
{
m_xDropTargetDragContext.clear();
try
{
context->rejectDrag();
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
{
}
}
2001-02-05 08:45:05 +00:00
}
return nRet;
}
// DNDListenerContainer::fireDropActionChangedEvent
2001-02-05 08:45:05 +00:00
sal_uInt32 DNDListenerContainer::fireDropActionChangedEvent( const Reference< XDropTargetDragContext >& context,
2001-02-20 10:17:45 +00:00
sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions )
2001-02-05 08:45:05 +00:00
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDropTargetListener>::get());
2001-02-05 08:45:05 +00:00
2001-02-14 15:37:54 +00:00
if( pContainer && m_bActive )
2001-02-05 08:45:05 +00:00
{
OInterfaceIteratorHelper aIterator( *pContainer );
// remember context to use in own context methods
m_xDropTargetDragContext = context;
2001-02-20 10:17:45 +00:00
// do not construct the event before you are sure at least one listener is registered
DropTargetDragEvent aEvent( static_cast < XDropTarget * > (this), 0,
static_cast < XDropTargetDragContext * > (this),
dropAction, locationX, locationY, sourceActions );
2001-02-20 10:17:45 +00:00
2001-02-05 08:45:05 +00:00
while (aIterator.hasMoreElements())
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDropTargetListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
if( m_xDropTargetDragContext.is() )
xListener->dropActionChanged( aEvent );
nRet++;
2001-02-05 08:45:05 +00:00
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
// if context still valid, then reject drag
if( m_xDropTargetDragContext.is() )
{
m_xDropTargetDragContext.clear();
try
{
context->rejectDrag();
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
{
}
}
2001-02-05 08:45:05 +00:00
}
return nRet;
}
// DNDListenerContainer::fireDragGestureEvent
sal_uInt32 DNDListenerContainer::fireDragGestureEvent( sal_Int8 dragAction, sal_Int32 dragOriginX,
2001-02-20 10:17:45 +00:00
sal_Int32 dragOriginY, const Reference< XDragSource >& dragSource, const Any& triggerEvent )
2001-02-05 08:45:05 +00:00
{
sal_uInt32 nRet = 0;
// fire DropTargetDropEvent on all XDropTargetListeners
OInterfaceContainerHelper *pContainer = rBHelper.getContainer( cppu::UnoType<XDragGestureListener>::get());
2001-02-05 08:45:05 +00:00
if( pContainer )
{
OInterfaceIteratorHelper aIterator( *pContainer );
2001-02-20 10:17:45 +00:00
// do not construct the event before you are sure at least one listener is registered
DragGestureEvent aEvent( static_cast < XDragGestureRecognizer * > (this), dragAction,
dragOriginX, dragOriginY, dragSource, triggerEvent );
2001-02-05 08:45:05 +00:00
while( aIterator.hasMoreElements() )
{
// FIXME: this can be simplified as soon as the Iterator has a remove method
Reference< XInterface > xElement( aIterator.next() );
try
{
// this may result in a runtime exception
Reference < XDragGestureListener > xListener( xElement, UNO_QUERY );
if( xListener.is() )
{
xListener->dragGestureRecognized( aEvent );
nRet++;
}
}
2011-06-18 00:01:50 +01:00
catch (const RuntimeException&)
2001-02-05 08:45:05 +00:00
{
pContainer->removeInterface( xElement );
}
}
}
return nRet;
}
// DNDListenerContainer::acceptDrag
void SAL_CALL DNDListenerContainer::acceptDrag( sal_Int8 dragOperation ) throw (RuntimeException, std::exception)
{
if( m_xDropTargetDragContext.is() )
{
m_xDropTargetDragContext->acceptDrag( dragOperation );
m_xDropTargetDragContext.clear();
}
}
// DNDListenerContainer::rejectDrag
void SAL_CALL DNDListenerContainer::rejectDrag( ) throw (RuntimeException, std::exception)
{
// nothing to do here
}
// DNDListenerContainer::acceptDrop
void SAL_CALL DNDListenerContainer::acceptDrop( sal_Int8 dropOperation ) throw (RuntimeException, std::exception)
{
if( m_xDropTargetDropContext.is() )
m_xDropTargetDropContext->acceptDrop( dropOperation );
}
// DNDListenerContainer::rejectDrop
void SAL_CALL DNDListenerContainer::rejectDrop( ) throw (RuntimeException, std::exception)
{
// nothing to do here
}
// DNDListenerContainer::dropComplete
void SAL_CALL DNDListenerContainer::dropComplete( sal_Bool success ) throw (RuntimeException, std::exception)
{
if( m_xDropTargetDropContext.is() )
{
m_xDropTargetDropContext->dropComplete( success );
m_xDropTargetDropContext.clear();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */