summaryrefslogtreecommitdiff
path: root/dtrans
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-02-06 09:23:58 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-02-06 09:23:58 +0000
commite4f94dcdf743d841d06610ac07e795a2009f0735 (patch)
treed7b7645efd94affa103d99cef44f6379056f8044 /dtrans
parentc349f2bae06b9658c40a97dd92d1bc7b14e5af87 (diff)
removed XDropTargetFactory according to new specification
Diffstat (limited to 'dtrans')
-rw-r--r--dtrans/source/X11/X11_droptarget.cxx66
-rw-r--r--dtrans/source/X11/X11_selection.cxx41
-rw-r--r--dtrans/source/X11/X11_selection.hxx58
-rw-r--r--dtrans/source/X11/X11_service.cxx45
-rw-r--r--dtrans/source/X11/dtransX11.xml1
5 files changed, 150 insertions, 61 deletions
diff --git a/dtrans/source/X11/X11_droptarget.cxx b/dtrans/source/X11/X11_droptarget.cxx
index 998e8bc1385d..582cde0caef0 100644
--- a/dtrans/source/X11/X11_droptarget.cxx
+++ b/dtrans/source/X11/X11_droptarget.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: X11_droptarget.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mh $ $Date: 2001-01-31 15:37:25 $
+ * last change: $Author: pl $ $Date: 2001-02-06 10:23:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,12 +62,39 @@
#include <X11_selection.hxx>
using namespace x11;
+using namespace rtl;
+using namespace com::sun::star::lang;
using namespace com::sun::star::datatransfer;
using namespace com::sun::star::datatransfer::dnd;
+DropTarget::DropTarget() :
+ ::cppu::WeakComponentImplHelper3<
+ XDropTarget,
+ XInitialization,
+ XServiceInfo
+ >( m_aMutex ),
+ m_bActive( false ),
+ m_nDefaultActions( 0 ),
+ m_aTargetWindow( None )
+{
+}
+
DropTarget::~DropTarget()
{
- SelectionManager::get().deregisterDropTarget( Reference< XDropTarget >(this) );
+ SelectionManager::get().deregisterDropTarget( this );
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::initialize( const Sequence< Any >& args )
+{
+ if( args.getLength() > 1 )
+ {
+ sal_Int32 aWindow = None;
+ args.getConstArray()[1] >>= aWindow;
+ SelectionManager::get().initialize( args );
+ SelectionManager::get().registerDropTarget( aWindow, this );
+ }
}
// --------------------------------------------------------------------------
@@ -199,3 +226,36 @@ void DropTarget::dropActionChanged( const DropTargetDragEvent& dtde )
(*it2)->dropActionChanged( dtde );
}
}
+
+/*
+ * XServiceInfo
+ */
+
+// ------------------------------------------------------------------------
+
+OUString DropTarget::getImplementationName( )
+{
+ return OUString::createFromAscii(XDND_DROPTARGET_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool DropTarget::supportsService( const OUString& ServiceName )
+{
+ Sequence < OUString > SupportedServicesNames = Xdnd_dropTarget_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > DropTarget::getSupportedServiceNames()
+{
+ return Xdnd_dropTarget_getSupportedServiceNames();
+}
+
+
diff --git a/dtrans/source/X11/X11_selection.cxx b/dtrans/source/X11/X11_selection.cxx
index 6572121cd037..a73dde38d825 100644
--- a/dtrans/source/X11/X11_selection.cxx
+++ b/dtrans/source/X11/X11_selection.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: X11_selection.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: pl $ $Date: 2001-02-05 13:08:59 $
+ * last change: $Author: pl $ $Date: 2001-02-06 10:23:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -229,9 +229,8 @@ SelectionManager::IncrementalTransfer::IncrementalTransfer(
// ------------------------------------------------------------------------
SelectionManager::SelectionManager() :
- ::cppu::WeakComponentImplHelper7<
+ ::cppu::WeakComponentImplHelper6<
XDropTargetDropContext,
- XDropTargetFactory,
XDragSource,
XDragSourceContext,
XInitialization,
@@ -2468,28 +2467,17 @@ void SelectionManager::deregisterHandler( Atom selection )
m_pInstance = NULL;
}
-/*
- * XDropTargetFactory
- */
-
// ------------------------------------------------------------------------
-Reference< XDropTarget > SelectionManager::createDropTarget( const Sequence< sal_Int8 >& windowId )
+void SelectionManager::registerDropTarget( Window aWindow, DropTarget* pTarget )
{
- Window aWindow = None;
- Reference< XDropTarget > xRet;
-
- if( windowId.getLength() == sizeof( aWindow ) )
- aWindow = *(Window*)windowId.getConstArray();
+ MutexGuard aGuard(m_aMutex);
// sanity check
::std::hash_map< Window, DropTargetEntry >::const_iterator it =
m_aDropTargets.find( aWindow );
if( it != m_aDropTargets.end() )
- {
OSL_ASSERT( "attempt to register window as drop target twice" );
- xRet = it->second.m_xTarget;
- }
else if( aWindow )
{
XSelectInput( m_pDisplay, aWindow, PropertyChangeMask );
@@ -2497,7 +2485,7 @@ Reference< XDropTarget > SelectionManager::createDropTarget( const Sequence< sal
// set XdndAware
XChangeProperty( m_pDisplay, aWindow, m_nXdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&nXdndProtocolRevision, 1 );
- DropTargetEntry aEntry( new DropTarget() );
+ DropTargetEntry aEntry( pTarget );
// get root window of window (in 99.999% of all cases this will be
// DefaultRootWindow( m_pDisplay )
int x, y;
@@ -2505,27 +2493,18 @@ Reference< XDropTarget > SelectionManager::createDropTarget( const Sequence< sal
XGetGeometry( m_pDisplay, aWindow, &aEntry.m_aRootWindow,
&x, &y, &w, &h, &bw, &d );
m_aDropTargets[ aWindow ] = aEntry;
- xRet = aEntry.m_xTarget;
}
else
OSL_ASSERT( "attempt to register None as drop target" );
-
- return xRet;
}
// ------------------------------------------------------------------------
-void SelectionManager::deregisterDropTarget( const Reference< XDropTarget >& xTarget )
+void SelectionManager::deregisterDropTarget( Window aWindow )
{
- for( ::std::hash_map< Window, DropTargetEntry >::iterator it =
- m_aDropTargets.begin(); it != m_aDropTargets.end(); ++it )
- {
- if( it->second.m_xTarget == xTarget )
- {
- m_aDropTargets.erase( it );
- break;
- }
- }
+ MutexGuard aGuard(m_aMutex);
+
+ m_aDropTargets.erase( aWindow );
}
/*
diff --git a/dtrans/source/X11/X11_selection.hxx b/dtrans/source/X11/X11_selection.hxx
index 79af207e213e..da609aeaf07d 100644
--- a/dtrans/source/X11/X11_selection.hxx
+++ b/dtrans/source/X11/X11_selection.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: X11_selection.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: pl $ $Date: 2001-02-05 13:08:59 $
+ * last change: $Author: pl $ $Date: 2001-02-06 10:23:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,12 +62,12 @@
#ifndef _DTRANS_X11_SELECTION_HXX_
#define _DTRANS_X11_SELECTION_HXX_
-#ifndef _CPPUHELPER_COMPBASE1_HXX_
-#include <cppuhelper/compbase1.hxx>
+#ifndef _CPPUHELPER_COMPBASE3_HXX_
+#include <cppuhelper/compbase3.hxx>
#endif
-#ifndef _CPPUHELPER_COMPBASE7_HXX_
-#include <cppuhelper/compbase7.hxx>
+#ifndef _CPPUHELPER_COMPBASE6_HXX_
+#include <cppuhelper/compbase6.hxx>
#endif
#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
@@ -82,10 +82,6 @@
#include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
#endif
-#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETFACTORY_HPP_
-#include <com/sun/star/datatransfer/dnd/XDropTargetFactory.hpp>
-#endif
-
#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGSOURCE_HPP_
#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
#endif
@@ -125,6 +121,7 @@
#include <X11/Xlib.h>
#define XDND_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndSupport"
+#define XDND_DROPTARGET_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndDropTarget"
using namespace ::com::sun::star::uno;
@@ -141,18 +138,21 @@ namespace x11 {
};
class DropTarget :
- public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::dnd::XDropTarget >
+ public ::cppu::WeakComponentImplHelper3<
+ ::com::sun::star::datatransfer::dnd::XDropTarget,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::lang::XServiceInfo
+ >
{
public:
::osl::Mutex m_aMutex;
bool m_bActive;
sal_Int8 m_nDefaultActions;
+ Window m_aTargetWindow;
::std::list< Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener > >
m_aListeners;
- DropTarget() :
- m_bActive( false ),
- m_nDefaultActions( 0 ) {}
+ DropTarget();
virtual ~DropTarget();
// convenience functions that loop over listeners
@@ -161,6 +161,10 @@ namespace x11 {
void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde );
void dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde );
void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& args );
+
// XDropTarget
virtual void SAL_CALL addDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& );
virtual void SAL_CALL removeDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& );
@@ -168,12 +172,17 @@ namespace x11 {
virtual void SAL_CALL setActive( sal_Bool active );
virtual sal_Int8 SAL_CALL getDefaultActions();
virtual void SAL_CALL setDefaultActions( sal_Int8 actions );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName();
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupportedServiceNames();
};
class SelectionManager :
- public ::cppu::WeakComponentImplHelper7<
+ public ::cppu::WeakComponentImplHelper6<
::com::sun::star::datatransfer::dnd::XDropTargetDropContext,
- ::com::sun::star::datatransfer::dnd::XDropTargetFactory,
::com::sun::star::datatransfer::dnd::XDragSource,
::com::sun::star::datatransfer::dnd::XDragSourceContext,
::com::sun::star::lang::XInitialization,
@@ -236,26 +245,22 @@ namespace x11 {
struct DropTargetEntry
{
DropTarget* m_pTarget;
- Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >
- m_xTarget;
Window m_aRootWindow;
DropTargetEntry() : m_pTarget( NULL ), m_aRootWindow( None ) {}
DropTargetEntry( DropTarget* pTarget ) :
m_pTarget( pTarget ),
- m_xTarget( pTarget ),
m_aRootWindow( None )
{}
DropTargetEntry( const DropTargetEntry& rEntry ) :
m_pTarget( rEntry.m_pTarget ),
- m_xTarget( rEntry.m_xTarget ),
m_aRootWindow( rEntry.m_aRootWindow )
{}
~DropTargetEntry() {}
DropTarget* operator->() const { return m_pTarget; }
DropTargetEntry& operator=(const DropTargetEntry& rEntry)
- { m_pTarget = rEntry.m_pTarget; m_xTarget = rEntry.m_xTarget; m_aRootWindow = rEntry.m_aRootWindow; return *this; }
+ { m_pTarget = rEntry.m_pTarget; m_aRootWindow = rEntry.m_aRootWindow; return *this; }
};
// internal data
@@ -431,6 +436,10 @@ namespace x11 {
bool getPasteDataTypes( Atom selection, Sequence< ::com::sun::star::datatransfer::DataFlavor >& rTypes );
bool getPasteData( Atom selection, const ::rtl::OUString& rType, Sequence< sal_Int8 >& rData );
+ // for XDropTarget to register/deregister itself
+ void registerDropTarget( Window aWindow, DropTarget* pTarget );
+ void deregisterDropTarget( Window aWindow );
+
// XDropTargetDragContext
virtual void SAL_CALL accept( sal_Int8 dragOperation );
virtual void SAL_CALL reject();
@@ -441,9 +450,6 @@ namespace x11 {
// XDropTargetDropContext
virtual void SAL_CALL dropComplete( sal_Bool success );
- // XDropTargetFactory
- virtual Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >
- SAL_CALL createDropTarget( const Sequence< sal_Int8 >& windowId );
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName();
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
@@ -483,6 +489,10 @@ namespace x11 {
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Xdnd_createInstance(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Xdnd_dropTarget_getSupportedServiceNames();
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Xdnd_dropTarget_createInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
+
// ------------------------------------------------------------------------
}
diff --git a/dtrans/source/X11/X11_service.cxx b/dtrans/source/X11/X11_service.cxx
index 07ecb2a5d4da..b65f6a8eb6e0 100644
--- a/dtrans/source/X11/X11_service.cxx
+++ b/dtrans/source/X11/X11_service.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: X11_service.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mh $ $Date: 2001-01-31 15:37:28 $
+ * last change: $Author: pl $ $Date: 2001-02-06 10:23:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,6 +122,23 @@ Reference< XInterface > SAL_CALL Xdnd_createInstance(
return Reference < XInterface >( ( OWeakObject * )& SelectionManager::get() );
}
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL Xdnd_dropTarget_getSupportedServiceNames()
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DropTarget");
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL Xdnd_dropTarget_createInstance(
+ const Reference< XMultiServiceFactory > & xMultiServiceFactory)
+{
+ return Reference < XInterface >( ( OWeakObject * ) new DropTarget() );
+}
+
}
static const OUString& getClipboardImplementationName()
@@ -148,6 +165,18 @@ static const OUString& getXdndServiceName()
return aImpl;
}
+static const OUString& getXdndDropTargetImplementationName()
+{
+ static OUString aImpl = OUString::createFromAscii(XDND_DROPTARGET_IMPLEMENTATION_NAME);
+ return aImpl;
+}
+
+static const OUString& getXdndDropTargetServiceName()
+{
+ static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DropTarget" );
+ return aImpl;
+}
+
extern "C" {
void SAL_CALL component_getImplementationEnvironment(
const sal_Char** ppEnvTypeName,
@@ -176,6 +205,12 @@ extern "C" {
aImplName += getXdndServiceName();
xKey->createKey( aImplName );
+ aImplName = OUString::createFromAscii( "/" );
+ aImplName += getXdndDropTargetImplementationName();
+ aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
+ aImplName += getXdndDropTargetServiceName();
+ xKey->createKey( aImplName );
+
return sal_True;
}
catch( ::com::sun::star::registry::InvalidRegistryException& )
@@ -213,6 +248,12 @@ extern "C" {
xMgr, aImplName, Xdnd_createInstance,
Xdnd_getSupportedServiceNames() );
}
+ else if( aImplName.equals( getXdndDropTargetImplementationName() ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ xMgr, aImplName, Xdnd_dropTarget_createInstance,
+ Xdnd_dropTarget_getSupportedServiceNames() );
+ }
if( xFactory.is() )
{
xFactory->acquire();
diff --git a/dtrans/source/X11/dtransX11.xml b/dtrans/source/X11/dtransX11.xml
index 53825958c5b3..4bb92e8fe38a 100644
--- a/dtrans/source/X11/dtransX11.xml
+++ b/dtrans/source/X11/dtransX11.xml
@@ -42,7 +42,6 @@
<Type> com.sun.star.datatransfer.dnd.XDropTargetDropContext </Type>
<Type> com.sun.star.datatransfer.dnd.XDropTargetDragContext </Type>
<Type> com.sun.star.datatransfer.dnd.XDropTarget </Type>
-<Type> com.sun.star.datatransfer.dnd.XDropTargetFactory </Type>
<Type> com.sun.star.datatransfer.dnd.DNDConstants </Type>
<Type> com.sun.star.datatransfer.dnd.XDragSource </Type>
<Type> com.sun.star.datatransfer.dnd.XDragSourceContext </Type>