summaryrefslogtreecommitdiff
path: root/dtrans/source
diff options
context:
space:
mode:
Diffstat (limited to 'dtrans/source')
-rw-r--r--dtrans/source/X11/X11_clipboard.cxx305
-rw-r--r--dtrans/source/X11/X11_clipboard.hxx188
-rw-r--r--dtrans/source/X11/X11_droptarget.cxx201
-rw-r--r--dtrans/source/X11/X11_selection.cxx1687
-rw-r--r--dtrans/source/X11/X11_selection.hxx455
-rw-r--r--dtrans/source/X11/X11_service.cxx225
-rw-r--r--dtrans/source/X11/X11_transferable.cxx154
-rw-r--r--dtrans/source/X11/X11_transferable.hxx116
-rw-r--r--dtrans/source/X11/dtransX11.xml66
-rw-r--r--dtrans/source/X11/makefile.mk111
-rw-r--r--dtrans/source/cnttype/exports.dxp3
-rw-r--r--dtrans/source/cnttype/makefile.mk110
-rw-r--r--dtrans/source/cnttype/mcnttfactory.cxx163
-rw-r--r--dtrans/source/cnttype/mcnttfactory.hxx133
-rw-r--r--dtrans/source/cnttype/mcnttype.cxx451
-rw-r--r--dtrans/source/cnttype/mcnttype.hxx145
-rw-r--r--dtrans/source/cnttype/mcnttype.xml49
-rw-r--r--dtrans/source/cnttype/mctfentry.cxx206
-rw-r--r--dtrans/source/cnttype/wbench/makefile.mk91
-rw-r--r--dtrans/source/cnttype/wbench/testcnttype.cxx330
-rw-r--r--dtrans/source/generic/clipboardmanager.cxx300
-rw-r--r--dtrans/source/generic/clipboardmanager.hxx230
-rw-r--r--dtrans/source/generic/dtrans.cxx161
-rw-r--r--dtrans/source/generic/dtrans.xml58
-rw-r--r--dtrans/source/generic/exports.dxp3
-rw-r--r--dtrans/source/generic/exports.map9
-rw-r--r--dtrans/source/generic/generic_clipboard.cxx251
-rw-r--r--dtrans/source/generic/generic_clipboard.hxx242
-rw-r--r--dtrans/source/generic/makefile.mk101
-rw-r--r--dtrans/source/test/makefile.mk89
-rw-r--r--dtrans/source/test/test_dtrans.cxx575
-rw-r--r--dtrans/source/win32/dnd/dnd.xml58
-rw-r--r--dtrans/source/win32/dnd/dndentry.cxx194
-rw-r--r--dtrans/source/win32/dnd/globals.cxx141
-rw-r--r--dtrans/source/win32/dnd/globals.hxx101
-rw-r--r--dtrans/source/win32/dnd/makefile.mk140
-rw-r--r--dtrans/source/win32/dnd/source.cxx242
-rw-r--r--dtrans/source/win32/dnd/source.hxx177
-rw-r--r--dtrans/source/win32/dnd/sourcecontext.cxx108
-rw-r--r--dtrans/source/win32/dnd/sourcecontext.hxx108
-rw-r--r--dtrans/source/win32/dnd/target.cxx571
-rw-r--r--dtrans/source/win32/dnd/target.hxx238
-rw-r--r--dtrans/source/win32/dnd/targetdragcontext.cxx99
-rw-r--r--dtrans/source/win32/dnd/targetdragcontext.hxx107
-rw-r--r--dtrans/source/win32/dnd/targetdropcontext.cxx91
-rw-r--r--dtrans/source/win32/dnd/targetdropcontext.hxx100
-rw-r--r--dtrans/source/win32/workbench/XTDo.cxx459
-rw-r--r--dtrans/source/win32/workbench/XTDo.hxx162
-rw-r--r--dtrans/source/win32/workbench/makefile.mk130
-rw-r--r--dtrans/source/win32/workbench/test_wincb.cxx427
-rw-r--r--dtrans/source/win32/workbench/testmarshal.cxx277
51 files changed, 11138 insertions, 0 deletions
diff --git a/dtrans/source/X11/X11_clipboard.cxx b/dtrans/source/X11/X11_clipboard.cxx
new file mode 100644
index 000000000000..fc390fb84c50
--- /dev/null
+++ b/dtrans/source/X11/X11_clipboard.cxx
@@ -0,0 +1,305 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_clipboard.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:24 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <X11/Xatom.h>
+#include <X11_clipboard.hxx>
+#include <X11_transferable.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_RENDERINGCAPABILITIES_HPP_
+#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h> // declaration of generic uno interface
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx> // mapping stuff
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::clipboard;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+using namespace x11;
+
+// ------------------------------------------------------------------------
+
+X11Clipboard::X11Clipboard() :
+ m_aMutex(),
+ WeakComponentImplHelper3< XClipboardEx, XServiceInfo, XInitialization > (m_aMutex)
+{
+ // XXX: currently X11Clipboard starts without arguments
+ // this will need to change
+ initialize( Sequence< Any >() );
+}
+
+// ------------------------------------------------------------------------
+
+X11Clipboard::~X11Clipboard()
+{
+#ifdef DEBUG
+ fprintf( stderr, "shutting down X11Clipboard\n" );
+#endif
+ SelectionManager& rManager(SelectionManager::get());
+ rManager.deregisterHandler( XA_PRIMARY );
+ rManager.deregisterHandler( rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ) );
+}
+
+// ------------------------------------------------------------------------
+
+void X11Clipboard::initialize( const Sequence< Any >& arguments )
+{
+ SelectionManager& rManager = SelectionManager::get();
+ m_xSelectionManager = &rManager;
+ rManager.initialize( arguments );
+ rManager.registerHandler( XA_PRIMARY, *this );
+ rManager.registerHandler( rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ), *this );
+
+ if ( rManager.getDisplay() == NULL )
+ throw RuntimeException(
+ OUString::createFromAscii("DISPLAY not set or connect to specified X server failed"),
+ static_cast < XClipboard * > (this));
+}
+
+// ------------------------------------------------------------------------
+
+void X11Clipboard::fireChangedContentsEvent()
+{
+#if 0
+ OInterfaceContainerHelper *pContainer =
+ rBHelper.aLC.getContainer(getCppuType( (Reference < XClipboardListener > *) 0));
+
+ if (pContainer)
+ {
+ ClipboardEvent aEvent(static_cast < XClipboard * > (this), m_aContents);
+ OInterfaceIteratorHelper aIterator(*pContainer);
+
+ while (aIterator.hasMoreElements())
+ {
+ Reference < XClipboardListener > xListener(aIterator.next(), UNO_QUERY);
+ if (xListener.is())
+ xListener->changedContents(aEvent);
+ }
+ }
+#endif
+}
+
+// ------------------------------------------------------------------------
+
+void X11Clipboard::clearContents()
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if ( m_aOwner.is() ) {
+ m_aOwner->lostOwnership(static_cast < XClipboard * > (this), m_aContents);
+ m_aContents.clear();
+ m_aOwner.clear();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL X11Clipboard::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(X11_CLIPBOARD_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SAL_CALL X11Clipboard::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Sequence < OUString > SupportedServicesNames = X11Clipboard_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL X11Clipboard::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return X11Clipboard_getSupportedServiceNames();
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XTransferable > SAL_CALL X11Clipboard::getContents()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if( ! m_aContents.is() )
+ m_aContents = new X11Transferable( SelectionManager::get() );
+ return m_aContents;
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL X11Clipboard::setContents(
+ const Reference< XTransferable >& xTrans,
+ const Reference< XClipboardOwner >& xClipboardOwner )
+ throw(RuntimeException)
+{
+ // remember old values for callbacks before setting the new ones.
+ ClearableMutexGuard aGuard(m_aMutex);
+
+ Reference< XClipboardOwner > oldOwner( m_aOwner );
+ m_aOwner = xClipboardOwner;
+
+ Reference< XTransferable > oldContents( m_aContents );
+ m_aContents = xTrans;
+
+ aGuard.clear();
+
+ // for now request ownership for both selections
+ SelectionManager& rSelectionManager = SelectionManager::get();
+ rSelectionManager.requestOwnership( XA_PRIMARY );
+ rSelectionManager.requestOwnership( rSelectionManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ) );
+
+ // notify old owner on loss of ownership
+ if( oldOwner.is() )
+ oldOwner->lostOwnership(static_cast < XClipboard * > (this), oldContents);
+
+ // notify all listeners on content changes
+ fireChangedContentsEvent();
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL X11Clipboard::getName()
+ throw(RuntimeException)
+{
+ return OUString();
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL X11Clipboard::getRenderingCapabilities()
+ throw(RuntimeException)
+{
+ return RenderingCapabilities::Delayed;
+}
+
+
+// ------------------------------------------------------------------------
+#if 0
+void SAL_CALL X11Clipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ rBHelper.addListener( getCppuType( (const ::com::sun::star::uno::Reference< XClipboard > *) 0), listener );
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL X11Clipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ rBHelper.removeListener( getCppuType( (const Reference< XClipboardListener > *) 0 ), listener );
+}
+
+#endif
+
+// ------------------------------------------------------------------------
+
+Reference< XTransferable > X11Clipboard::getTransferable()
+{
+ return getContents();
+}
+
+// ------------------------------------------------------------------------
+
+void X11Clipboard::clearTransferable()
+{
+ clearContents();
+}
+
diff --git a/dtrans/source/X11/X11_clipboard.hxx b/dtrans/source/X11/X11_clipboard.hxx
new file mode 100644
index 000000000000..c627269ecf07
--- /dev/null
+++ b/dtrans/source/X11/X11_clipboard.hxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_clipboard.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:25 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_X11_CLIPBOARD_HXX_
+#define _DTRANS_X11_CLIPBOARD_HXX_
+
+#ifndef _DTRANS_X11_SELECTION_HXX_
+#include <X11_selection.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDEX_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDNOTIFIER_HPP_
+//#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#endif
+
+#ifndef _CPPUHELPER_COMPBASE3_HXX_
+#include <cppuhelper/compbase3.hxx>
+#endif
+
+// ------------------------------------------------------------------------
+
+#define X11_CLIPBOARD_IMPLEMENTATION_NAME "com.sun.star.datatransfer.X11ClipboardSupport"
+
+namespace x11 {
+
+ class X11Clipboard :
+ public ::cppu::WeakComponentImplHelper3 <
+ ::com::sun::star::datatransfer::clipboard::XClipboardEx,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XInitialization
+ >,
+ public SelectionAdaptor
+ {
+ ::osl::Mutex m_aMutex;
+
+ Reference< ::com::sun::star::datatransfer::XTransferable > m_aContents;
+ Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
+
+ Reference< ::com::sun::star::lang::XInitialization > m_xSelectionManager;
+
+ virtual ~X11Clipboard();
+
+ protected:
+
+
+ friend class SelectionManager;
+ friend class X11_Transferable;
+
+ void fireChangedContentsEvent();
+ void clearContents();
+
+ public:
+
+ X11Clipboard();
+
+ /*
+ * XInitialization
+ */
+ virtual void SAL_CALL initialize( const Sequence< Any >& arguments );
+
+ /*
+ * XServiceInfo
+ */
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(RuntimeException);
+
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(RuntimeException);
+
+ /*
+ * XClipboard
+ */
+
+ virtual Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
+ throw(RuntimeException);
+
+ virtual void SAL_CALL setContents(
+ const Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans,
+ const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
+ throw(RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getName()
+ throw(RuntimeException);
+
+ /*
+ * XClipboardEx
+ */
+
+ virtual sal_Int8 SAL_CALL getRenderingCapabilities()
+ throw(RuntimeException);
+
+ /*
+ * XClipboardNotifier
+ */
+#if 0
+ virtual void SAL_CALL addClipboardListener(
+ const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
+ throw(RuntimeException);
+
+ virtual void SAL_CALL removeClipboardListener(
+ const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
+ throw(RuntimeException);
+#endif
+
+ /*
+ * SelectionAdaptor
+ */
+ virtual Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable();
+ virtual void clearTransferable();
+ // returns true if conversion was successful
+ };
+
+// ------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > SAL_CALL X11Clipboard_getSupportedServiceNames();
+ Reference< XInterface > SAL_CALL X11Clipboard_createInstance(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
+
+// ------------------------------------------------------------------------
+
+} // namepspace
+
+#endif
diff --git a/dtrans/source/X11/X11_droptarget.cxx b/dtrans/source/X11/X11_droptarget.cxx
new file mode 100644
index 000000000000..998e8bc1385d
--- /dev/null
+++ b/dtrans/source/X11/X11_droptarget.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_droptarget.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:25 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <X11_selection.hxx>
+
+using namespace x11;
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::dnd;
+
+DropTarget::~DropTarget()
+{
+ SelectionManager::get().deregisterDropTarget( Reference< XDropTarget >(this) );
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::addDropTargetListener( const Reference< XDropTargetListener >& xListener )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ m_aListeners.push_back( xListener );
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::removeDropTargetListener( const Reference< XDropTargetListener >& xListener )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ m_aListeners.remove( xListener );
+}
+
+// --------------------------------------------------------------------------
+
+sal_Bool DropTarget::isActive()
+{
+ return m_bActive;
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::setActive( sal_Bool active )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ m_bActive = active;
+}
+
+// --------------------------------------------------------------------------
+
+sal_Int8 DropTarget::getDefaultActions()
+{
+ return m_nDefaultActions;
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::setDefaultActions( sal_Int8 actions )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ m_nDefaultActions = actions;
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::drop( const DropTargetDropEvent& dtde )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ ::std::list< Reference< XDropTargetListener > >::iterator it1, it2;
+ it1 = m_aListeners.begin();
+ while( it1 != m_aListeners.end() )
+ {
+ it2 = it1;
+ it1++;
+ (*it2)->drop( dtde );
+ }
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::dragEnter( const DropTargetDragEvent& dtde )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ ::std::list< Reference< XDropTargetListener > >::iterator it1, it2;
+ it1 = m_aListeners.begin();
+ while( it1 != m_aListeners.end() )
+ {
+ it2 = it1;
+ it1++;
+ (*it2)->dragEnter( dtde );
+ }
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::dragExit( const DropTargetEvent& dte )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ ::std::list< Reference< XDropTargetListener > >::iterator it1, it2;
+ it1 = m_aListeners.begin();
+ while( it1 != m_aListeners.end() )
+ {
+ it2 = it1;
+ it1++;
+ (*it2)->dragExit( dte );
+ }
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::dragOver( const DropTargetDragEvent& dtde )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ ::std::list< Reference< XDropTargetListener > >::iterator it1, it2;
+ it1 = m_aListeners.begin();
+ while( it1 != m_aListeners.end() )
+ {
+ it2 = it1;
+ it1++;
+ (*it2)->dragOver( dtde );
+ }
+}
+
+// --------------------------------------------------------------------------
+
+void DropTarget::dropActionChanged( const DropTargetDragEvent& dtde )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ ::std::list< Reference< XDropTargetListener > >::iterator it1, it2;
+ it1 = m_aListeners.begin();
+ while( it1 != m_aListeners.end() )
+ {
+ it2 = it1;
+ it1++;
+ (*it2)->dropActionChanged( dtde );
+ }
+}
diff --git a/dtrans/source/X11/X11_selection.cxx b/dtrans/source/X11/X11_selection.cxx
new file mode 100644
index 000000000000..44a8fe598366
--- /dev/null
+++ b/dtrans/source/X11/X11_selection.cxx
@@ -0,0 +1,1687 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_selection.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <unistd.h>
+#include <stdio.h>
+#include <X11/Xatom.h>
+#ifdef LINUX
+#include <sys/poll.h>
+#else
+#include <poll.h>
+#endif
+
+#include <X11_selection.hxx>
+#include <X11_transferable.hxx>
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_DNDCONSTANTS_HPP_
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#endif
+
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+
+#define INCR_MIN_SIZE 1024
+#define INCR_TIMEOUT 5
+
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+using namespace x11;
+
+// static members of SelectionManager
+Mutex SelectionManager::m_Mutex;
+SelectionManager* SelectionManager::m_pInstance = NULL;
+
+static const int nXdndProtocolRevision = 4;
+
+// mapping between mime types (or what the office thinks of mime types)
+// and X convention types
+// for clipboard and primary selections there is only a convention for text
+// that the encoding name of the text is taken as type in all capitalized letters
+// TODO: implement Compound Text conversion
+// the convention for Xdnd is mime types as specified by the corresponding
+// RFC's with the addition that text/plain without charset tag contains iso8859-1
+struct NativeTypeEntry
+{
+ Atom nAtom;
+ const char* pType; // Mime encoding on our side
+ const char* pNativeType; // string corresponding to nAtom for the case of nAtom being uninitialized
+ int nFormat; // the corresponding format
+};
+
+static NativeTypeEntry aXdndConversionTab[] =
+{
+ { 0, "text/plain;charset=iso8859-1", "text/plain", 8 }
+};
+
+static NativeTypeEntry aNativeConversionTab[] =
+{
+ { 0, "text/plain;charset=utf-16", "ISO10646-1", 16 },
+ { 0, "text/plain;charset=utf-8", "UTF8_STRING", 8 },
+ { 0, "text/plain;charset=utf-8", "UTF-8", 8 },
+ // ISO encodings
+ { 0, "text/plain;charset=iso8859-2", "ISO8859-2", 8 },
+ { 0, "text/plain;charset=iso8859-3", "ISO8859-3", 8 },
+ { 0, "text/plain;charset=iso8859-4", "ISO8859-4", 8 },
+ { 0, "text/plain;charset=iso8859-5", "ISO8859-5", 8 },
+ { 0, "text/plain;charset=iso8859-6", "ISO8859-6", 8 },
+ { 0, "text/plain;charset=iso8859-7", "ISO8859-7", 8 },
+ { 0, "text/plain;charset=iso8859-8", "ISO8859-8", 8 },
+ { 0, "text/plain;charset=iso8859-9", "ISO8859-9", 8 },
+ { 0, "text/plain;charset=iso8859-10", "ISO8859-10", 8 },
+ { 0, "text/plain;charset=iso8859-13", "ISO8859-13", 8 },
+ { 0, "text/plain;charset=iso8859-14", "ISO8859-14", 8 },
+ { 0, "text/plain;charset=iso8859-15", "ISO8859-15", 8 },
+ // asian encodings
+ { 0, "text/plain;charset=jisx0201.1976-0", "JISX0201.1976-0", 8 },
+ { 0, "text/plain;charset=jisx0208.1983-0", "JISX0208.1983-0", 8 },
+ { 0, "text/plain;charset=jisx0208.1990-0", "JISX0208.1990-0", 8 },
+ { 0, "text/plain;charset=jisx0212.1990-0", "JISX0212.1990-0", 8 },
+ { 0, "text/plain;charset=gb2312.1980-0", "GB2312.1980-0", 8 },
+ { 0, "text/plain;charset=ksc5601.1992-0", "KSC5601.1992-0", 8 },
+ // eastern european encodings
+ { 0, "text/plain;charset=koi8-r", "KOI8-R", 8 },
+ // String (== iso8859-1)
+ { XA_STRING, "text/plain;charset=iso8859-1", "STRING", 8 }
+};
+
+rtl_TextEncoding x11::getTextPlainEncoding( const OUString& rMimeType )
+{
+ rtl_TextEncoding aEncoding = RTL_TEXTENCODING_DONTKNOW;
+ OUString aMimeType( rMimeType.toLowerCase() );
+ int nTokens = aMimeType.getTokenCount( ';' );
+ if( aMimeType.getToken( 0, ';' ).equalsAsciiL( "text/plain" , 10 ) )
+ {
+ if( aMimeType.getLength() == 10 ) // only "text/plain"
+ aEncoding = RTL_TEXTENCODING_ISO_8859_1;
+ else
+ {
+ for( int i = 1; i < nTokens; i++ )
+ {
+ OUString aToken = aMimeType.getToken( i, ';' );
+ if( aToken.getToken( 0, '=' ).equalsAsciiL( "charset", 7 ) )
+ {
+ OString aEncToken = OUStringToOString( aToken.getToken( 1, '=' ), RTL_TEXTENCODING_ISO_8859_1 );
+ aEncoding = rtl_getTextEncodingFromUnixCharset( aEncToken.getStr() );
+ if( aEncToken == RTL_TEXTENCODING_DONTKNOW )
+ {
+ if( aEncToken.equals( "utf-8" ) )
+ aEncoding = RTL_TEXTENCODING_UTF8;
+ }
+ if( aEncoding != RTL_TEXTENCODING_DONTKNOW )
+ break;
+ }
+ }
+ }
+ }
+ return aEncoding;
+}
+
+// ------------------------------------------------------------------------
+
+SelectionManager::IncrementalTransfer::IncrementalTransfer(
+ const Sequence< sal_Int8 >& rData,
+ Window aRequestor,
+ Atom aProperty,
+ Atom aTarget,
+ int nFormat
+ ) :
+ m_aData( rData ),
+ m_aRequestor( aRequestor ),
+ m_aProperty( aProperty ),
+ m_aTarget( aTarget ),
+ m_nFormat( nFormat ),
+ m_nBufferPos( 0 ),
+ m_nTransferStartTime( time( NULL ) )
+{
+}
+
+// ------------------------------------------------------------------------
+
+SelectionManager::SelectionManager() :
+ ::cppu::WeakComponentImplHelper8<
+ XDropTargetDropContext,
+ XDropTargetDragContext,
+ XDropTargetFactory,
+ XDragSource,
+ XDragSourceContext,
+ XInitialization,
+ XEventHandler,
+ XServiceInfo > (m_Mutex),
+ m_pDisplay( NULL ),
+ m_aWindow( None ),
+ m_aDropWindow( None ),
+ m_aDropMessageWindow( None ),
+ m_aThread( NULL ),
+ m_nCurrentProtocolVersion( nXdndProtocolRevision )
+{
+ m_aDropEnterEvent.data.l[0] = None;
+ m_bDropEnterSent = true;
+}
+
+void SelectionManager::initialize( const Sequence< Any >& arguments )
+{
+ if( ! m_xDisplayConnection.is() )
+ {
+ /*
+ * first argument must be a ::com::sun::star::awt::XDisplayConnection
+ * from this we will get the XEvents of the vcl event loop by
+ * registering us as XEventHandler on it.
+ *
+ * implementor's note:
+ * <RANT>
+ * Because XDND implementations send their ClientMessage events with
+ * XSendEvent and event mask 0 (which is perfectly sensible)
+ * these events get only sent to the connection that created
+ * the window in question: the vcl display.
+ *
+ * So this whole service should be implemented in vcl where
+ * it belongs. But as usual the dogmatics win and the dogma says:
+ * "vcl bad, service good". So instead of making vcl a service
+ * providing library we make a new one that is "independent" of vcl,
+ * because it is not linked against it and dispatch every event of
+ * the vcl event loop to here via uno mechanisms (that is copying it,
+ * locking and unlocking mutexes). Well, the user has fast computers
+ * these days, so why do we need performance where more memory and
+ * a faster CPU will do the job ?
+ * And that is why this runs under the title:
+ * How NOT to implement a service
+ * or the victory of dogma over common sense.
+ * </RANT>
+ */
+ if( arguments.getLength() > 0 )
+ arguments.getConstArray()[0] >>= m_xDisplayConnection;
+ if( ! m_xDisplayConnection.is() )
+ {
+#if 0
+ // for the time being try to live without XDisplayConnection
+ // for the sake of clipboard service
+ // clipboard service should be initialized with a XDisplayConnection
+ // in the future
+ Exception aExc;
+ aExc.Message = OUString::createFromAscii( "initialize me with a valid XDisplayConnection" );
+ aExc.Context = static_cast< OWeakObject* >(this);
+ throw aExc;
+#endif
+ }
+ else
+ m_xDisplayConnection->addEventHandler( Any(), this, ~0 );
+ }
+
+ if( ! m_pDisplay )
+ {
+ OUString aUDisplay;
+ if( m_xDisplayConnection.is() )
+ {
+ Any aIdentifier;
+ aIdentifier = m_xDisplayConnection->getIdentifier();
+ aIdentifier >>= aUDisplay;
+ }
+
+ OString aDisplayName( OUStringToOString( aUDisplay, RTL_TEXTENCODING_ISO_8859_1 ) );
+
+ m_pDisplay = XOpenDisplay( aDisplayName.getLength() ? aDisplayName.getStr() : NULL );
+
+ if( m_pDisplay )
+ {
+ // clipboard selection
+ m_nCLIPBOARDAtom = getAtom( OUString::createFromAscii( "CLIPBOARD" ) );
+
+ // special targets
+ m_nTARGETSAtom = getAtom( OUString::createFromAscii( "TARGETS" ) );
+ m_nTEXTAtom = getAtom( OUString::createFromAscii( "TEXT" ) );
+ m_nINCRAtom = getAtom( OUString::createFromAscii( "INCR" ) );
+
+ // Atoms for Xdnd protocol
+ m_nXdndAware = getAtom( OUString::createFromAscii( "XdndAware" ) );
+ m_nXdndEnter = getAtom( OUString::createFromAscii( "XdndEnter" ) );
+ m_nXdndLeave = getAtom( OUString::createFromAscii( "XdndLeave" ) );
+ m_nXdndPosition = getAtom( OUString::createFromAscii( "XdndPosition" ) );
+ m_nXdndStatus = getAtom( OUString::createFromAscii( "XdndStatus" ) );
+ m_nXdndDrop = getAtom( OUString::createFromAscii( "XdndDrop" ) );
+ m_nXdndFinished = getAtom( OUString::createFromAscii( "XdndFinished" ) );
+ m_nXdndSelection = getAtom( OUString::createFromAscii( "XdndSelection" ) );
+ m_nXdndTypeList = getAtom( OUString::createFromAscii( "XdndTypeList" ) );
+ m_nXdndProxy = getAtom( OUString::createFromAscii( "XdndProxy" ) );
+ m_nXdndActionCopy = getAtom( OUString::createFromAscii( "XdndActionCopy" ) );
+ m_nXdndActionMove = getAtom( OUString::createFromAscii( "XdndActionMove" ) );
+ m_nXdndActionLink = getAtom( OUString::createFromAscii( "XdndActionLink" ) );
+ m_nXdndActionAsk = getAtom( OUString::createFromAscii( "XdndActionAsk" ) );
+ m_nXdndActionPrivate= getAtom( OUString::createFromAscii( "XdndActionPrivate" ) );
+
+ // create a (invisible) message window
+ m_aWindow = XCreateSimpleWindow( m_pDisplay, DefaultRootWindow( m_pDisplay ),
+ 10, 10, 10, 10, 0, 0, 1 );
+
+ if( m_aWindow )
+ {
+ // just interested in SelectionClear/Notify/Request and PropertyChange
+ XSelectInput( m_pDisplay, m_aWindow, PropertyChangeMask );
+ // create the transferable for Drag operations
+ m_xDropTransferable = new X11Transferable( *this, m_nXdndSelection );
+ registerHandler( m_nXdndSelection, *this );
+
+ m_aThread = osl_createThread( run, this );
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+SelectionManager::~SelectionManager()
+{
+ MutexGuard aGuard(m_Mutex);
+
+ if( m_aThread )
+ {
+ osl_terminateThread( m_aThread );
+ osl_joinWithThread( m_aThread );
+ }
+
+#ifdef DEBUG
+ fprintf( stderr, "shutting down SelectionManager\n" );
+#endif
+
+ if( m_pDisplay )
+ {
+ deregisterHandler( m_nXdndSelection );
+ // destroy message window
+ if( m_aWindow )
+ XDestroyWindow( m_pDisplay, m_aWindow );
+
+ XCloseDisplay( m_pDisplay );
+ }
+ m_pInstance = NULL;
+}
+
+// ------------------------------------------------------------------------
+
+SelectionAdaptor* SelectionManager::getAdaptor( Atom selection )
+{
+ ::std::hash_map< Atom, Selection* >::iterator it =
+ m_aSelections.find( selection );
+ return it != m_aSelections.end() ? it->second->m_pAdaptor : NULL;
+}
+
+// ------------------------------------------------------------------------
+
+bool SelectionManager::convertData(
+ const Reference< XTransferable >& xTransferable,
+ const OUString& rType,
+ Sequence< sal_Int8 >& rData )
+{
+ bool bSuccess = false;
+
+ if( ! xTransferable.is() )
+ return bSuccess;
+
+ DataFlavor aFlavor;
+ aFlavor.MimeType = rType;
+ if( rType.getToken( 0, ';' ).compareToAscii( "text/plain" ) == 0 )
+ {
+ if( rType.getToken( 1, ';' ).compareToAscii( "charset=utf-16" ) == 0 )
+ aFlavor.DataType = getCppuType( (OUString *) 0 );
+ else
+ aFlavor.DataType = getCppuType( (Sequence< sal_Int8 >*)0 );
+ }
+ else
+ aFlavor.DataType = getCppuType( (Sequence< sal_Int8 >*)0 );
+
+ if( xTransferable->isDataFlavorSupported( aFlavor ) )
+ {
+ Any aValue( xTransferable->getTransferData( aFlavor ) );
+ if( aValue.getValueTypeClass() == TypeClass_STRING )
+ {
+ OUString aString;
+ aValue >>= aString;
+ rData = Sequence< sal_Int8 >( (sal_Int8*)aString.getStr(), aString.getLength() * sizeof( sal_Unicode ) );
+ bSuccess = true;
+ }
+ else if( aValue.getValueType() == getCppuType( (Sequence< sal_Int8 >*)0 ) )
+ {
+ aValue >>= rData;
+ bSuccess = true;
+ }
+ }
+ else if( rType.compareToAscii( "text/plain", 10 ) == 0 )
+ {
+ rtl_TextEncoding aEncoding = getTextPlainEncoding( rType );
+ if( aEncoding != RTL_TEXTENCODING_DONTKNOW )
+ {
+ aFlavor.MimeType = OUString::createFromAscii( "text/plain;charset=utf-16" );
+ aFlavor.DataType = getCppuType( (OUString *) 0 );
+ if( xTransferable->isDataFlavorSupported( aFlavor ) )
+ {
+ Any aValue( xTransferable->getTransferData( aFlavor ) );
+ OUString aString;
+ aValue >>= aString;
+ OString aByteString( OUStringToOString( aString, aEncoding ) );
+ rData = Sequence< sal_Int8 >( (sal_Int8*)aByteString.getStr(), aByteString.getLength() * sizeof( sal_Char ) );
+ bSuccess = true;
+ }
+ }
+ }
+ return bSuccess;
+}
+
+// ------------------------------------------------------------------------
+
+SelectionManager& SelectionManager::get()
+{
+ MutexGuard aGuard(m_Mutex);
+
+ if( m_pInstance == NULL )
+ m_pInstance = new SelectionManager();
+
+ return *m_pInstance;
+}
+
+// ------------------------------------------------------------------------
+
+const OUString& SelectionManager::getString( Atom aAtom )
+{
+ MutexGuard aGuard(m_Mutex);
+
+ ::std::hash_map< Atom, OUString >::const_iterator it;
+ if( ( it = m_aAtomToString.find( aAtom ) ) == m_aAtomToString.end() )
+ {
+ static OUString aEmpty;
+ char* pAtom = XGetAtomName( m_pDisplay, aAtom );
+ if( ! pAtom )
+ return aEmpty;
+ OUString aString( OStringToOUString( pAtom, RTL_TEXTENCODING_ISO_8859_1 ) );
+ XFree( pAtom );
+ m_aStringToAtom[ aString ] = aAtom;
+ m_aAtomToString[ aAtom ] = aString;
+ }
+ return m_aAtomToString[ aAtom ];
+}
+
+// ------------------------------------------------------------------------
+
+Atom SelectionManager::getAtom( const OUString& rString )
+{
+ MutexGuard aGuard(m_Mutex);
+
+ ::std::hash_map< OUString, Atom, OUStringHash >::const_iterator it;
+ if( ( it = m_aStringToAtom.find( rString ) ) == m_aStringToAtom.end() )
+ {
+ Atom aAtom = XInternAtom( m_pDisplay, OUStringToOString( rString, RTL_TEXTENCODING_ISO_8859_1 ), False );
+ m_aStringToAtom[ rString ] = aAtom;
+ m_aAtomToString[ aAtom ] = rString;
+ }
+ return m_aStringToAtom[ rString ];
+}
+
+// ------------------------------------------------------------------------
+
+bool SelectionManager::requestOwnership( Atom selection )
+{
+ bool bSuccess = false;
+ if( m_pDisplay && m_aWindow )
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ SelectionAdaptor* pAdaptor = getAdaptor( selection );
+ if( pAdaptor )
+ {
+ XSetSelectionOwner( m_pDisplay, selection, m_aWindow, CurrentTime );
+ if( XGetSelectionOwner( m_pDisplay, selection ) == m_aWindow )
+ bSuccess = true;
+#ifdef DEBUG
+ fprintf( stderr, "%s ownership for selection %s\n",
+ bSuccess ? "acquired" : "failed to acquire",
+ OUStringToOString( getString( selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+ }
+#ifdef DEBUG
+ else
+ fprintf( stderr, "no adaptor for selection %s\n",
+ OUStringToOString( getString( selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+ }
+ return bSuccess;
+}
+
+// ------------------------------------------------------------------------
+
+Atom SelectionManager::convertTypeToNative( const OUString& rType, Atom selection, int& rFormat )
+{
+ NativeTypeEntry* pTab = selection == m_nXdndSelection ? aXdndConversionTab : aNativeConversionTab;
+ int nTabEntries = selection == m_nXdndSelection
+ ? sizeof(aXdndConversionTab)/sizeof(aXdndConversionTab[0]) :
+ sizeof(aNativeConversionTab)/sizeof(aNativeConversionTab[0]);
+
+ OString aType( OUStringToOString( rType, RTL_TEXTENCODING_ISO_8859_1 ) );
+ for( int i = 0; i < nTabEntries; i++ )
+ {
+ if( aType.equalsIgnoreCase( pTab[i].pType ) )
+ {
+ if( ! pTab[i].nAtom )
+ pTab[i].nAtom = getAtom( OStringToOUString( pTab[i].pNativeType, RTL_TEXTENCODING_ISO_8859_1 ) );
+ rFormat = pTab[i].nFormat;
+ return pTab[i].nAtom;
+ }
+ }
+ rFormat = 8; // byte buffer
+ return getAtom( rType );
+};
+
+// ------------------------------------------------------------------------
+
+OUString SelectionManager::convertTypeFromNative( Atom nType, Atom selection )
+{
+ NativeTypeEntry* pTab = selection == m_nXdndSelection ? aXdndConversionTab : aNativeConversionTab;
+ int nTabEntries = selection == m_nXdndSelection
+ ? sizeof(aXdndConversionTab)/sizeof(aXdndConversionTab[0]) :
+ sizeof(aNativeConversionTab)/sizeof(aNativeConversionTab[0]);
+
+ for( int i = 0; i < nTabEntries; i++ )
+ {
+ if( ! pTab[i].nAtom )
+ pTab[i].nAtom = getAtom( OStringToOUString( pTab[i].pNativeType, RTL_TEXTENCODING_ISO_8859_1 ) );
+ if( nType == pTab[i].nAtom )
+ return OStringToOUString( pTab[i].pType, RTL_TEXTENCODING_ISO_8859_1 );
+ }
+ return getString( nType );
+}
+
+// ------------------------------------------------------------------------
+
+bool SelectionManager::getPasteData( Atom selection, Atom type, Sequence< sal_Int8 >& rData )
+{
+ ::std::hash_map< Atom, Selection* >::iterator it;
+ bool bSuccess = false;
+
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ it = m_aSelections.find( selection );
+ if( it == m_aSelections.end() )
+ return false;
+
+ Window aSelectionOwner = XGetSelectionOwner( m_pDisplay, selection );
+ if( aSelectionOwner == None )
+ return false;
+ if( aSelectionOwner == m_aWindow )
+ {
+ // probably bad timing led us here
+#ifdef DEBUG
+ fprintf( stderr, "Innere Nabelschau\n" );
+#endif
+ return false;
+ }
+
+ XConvertSelection( m_pDisplay, selection, type, selection, m_aWindow, selection == m_nXdndSelection ? m_nDropTime : CurrentTime );
+ it->second->m_eState = Selection::WaitingForResponse;
+ it->second->m_aData = Sequence< sal_Int8 >();
+ it->second->m_aDataArrived.reset();
+ // really start the request; if we don't flush the
+ // queue the request won't leave it because there are no more
+ // X calls after this until the data arrived or timeout
+ XFlush( m_pDisplay );
+ }
+
+ // do a reschedule
+ time_t nBegin = time( NULL );
+ pollfd aPollFD;
+ XEvent event;
+ // query socket handle to poll on
+ aPollFD.fd = ConnectionNumber( m_pDisplay );
+ aPollFD.events = POLLIN;
+ aPollFD.revents = 0;
+
+ do
+ {
+ if( poll( &aPollFD, 1, 2000 ) > 0 )
+ {
+ MutexGuard aGuard(m_Mutex);
+ while( XPending( m_pDisplay ) > 0 )
+ {
+ XNextEvent( m_pDisplay, &event );
+ handleXEvent( event );
+ }
+ }
+ osl_yieldThread();
+ } while( ! it->second->m_aDataArrived.check() && time(NULL)-nBegin < 3 );
+
+ if( it->second->m_aDataArrived.check() &&
+ it->second->m_aData.getLength() )
+ {
+ rData = it->second->m_aData;
+ bSuccess = true;
+ }
+ return bSuccess;
+}
+
+// ------------------------------------------------------------------------
+
+bool SelectionManager::getPasteData( Atom selection, const ::rtl::OUString& rType, Sequence< sal_Int8 >& rData )
+{
+ int nFormat;
+ bool bSuccess = false;
+
+ if( rType.equalsAsciiL( "text/plain;charset=utf-16", 25 ) )
+ {
+ // lets see if we have UTF16 else try to find something convertible
+ ::std::hash_map< Atom, Selection* >::iterator it;
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ it = m_aSelections.find( selection );
+ if( it == m_aSelections.end() )
+ return false;
+ }
+ if( it->second->m_aTypes.getLength() && ! it->second->m_bHaveUTF16 )
+ {
+ const Sequence< DataFlavor >& rTypes( it->second->m_aTypes );
+ Sequence< sal_Int8 > aData;
+ for( int i = 0; i < rTypes.getLength(); i++ )
+ {
+ rtl_TextEncoding aEncoding = getTextPlainEncoding( rTypes.getConstArray()[i].MimeType );
+ if( aEncoding != RTL_TEXTENCODING_DONTKNOW &&
+ aEncoding != RTL_TEXTENCODING_UNICODE &&
+ getPasteData(
+ selection,
+ convertTypeToNative(
+ rTypes.getConstArray()[i].MimeType,
+ selection, nFormat ),
+ aData )
+ )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "using \"%s\" instead of \"%s\"\n",
+ OUStringToOString( rTypes.getConstArray()[i].MimeType, RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ OUStringToOString( rType, RTL_TEXTENCODING_ISO_8859_1 ).getStr()
+ );
+#endif
+ OString aConvert( (sal_Char*)aData.getConstArray(), aData.getLength() );
+ OUString aUTF( OStringToOUString( aConvert, aEncoding ) );
+ rData = Sequence< sal_Int8 >( (sal_Int8*)aUTF.getStr(), (aUTF.getLength()+1)*sizeof( sal_Unicode ) );
+ bSuccess = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if( ! bSuccess )
+ bSuccess = getPasteData( selection, convertTypeToNative( rType, selection, nFormat ), rData );
+#ifdef DEBUG
+ fprintf( stderr, "getPasteData for selection %s and data type %s returns %s, returned sequence has length %d\n",
+ OUStringToOString( getString( selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ OUStringToOString( rType, RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ bSuccess ? "true" : "false",
+ rData.getLength()
+ );
+#endif
+ return bSuccess;
+}
+
+// ------------------------------------------------------------------------
+
+bool SelectionManager::getPasteDataTypes( Atom selection, Sequence< DataFlavor >& rTypes )
+{
+ ::std::hash_map< Atom, Selection* >::iterator it;
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ it = m_aSelections.find( selection );
+ if( it != m_aSelections.end() &&
+ it->second->m_aTypes.getLength() &&
+ abs( it->second->m_nLastTimestamp - time( NULL ) ) < 2
+ )
+ {
+ rTypes = it->second->m_aTypes;
+ return true;
+ }
+ }
+
+ bool bSuccess = false;
+ bool bHaveUTF16 = false;
+ bool bHaveText = false;
+ Sequence< sal_Int8 > aAtoms;
+
+ if( selection == m_nXdndSelection )
+ {
+ // xdnd sends first three types with XdndEnter
+ // if more than three types are supported then the XDndTypeList
+ // property on the source window is used
+ if( m_aDropEnterEvent.data.l[0] && m_aCurrentDropWindow )
+ {
+ if( m_aDropEnterEvent.data.l[1] & 1 )
+ {
+ const int atomcount = 256;
+ // more than three types; look in property
+ MutexGuard aGuard(m_Mutex);
+
+ Atom nType;
+ int nFormat;
+ unsigned long nItems, nBytes;
+ unsigned char* pBytes = NULL;
+
+ XGetWindowProperty( m_pDisplay, m_aDropEnterEvent.data.l[0],
+ m_nXdndTypeList, 0, atomcount, False,
+ XA_ATOM,
+ &nType, &nFormat, &nItems, &nBytes, &pBytes );
+#ifdef DEBUG
+ fprintf( stderr, "have %d data types in XdndTypeList\n", nItems );
+#endif
+ if( nItems == atomcount && nBytes > 0 )
+ {
+ // wow ... more than 256 types !
+ aAtoms.realloc( sizeof( Atom )*atomcount+nBytes );
+ memcpy( aAtoms.getArray(), pBytes, sizeof( Atom )*atomcount );
+ XFree( pBytes );
+ pBytes = NULL;
+ XGetWindowProperty( m_pDisplay, m_aDropEnterEvent.data.l[0],
+ m_nXdndTypeList, atomcount, nBytes/sizeof(Atom),
+ False, XA_ATOM,
+ &nType, &nFormat, &nItems, &nBytes, &pBytes );
+ {
+ memcpy( aAtoms.getArray()+atomcount*sizeof(Atom), pBytes, nItems*sizeof(Atom) );
+ XFree( pBytes );
+ }
+ }
+ else
+ {
+ aAtoms.realloc( sizeof(Atom)*nItems );
+ memcpy( aAtoms.getArray(), pBytes, nItems*sizeof(Atom) );
+ XFree( pBytes );
+ }
+ }
+ else
+ {
+ // one to three types
+ int n = 0, i;
+ for( i = 0; i < 3; i++ )
+ if( m_aDropEnterEvent.data.l[2+i] )
+ n++;
+#ifdef DEBUG
+ fprintf( stderr, "have %d data types in XdndEnter\n", n );
+#endif
+ aAtoms.realloc( sizeof(Atom)*n );
+ for( i = 0, n = 0; i < 3; i++ )
+ if( m_aDropEnterEvent.data.l[2+i] )
+ ((Atom*)aAtoms.getArray())[n++] = m_aDropEnterEvent.data.l[2+i];
+ }
+ }
+ }
+ // get data of type TARGETS
+ else if( ! getPasteData( selection, m_nTARGETSAtom, aAtoms ) )
+ aAtoms = Sequence< sal_Int8 >();
+
+ if( aAtoms.getLength() )
+ {
+ int nAtoms = aAtoms.getLength() / 4;
+ Atom* pAtoms = (Atom*)aAtoms.getArray();
+ rTypes.realloc( nAtoms );
+ DataFlavor* pFlavors = rTypes.getArray();
+ while( nAtoms-- )
+ {
+ if( *pAtoms && *pAtoms < 0x01000000 )
+ {
+ pFlavors->MimeType = convertTypeFromNative( *pAtoms, selection );
+ pFlavors->DataType = getCppuType( (Sequence< sal_Int8 >*)0 );
+ if( pFlavors->MimeType.getToken( 0, ';' ).equalsAsciiL( "text/plain", 10 ) )
+ {
+ bHaveText = true;
+ if( pFlavors->MimeType.getToken( 1, ';' ).compareToAscii( "charset=utf-16" ) == 0 )
+ {
+ bHaveUTF16 = true;
+ pFlavors->DataType = getCppuType( (OUString*)0 );
+ }
+ }
+ }
+ pAtoms++;
+ pFlavors++;
+ }
+ bSuccess = rTypes.getLength() ? true : false;
+ if( bHaveText && ! bHaveUTF16 )
+ {
+ int nNewFlavors = rTypes.getLength()+1;
+ Sequence< DataFlavor > aTemp( nNewFlavors );
+ for( int i = 0; i < nNewFlavors-1; i++ )
+ aTemp.getArray()[i+1] = rTypes.getConstArray()[i];
+ aTemp.getArray()[0].MimeType = OUString::createFromAscii( "text/plain;charset=utf-16" );
+ aTemp.getArray()[0].DataType = getCppuType( (OUString*)0 );
+ rTypes = aTemp;
+ }
+ }
+
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ it = m_aSelections.find( selection );
+ if( it != m_aSelections.end() )
+ {
+ if( bSuccess )
+ {
+ it->second->m_aTypes = rTypes;
+ it->second->m_nLastTimestamp = time( NULL );
+ it->second->m_bHaveUTF16 = bHaveUTF16;
+ }
+ else
+ {
+ it->second->m_aTypes = Sequence< DataFlavor >();
+ it->second->m_nLastTimestamp = 0;
+ it->second->m_bHaveUTF16 = false;
+ }
+ }
+ }
+
+#ifdef DEBUG
+ fprintf( stderr, "SelectionManager::getPasteDataTypes( %s ) = %s\n", OUStringToOString( getString( selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(), bSuccess ? "true" : "false" );
+ for( int i = 0; i < rTypes.getLength(); i++ )
+ fprintf( stderr, "type: %s\n", OUStringToOString( rTypes.getConstArray()[i].MimeType, RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+
+ return bSuccess;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleSelectionRequest( XSelectionRequestEvent& rRequest )
+{
+#ifdef DEBUG
+ fprintf( stderr, "handleSelectionRequest for selection %s and target %s\n",
+ OUStringToOString( getString( rRequest.selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ OUStringToOString( getString( rRequest.target ), RTL_TEXTENCODING_ISO_8859_1 ).getStr()
+ );
+#endif
+
+ XEvent aNotify;
+
+ aNotify.type = SelectionNotify;
+ aNotify.xselection.display = rRequest.display;
+ aNotify.xselection.send_event = True;
+ aNotify.xselection.requestor = rRequest.requestor;
+ aNotify.xselection.selection = rRequest.selection;
+ aNotify.xselection.time = rRequest.time;
+ aNotify.xselection.target = rRequest.target;
+ aNotify.xselection.property = None;
+
+ SelectionAdaptor* pAdaptor = getAdaptor( rRequest.selection );
+ // ensure that we still own that selection
+ if( pAdaptor &&
+ XGetSelectionOwner( m_pDisplay, rRequest.selection ) == m_aWindow )
+ {
+ if( rRequest.target == m_nTARGETSAtom )
+ {
+ // someone requests our types
+ Reference< XTransferable > xTrans( pAdaptor->getTransferable() );
+ if( xTrans.is() )
+ {
+ Sequence< DataFlavor > aFlavors = xTrans->getTransferDataFlavors();
+ Atom* pTypes = new Atom[ aFlavors.getLength() ];
+ int nFormat;
+ for( int i = 0; i < aFlavors.getLength(); i++ )
+ pTypes[i] = convertTypeToNative( aFlavors.getConstArray()[i].MimeType, rRequest.selection, nFormat );
+ XChangeProperty( m_pDisplay, rRequest.requestor, rRequest.property,
+ XA_ATOM, 32, PropModeReplace, (const unsigned char*)pTypes, aFlavors.getLength() );
+ aNotify.xselection.property = rRequest.property;
+ delete pTypes;
+ }
+ }
+ else
+ {
+ // special target TEXT allows us to transfer
+ // the data in an encoding of our choice
+ // it is debatable wether ISO10646-1 is a good choice
+ // UTF-8 or Compound would be understood by more applications
+ if( rRequest.target == m_nTEXTAtom )
+ rRequest.target = getAtom( OUString::createFromAscii( "ISO10646-1" ) );
+
+ Sequence< sal_Int8 > aData;
+ OUString aType( convertTypeFromNative( rRequest.target, rRequest.selection ) );
+ if( convertData( pAdaptor->getTransferable(), aType, aData ) )
+ {
+ // conversion succeeded
+ int nFormat;
+ aNotify.xselection.target = convertTypeToNative( aType, rRequest.selection, nFormat );
+ aNotify.xselection.property = rRequest.property;
+ if( aData.getLength() > INCR_MIN_SIZE )
+ {
+ // use incr protocol
+ int nBufferPos = 0;
+ int nMinSize = INCR_MIN_SIZE;
+ XChangeProperty( m_pDisplay, rRequest.requestor, rRequest.property,
+ m_nINCRAtom, 32, PropModeReplace, (unsigned char*)&nMinSize, 1 );
+ XSelectInput( m_pDisplay, rRequest.requestor, PropertyChangeMask );
+ IncrementalTransfer aTransfer( aData,
+ rRequest.requestor,
+ rRequest.property,
+ rRequest.target,
+ nFormat
+ );
+ m_aIncrementals[ rRequest.requestor ].push_back( aTransfer );
+ }
+ else
+ XChangeProperty( m_pDisplay,
+ rRequest.requestor,
+ rRequest.property,
+ rRequest.target,
+ nFormat,
+ PropModeReplace,
+ (const unsigned char*)aData.getConstArray(),
+ aData.getLength()/(nFormat/8) );
+ }
+#ifdef DEBUG
+ else
+ fprintf( stderr, "convertData failed for type: %s \n",
+ OUStringToOString( aType, RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+ }
+ }
+
+ XSendEvent( m_pDisplay, rRequest.requestor, False, 0, &aNotify );
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleReceivePropertyNotify( XPropertyEvent& rNotify )
+{
+ // data we requested arrived
+#ifdef DEBUG
+ fprintf( stderr, "handleReceivePropertyNotify for property %s\n",
+ OUStringToOString( getString( rNotify.atom ), RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+
+ ::std::hash_map< Atom, Selection* >::iterator it =
+ m_aSelections.find( rNotify.atom );
+ if( it != m_aSelections.end() &&
+ rNotify.state == PropertyNewValue &&
+ ( it->second->m_eState == Selection::WaitingForResponse ||
+ it->second->m_eState == Selection::WaitingForData ||
+ it->second->m_eState == Selection::IncrementalTransfer
+ )
+ )
+ {
+ Atom nType = None;
+ int nFormat = 0;
+ unsigned long nItems = 0, nBytes = 0;
+ unsigned char* pData = NULL;
+
+ // get type and length
+ XGetWindowProperty( m_pDisplay,
+ rNotify.window,
+ rNotify.atom,
+ 0, 0,
+ False,
+ AnyPropertyType,
+ &nType, &nFormat,
+ &nItems, &nBytes,
+ &pData );
+#ifdef DEBUG
+ fprintf( stderr, "found %d bytes data of type %s and format %d, items = %d\n",
+ nBytes,
+ OUStringToOString( getString( nType ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ nFormat, nItems );
+#endif
+ if( pData )
+ {
+ XFree( pData );
+ pData = NULL;
+ }
+
+ if( nType == m_nINCRAtom )
+ {
+ // start data transfer
+ XDeleteProperty( m_pDisplay, rNotify.window, rNotify.atom );
+ it->second->m_eState = Selection::IncrementalTransfer;
+ }
+ else if( nType != None )
+ {
+ XGetWindowProperty( m_pDisplay,
+ rNotify.window,
+ rNotify.atom,
+ 0, nBytes/4 +1,
+ True,
+ nType,
+ &nType, &nFormat,
+ &nItems, &nBytes,
+ &pData );
+#ifdef DEBUG
+ fprintf( stderr, "read %d items data of type %s and format %d, %d bytes left in property\n",
+ nItems,
+ OUStringToOString( getString( nType ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ nFormat, nBytes );
+#endif
+ if( it->second->m_eState == Selection::WaitingForData ||
+ it->second->m_eState == Selection::WaitingForResponse )
+ {
+ // copy data
+ it->second->m_aData = Sequence< sal_Int8 >( (sal_Int8*)pData, nItems*nFormat/8 );
+ it->second->m_eState = Selection::Inactive;
+ it->second->m_aDataArrived.set();
+ }
+ else if( it->second->m_eState == Selection::IncrementalTransfer )
+ {
+ // append data
+ Sequence< sal_Int8 > aData( it->second->m_aData.getLength() + nItems*nFormat/8 );
+ memcpy( aData.getArray(), it->second->m_aData.getArray(), it->second->m_aData.getLength() );
+ memcpy( aData.getArray() + it->second->m_aData.getLength(), pData, nItems*nFormat/8 );
+ it->second->m_aData = aData;
+ }
+ if( pData )
+ XFree( pData );
+ }
+ else if( it->second->m_eState == Selection::IncrementalTransfer )
+ {
+ it->second->m_eState = Selection::Inactive;
+ it->second->m_aDataArrived.set();
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleSendPropertyNotify( XPropertyEvent& rNotify )
+{
+ // ready for next part of a IncrementalTransfer
+#ifdef DEBUG
+ fprintf( stderr, "handleSendPropertyNotify for property %s\n",
+ OUStringToOString( getString( rNotify.atom ), RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
+#endif
+ ::std::hash_map< Window, ::std::list< IncrementalTransfer > >::iterator it;
+ it = m_aIncrementals.find( rNotify.window );
+ int nCurrentTime = time( NULL );
+ if( it != m_aIncrementals.end() )
+ {
+ ::std::list< IncrementalTransfer >::iterator inc_it = it->second.begin();
+ while( inc_it != it->second.end() )
+ {
+ bool bDone = false;
+ if( inc_it->m_aProperty == rNotify.atom )
+ {
+ if( rNotify.state != PropertyDelete )
+ bDone = true;
+ else
+ {
+ int nBytes = inc_it->m_aData.getLength() - inc_it->m_nBufferPos;
+ nBytes = nBytes > INCR_MIN_SIZE ? INCR_MIN_SIZE : nBytes;
+ XChangeProperty(
+ m_pDisplay,
+ inc_it->m_aRequestor,
+ inc_it->m_aProperty,
+ inc_it->m_aTarget,
+ inc_it->m_nFormat,
+ PropModeReplace,
+ (const unsigned char*)inc_it->m_aData.getConstArray()+inc_it->m_nBufferPos,
+ nBytes/(inc_it->m_nFormat/8) );
+ inc_it->m_nBufferPos += nBytes;
+ if( nBytes == 0 )
+ bDone = true;
+ }
+ }
+ else if( nCurrentTime - inc_it->m_nTransferStartTime > INCR_TIMEOUT )
+ bDone = true;
+ if( bDone )
+ {
+ ::std::list< IncrementalTransfer >::iterator temp_it = inc_it;
+ ++inc_it;
+ it->second.erase( temp_it );
+ }
+ else
+ ++inc_it;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleSelectionNotify( XSelectionEvent& rNotify )
+{
+ // notification about success/failure of one of our conversion requests
+#ifdef DEBUG
+ fprintf( stderr, "handleSelectionNotify for selection %s and property %s\n",
+ OUStringToOString( getString( rNotify.selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
+ rNotify.property == None ? "None" : OUStringToOString( getString( rNotify.property ), RTL_TEXTENCODING_ISO_8859_1 ).getStr()
+ );
+#endif
+ ::std::hash_map< Atom, Selection* >::iterator it =
+ m_aSelections.find( rNotify.selection );
+ if( ( rNotify.requestor == m_aWindow || rNotify.requestor == m_aCurrentDropWindow ) &&
+ it != m_aSelections.end() &&
+ it->second->m_eState == Selection::WaitingForResponse )
+ {
+ // get the bytes, by INCR if necessary
+ if( rNotify.property == None )
+ {
+ it->second->m_eState = Selection::Inactive;
+ it->second->m_aData = Sequence< sal_Int8 >();
+ it->second->m_aDataArrived.set();
+ }
+ else
+ it->second->m_eState = Selection::WaitingForData;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleDropEvent( XClientMessageEvent& rMessage )
+{
+ // handle drop related events
+
+ Window aSource = rMessage.data.l[0];
+ Window aTarget = rMessage.window;
+
+ ::std::hash_map< Window, DropTargetEntry >::iterator it =
+ m_aDropTargets.find( aTarget );
+ if( it != m_aDropTargets.end() &&
+ ( m_aDropEnterEvent.data.l[0] == None || m_aDropEnterEvent.data.l[0] == aSource )
+ )
+ {
+ if( rMessage.message_type == m_nXdndEnter )
+ {
+ m_aDropEnterEvent = rMessage;
+ m_bDropEnterSent = false;
+ m_aCurrentDropWindow = aTarget;
+ m_nCurrentProtocolVersion = m_aDropEnterEvent.data.l[1] >> 24;
+#ifdef DEBUG
+ fprintf( stderr, "received XdndEnter on 0x%x\n", aTarget );
+#endif
+ }
+ else if(
+ rMessage.message_type == m_nXdndPosition &&
+ aSource == m_aDropEnterEvent.data.l[0]
+ )
+ {
+ m_nDropTime = m_nCurrentProtocolVersion > 0 ? rMessage.data.l[3] : CurrentTime;
+
+ Window aChild;
+ XTranslateCoordinates( m_pDisplay,
+ it->second.m_aRootWindow,
+ it->first,
+ rMessage.data.l[2] >> 16,
+ rMessage.data.l[2] & 0xffff,
+ &m_nLastX, &m_nLastY,
+ &aChild );
+
+#ifdef DEBUG
+ fprintf( stderr, "received XdndPosition on 0x%x (%d, %d)\n", aTarget, m_nLastX, m_nLastY );
+#endif
+ DropTargetDragEvent aEvent;
+ aEvent.Source = static_cast< XDropTarget* >(it->second.m_pTarget);
+ aEvent.Context = static_cast< XDropTargetDragContext* >(this);
+ aEvent.Location.X = m_nLastX;
+ aEvent.Location.Y = m_nLastY;
+ if( m_nCurrentProtocolVersion < 2 )
+ aEvent.DropAction = DNDConstants::ACTION_COPY;
+ else if( rMessage.data.l[4] == m_nXdndActionCopy )
+ aEvent.DropAction = DNDConstants::ACTION_COPY;
+ else if( rMessage.data.l[4] == m_nXdndActionMove )
+ aEvent.DropAction = DNDConstants::ACTION_MOVE;
+ else if( rMessage.data.l[4] == m_nXdndActionLink )
+ aEvent.DropAction = DNDConstants::ACTION_LINK;
+ else if( rMessage.data.l[4] == m_nXdndActionAsk )
+ // currently no interface to implement ask
+ aEvent.DropAction = ~0;
+ else
+ aEvent.DropAction = DNDConstants::ACTION_NONE;
+ m_nLastDropAction = aEvent.DropAction;
+ if( ! m_bDropEnterSent )
+ {
+ m_bDropEnterSent = true;
+ it->second->dragEnter( aEvent );
+ }
+ else
+ it->second->dragOver( aEvent );
+ }
+ else if(
+ rMessage.message_type == m_nXdndLeave &&
+ aSource == m_aDropEnterEvent.data.l[0]
+ )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "received XdndLeave on 0x%x\n", aTarget );
+#endif
+ DropTargetDropEvent aEvent;
+ aEvent.Source = static_cast< XDropTarget* >(it->second.m_pTarget);
+ aEvent.Context = static_cast< XDropTargetDropContext* >(this);
+ it->second->dragExit( aEvent );
+ m_aDropEnterEvent.data.l[0] = None;
+ if( m_aCurrentDropWindow == aTarget )
+ m_aCurrentDropWindow = None;
+ m_nCurrentProtocolVersion = nXdndProtocolRevision;
+ }
+ else if(
+ rMessage.message_type == m_nXdndDrop &&
+ aSource == m_aDropEnterEvent.data.l[0]
+ )
+ {
+ m_nDropTime = m_nCurrentProtocolVersion > 0 ? rMessage.data.l[2] : CurrentTime;
+
+#ifdef DEBUG
+ fprintf( stderr, "received XdndDrop on 0x%x (%d, %d)\n", aTarget, m_nLastX, m_nLastY );
+#endif
+ DropTargetDropEvent aEvent;
+ aEvent.Source = static_cast< XDropTarget* >(it->second.m_pTarget);
+ aEvent.Context = static_cast< XDropTargetDropContext* >(this);
+ aEvent.Location.X = m_nLastX;
+ aEvent.Location.Y = m_nLastY;
+ aEvent.DropAction = m_nLastDropAction;
+ // there is nothing corresponding to source supported actions
+ // every source can do link, copy and move
+ aEvent.SourceActions = m_nLastDropAction;
+ aEvent.Transferable = m_xDropTransferable;
+
+ it->second->drop( aEvent );
+ }
+ }
+}
+
+/*
+ * XDropTargetDropContext
+ */
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::rejectDrop()
+{
+ rejectDrag();
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::acceptDrop( sal_Int8 dropOperation )
+{
+ acceptDrag( dropOperation );
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::dropComplete( sal_Bool bSuccess )
+{
+ if( m_aDropEnterEvent.data.l[0] && m_aCurrentDropWindow )
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ XEvent aEvent;
+ aEvent.xclient.type = ClientMessage;
+ aEvent.xclient.display = m_pDisplay;
+ aEvent.xclient.window = m_aDropEnterEvent.data.l[0];
+ aEvent.xclient.message_type = m_nXdndFinished;
+ aEvent.xclient.format = 32;
+ aEvent.xclient.data.l[0] = m_aCurrentDropWindow;
+ aEvent.xclient.data.l[1] = 0;
+
+#ifdef DEBUG
+ fprintf( stderr, "Sending XdndFinished to 0x%x\n",
+ m_aDropEnterEvent.data.l[0]
+ );
+#endif
+
+ XSendEvent( m_pDisplay, m_aDropEnterEvent.data.l[0],
+ False, NoEventMask, & aEvent );
+
+ m_aDropEnterEvent.data.l[0] = None;
+ m_aCurrentDropWindow = None;
+ m_nCurrentProtocolVersion = nXdndProtocolRevision;
+ }
+}
+
+/*
+ * XDropTargetDragContext
+ */
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::sendDragStatus( Atom nDropAction )
+{
+ if( m_aDropEnterEvent.data.l[0] && m_aCurrentDropWindow )
+ {
+ MutexGuard aGuard(m_Mutex);
+
+ XEvent aEvent;
+ aEvent.xclient.type = ClientMessage;
+ aEvent.xclient.display = m_pDisplay;
+ aEvent.xclient.window = m_aDropEnterEvent.data.l[0];
+ aEvent.xclient.message_type = m_nXdndStatus;
+ aEvent.xclient.format = 32;
+ aEvent.xclient.data.l[0] = m_aCurrentDropWindow;
+ aEvent.xclient.data.l[1] = 2;
+ if( nDropAction == m_nXdndActionMove ||
+ nDropAction == m_nXdndActionLink ||
+ nDropAction == m_nXdndActionCopy )
+ aEvent.xclient.data.l[1] |= 1;
+ aEvent.xclient.data.l[2] = 0;
+ aEvent.xclient.data.l[3] = 0;
+ aEvent.xclient.data.l[4] = m_nCurrentProtocolVersion > 1 ? nDropAction : 0;
+
+#ifdef DEBUG
+ fprintf( stderr, "Sending XdndStatus to 0x%x with action %s\n",
+ m_aDropEnterEvent.data.l[0],
+ OUStringToOString( getString( nDropAction ), RTL_TEXTENCODING_ISO_8859_1 ).getStr()
+ );
+#endif
+
+ XSendEvent( m_pDisplay, m_aDropEnterEvent.data.l[0],
+ False, NoEventMask, & aEvent );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleDragEvent( XClientMessageEvent& rMessage )
+{
+ // handle drag related events
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::acceptDrag( sal_Int8 dragOperation )
+{
+ Atom nAction = None;
+ switch( dragOperation )
+ {
+ case DNDConstants::ACTION_LINK:
+ nAction = m_nXdndActionLink;
+ break;
+ case DNDConstants::ACTION_MOVE:
+ nAction = m_nXdndActionMove;
+ break;
+ case DNDConstants::ACTION_COPY:
+ nAction = m_nXdndActionCopy;
+ break;
+ }
+ sendDragStatus( nAction );
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::rejectDrag()
+{
+ sendDragStatus( None );
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< DataFlavor > SelectionManager::getCurrentDataFlavors()
+{
+ Sequence< DataFlavor > aFlavors;
+ getPasteDataTypes( m_nXdndSelection, aFlavors );
+ return aFlavors;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SelectionManager::isDataFlavorSupported( const DataFlavor& flavor )
+{
+ return m_xDropTransferable->isDataFlavorSupported( flavor );
+}
+
+/*
+ * XDragSource
+ */
+
+sal_Bool SelectionManager::isDragImageSupported()
+{
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int32 SelectionManager::getDefaultCursor( sal_Int8 dragAction )
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::executeDrag(
+ const DragGestureEvent& trigger,
+ sal_Int8 sourceActions,
+ sal_Int32 cursor,
+ sal_Int32 image,
+ const Reference< XTransferable >& transferable,
+ const Reference< XDragSourceListener >& listener
+ )
+{
+}
+
+/*
+ * XDragSourceContext
+ */
+
+sal_Int32 SelectionManager::getCurrentCursor()
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::setCursor( sal_Int32 cursor )
+{
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::setImage( sal_Int32 image )
+{
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::transferablesFlavorsChanged()
+{
+}
+
+/*
+ * dispatch loop
+ */
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::handleXEvent( XEvent& rEvent )
+{
+ /*
+ * since we are XConnectionListener to a second X display
+ * to get client messages it is essential not to dispatch
+ * events twice that we get on both connections
+ */
+ if( rEvent.xany.display != m_pDisplay && rEvent.type != ClientMessage )
+ return;
+
+ MutexGuard aGuard(m_Mutex);
+ switch (rEvent.type)
+ {
+ case SelectionClear:
+ {
+#ifdef DEBUG
+ fprintf( stderr, "SelectionClear for selection %s\n",
+ OUStringToOString( getString( rEvent.xselectionclear.selection ), RTL_TEXTENCODING_ISO_8859_1 ).getStr()
+ );
+#endif
+ SelectionAdaptor* pAdaptor = getAdaptor( rEvent.xselectionclear.selection );
+ if ( pAdaptor )
+ pAdaptor->clearTransferable();
+ }
+ break;
+
+ case SelectionRequest:
+ handleSelectionRequest( rEvent.xselectionrequest );
+ break;
+ case PropertyNotify:
+ if( rEvent.xproperty.window == m_aWindow ||
+ rEvent.xproperty.window == m_aCurrentDropWindow
+ )
+ handleReceivePropertyNotify( rEvent.xproperty );
+ else
+ handleSendPropertyNotify( rEvent.xproperty );
+ break;
+ case SelectionNotify:
+ handleSelectionNotify( rEvent.xselection );
+ break;
+ case ClientMessage:
+ // messages from drag target
+ if( rEvent.xclient.message_type == m_nXdndStatus ||
+ rEvent.xclient.message_type == m_nXdndFinished )
+ handleDragEvent( rEvent.xclient );
+ // messages from drag source
+ else if(
+ rEvent.xclient.message_type == m_nXdndEnter ||
+ rEvent.xclient.message_type == m_nXdndLeave ||
+ rEvent.xclient.message_type == m_nXdndPosition ||
+ rEvent.xclient.message_type == m_nXdndDrop
+ )
+ handleDropEvent( rEvent.xclient );
+ break;
+ default:
+ ;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::run( void* pThis )
+{
+ // dispatch until the cows come home
+
+ SelectionManager* This = (SelectionManager*)pThis;
+ pollfd aPollFD;
+ XEvent event;
+
+ // query socket handle to poll on
+ aPollFD.fd = ConnectionNumber( This->m_pDisplay );
+ aPollFD.events = POLLIN;
+ aPollFD.revents = 0;
+
+ osl_yieldThread();
+ while( osl_scheduleThread(This->m_aThread) )
+ {
+ // wait for activity (outside the xlib)
+ if( poll( &aPollFD, 1, 200 ) > 0 )
+ {
+ // now acquire the mutex to prevent other threads
+ // from using the same X connection
+ MutexGuard aGuard(m_Mutex);
+
+ while( XPending( This->m_pDisplay ) > 0 )
+ {
+ XNextEvent( This->m_pDisplay, &event );
+ This->handleXEvent( event );
+ }
+ }
+ else
+ XSync( This->m_pDisplay, False );
+ osl_yieldThread();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SelectionManager::handleEvent( const Any& event )
+{
+ Sequence< sal_Int8 > aSeq;
+ event >>= aSeq;
+
+ XEvent* pEvent = (XEvent*)aSeq.getArray();
+ handleXEvent( *pEvent );
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::registerHandler( Atom selection, SelectionAdaptor& rAdaptor )
+{
+ MutexGuard aGuard(m_Mutex);
+
+ Selection* pNewSelection = new Selection();
+ pNewSelection->m_pAdaptor = &rAdaptor;
+ pNewSelection->m_aAtom = selection;
+ m_aSelections[ selection ] = pNewSelection;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::deregisterHandler( Atom selection )
+{
+ MutexGuard aGuard(m_Mutex);
+
+ ::std::hash_map< Atom, Selection* >::iterator it =
+ m_aSelections.find( selection );
+ if( it != m_aSelections.end() )
+ {
+ delete it->second;
+ m_aSelections.erase( it );
+ }
+ if( m_aSelections.size() == 0 )
+ m_pInstance = NULL;
+}
+
+/*
+ * XDropTargetFactory
+ */
+
+// ------------------------------------------------------------------------
+
+Reference< XDropTarget > SelectionManager::createDropTarget( const Sequence< sal_Int8 >& windowId )
+{
+ Window aWindow = None;
+ Reference< XDropTarget > xRet;
+
+ if( windowId.getLength() == sizeof( aWindow ) )
+ aWindow = *(Window*)windowId.getConstArray();
+
+ // 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 );
+
+ // set XdndAware
+ XChangeProperty( m_pDisplay, aWindow, m_nXdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&nXdndProtocolRevision, 1 );
+
+ DropTargetEntry aEntry( new DropTarget() );
+ // get root window of window (in 99.999% of all cases this will be
+ // DefaultRootWindow( m_pDisplay )
+ int x, y;
+ unsigned int w, h, bw, d;
+ 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 )
+{
+ 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;
+ }
+ }
+}
+
+/*
+ * XServiceInfo
+ */
+
+// ------------------------------------------------------------------------
+
+OUString SelectionManager::getImplementationName( )
+{
+ return OUString::createFromAscii(XDND_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SelectionManager::supportsService( const OUString& ServiceName )
+{
+ Sequence < OUString > SupportedServicesNames = Xdnd_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SelectionManager::getSupportedServiceNames()
+{
+ return Xdnd_getSupportedServiceNames();
+}
+
+
+// ------------------------------------------------------------------------
+
+/*
+ * SelectionAdaptor
+ */
+
+Reference< XTransferable > SelectionManager::getTransferable()
+{
+ return m_xDragSourceTransferable;
+}
+
+// ------------------------------------------------------------------------
+
+void SelectionManager::clearTransferable()
+{
+ m_xDragSourceTransferable.clear();
+}
diff --git a/dtrans/source/X11/X11_selection.hxx b/dtrans/source/X11/X11_selection.hxx
new file mode 100644
index 000000000000..12c88a27d02d
--- /dev/null
+++ b/dtrans/source/X11/X11_selection.hxx
@@ -0,0 +1,455 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_selection.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:28 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_X11_SELECTION_HXX_
+#define _DTRANS_X11_SELECTION_HXX_
+
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+
+#ifndef _CPPUHELPER_COMPBASE8_HXX_
+#include <cppuhelper/compbase8.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGET_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETDROPCONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETDRAGCONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.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
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGSOURCECONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_AWT_XDISPLAYCONNECTION_HPP_
+#include <com/sun/star/awt/XDisplayConnection.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+
+#ifndef _OSL_CONDITION_HXX_
+#include <osl/conditn.hxx>
+#endif
+
+#ifndef __SGI_STL_HASH_MAP
+#include <hash_map>
+#endif
+
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+
+#include <X11/Xlib.h>
+
+#define XDND_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndSupport"
+
+using namespace ::com::sun::star::uno;
+
+namespace x11 {
+
+// ------------------------------------------------------------------------
+ rtl_TextEncoding getTextPlainEncoding( const ::rtl::OUString& rMimeType );
+
+ class SelectionAdaptor
+ {
+ public:
+ virtual Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable() = 0;
+ virtual void clearTransferable() = 0;
+ };
+
+ class DropTarget :
+ public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::dnd::XDropTarget >
+ {
+ public:
+ ::osl::Mutex m_aMutex;
+ bool m_bActive;
+ sal_Int8 m_nDefaultActions;
+ ::std::list< Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener > >
+ m_aListeners;
+
+ DropTarget() :
+ m_bActive( false ),
+ m_nDefaultActions( 0 ) {}
+ virtual ~DropTarget();
+
+ // convenience functions that loop over listeners
+ void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde );
+ void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte );
+ 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 );
+ // 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 >& );
+ virtual sal_Bool SAL_CALL isActive();
+ virtual void SAL_CALL setActive( sal_Bool active );
+ virtual sal_Int8 SAL_CALL getDefaultActions();
+ virtual void SAL_CALL setDefaultActions( sal_Int8 actions );
+ };
+
+ class SelectionManager :
+ public ::cppu::WeakComponentImplHelper8<
+ ::com::sun::star::datatransfer::dnd::XDropTargetDropContext,
+ ::com::sun::star::datatransfer::dnd::XDropTargetDragContext,
+ ::com::sun::star::datatransfer::dnd::XDropTargetFactory,
+ ::com::sun::star::datatransfer::dnd::XDragSource,
+ ::com::sun::star::datatransfer::dnd::XDragSourceContext,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::awt::XEventHandler,
+ ::com::sun::star::lang::XServiceInfo
+ >,
+ public SelectionAdaptor
+ {
+ // for INCR type selection transfer
+ // INCR protocol is used if the data cannot
+ // be transported at once but in parts
+ // IncrementalTransfer holds the bytes to be transmitted
+ // as well a the current position
+ // INCR triggers the delivery of the next part by deleting the
+ // property used to transfer the data
+ struct IncrementalTransfer
+ {
+ Sequence< sal_Int8 >
+ m_aData;
+ int m_nBufferPos;
+ Window m_aRequestor;
+ Atom m_aProperty;
+ Atom m_aTarget;
+ int m_nFormat;
+ int m_nTransferStartTime;
+
+ IncrementalTransfer( const Sequence< sal_Int8 >& rData, Window aRequestor, Atom aProperty, Atom aTarget, int nFormat );
+ };
+
+ // a struct to hold the data associated with a selection
+ struct Selection
+ {
+ enum State
+ {
+ Inactive, WaitingForResponse, WaitingForData, IncrementalTransfer
+ };
+
+ State m_eState;
+ SelectionAdaptor* m_pAdaptor;
+ Atom m_aAtom;
+ ::osl::Condition m_aDataArrived;
+ Sequence< sal_Int8 >
+ m_aData;
+ Sequence< ::com::sun::star::datatransfer::DataFlavor >
+ m_aTypes;
+ // this is used for caching
+ // m_aTypes is invalid after 2 seconds
+ int m_nLastTimestamp;
+ bool m_bHaveUTF16;
+
+ Selection() : m_eState( Inactive ),
+ m_pAdaptor( NULL ),
+ m_aAtom( None ),
+ m_nLastTimestamp( 0 ),
+ m_bHaveUTF16( false )
+ {}
+ };
+
+ // a struct to hold data associated with a XDropTarget
+ 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; }
+ };
+
+ // internal data
+ Display* m_pDisplay;
+ oslThread m_aThread;
+ Window m_aWindow;
+ Reference< ::com::sun::star::awt::XDisplayConnection >
+ m_xDisplayConnection;
+
+ // None if no Dnd action is running with us as source
+ Window m_aDropWindow;
+ // either m_aDropWindow or its XdndProxy
+ Window m_aDropMessageWindow;
+
+ // contains the XdndEnterEvent of a drop action running
+ // with one of our targets. The data.l[0] member
+ // (conatining the drag source window) is set
+ // to None while that is not the case
+ XClientMessageEvent m_aDropEnterEvent;
+ // set to false on XdndEnter
+ // set to true on first XdndPosition or XdndLeave
+ bool m_bDropEnterSent;
+ Window m_aCurrentDropWindow;
+ // time code of XdndDrop
+ Time m_nDropTime;
+ int m_nLastX, m_nLastY;
+ int m_nCurrentProtocolVersion;
+ sal_Int8 m_nLastDropAction;
+
+ ::std::hash_map< Window, DropTargetEntry >
+ m_aDropTargets;
+ // XTransferable for Xdnd with foreign drag source
+ Reference< ::com::sun::star::datatransfer::XTransferable >
+ m_xDropTransferable;
+
+ // XTransferable for Xdnd when we are drag source
+ Reference< ::com::sun::star::datatransfer::XTransferable >
+ m_xDragSourceTransferable;
+
+ // some special atoms that are needed often
+ Atom m_nCLIPBOARDAtom;
+ Atom m_nTARGETSAtom;
+ Atom m_nTEXTAtom;
+ Atom m_nINCRAtom;
+ Atom m_nXdndAware;
+ Atom m_nXdndEnter;
+ Atom m_nXdndLeave;
+ Atom m_nXdndPosition;
+ Atom m_nXdndStatus;
+ Atom m_nXdndDrop;
+ Atom m_nXdndFinished;
+ Atom m_nXdndSelection;
+ Atom m_nXdndTypeList;
+ Atom m_nXdndProxy;
+ Atom m_nXdndActionCopy;
+ Atom m_nXdndActionMove;
+ Atom m_nXdndActionLink;
+ Atom m_nXdndActionAsk;
+ Atom m_nXdndActionPrivate;
+
+ // caching for atoms
+ ::std::hash_map< Atom, ::rtl::OUString >
+ m_aAtomToString;
+ ::std::hash_map< ::rtl::OUString, Atom, ::rtl::OUStringHash >
+ m_aStringToAtom;
+
+ // the registered selections
+ ::std::hash_map< Atom, Selection* >
+ m_aSelections;
+ // IncrementalTransfers in progress
+ ::std::hash_map< Window, ::std::list< IncrementalTransfer > >
+ m_aIncrementals;
+
+ // do not use X11 multithreading capabilities
+ // since this leads to deadlocks in different Xlib implentations
+ // (XFree as well as Xsun) use an own mutex instead
+ static ::osl::Mutex m_Mutex;
+ // currently this service supports only one display
+ // this should be changed to a hash_map indexed by the
+ // display name in the future
+ static SelectionManager* m_pInstance;
+
+ SelectionManager();
+ ~SelectionManager();
+
+ SelectionAdaptor* getAdaptor( Atom selection );
+
+ // handle various events
+ void handleSelectionRequest( XSelectionRequestEvent& rRequest );
+ void handleSendPropertyNotify( XPropertyEvent& rNotify );
+ void handleReceivePropertyNotify( XPropertyEvent& rNotify );
+ void handleSelectionNotify( XSelectionEvent& rNotify );
+ void handleDragEvent( XClientMessageEvent& rMessage );
+ void handleDropEvent( XClientMessageEvent& rMessage );
+
+ void sendDragStatus( Atom nDropAction );
+
+ bool getPasteData( Atom selection, Atom type, Sequence< sal_Int8 >& rData );
+ // returns true if conversion was successful
+ bool convertData( const Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
+ const ::rtl::OUString& rType,
+ Sequence< sal_Int8 >& rData );
+
+ // thread dispatch loop
+ static void run( void* );
+ void handleXEvent( XEvent& rEvent );
+ public:
+ static SelectionManager& get();
+
+ Display * getDisplay() { return m_pDisplay; };
+ Window getWindow() { return m_aWindow; };
+
+
+ void registerHandler( Atom selection, SelectionAdaptor& rAdaptor );
+ void deregisterHandler( Atom selection );
+ bool requestOwnership( Atom selection );
+
+
+ Atom getAtom( const ::rtl::OUString& rString );
+ const ::rtl::OUString& getString( Atom nAtom );
+
+ // type conversion
+ Atom convertTypeToNative( const ::rtl::OUString& rType, Atom selection, int& rFormat );
+ ::rtl::OUString convertTypeFromNative( Atom nType, Atom selection );
+
+ Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >
+ registerDropTarget( Window aWindow );
+ void deregisterDropTarget( const Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >& xTarget );
+
+ // methods for transferable
+ bool getPasteDataTypes( Atom selection, Sequence< ::com::sun::star::datatransfer::DataFlavor >& rTypes );
+ bool getPasteData( Atom selection, const ::rtl::OUString& rType, Sequence< sal_Int8 >& rData );
+
+ // XDropTargetDropContext
+ virtual void SAL_CALL acceptDrop( sal_Int8 dropOperation );
+ virtual void SAL_CALL rejectDrop();
+ virtual void SAL_CALL dropComplete( sal_Bool success );
+
+ // XDropTargetDragContext
+ virtual void SAL_CALL acceptDrag( sal_Int8 dragOperation );
+ virtual void SAL_CALL rejectDrag();
+ virtual Sequence< ::com::sun::star::datatransfer::DataFlavor >
+ SAL_CALL getCurrentDataFlavors();
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& df );
+
+ // 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 );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupportedServiceNames();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& arguments );
+
+ // XEventHandler
+ virtual sal_Bool SAL_CALL handleEvent( const Any& event );
+
+ // XDragSource
+ virtual sal_Bool SAL_CALL isDragImageSupported();
+ virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction );
+ virtual void SAL_CALL executeDrag(
+ const ::com::sun::star::datatransfer::dnd::DragGestureEvent& trigger,
+ sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image,
+ const Reference< ::com::sun::star::datatransfer::XTransferable >& transferable,
+ const Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener >& listener
+ );
+
+ // XDragSourceContext
+ virtual sal_Int32 SAL_CALL getCurrentCursor();
+ virtual void SAL_CALL setCursor( sal_Int32 cursor );
+ virtual void SAL_CALL setImage( sal_Int32 image );
+ virtual void SAL_CALL transferablesFlavorsChanged();
+
+ // SelectionAdaptor for XdndSelection Drag (we are drag source)
+ virtual Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable();
+ virtual void clearTransferable();
+ };
+
+// ------------------------------------------------------------------------
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Xdnd_getSupportedServiceNames();
+ ::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);
+
+// ------------------------------------------------------------------------
+
+}
+
+#endif
diff --git a/dtrans/source/X11/X11_service.cxx b/dtrans/source/X11/X11_service.cxx
new file mode 100644
index 000000000000..07ecb2a5d4da
--- /dev/null
+++ b/dtrans/source/X11/X11_service.cxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_service.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:28 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <X11_clipboard.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h> // declaration of generic uno interface
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx> // mapping stuff
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::lang;
+using namespace x11;
+
+namespace x11 {
+
+Sequence< OUString > SAL_CALL X11Clipboard_getSupportedServiceNames()
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard");
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL X11Clipboard_createInstance(
+ const Reference< XMultiServiceFactory > & xMultiServiceFactory)
+{
+ return Reference < XInterface >( ( OWeakObject * ) new X11Clipboard());
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL Xdnd_getSupportedServiceNames()
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DragAndDrop");
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL Xdnd_createInstance(
+ const Reference< XMultiServiceFactory > & xMultiServiceFactory)
+{
+ return Reference < XInterface >( ( OWeakObject * )& SelectionManager::get() );
+}
+
+}
+
+static const OUString& getClipboardImplementationName()
+{
+ static OUString aImpl = OUString::createFromAscii(X11_CLIPBOARD_IMPLEMENTATION_NAME);
+ return aImpl;
+}
+
+static const OUString& getClipboardServiceName()
+{
+ static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard" );
+ return aImpl;
+}
+
+static const OUString& getXdndImplementationName()
+{
+ static OUString aImpl = OUString::createFromAscii(XDND_IMPLEMENTATION_NAME );
+ return aImpl;
+}
+
+static const OUString& getXdndServiceName()
+{
+ static OUString aImpl = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DragAndDrop" );
+ return aImpl;
+}
+
+extern "C" {
+ void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char** ppEnvTypeName,
+ uno_Environment** ppEnv )
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pXUnoKey )
+ {
+ if( pXUnoKey )
+ {
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) );
+
+ OUString aImplName = OUString::createFromAscii( "/" );
+ aImplName += getClipboardImplementationName();
+ aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
+ aImplName += getClipboardServiceName();
+ xKey->createKey( aImplName );
+
+ aImplName = OUString::createFromAscii( "/" );
+ aImplName += getXdndImplementationName();
+ aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/" );
+ aImplName += getXdndServiceName();
+ xKey->createKey( aImplName );
+
+ return sal_True;
+ }
+ catch( ::com::sun::star::registry::InvalidRegistryException& )
+ {
+ }
+ }
+ return sal_False;
+ }
+
+ void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pXUnoSMgr,
+ void* pXUnoKey
+ )
+ {
+ void* pRet = 0;
+
+ ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
+
+ if( pXUnoSMgr )
+ {
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
+ reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
+ );
+ Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
+ if( aImplName.equals( getClipboardImplementationName() ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ xMgr, aImplName, X11Clipboard_createInstance,
+ X11Clipboard_getSupportedServiceNames() );
+ }
+ else if( aImplName.equals( getXdndImplementationName() ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ xMgr, aImplName, Xdnd_createInstance,
+ Xdnd_getSupportedServiceNames() );
+ }
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+ }
+
+} /* extern "C" */
diff --git a/dtrans/source/X11/X11_transferable.cxx b/dtrans/source/X11/X11_transferable.cxx
new file mode 100644
index 000000000000..eaa25b7941ef
--- /dev/null
+++ b/dtrans/source/X11/X11_transferable.cxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_transferable.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:28 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <X11_transferable.hxx>
+#include <X11/Xatom.h>
+
+#ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_
+#include <com/sun/star/io/IOException.hpp>
+#endif
+
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+
+using namespace x11;
+
+
+X11Transferable::X11Transferable(
+ SelectionManager& rManager,
+ Atom selection
+ ) :
+ m_rManager( rManager ),
+ m_aSelection( selection )
+{
+}
+
+//==================================================================================================
+
+X11Transferable::~X11Transferable()
+{
+}
+
+//==================================================================================================
+
+Any SAL_CALL X11Transferable::getTransferData( const DataFlavor& rFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any aRet;
+ Sequence< sal_Int8 > aData;
+ bool bSuccess = m_rManager.getPasteData( m_aSelection ? m_aSelection : XA_PRIMARY, rFlavor.MimeType, aData );
+ if( ! bSuccess && m_aSelection == 0 )
+ bSuccess = m_rManager.getPasteData( m_rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ), rFlavor.MimeType, aData );
+
+ if( ! bSuccess )
+ {
+ throw UnsupportedFlavorException( rFlavor.MimeType, static_cast < XTransferable * > ( this ) );
+ }
+ if( rFlavor.MimeType.equalsIgnoreCase( OUString::createFromAscii( "text/plain;charset=utf-16" ) ) )
+ {
+ OUString aString( (sal_Unicode*)aData.getConstArray(), aData.getLength()/sizeof( sal_Unicode ) );
+ aRet <<= aString;
+ }
+ else
+ aRet <<= aData;
+ return aRet;
+}
+
+//==================================================================================================
+
+Sequence< DataFlavor > SAL_CALL X11Transferable::getTransferDataFlavors()
+ throw(RuntimeException)
+{
+ Sequence< DataFlavor > aFlavorList;
+ bool bSuccess = m_rManager.getPasteDataTypes( m_aSelection ? m_aSelection : XA_PRIMARY, aFlavorList );
+ if( ! bSuccess && m_aSelection == 0 )
+ bSuccess = m_rManager.getPasteDataTypes( m_rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ), aFlavorList );
+
+ return aFlavorList;
+}
+
+//==================================================================================================
+
+sal_Bool SAL_CALL X11Transferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ if( aFlavor.DataType != getCppuType( (Sequence< sal_Int8 >*)0 ) )
+ {
+ if( ! aFlavor.MimeType.equalsIgnoreCase( OUString::createFromAscii( "text/plain;charset=utf-16" ) ) &&
+ aFlavor.DataType == getCppuType( (OUString*)0 ) )
+ return false;
+ }
+
+ Sequence< DataFlavor > aFlavors( getTransferDataFlavors() );
+ for( int i = 0; i < aFlavors.getLength(); i++ )
+ if( aFlavor.MimeType.equalsIgnoreCase( aFlavors.getConstArray()[i].MimeType ) &&
+ aFlavor.DataType == aFlavors.getConstArray()[i].DataType )
+ return sal_True;
+
+ return sal_False;
+}
+
diff --git a/dtrans/source/X11/X11_transferable.hxx b/dtrans/source/X11/X11_transferable.hxx
new file mode 100644
index 000000000000..f3ab2949c3b0
--- /dev/null
+++ b/dtrans/source/X11/X11_transferable.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: X11_transferable.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:29 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_X11_TRANSFERABLE_HXX_
+#define _DTRANS_X11_TRANSFERABLE_HXX_
+
+#ifndef _DTRANS_X11_SELECTION_HXX_
+#include <X11_selection.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HDL_
+#include <com/sun/star/lang/XEventListener.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+namespace x11 {
+
+ class X11Transferable : public ::cppu::WeakImplHelper1 <
+ ::com::sun::star::datatransfer::XTransferable >
+ {
+ ::osl::Mutex m_aMutex;
+
+ SelectionManager& m_rManager;
+ Atom m_aSelection;
+
+ virtual ~X11Transferable();
+
+ public:
+
+ X11Transferable( SelectionManager& rManager, Atom selection = None );
+
+ /*
+ * XTransferable
+ */
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw(::com::sun::star::datatransfer::UnsupportedFlavorException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw(::com::sun::star::uno::RuntimeException);
+ };
+
+} // namespace
+
+#endif
diff --git a/dtrans/source/X11/dtransX11.xml b/dtrans/source/X11/dtransX11.xml
new file mode 100644
index 000000000000..53825958c5b3
--- /dev/null
+++ b/dtrans/source/X11/dtransX11.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Tino Rachui </Author>
+
+<Name> com.sun.star.comp.datatransfer.X11 </Name>
+
+<Description>
+ The X11 implementation of the datatransfer service.
+</Description>
+
+<ModuleName> dtransX11 </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="experimental"/>
+
+<SupportedService> com.sun.star.datatransfer.clipboard.SystemClipboard </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+<Type> com.sun.star.datatransfer.clipboard.XClipboardEx </Type>
+<Type> com.sun.star.datatransfer.XTransferable </Type>
+<Type> com.sun.star.datatransfer.clipboard.RenderingCapabilities </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardOwner </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardListener </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardNotifier </Type>
+
+<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>
+
+<Type> com.sun.star.awt.XDisplayConnection </Type>
+
+<Type> com.sun.star.lang.DisposedException </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.container.XSet </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/dtrans/source/X11/makefile.mk b/dtrans/source/X11/makefile.mk
new file mode 100644
index 000000000000..c3e0314b9a25
--- /dev/null
+++ b/dtrans/source/X11/makefile.mk
@@ -0,0 +1,111 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:37:23 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=dtrans
+TARGET=dtransX11
+
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : ..$/cppumaker.mk
+
+# ------------------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/X11_transferable.obj \
+ $(SLO)$/X11_clipboard.obj \
+ $(SLO)$/X11_selection.obj \
+ $(SLO)$/X11_droptarget.obj \
+ $(SLO)$/X11_service.obj
+
+SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ -lX11
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1OBJS= $(SLOFILES)
+
+APP1NOSAL=TRUE
+APP1TARGET=testunxcb
+APP1OBJS=$(SLO)$/test_unxcb.obj
+APP1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/dtrans/source/cnttype/exports.dxp b/dtrans/source/cnttype/exports.dxp
new file mode 100644
index 000000000000..028ac4175990
--- /dev/null
+++ b/dtrans/source/cnttype/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/dtrans/source/cnttype/makefile.mk b/dtrans/source/cnttype/makefile.mk
new file mode 100644
index 000000000000..21f28421827d
--- /dev/null
+++ b/dtrans/source/cnttype/makefile.mk
@@ -0,0 +1,110 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:36:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=dtrans
+TARGET=mcnttype
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+COMP1TYPELIST=$(TARGET)
+COMPRDB=$(SOLARBINDIR)$/applicat.rdb
+USE_BOUNDCHK=
+
+.IF "$(USE_BOUNDCHK)"=="TR"
+bndchk=tr
+stoponerror=tr
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+SLOFILES=$(SLO)$/mctfentry.obj \
+ $(SLO)$/mcnttfactory.obj \
+ $(SLO)$/mcnttype.obj
+
+SHL1TARGET=$(TARGET)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+#SHL1DEPN+= makefile.mk $(TARGET).xml
+SHL1IMPLIB=i$(SHL1TARGET)
+
+#--- comment -----------------
+
+SHL1OBJS= $(SLOFILES)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/dtrans/source/cnttype/mcnttfactory.cxx b/dtrans/source/cnttype/mcnttfactory.cxx
new file mode 100644
index 000000000000..d5a480507cd7
--- /dev/null
+++ b/dtrans/source/cnttype/mcnttfactory.cxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * $RCSfile: mcnttfactory.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _MCNTTFACTORY_HXX_
+#include "mcnttfactory.hxx"
+#endif
+
+#ifndef _MCNTTYPE_HXX_
+#include "mcnttype.hxx"
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory"
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::datatransfer;
+
+//------------------------------------------------------------------------
+// helper functions
+//------------------------------------------------------------------------
+
+namespace
+{
+ Sequence< OUString > SAL_CALL MimeContentTypeFactory_getSupportedServiceNames( )
+ {
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.MimeContentTypeFactory");
+ return aRet;
+ }
+}
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+CMimeContentTypeFactory::CMimeContentTypeFactory( const Reference< XMultiServiceFactory >& rSrvMgr ) :
+ m_SrvMgr( rSrvMgr )
+{
+}
+
+//------------------------------------------------------------------------
+// createMimeContentType
+//------------------------------------------------------------------------
+
+Reference< XMimeContentType > CMimeContentTypeFactory::createMimeContentType( const OUString& aContentType )
+ throw( IllegalArgumentException, RuntimeException )
+{
+ MutexGuard aGuard( m_aMutex );
+ return Reference< XMimeContentType >( new CMimeContentType( aContentType ) );
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+OUString SAL_CALL CMimeContentTypeFactory::getImplementationName( )
+ throw( RuntimeException )
+{
+ return OUString::createFromAscii( MIMECONTENTTYPEFACTORY_IMPL_NAME );
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+sal_Bool SAL_CALL CMimeContentTypeFactory::supportsService( const OUString& ServiceName )
+ throw( RuntimeException )
+{
+ Sequence < OUString > SupportedServicesNames = MimeContentTypeFactory_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// -------------------------------------------------
+// XServiceInfo
+// -------------------------------------------------
+
+Sequence< OUString > SAL_CALL CMimeContentTypeFactory::getSupportedServiceNames( )
+ throw( RuntimeException )
+{
+ return MimeContentTypeFactory_getSupportedServiceNames( );
+} \ No newline at end of file
diff --git a/dtrans/source/cnttype/mcnttfactory.hxx b/dtrans/source/cnttype/mcnttfactory.hxx
new file mode 100644
index 000000000000..d420201b7dc0
--- /dev/null
+++ b/dtrans/source/cnttype/mcnttfactory.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * $RCSfile: mcnttfactory.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _MCNTTFACTORY_HXX_
+#define _MCNTTFACTORY_HXX_
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _CPPUHELPER_COMPBASE2_HXX_
+#include <cppuhelper/compbase2.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPEFACTORY_HPP_
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// deklarations
+//------------------------------------------------------------------------
+
+class CMimeContentTypeFactory : public
+ cppu::WeakImplHelper2< com::sun::star::datatransfer::XMimeContentTypeFactory, \
+ com::sun::star::lang::XServiceInfo >
+{
+
+public:
+ CMimeContentTypeFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr );
+
+ //------------------------------------------------
+ // XMimeContentTypeFactory
+ //------------------------------------------------
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentType > SAL_CALL createMimeContentType( const ::rtl::OUString& aContentType )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ //------------------------------------------------
+ // XServiceInfo
+ //------------------------------------------------
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+private:
+ ::osl::Mutex m_aMutex;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr;
+};
+
+
+#endif
+
diff --git a/dtrans/source/cnttype/mcnttype.cxx b/dtrans/source/cnttype/mcnttype.cxx
new file mode 100644
index 000000000000..3601a5260cd2
--- /dev/null
+++ b/dtrans/source/cnttype/mcnttype.cxx
@@ -0,0 +1,451 @@
+/*************************************************************************
+ *
+ * $RCSfile: mcnttype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#ifndef _MCNTTYPE_HXX_
+#include "mcnttype.hxx"
+#endif
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace rtl;
+using namespace std;
+using namespace osl;
+
+//------------------------------------------------------------------------
+// constants
+//------------------------------------------------------------------------
+
+const OUString TSPECIALS = OUString::createFromAscii( "()<>@,;:\\\"/[]?=" );
+const OUString TOKEN = OUString::createFromAscii( "!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~." );
+const OUString SPACE = OUString::createFromAscii( " " );
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+CMimeContentType::CMimeContentType( const OUString& aCntType )
+{
+ init( aCntType );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::getMediaType( ) throw(RuntimeException)
+{
+ return m_MediaType;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::getMediaSubtype( ) throw(RuntimeException)
+{
+ return m_MediaSubtype;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::getFullMediaType( ) throw(RuntimeException)
+{
+ return m_MediaType + OUString::createFromAscii( "/" ) + m_MediaSubtype;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL CMimeContentType::getParameters( ) throw(RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+
+ Sequence< OUString > seqParams;
+
+ map< OUString, OUString >::iterator iter;
+ map< OUString, OUString >::iterator iter_end = m_ParameterMap.end( );
+
+ for ( iter = m_ParameterMap.begin( ); iter != iter_end; ++iter )
+ {
+ seqParams.realloc( seqParams.getLength( ) + 1 );
+ seqParams[seqParams.getLength( ) - 1] = iter->first;
+ }
+
+ return seqParams;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CMimeContentType::hasParameter( const OUString& aName ) throw(RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+ return ( m_ParameterMap.end( ) != m_ParameterMap.find( aName ) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::getParameterValue( const OUString& aName ) throw(NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
+
+ if ( !hasParameter( aName ) )
+ throw NoSuchElementException( );
+
+ return m_ParameterMap.find( aName )->second;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::init( const OUString& aCntType ) throw( IllegalArgumentException )
+{
+ if ( !aCntType.getLength( ) )
+ throw IllegalArgumentException( );
+
+ m_nPos = 0;
+ m_ContentType = aCntType;
+ getSym( );
+ type();
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::getSym( void )
+{
+ if ( m_nPos < m_ContentType.getLength( ) )
+ {
+ m_nxtSym = OUString( &m_ContentType[m_nPos], 1 );
+ ++m_nPos;
+ return;
+ }
+
+ m_nxtSym = OUString( );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::acceptSym( const OUString& pSymTlb )
+{
+ if ( pSymTlb.indexOf( m_nxtSym ) < 0 )
+ throw IllegalArgumentException( );
+
+ getSym();
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::skipSpaces( void )
+{
+ while ( SPACE == m_nxtSym )
+ getSym( );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::type( void )
+{
+ skipSpaces( );
+
+ // check FIRST( type )
+ if ( !isInRange( m_nxtSym, TOKEN ) )
+ throw IllegalArgumentException( );
+
+ // parse
+ while( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN ) )
+ m_MediaType += m_nxtSym;
+ else if ( isInRange( m_nxtSym, OUString::createFromAscii( "/ " ) ) )
+ break;
+ else
+ throw IllegalArgumentException( );
+ getSym( );
+ }
+
+ // check FOLLOW( type )
+ skipSpaces( );
+ acceptSym( OUString::createFromAscii( "/" ) );
+
+ subtype( );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::subtype( void )
+{
+ skipSpaces( );
+
+ // check FIRST( subtype )
+ if ( !isInRange( m_nxtSym, TOKEN ) )
+ throw IllegalArgumentException( );
+
+ while( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN ) )
+ m_MediaSubtype += m_nxtSym;
+ else if ( isInRange( m_nxtSym, OUString::createFromAscii( "; " ) ) )
+ break;
+ else
+ throw IllegalArgumentException( );
+ getSym( );
+ }
+
+ // parse the rest
+ skipSpaces( );
+ trailer();
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::trailer( void )
+{
+ while( m_nxtSym.getLength( ) )
+ {
+ if ( m_nxtSym == OUString::createFromAscii( "(" ) )
+ {
+ getSym( );
+ comment( );
+ acceptSym( OUString::createFromAscii( ")" ) );
+ }
+ else if ( m_nxtSym == OUString::createFromAscii( ";" ) )
+ {
+ // get the parameter name
+ getSym( );
+ skipSpaces( );
+
+ if ( !isInRange( m_nxtSym, TOKEN ) )
+ throw IllegalArgumentException( );
+
+ OUString pname = pName( );
+
+ skipSpaces();
+ acceptSym( OUString::createFromAscii( "=" ) );
+
+ // get the parameter value
+ skipSpaces( );
+
+ OUString pvalue = pValue( );
+
+ // insert into map
+ if ( !m_ParameterMap.insert( pair < const OUString, OUString > ( pname, pvalue ) ).second )
+ throw IllegalArgumentException( );
+ }
+ else
+ throw IllegalArgumentException( );
+
+ skipSpaces( );
+ }
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::pName( )
+{
+ OUString pname;
+
+ while( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN ) )
+ pname += m_nxtSym;
+ else if ( isInRange( m_nxtSym, OUString::createFromAscii( "= " ) ) )
+ break;
+ else
+ throw IllegalArgumentException( );
+ getSym( );
+ }
+
+ return pname;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::pValue( )
+{
+ OUString pvalue;
+
+ // quoted pvalue
+ if ( m_nxtSym == OUString::createFromAscii( "\"" ) )
+ {
+ getSym( );
+ pvalue = quotedPValue( );
+
+ if ( OUString( &pvalue[pvalue.getLength() - 1], 1 ) != OUString::createFromAscii( "\"" ) )
+ throw IllegalArgumentException( );
+
+ // remove the last quote-sign
+ OUString qpvalue( pvalue, pvalue.getLength( ) - 1 );
+ pvalue = qpvalue;
+
+ if ( !pvalue.getLength( ) )
+ throw IllegalArgumentException( );
+ }
+ else if ( isInRange( m_nxtSym, TOKEN ) ) // unquoted pvalue
+ {
+ pvalue = nonquotedPValue( );
+ }
+ else
+ throw IllegalArgumentException( );
+
+ return pvalue;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::quotedPValue( )
+{
+ OUString pvalue;
+
+ while ( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN + TSPECIALS ) )
+ pvalue += m_nxtSym;
+ else if ( m_nxtSym == SPACE )
+ break;
+ else
+ throw IllegalArgumentException( );
+ getSym( );
+ }
+
+ return pvalue;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+OUString SAL_CALL CMimeContentType::nonquotedPValue( )
+{
+ OUString pvalue;
+
+ while ( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN ) )
+ pvalue += m_nxtSym;
+ else if ( isInRange( m_nxtSym, OUString::createFromAscii( "; " ) ) )
+ break;
+ else
+ throw IllegalArgumentException( );
+ getSym( );
+ }
+
+ return pvalue;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CMimeContentType::comment( void )
+{
+ while ( m_nxtSym.getLength( ) )
+ {
+ if ( isInRange( m_nxtSym, TOKEN + SPACE ) )
+ getSym( );
+ else if ( m_nxtSym, OUString::createFromAscii( ")" ) )
+ break;
+ else
+ throw IllegalArgumentException( );
+ }
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CMimeContentType::isInRange( const rtl::OUString& aChr, const rtl::OUString& aRange )
+{
+ return ( aRange.indexOf( aChr ) > -1 );
+} \ No newline at end of file
diff --git a/dtrans/source/cnttype/mcnttype.hxx b/dtrans/source/cnttype/mcnttype.hxx
new file mode 100644
index 000000000000..fc78397279a7
--- /dev/null
+++ b/dtrans/source/cnttype/mcnttype.hxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * $RCSfile: mcnttype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _MCNTTYPE_HXX_
+#define _MCNTTYPE_HXX_
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPE_HPP_
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#endif
+
+#include <stl/map>
+
+//------------------------------------------------------------------------
+// deklarations
+//------------------------------------------------------------------------
+
+class CMimeContentType : public
+ cppu::WeakImplHelper1< com::sun::star::datatransfer::XMimeContentType >
+{
+public:
+ CMimeContentType( const rtl::OUString& aCntType );
+
+ //-------------------------------------------
+ // XMimeContentType
+ //-------------------------------------------
+
+ virtual ::rtl::OUString SAL_CALL getMediaType( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getMediaSubtype( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getFullMediaType( ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getParameters( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasParameter( const ::rtl::OUString& aName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getParameterValue( const ::rtl::OUString& aName )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+private:
+ void SAL_CALL init( const rtl::OUString& aCntType ) throw( com::sun::star::lang::IllegalArgumentException );
+ void SAL_CALL getSym( void );
+ void SAL_CALL acceptSym( const rtl::OUString& pSymTlb );
+ void SAL_CALL skipSpaces( void );
+ void SAL_CALL type( void );
+ void SAL_CALL subtype( void );
+ void SAL_CALL trailer( void );
+ rtl::OUString SAL_CALL pName( );
+ rtl::OUString SAL_CALL pValue( );
+ rtl::OUString SAL_CALL quotedPValue( );
+ rtl::OUString SAL_CALL nonquotedPValue( );
+ void SAL_CALL comment( void );
+ sal_Bool SAL_CALL isInRange( const rtl::OUString& aChr, const rtl::OUString& aRange );
+
+private:
+ ::osl::Mutex m_aMutex;
+ rtl::OUString m_MediaType;
+ rtl::OUString m_MediaSubtype;
+ rtl::OUString m_ContentType;
+ std::map< rtl::OUString, rtl::OUString > m_ParameterMap;
+ sal_Int32 m_nPos;
+ rtl::OUString m_nxtSym;
+};
+
+#endif
+
diff --git a/dtrans/source/cnttype/mcnttype.xml b/dtrans/source/cnttype/mcnttype.xml
new file mode 100644
index 000000000000..e10ab968d84d
--- /dev/null
+++ b/dtrans/source/cnttype/mcnttype.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Tino Rachui </Author>
+
+<Name> com.sun.star.comp.datatransfer.MimeContentTypeFactory </Name>
+
+<Description>
+ The win32 implementation of the datatransfer service.
+</Description>
+
+<ModuleName> mcnttype </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="experimental"/>
+
+<SupportedService> com.sun.star.datatransfer.MimeContentTypeFactory </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+<Type> com.sun.star.datatransfer.XMimeContentTypeFactory </Type>
+<Type> com.sun.star.datatransfer.XMimeContentType </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.container.XSet </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/dtrans/source/cnttype/mctfentry.cxx b/dtrans/source/cnttype/mctfentry.cxx
new file mode 100644
index 000000000000..b651dbdf6f6e
--- /dev/null
+++ b/dtrans/source/cnttype/mctfentry.cxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * $RCSfile: mctfentry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:58 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//-----------------------------------------------------------------
+// includes of other projects
+//-----------------------------------------------------------------
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
+#include <com/sun/star/container/XSet.hpp>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPEFACTORY_HPP_
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#endif
+
+#ifndef _MCNTTFACTORY_HXX_
+#include "mcnttfactory.hxx"
+#endif
+
+//-----------------------------------------------------------------
+// some defines
+//-----------------------------------------------------------------
+
+// the service names
+#define MIMECONTENTTYPEFACTORY_SERVICE_NAME "com.sun.star.datatransfer.MimeContentTypeFactory"
+
+// the implementation names
+#define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory"
+
+// the registry key names
+// a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
+// < Implementation-Name ></UNO/SERVICES/>< Service-Name >
+#define MIMECONTENTTYPEFACTORY_REGKEY_NAME "/com.sun.star.datatransfer.MimeCntTypeFactory/UNO/SERVICES/com.sun.star.datatransfer.MimeContentTypeFactory"
+
+//-----------------------------------------------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::registry ;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::datatransfer;
+
+//-----------------------------------------------------------------
+// create a static object to initialize the shell9x library
+//-----------------------------------------------------------------
+
+namespace
+{
+
+ //-----------------------------------------------------------------------------------------------------------
+ // functions to create a new Clipboad instance; is needed by factory helper implementation
+ // @param rServiceManager - service manager, useful if the component needs other uno services
+ // so we should give it to every UNO-Implementation component
+ //-----------------------------------------------------------------------------------------------------------
+
+ Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
+ {
+ return Reference< XInterface >( static_cast< XMimeContentTypeFactory* >( new CMimeContentTypeFactory( rServiceManager ) ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//-------------------------------------------------------------------------
+// component_writeInfo - to register a UNO-Service
+// to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
+// to view the registry use: regview *.rdb /SERVICES/ServiceName
+// (you must use the full services name e.g. com.sun.star.frame.FilePicker
+//-------------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
+{
+ sal_Bool bRetVal = sal_False;
+
+ if ( pRegistryKey )
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( MIMECONTENTTYPEFACTORY_REGKEY_NAME ) ) );
+ bRetVal = sal_True;
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSHURE(sal_False, "InvalidRegistryException caught");
+ bRetVal = sal_False;
+ }
+ }
+
+ return bRetVal;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+// returns a factory to create XFilePicker-Services
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey )
+{
+ void* pRet = 0;
+
+ if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, MIMECONTENTTYPEFACTORY_IMPL_NAME ) ) )
+ {
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( MIMECONTENTTYPEFACTORY_SERVICE_NAME ) );
+
+ Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
+ OUString::createFromAscii( pImplName ),
+ createInstance,
+ aSNS ) );
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
diff --git a/dtrans/source/cnttype/wbench/makefile.mk b/dtrans/source/cnttype/wbench/makefile.mk
new file mode 100644
index 000000000000..752246d0b30d
--- /dev/null
+++ b/dtrans/source/cnttype/wbench/makefile.mk
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:36:58 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=dtrans
+TARGET=testcnttype
+LIBTARGET=NO
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.INCLUDE : settings.mk
+
+.INCLUDE : ..$/..$/cppumaker.mk
+
+CFLAGS+=-GX
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= $(OBJ)$/testcnttype.obj
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/testcnttype.obj
+
+APP1STDLIBS= $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+#.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/dtrans/source/cnttype/wbench/testcnttype.cxx b/dtrans/source/cnttype/wbench/testcnttype.cxx
new file mode 100644
index 000000000000..f90a6ae90ff3
--- /dev/null
+++ b/dtrans/source/cnttype/wbench/testcnttype.cxx
@@ -0,0 +1,330 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcnttype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:58 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+//_________________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPE_HPP_
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPEFACTORY_HPP_
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include <stdio.h>
+
+#include <stl/vector>
+
+//-------------------------------------------------------------
+// my defines
+//-------------------------------------------------------------
+
+#define TEST_CLIPBOARD
+#define RDB_SYSPATH "d:\\projects\\src616\\dtrans\\wntmsci7\\bin\\applicat.rdb"
+
+//------------------------------------------------------------
+// namesapces
+//------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+//------------------------------------------------------------
+// globales
+//------------------------------------------------------------
+
+//################################################################
+
+/*
+void CheckMimeContentType( const OUString& aCntType, const OUString& aType, const OUString& aSubtype, sal_Int32 nParams )
+{
+
+ Reference< XMimeContentType > xMimeCntType = xMCntTypeFactory->createMimeContentType( aCntType );
+
+ OSL_ASSERT( aType == xMimeCntType->getMediaType ( ) );
+ OSL_ASSERT( aSubtype == xMimeCntType->getMediaSubtype ( ) );
+
+ try
+ {
+ Sequence< OUString > seqParam = xMimeCntType->getParameters( );
+ OSL_ASSERT( seqParam.getLength( ) == nParams );
+
+ OUString param;
+ OUString pvalue;
+ for ( sal_Int32 i = 0; i < seqParam.getLength( ); i++ )
+ {
+ param = seqParam[i];
+ OSL_ASSERT( xMimeCntType->hasParameter( param ) );
+
+ pvalue = xMimeCntType->getParameterValue( param );
+ }
+
+ pvalue = xMimeCntType->getParameterValue( OUString::createFromAscii( "aparam" ) );
+ }
+ catch( IllegalArgumentException& )
+ {
+ printf( "FAILED: Invalid Mime Contenttype detected\n" );
+ }
+ catch( NoSuchElementException& )
+ {
+
+ }
+}
+*/
+
+//----------------------------------------------------------------
+//
+//----------------------------------------------------------------
+
+void ShutdownServiceMgr( Reference< XMultiServiceFactory >& SrvMgr )
+{
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( SrvMgr, UNO_QUERY );
+
+ if ( !xComponent.is() )
+ OSL_ENSURE(sal_False, "Error shuting down");
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ SrvMgr.clear();
+ SrvMgr = Reference< XMultiServiceFactory >();
+}
+
+//----------------------------------------------------------------
+//
+//----------------------------------------------------------------
+
+sal_Bool readCntTypesFromFileIntoVector( char* fname, vector< string >& vecData )
+{
+ FILE* fstream;
+
+ fstream = fopen( fname, "r+" );
+ if ( !fstream )
+ return sal_False;
+
+ // set pointer to file start
+ fseek( fstream, 0L, SEEK_SET );
+
+ char line[1024];
+ while ( fscanf( fstream, "%[^\n]s", line ) != EOF )
+ {
+ vecData.push_back( line );
+ fgetc( fstream );
+ }
+
+ fclose( fstream );
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------
+//
+//----------------------------------------------------------------
+
+sal_Bool processCntTypesAndWriteResultIntoFile( char* fname, vector< string >& vecData, Reference< XMimeContentTypeFactory > cnttypeFactory )
+{
+ FILE* fstream;
+
+ fstream = fopen( fname, "w" );
+ if ( !fstream )
+ return sal_False;
+
+ // set pointer to file start
+ fseek( fstream, 0L, SEEK_SET );
+
+ vector< string >::iterator iter_end = vecData.end( );
+ const char* pStr = NULL;
+
+ for ( vector< string >::iterator iter = vecData.begin( ); iter != iter_end; ++iter )
+ {
+ try
+ {
+ fprintf( fstream, "Gelesen: %s\n", iter->c_str( ) );
+
+ Reference< XMimeContentType > xMCntTyp = cnttypeFactory->createMimeContentType( OUString::createFromAscii( iter->c_str( ) ) );
+
+ fwprintf( fstream, OUString::createFromAscii( "Type: %s\n" ), xMCntTyp->getMediaType( ).getStr( ) );
+ fwprintf( fstream, OUString::createFromAscii( "Subtype: %s\n" ), xMCntTyp->getMediaSubtype( ).getStr( ) );
+
+ Sequence< OUString > seqParam = xMCntTyp->getParameters( );
+ sal_Int32 nParams = seqParam.getLength( );
+
+ for ( sal_Int32 i = 0; i < nParams; i++ )
+ {
+ fwprintf( fstream, OUString::createFromAscii("PName: %s\n" ), seqParam[i].getStr( ) );
+ fwprintf( fstream, OUString::createFromAscii("PValue: %s\n" ), xMCntTyp->getParameterValue( seqParam[i] ).getStr( ) );
+ }
+ }
+ catch( IllegalArgumentException& ex )
+ {
+ fwprintf( fstream, OUString::createFromAscii( "Fehlerhafter Content-Type gelesen!!!\n\n" ) );
+ }
+ catch( NoSuchElementException& )
+ {
+ fwprintf( fstream, OUString::createFromAscii( "Parameterwert nicht vorhanden\n" ) );
+ }
+ catch( ... )
+ {
+ fwprintf( fstream, OUString::createFromAscii( "Unbekannter Fehler!!!\n\n" ) );
+ }
+
+ fwprintf( fstream, OUString::createFromAscii( "\n#############################################\n\n" ) );
+ }
+
+ fclose( fstream );
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------
+// main
+//----------------------------------------------------------------
+
+int SAL_CALL main( int nArgc, char* argv[] )
+{
+ if ( nArgc != 3 )
+ printf( "Start with: testcnttype input-file output-file\n" );
+
+ //-------------------------------------------------
+ // get the global service-manager
+ //-------------------------------------------------
+ OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
+
+ // Print a message if an error occured.
+ if ( !g_xFactory.is( ) )
+ {
+ OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ vector< string > vecCntTypes;
+
+ // open input-file and read the data
+ if ( !readCntTypesFromFileIntoVector( argv[1], vecCntTypes ) )
+ {
+ printf( "Can't open input file" );
+ ShutdownServiceMgr( g_xFactory );
+ }
+
+ Reference< XMimeContentTypeFactory >
+ xMCntTypeFactory( g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.MimeContentTypeFactory" ) ), UNO_QUERY );
+
+ if ( !xMCntTypeFactory.is( ) )
+ {
+ OSL_ENSURE( sal_False, "Error creating MimeContentTypeFactory Service" );
+ return(-1);
+ }
+
+ if ( !processCntTypesAndWriteResultIntoFile( argv[2], vecCntTypes, xMCntTypeFactory ) )
+ {
+ printf( "Can't open output file" );
+ ShutdownServiceMgr( g_xFactory );
+ }
+
+ //--------------------------------------------------
+ // shutdown the service manager
+ //--------------------------------------------------
+
+ ShutdownServiceMgr( g_xFactory );
+
+ return 0;
+}
diff --git a/dtrans/source/generic/clipboardmanager.cxx b/dtrans/source/generic/clipboardmanager.cxx
new file mode 100644
index 000000000000..b0149d4b95f1
--- /dev/null
+++ b/dtrans/source/generic/clipboardmanager.cxx
@@ -0,0 +1,300 @@
+/*************************************************************************
+ *
+ * $RCSfile: clipboardmanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <clipboardmanager.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+using namespace com::sun::star::container;
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::clipboard;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+using namespace std;
+
+
+// ------------------------------------------------------------------------
+
+OClipboardManager::OClipboardManager():
+ m_aMutex(),
+ WeakComponentImplHelper3< XClipboardManager, XEventListener, XServiceInfo > (m_aMutex),
+ m_defaultName(OUString::createFromAscii("default"))
+{
+}
+
+// ------------------------------------------------------------------------
+
+OClipboardManager::~OClipboardManager()
+{
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL OClipboardManager::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(CLIPBOARDMANAGER_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OClipboardManager::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Sequence < OUString > SupportedServicesNames = ClipboardManager_getSupportedServiceNames();
+
+ for ( sal_Int32 n = 0, nmax = SupportedServicesNames.getLength(); n < nmax; n++ )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL OClipboardManager::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return ClipboardManager_getSupportedServiceNames();
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XClipboard > SAL_CALL OClipboardManager::getClipboard( const OUString& aName )
+ throw(NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ // object is disposed already
+ if (rBHelper.bDisposed)
+ throw DisposedException(OUString::createFromAscii("object is disposed."),
+ static_cast < XClipboardManager * > (this));
+
+ ClipboardMap::iterator iter =
+ m_aClipboardMap.find(aName.getLength() ? aName : m_defaultName);
+
+ if (iter != m_aClipboardMap.end())
+ return iter->second;
+
+ throw NoSuchElementException(aName, static_cast < XClipboardManager * > (this));
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboardManager::addClipboard( const Reference< XClipboard >& xClipboard )
+ throw(IllegalArgumentException, ElementExistException, RuntimeException)
+{
+ OSL_ASSERT(xClipboard.is());
+
+ // check parameter
+ if (!xClipboard.is())
+ throw IllegalArgumentException(OUString::createFromAscii("empty reference"),
+ static_cast < XClipboardManager * > (this), 1);
+
+ // the name "default" is reserved for internal use
+ OUString aName = xClipboard->getName();
+ if (m_defaultName.compareTo(aName) == 0)
+ throw IllegalArgumentException(OUString::createFromAscii("name reserved"),
+ static_cast < XClipboardManager * > (this), 1);
+
+ // try to add new clipboard to the list
+ ClearableMutexGuard aGuard(m_aMutex);
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+ {
+ pair< const OUString, Reference< XClipboard > > value (
+ aName.getLength() ? aName : m_defaultName,
+ xClipboard );
+
+ pair< ClipboardMap::iterator, bool > p = m_aClipboardMap.insert(value);
+ aGuard.clear();
+
+ // insert failed, element must exist already
+ if (!p.second)
+ throw ElementExistException(aName, static_cast < XClipboardManager * > (this));
+
+ // request disposing notifications
+ Reference< XComponent > xComponent(xClipboard, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(static_cast < XEventListener * > (this));
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboardManager::removeClipboard( const OUString& aName )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if (!rBHelper.bDisposed)
+ m_aClipboardMap.erase(aName.getLength() ? aName : m_defaultName );
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL OClipboardManager::listClipboardNames()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if (rBHelper.bDisposed)
+ throw DisposedException(OUString::createFromAscii("object is disposed."),
+ static_cast < XClipboardManager * > (this));
+
+ if (rBHelper.bInDispose)
+ return Sequence< OUString > ();
+
+ Sequence< OUString > aRet(m_aClipboardMap.size());
+ ClipboardMap::iterator iter = m_aClipboardMap.begin();
+ ClipboardMap::iterator imax = m_aClipboardMap.end();
+
+ for (sal_Int32 n = 0; iter != imax; iter++)
+ aRet[n++] = iter->first;
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboardManager::dispose()
+ throw(RuntimeException)
+{
+ ClearableMutexGuard aGuard( rBHelper.rMutex );
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+ {
+ rBHelper.bInDispose = sal_True;
+ aGuard.clear();
+
+ // give everyone a chance to save his clipboard instance
+ EventObject aEvt(static_cast < XClipboardManager * > (this));
+ rBHelper.aLC.disposeAndClear( aEvt );
+
+ // removeClipboard is still allowed here, so make a copy of the
+ // list (to ensure integrety) and clear the original.
+ ClearableMutexGuard aGuard2( rBHelper.rMutex );
+ ClipboardMap aCopy(m_aClipboardMap);
+ m_aClipboardMap.clear();
+ aGuard2.clear();
+
+ // dispose all clipboards still in list
+ ClipboardMap::iterator iter = aCopy.begin();
+ ClipboardMap::iterator imax = aCopy.end();
+
+ for (; iter != imax; iter++)
+ {
+ Reference< XComponent > xComponent(iter->second, UNO_QUERY);
+ if (xComponent.is())
+ {
+ try
+ {
+ xComponent->removeEventListener(static_cast < XEventListener * > (this));
+ xComponent->dispose();
+ }
+
+ catch(Exception e)
+ {
+ // exceptions can be safely ignored here.
+ }
+ }
+ }
+
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboardManager::disposing( const EventObject& event )
+ throw(RuntimeException)
+{
+ Reference < XClipboard > xClipboard(event.Source, UNO_QUERY);
+
+ if (xClipboard.is())
+ removeClipboard(xClipboard->getName());
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL ClipboardManager_createInstance(
+ const Reference< XMultiServiceFactory > & xMultiServiceFactory)
+{
+ return Reference < XInterface >( ( OWeakObject * ) new OClipboardManager());
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ClipboardManager_getSupportedServiceNames()
+{
+ Sequence < OUString > SupportedServicesNames( 1 );
+ SupportedServicesNames[0] =
+ OUString::createFromAscii("com.sun.star.datatransfer.clipboard.ClipboardManager");
+ return SupportedServicesNames;
+}
+
+
+
+
+
diff --git a/dtrans/source/generic/clipboardmanager.hxx b/dtrans/source/generic/clipboardmanager.hxx
new file mode 100644
index 000000000000..da8a95db26cc
--- /dev/null
+++ b/dtrans/source/generic/clipboardmanager.hxx
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * $RCSfile: clipboardmanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_CLIPBOARDMANAGER_HXX_
+#define _DTRANS_CLIPBOARDMANAGER_HXX_
+
+#ifndef _CPPUHELPER_COMPBASE3_HXX_
+#include <cppuhelper/compbase3.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDMANAGER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardManager.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#include <stl/map>
+
+// ------------------------------------------------------------------------
+
+#define CLIPBOARDMANAGER_IMPLEMENTATION_NAME "com.sun.star.comp.datatransfer.ClipboardManager"
+
+// ------------------------------------------------------------------------
+
+typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > > ClipboardMap;
+
+// ------------------------------------------------------------------------
+
+class OClipboardManager : public ::cppu::WeakComponentImplHelper3 < \
+::com::sun::star::datatransfer::clipboard::XClipboardManager, \
+::com::sun::star::lang::XEventListener, \
+::com::sun::star::lang::XServiceInfo >
+{
+ ClipboardMap m_aClipboardMap;
+ ::osl::Mutex m_aMutex;
+
+ const ::rtl::OUString m_defaultName;
+
+ virtual ~OClipboardManager();
+
+public:
+
+ OClipboardManager();
+
+ /*
+ * XServiceInfo
+ */
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XComponent
+ */
+
+ virtual void SAL_CALL dispose()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XEventListener
+ */
+
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XClipboardManager
+ */
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const ::rtl::OUString& aName )
+ throw(::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL addClipboard( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& xClipboard )
+ throw(::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::ElementExistException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removeClipboard( const ::rtl::OUString& aName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL listClipboardNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+
+};
+
+// ------------------------------------------------------------------------
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClipboardManager_getSupportedServiceNames();
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClipboardManager_createInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dtrans/source/generic/dtrans.cxx b/dtrans/source/generic/dtrans.cxx
new file mode 100644
index 000000000000..1219f993ac74
--- /dev/null
+++ b/dtrans/source/generic/dtrans.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * $RCSfile: dtrans.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:36:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <cppuhelper/factory.hxx>
+#include <clipboardmanager.hxx>
+#include <generic_clipboard.hxx>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace rtl;
+
+extern "C"
+{
+
+//==================================================================================================
+
+void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,
+ uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//==================================================================================================
+
+sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii("/" CLIPBOARDMANAGER_IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL = ClipboardManager_getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii("/" GENERIC_CLIPBOARD_IMPLEMENTATION_NAME "/UNO/SERVICES" ) );
+
+ const Sequence< OUString > & rSNL2 = GenericClipboard_getSupportedServiceNames();
+ pArray = rSNL2.getConstArray();
+ for ( nPos = rSNL2.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return sal_False;
+}
+
+//==================================================================================================
+
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName,
+ void * pServiceManager,
+ void * pRegistryKey
+)
+{
+ void * pRet = 0;
+
+ if (pServiceManager)
+ {
+ Reference< XSingleServiceFactory > xFactory;
+
+ if (rtl_str_compare( pImplName, CLIPBOARDMANAGER_IMPLEMENTATION_NAME ) == 0)
+ {
+ xFactory = createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ ClipboardManager_createInstance,
+ ClipboardManager_getSupportedServiceNames() );
+ }
+ else if (rtl_str_compare( pImplName, GENERIC_CLIPBOARD_IMPLEMENTATION_NAME ) == 0)
+ {
+ xFactory = createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ GenericClipboard_createInstance,
+ GenericClipboard_getSupportedServiceNames() );
+ }
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+}
diff --git a/dtrans/source/generic/dtrans.xml b/dtrans/source/generic/dtrans.xml
new file mode 100644
index 000000000000..b42b29fdf992
--- /dev/null
+++ b/dtrans/source/generic/dtrans.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Oliver Braun </Author>
+
+<Name> com.sun.star.comp.datatransfer.generic </Name>
+
+<Description>
+ This component covers
+ the generic part of data transfer concept.
+</Description>
+
+<ModuleName> dtrans </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="experimental"/>
+
+<SupportedService> com.sun.star.datatransfer.clipboard.ClipboardManager </SupportedService>
+<SupportedService> com.sun.star.datatransfer.clipboard.GenericClipboard </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+<Type> com.sun.star.datatransfer.clipboard.RenderingCapabilities </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardEx </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardManager </Type>
+<Type> com.sun.star.datatransfer.clipboard.XClipboardNotifier </Type>
+<Type> com.sun.star.datatransfer.XTransferableEx </Type>
+<Type> com.sun.star.datatransfer.XTransferableSource </Type>
+<Type> com.sun.star.io.XOutputStream </Type>
+<Type> com.sun.star.lang.DisposedException </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/dtrans/source/generic/exports.dxp b/dtrans/source/generic/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/dtrans/source/generic/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/dtrans/source/generic/exports.map b/dtrans/source/generic/exports.map
new file mode 100644
index 000000000000..28449cc0f4a8
--- /dev/null
+++ b/dtrans/source/generic/exports.map
@@ -0,0 +1,9 @@
+DTRANS_1_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ local:
+ *;
+};
+
diff --git a/dtrans/source/generic/generic_clipboard.cxx b/dtrans/source/generic/generic_clipboard.cxx
new file mode 100644
index 000000000000..dd8e2fb2c970
--- /dev/null
+++ b/dtrans/source/generic/generic_clipboard.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * $RCSfile: generic_clipboard.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <generic_clipboard.hxx>
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_RENDERINGCAPABILITIES_HPP_
+#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
+#endif
+
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::clipboard;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+OClipboard::OClipboard() :
+ m_aMutex(),
+ WeakComponentImplHelper4< XClipboardEx, XClipboardNotifier, XServiceInfo, XInitialization > (m_aMutex),
+ m_bInitialized(sal_False)
+{
+}
+
+// ------------------------------------------------------------------------
+
+OClipboard::OClipboard(const ::rtl::OUString& rName) :
+ m_aMutex(),
+ WeakComponentImplHelper4< XClipboardEx, XClipboardNotifier, XServiceInfo, XInitialization > (m_aMutex),
+ m_aName(rName),
+ m_bInitialized(sal_True)
+{
+}
+
+// ------------------------------------------------------------------------
+
+OClipboard::~OClipboard()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboard::initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException)
+{
+ if (!m_bInitialized)
+ {
+ for (sal_Int32 n = 0, nmax = aArguments.getLength(); n < nmax; n++)
+ if (aArguments[n].getValueType() == getCppuType((OUString *) 0))
+ {
+ aArguments[0] >>= m_aName;
+ break;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL OClipboard::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(GENERIC_CLIPBOARD_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OClipboard::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Sequence < OUString > SupportedServicesNames = GenericClipboard_getSupportedServiceNames();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL OClipboard::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return GenericClipboard_getSupportedServiceNames();
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XTransferable > SAL_CALL OClipboard::getContents()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_aContents;
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboard::setContents(const Reference< XTransferable >& xTrans,
+ const Reference< XClipboardOwner >& xClipboardOwner )
+ throw(RuntimeException)
+{
+ // remember old values for callbacks before setting the new ones.
+ ClearableMutexGuard aGuard(m_aMutex);
+
+ Reference< XClipboardOwner > oldOwner(m_aOwner);
+ m_aOwner = xClipboardOwner;
+
+ Reference< XTransferable > oldContents(m_aContents);
+ m_aContents = xTrans;
+
+ aGuard.clear();
+
+ // notify old owner on loss of ownership
+ if( oldOwner.is() )
+ oldOwner->lostOwnership(static_cast < XClipboard * > (this), oldContents);
+
+ // notify all listeners on content changes
+ OInterfaceContainerHelper *pContainer =
+ rBHelper.aLC.getContainer(getCppuType( (Reference < XClipboardListener > *) 0));
+ if (pContainer)
+ {
+ ClipboardEvent aEvent(static_cast < XClipboard * > (this), m_aContents);
+ OInterfaceIteratorHelper aIterator(*pContainer);
+
+ while (aIterator.hasMoreElements())
+ {
+ Reference < XClipboardListener > xListener(aIterator.next(), UNO_QUERY);
+ if (xListener.is())
+ xListener->changedContents(aEvent);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL OClipboard::getName()
+ throw(RuntimeException)
+{
+ return m_aName;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OClipboard::getRenderingCapabilities()
+ throw(RuntimeException)
+{
+ return RenderingCapabilities::Delayed;
+}
+
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not add listeners in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed)
+ rBHelper.aLC.addInterface( getCppuType( (const ::com::sun::star::uno::Reference< XClipboardListener > *) 0), listener );
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL OClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed)
+ rBHelper.aLC.removeInterface( getCppuType( (const Reference< XClipboardListener > *) 0 ), listener ); \
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL GenericClipboard_getSupportedServiceNames()
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.GenericClipboard");
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL GenericClipboard_createInstance(
+ const Reference< XMultiServiceFactory > & xMultiServiceFactory)
+{
+ return Reference < XInterface >( ( OWeakObject * ) new OClipboard());
+}
diff --git a/dtrans/source/generic/generic_clipboard.hxx b/dtrans/source/generic/generic_clipboard.hxx
new file mode 100644
index 000000000000..6e56f305ddf4
--- /dev/null
+++ b/dtrans/source/generic/generic_clipboard.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * $RCSfile: generic_clipboard.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_GENERIC_CLIPBOARD_HXX_
+#define _DTRANS_GENERIC_CLIPBOARD_HXX_
+
+#ifndef _CPPUHELPER_COMPBASE4_HXX_
+#include <cppuhelper/compbase4.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDEX_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBAORD_XCLIPBOARDNOTIFIER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+
+// ------------------------------------------------------------------------
+
+#define GENERIC_CLIPBOARD_IMPLEMENTATION_NAME "com.sun.star.comp.datatransfer.GenericClipboard"
+
+// ------------------------------------------------------------------------
+
+class OClipboard : public ::cppu::WeakComponentImplHelper4 < \
+::com::sun::star::datatransfer::clipboard::XClipboardEx, \
+::com::sun::star::datatransfer::clipboard::XClipboardNotifier, \
+::com::sun::star::lang::XServiceInfo, \
+::com::sun::star::lang::XInitialization >
+{
+ ::osl::Mutex m_aMutex;
+ ::rtl::OUString m_aName;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > m_aContents;
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
+
+ sal_Bool m_bInitialized;
+ virtual ~OClipboard();
+
+public:
+
+ OClipboard(const ::rtl::OUString& rName);
+ OClipboard();
+
+ /*
+ * XInitialization
+ */
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XServiceInfo
+ */
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XClipboard
+ */
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setContents(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getName()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XClipboardEx
+ */
+
+ virtual sal_Int8 SAL_CALL getRenderingCapabilities()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ /*
+ * XClipboardNotifier
+ */
+
+ virtual void SAL_CALL addClipboardListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removeClipboardListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+};
+
+// ------------------------------------------------------------------------
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GenericClipboard_getSupportedServiceNames();
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GenericClipboard_createInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory);
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dtrans/source/generic/makefile.mk b/dtrans/source/generic/makefile.mk
new file mode 100644
index 000000000000..8eed03e45515
--- /dev/null
+++ b/dtrans/source/generic/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:37:00 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=dtrans
+TARGET=generic
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+COMP1TYPELIST=dtrans
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/generic_clipboard.obj \
+ $(SLO)$/clipboardmanager.obj \
+ $(SLO)$/dtrans.obj
+
+
+SHL1TARGET= dtrans
+SHL1VERSIONMAP= exports.map
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1OBJS= $(SLOFILES)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/dtrans/source/test/makefile.mk b/dtrans/source/test/makefile.mk
new file mode 100644
index 000000000000..eaf87f41084c
--- /dev/null
+++ b/dtrans/source/test/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:37:02 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME= dtrans
+TARGET= test_dtrans
+
+LIBTARGET=NO
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+.INCLUDE : ..$/cppumaker.mk
+
+# --- Files --------------------------------------------------------
+
+APP1TARGET= $(TARGET)
+APP1OBJS= \
+ $(OBJ)$/test_dtrans.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+
diff --git a/dtrans/source/test/test_dtrans.cxx b/dtrans/source/test/test_dtrans.cxx
new file mode 100644
index 000000000000..4393c7ba19b0
--- /dev/null
+++ b/dtrans/source/test/test_dtrans.cxx
@@ -0,0 +1,575 @@
+/*************************************************************************
+ *
+ * $RCSfile: test_dtrans.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:02 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+//------------------------------------------------------------------------
+// interface includes
+//------------------------------------------------------------------------
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDMANAGER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardManager.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDOWNER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDNOTIFIER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+
+//------------------------------------------------------------------------
+// other includes
+//------------------------------------------------------------------------
+
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+//#include <stl/memory>
+
+//#include <process.h>
+
+//------------------------------------------------------------------------
+// my defines
+//------------------------------------------------------------------------
+
+#ifdef UNX
+#define PATH_SEPERATOR '/'
+#else
+#define PATH_SEPERATOR '\\'
+#endif
+
+#define ENSURE( a, b ) if( !a ) { fprintf( stderr, b "\n" ); exit( -1 ); }
+#define TEST( a, b ) fprintf( stderr, "Testing " a ); fprintf( stderr, b ? "passed\n" : "FAILED\n" )
+#define PERFORM( a, b ) fprintf( stderr, "Performing " a); b; fprintf( stderr, "done\n" )
+#define TRACE( a ) fprintf( stderr, a )
+
+//------------------------------------------------------------------------
+// namespaces
+//------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+//------------------------------------------------------------------------
+// globals
+//------------------------------------------------------------------------
+
+const char * app = NULL;
+
+//------------------------------------------------------------------------
+// ClipboardOwner
+//------------------------------------------------------------------------
+
+class ClipboardOwner : public WeakImplHelper1< XClipboardOwner >
+{
+ Reference< XClipboard > m_xClipboard;
+ Reference< XTransferable > m_xTransferable;
+
+ sal_uInt32 m_nReceivedLostOwnerships;
+
+public:
+ ClipboardOwner();
+
+ //--------------------------------------------------------------------
+ // XClipboardOwner
+ //--------------------------------------------------------------------
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+ sal_uInt32 receivedLostOwnerships() { return m_nReceivedLostOwnerships; };
+ Reference< XClipboard > lostOwnershipClipboardValue() { return m_xClipboard; }
+ Reference< XTransferable > lostOwnershipTransferableValue() { return m_xTransferable; };
+};
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+ClipboardOwner::ClipboardOwner():
+ m_nReceivedLostOwnerships( 0 )
+{
+}
+
+//------------------------------------------------------------------------
+// lostOwnership
+//------------------------------------------------------------------------
+
+void SAL_CALL ClipboardOwner::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+ m_nReceivedLostOwnerships++;
+ m_xClipboard = xClipboard;
+ m_xTransferable = xTrans;
+}
+
+//------------------------------------------------------------------------
+// ClipboardListener
+//------------------------------------------------------------------------
+
+class ClipboardListener : public WeakImplHelper1< XClipboardListener >
+{
+ Reference< XClipboard > m_xClipboard;
+ Reference< XTransferable > m_xTransferable;
+
+ sal_uInt32 m_nReceivedChangedContentsEvents;
+
+public:
+ ClipboardListener();
+
+ //--------------------------------------------------------------------
+ // XClipboardOwner
+ //--------------------------------------------------------------------
+
+ virtual void SAL_CALL changedContents( const ClipboardEvent& event ) throw(RuntimeException);
+
+ //--------------------------------------------------------------------
+ // XEventListener
+ //--------------------------------------------------------------------
+
+ virtual void SAL_CALL disposing( const EventObject& event ) throw(RuntimeException);
+
+ sal_uInt32 receivedChangedContentsEvents() { return m_nReceivedChangedContentsEvents; };
+ Reference< XClipboard > changedContentsEventClipboardValue() { return m_xClipboard; }
+ Reference< XTransferable > changedContentsEventTransferableValue() { return m_xTransferable; };
+};
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+ClipboardListener::ClipboardListener():
+ m_nReceivedChangedContentsEvents( 0 )
+{
+}
+
+//------------------------------------------------------------------------
+// changedContents
+//------------------------------------------------------------------------
+
+void SAL_CALL ClipboardListener::changedContents( const ClipboardEvent& event )
+ throw(RuntimeException)
+{
+ m_nReceivedChangedContentsEvents++;
+ m_xClipboard = Reference< XClipboard > (event.Source, UNO_QUERY);
+ m_xTransferable = event.Contents;
+}
+
+//------------------------------------------------------------------------
+// disposing
+//------------------------------------------------------------------------
+
+void SAL_CALL ClipboardListener::disposing( const EventObject& event )
+ throw(RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------
+// StringTransferable
+//------------------------------------------------------------------------
+
+class StringTransferable : public WeakImplHelper2< XClipboardOwner, XTransferable >
+{
+public:
+ StringTransferable( );
+
+ //--------------------------------------------------------------------
+ // XTransferable
+ //--------------------------------------------------------------------
+
+ virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException);
+ virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
+
+ //--------------------------------------------------------------------
+ // XClipboardOwner
+ //--------------------------------------------------------------------
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+ sal_Bool receivedLostOwnership() { return m_receivedLostOwnership; };
+ void clearReceivedLostOwnership() { m_receivedLostOwnership = sal_False; };
+
+private:
+ Sequence< DataFlavor > m_seqDFlv;
+ OUString m_Data;
+ sal_Bool m_receivedLostOwnership;
+};
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+StringTransferable::StringTransferable( ) :
+ m_seqDFlv( 1 ),
+ m_receivedLostOwnership( sal_False ),
+ m_Data( OUString::createFromAscii("clipboard test content") )
+{
+ DataFlavor df;
+
+ /*
+ df.MimeType = L"text/plain; charset=unicode";
+ df.DataType = getCppuType( ( OUString* )0 );
+
+ m_seqDFlv[0] = df;
+ */
+
+ //df.MimeType = L"text/plain; charset=windows1252";
+ df.MimeType = OUString::createFromAscii( "text/html" );
+ df.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 );
+
+ m_seqDFlv[0] = df;
+}
+
+//------------------------------------------------------------------------
+// getTransferData
+//------------------------------------------------------------------------
+
+Any SAL_CALL StringTransferable::getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any anyData;
+
+ /*if ( aFlavor == m_seqDFlv[0] )
+ {
+ anyData = makeAny( m_Data );
+ } */
+#if 0
+ else if ( aFlavor == m_seqDFlv[0] )
+ {
+ OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
+ Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
+ sal_Int32 lenStr = aStr.getLength( );
+
+ for ( sal_Int32 i = 0; i < lenStr; ++i )
+ sOfChars[i] = aStr[i];
+
+ anyData = makeAny( sOfChars );
+ }
+#endif
+
+ return anyData;
+}
+
+//------------------------------------------------------------------------
+// getTransferDataFlavors
+//------------------------------------------------------------------------
+
+Sequence< DataFlavor > SAL_CALL StringTransferable::getTransferDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_seqDFlv;
+}
+
+//------------------------------------------------------------------------
+// isDataFlavorSupported
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ sal_Int32 nLength = m_seqDFlv.getLength( );
+ sal_Bool bRet = sal_False;
+
+// for ( sal_Int32 i = 0; i < nLength; ++i )
+// {
+// if ( m_seqDFlv[i] == aFlavor )
+// {
+// bRet = sal_True;
+// break;
+// }
+// }
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+// lostOwnership
+//------------------------------------------------------------------------
+
+void SAL_CALL StringTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+ m_receivedLostOwnership = sal_True;
+}
+
+//------------------------------------------------------------------------
+// main
+//------------------------------------------------------------------------
+
+int SAL_CALL main( int argc, const char* argv[] )
+{
+ OUString aRegistry;
+
+ //------------------------------------------------------------------
+ // check command line parameters
+ //------------------------------------------------------------------
+
+ if ( NULL == ( app = strrchr( argv[0], PATH_SEPERATOR ) ) )
+ app = argv[0];
+ else
+ app++;
+
+ for( int n = 1; n < argc; n++ )
+ {
+ if( strncmp( argv[n], "-r", 2 ) == 0 )
+ {
+ if( strlen( argv[n] ) > 2 )
+ aRegistry = OUString::createFromAscii( argv[n] + 2 );
+ else if ( n + 1 < argc )
+ aRegistry = OUString::createFromAscii( argv[++n] );
+ }
+ }
+
+ if( aRegistry.getLength() == 0 )
+ fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", app );
+
+ //------------------------------------------------------------------
+ // create service manager
+ //------------------------------------------------------------------
+ Reference< XMultiServiceFactory > xServiceManager;
+
+ try
+ {
+ xServiceManager = createRegistryServiceFactory( aRegistry, sal_True );
+ ENSURE( xServiceManager.is(), "*** ERROR *** service manager could not be created." );
+
+ //--------------------------------------------------------------
+ // create an instance of GenericClipboard service
+ //--------------------------------------------------------------
+
+ Sequence< Any > arguments(1);
+ arguments[0] = makeAny( OUString::createFromAscii( "generic" ) );
+
+ Reference< XClipboard > xClipboard( xServiceManager->createInstanceWithArguments(
+ OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboard" ),
+ arguments ), UNO_QUERY );
+
+ ENSURE( xClipboard.is(), "*** ERROR *** generic clipboard service could not be created." );
+
+ Reference< XClipboardNotifier > xClipboardNotifier( xClipboard, UNO_QUERY );
+ Reference< XClipboardListener > xClipboardListener = new ClipboardListener();
+ ClipboardListener * pListener = (ClipboardListener *) xClipboardListener.get();
+
+ if( xClipboardNotifier.is() )
+ xClipboardNotifier->addClipboardListener( xClipboardListener );
+
+ //--------------------------------------------------------------
+ // run various tests on clipboard implementation
+ //--------------------------------------------------------------
+
+ TRACE( "\n*** testing generic clipboard service ***\n" );
+
+ Reference< XTransferable > xContents = new StringTransferable();
+ Reference< XClipboardOwner > xOwner = new ClipboardOwner();
+ ClipboardOwner *pOwner = (ClipboardOwner *) xOwner.get();
+
+ TEST( "initial contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ PERFORM( "update on contents with clipboard owner: ", xClipboard->setContents( xContents, xOwner ) );
+ TEST( "current clipboard contents: ", xContents == xClipboard->getContents() );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 0 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 1 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventTransferableValue() == xContents );
+ }
+
+ PERFORM( "update on contents without data (clear): ", xClipboard->setContents( Reference< XTransferable >(), Reference< XClipboardOwner >() ) );
+ TEST( "if received lostOwnership message(s): ", pOwner->receivedLostOwnerships() > 0 );
+ TEST( "if received exactly 1 lostOwnership message: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "if received lostOwnership message for the correct clipboard: ", pOwner->lostOwnershipClipboardValue() == xClipboard );
+ TEST( "if received lostOwnership message for the correct transferable: ", pOwner->lostOwnershipTransferableValue() == xContents );
+ TEST( "current clipboard contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 1 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 2 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", ! pListener->changedContentsEventTransferableValue().is() );
+ }
+
+ PERFORM( "update on contents without clipboard owner: ", xClipboard->setContents( xContents, Reference< XClipboardOwner >() ) );
+ TEST( "that no further lostOwnership messages were received: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "current clipboard contents: ", xContents == xClipboard->getContents() );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 2 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 3 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", pListener->changedContentsEventTransferableValue() == xContents );
+ }
+
+
+ PERFORM( "update on contents without data (clear): ", xClipboard->setContents( Reference< XTransferable >(), Reference< XClipboardOwner >() ) );
+ TEST( "that no further lostOwnership messages were received: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "current clipboard contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 3 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 4 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", ! pListener->changedContentsEventTransferableValue().is() );
+ }
+
+ //--------------------------------------------------------------
+ // create an instance of ClipboardManager service
+ //--------------------------------------------------------------
+
+ Reference< XClipboardManager > xClipboardManager( xServiceManager->createInstance(
+ OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.ClipboardManager" ) ), UNO_QUERY );
+
+ ENSURE( xClipboardManager.is(), "*** ERROR *** clipboard manager service could not be created." );
+
+ //--------------------------------------------------------------
+ // run various tests on clipboard manager implementation
+ //--------------------------------------------------------------
+
+ TRACE( "\n*** testing clipboard manager service ***\n" );
+
+ TEST( "initial number of clipboards (0): ", xClipboardManager->listClipboardNames().getLength() == 0 );
+ PERFORM( "insertion of generic clipboard: ", xClipboardManager->addClipboard( xClipboard ) );
+ TEST( "number of inserted clipboards (1): ", xClipboardManager->listClipboardNames().getLength() == 1 );
+ TEST( "name of inserted clipboard (generic): ", xClipboardManager->listClipboardNames()[0] == OUString::createFromAscii( "generic" ) );
+ TEST( "inserted clipboard instance: ", xClipboardManager->getClipboard( OUString::createFromAscii( "generic" ) ) == xClipboard );
+ PERFORM( "removal of generic clipboard: ", xClipboardManager->removeClipboard( OUString::createFromAscii( "generic" ) ) );
+ TEST( "number of inserted clipboards (0): ", xClipboardManager->listClipboardNames().getLength() == 0 );
+ TRACE( "Testing inserted clipboard instance (none): " );
+ try
+ {
+ xClipboardManager->getClipboard( OUString::createFromAscii( "generic" ) );
+ TRACE( "FAILED\n" );
+ }
+ catch( NoSuchElementException e )
+ {
+ TRACE( "passed\n" );
+ }
+ }
+
+ catch ( Exception aException )
+ {
+ ENSURE( sal_False, "*** ERROR *** exception caught." );
+ }
+
+ //--------------------------------------------------------------------
+ // shutdown the service manager
+ //--------------------------------------------------------------------
+
+ // query XComponent interface
+ Reference< XComponent > xComponent( xServiceManager, UNO_QUERY );
+
+ ENSURE( xComponent.is(), "*** ERROR *** service manager does not support XComponent." );
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ xServiceManager.clear();
+
+ fprintf( stderr, "Done.\n" );
+ return 0;
+}
+
+
diff --git a/dtrans/source/win32/dnd/dnd.xml b/dtrans/source/win32/dnd/dnd.xml
new file mode 100644
index 000000000000..7bab1af4a290
--- /dev/null
+++ b/dtrans/source/win32/dnd/dnd.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Joachim Lingner </Author>
+
+<Name> com.sun.star.comp.datatransfer.dnd.OleDragAndDrop_V1 </Name>
+
+<Description>
+ The win32 implementation of the drop target service.
+</Description>
+
+<ModuleName> dnd </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="experimental"/>
+
+<SupportedService> com.sun.star.datatransfer.dnd.OleDragAndDrop</SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+<Type> com.sun.star.datatransfer.dnd.DNDConstants </Type>
+<Type> com.sun.star.datatransfer.dnd.XDropTarget </Type>
+<Type> com.sun.star.datatransfer.dnd.XDropTargetDragContext </Type>
+<Type> com.sun.star.datatransfer.dnd.XDropTargetListener </Type>
+<Type> com.sun.star.datatransfer.dnd.XDropTargetDropContext </Type>
+<Type> com.sun.star.datatransfer.dnd.XDragSourceContext </Type>
+<Type> com.sun.star.datatransfer.dnd.XDragSource </Type>
+<Type> com.sun.star.datatransfer.dnd.XDropTargetFactory </Type>
+<Type> com.sun.star.datatransfer.XTransferable </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XUnoTunnel </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/dtrans/source/win32/dnd/dndentry.cxx b/dtrans/source/win32/dnd/dndentry.cxx
new file mode 100644
index 000000000000..dccc1f001ad3
--- /dev/null
+++ b/dtrans/source/win32/dnd/dndentry.cxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: dndentry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+//______________________________________________________________________________________________________________
+// includes of other projects
+//______________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_
+#include <com/sun/star/container/XSet.hpp>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include "source.hxx"
+//-----------------------------------------------------------------
+// some defines
+//-----------------------------------------------------------------
+
+
+
+//-----------------------------------------------------------------------------------------------------------
+// namespace directives
+//-----------------------------------------------------------------------------------------------------------
+
+using namespace ::rtl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::registry ;
+using namespace ::cppu ;
+using namespace ::com::sun::star::lang;
+//using namespace ::com::sun::star::datatransfer::clipboard;
+
+//-----------------------------------------------------------------
+// create a static object to initialize the shell9x library
+//-----------------------------------------------------------------
+
+
+//-----------------------------------------------------------------------------------------------------------
+// functions to create a new Clipboad instance; is needed by factory helper implementation
+// @param rServiceManager - service manager, useful if the component needs other uno services
+// so we should give it to every UNO-Implementation component
+//-----------------------------------------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
+{
+ DragSource* pSource= new DragSource( rServiceManager );
+ return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
+}
+
+
+//-----------------------------------------------------------------------------------------------------------
+// the 3 important functions which will be exported
+//-----------------------------------------------------------------------------------------------------------
+
+extern "C"
+{
+
+//----------------------------------------------------------------------
+// component_getImplementationEnvironment
+//----------------------------------------------------------------------
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//-------------------------------------------------------------------------
+// component_writeInfo - to register a UNO-Service
+// to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
+// to view the registry use: regview *.rdb /SERVICES/ServiceName
+// (you must use the full services name e.g. com.sun.star.frame.FilePicker
+//-------------------------------------------------------------------------
+
+sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
+{
+ sal_Bool bRetVal = sal_False;
+
+ if ( pRegistryKey )
+ {
+ try
+ {
+ Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
+ pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_REGKEY_NAME ) ) );
+ bRetVal = sal_True;
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSHURE(sal_False, "InvalidRegistryException caught");
+ bRetVal = sal_False;
+ }
+ }
+
+ return bRetVal;
+}
+
+//----------------------------------------------------------------------
+// component_getFactory
+// returns a factory to create XFilePicker-Services
+//----------------------------------------------------------------------
+
+void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey )
+{
+ void* pRet = 0;
+
+ if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
+ {
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_SERVICE_NAME ) );
+
+// Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
+// reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
+// OUString::createFromAscii( pImplName ),
+// createDragSource,
+// aSNS ) );
+ Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
+ OUString::createFromAscii( pImplName ),
+ createDragSource,
+ aSNS));
+
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
diff --git a/dtrans/source/win32/dnd/globals.cxx b/dtrans/source/win32/dnd/globals.cxx
new file mode 100644
index 000000000000..12af71a6382d
--- /dev/null
+++ b/dtrans/source/win32/dnd/globals.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * $RCSfile: globals.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_DNDCONSTANTS_HPP_
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#endif
+
+#include "globals.hxx"
+
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+
+sal_Int8 dndOleKeysToAction( DWORD grfKeyState)
+{
+ sal_Int8 ret= 0;
+
+ // no MK_ALT, MK_CONTROL, MK_SHIFT
+ if( !(grfKeyState & MK_CONTROL) &&
+ !(grfKeyState & MK_ALT) &&
+ !(grfKeyState & MK_RBUTTON) )
+ {
+ ret= ACTION_MOVE;
+ }
+ else if ( grfKeyState & MK_CONTROL &&
+ !(grfKeyState & MK_SHIFT) )
+ {
+ ret= ACTION_COPY;
+ }
+ else if ( grfKeyState & MK_CONTROL &&
+ grfKeyState & MK_SHIFT)
+ {
+ ret= ACTION_LINK;
+ }
+ else if ( grfKeyState & MK_RBUTTON |
+ grfKeyState & MK_ALT)
+ {
+ ret= ACTION_COPY_OR_MOVE | ACTION_LINK;
+ }
+ return ret;
+}
+
+
+sal_Int8 dndOleDropEffectsToActions( DWORD dwEffect)
+{
+ sal_Int8 ret= ACTION_NONE;
+ if( dwEffect & DROPEFFECT_COPY)
+ ret |= ACTION_COPY;
+ if( dwEffect & DROPEFFECT_MOVE)
+ ret |= ACTION_MOVE;
+ if( dwEffect & DROPEFFECT_LINK)
+ ret |= ACTION_LINK;
+
+ return ret;
+}
+
+DWORD dndActionsToDropEffects( sal_Int8 actions)
+{
+ DWORD ret= DROPEFFECT_NONE;
+ if( actions & ACTION_MOVE)
+ ret |= DROPEFFECT_MOVE;
+ if( actions & ACTION_COPY)
+ ret |= DROPEFFECT_COPY;
+ if( actions & ACTION_LINK)
+ ret |= DROPEFFECT_LINK;
+ return ret;
+}
+
+DWORD dndActionsToSingleDropEffect( sal_Int8 actions)
+{
+ DWORD effects= dndActionsToDropEffects( actions);
+
+ sal_Int8 countEffect= 0;
+
+ if( effects & DROPEFFECT_MOVE)
+ countEffect++;
+ if( effects & DROPEFFECT_COPY)
+ countEffect++;
+ if( effects & DROPEFFECT_LINK)
+ countEffect++;
+
+ // DROPEFFECT_MOVE is the default effect
+ DWORD retVal= countEffect > 1 ? DROPEFFECT_MOVE : effects;
+ return retVal;
+}
diff --git a/dtrans/source/win32/dnd/globals.hxx b/dtrans/source/win32/dnd/globals.hxx
new file mode 100644
index 000000000000..daf7a1ab3573
--- /dev/null
+++ b/dtrans/source/win32/dnd/globals.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: globals.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _GLOBALS_HXX_
+#define _GLOBALS_HXX_
+
+#include <wtypes.h>
+#include <sal/types.h>
+
+// This maps key states as occur as parameter, e.g. in IDropTarget::DragEnter,
+// IDropSource::QueryContinueDrag, to actions as are declared in
+// com::sun::star::datatransfer::dnd::DNDConstants ( ACTION_MOVE etc).
+// If the grfKeyState indicates the ALt or right mousebutton then the returned
+// values combines all possible actions. This is because those key and button are
+// used when the user expect a menu to appear when he drops. The menu then
+// contains entries, such as move, copy, link, cancel.
+// An odd fact is that the argument grfKeyState in IDropTarget::Drop does not
+// contain mouse buttons (winnt 4 SP6). That indicates that the right mouse button
+// is not considered relevant in a drag operation. Contrarily the file explorer
+// gives that button a special meaning: the user has to select the effect from
+// a context menu on drop.
+sal_Int8 dndOleKeysToAction( DWORD grfKeyState);
+
+// The function maps a windows DROPEFFECTs to actions
+// ( com::sun::star::datatransfer::dnd::DNDConstants).
+// The argument can be a combination of different DROPEFFECTS,
+// In that case the return value is also a combination of the
+// appropriate actions.
+sal_Int8 dndOleDropEffectsToActions( DWORD dwEffect);
+
+// The function maps actions ( com::sun::star::datatransfer::dnd::DNDConstants)
+// to window DROPEFFECTs.
+// The argument can be a combination of different actions
+// In that case the return value is also a combination of the
+// appropriate DROPEFFECTS.
+DWORD dndActionsToDropEffects( sal_Int8 actions);
+
+// If the argument constitutes only one action then it is mapped to the
+// corresponding DROPEFFECT otherwise DROPEFFECT_MOVE is returned. This is
+// why move is the default effect (no modifiers pressed, or right mouse button
+// or Alt).
+DWORD dndActionsToSingleDropEffect( sal_Int8 actions);
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/makefile.mk b/dtrans/source/win32/dnd/makefile.mk
new file mode 100644
index 000000000000..b2e3cef7aadc
--- /dev/null
+++ b/dtrans/source/win32/dnd/makefile.mk
@@ -0,0 +1,140 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:37:17 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=dtrans
+TARGET=dnd
+# sysdtrans
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+COMP1TYPELIST=$(TARGET)
+COMPRDB=$(SOLARBINDIR)$/applicat.rdb
+USE_BOUNDCHK=
+
+.IF "$(USE_BOUNDCHK)"=="TR"
+bndchk=tr
+stoponerror=tr
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/..$/cppumaker.mk
+
+CFLAGS+=/GR -DUNICODE -D_UNICODE
+
+SLOFILES= $(OBJ)$/dndentry.obj \
+ $(OBJ)$/target.obj \
+ $(OBJ)$/source.obj \
+ $(OBJ)$/globals.obj \
+ $(OBJ)$/targetdropcontext.obj \
+ $(OBJ)$/targetdragcontext.obj \
+ $(OBJ)$/sourcecontext.obj \
+ $(SLO)$/DataObjectWrapper.obj \
+ $(OBJ)$/ImplHelper.obj \
+ $(OBJ)$/DTransHelper.obj \
+ $(OBJ)$/TransferableWrapper.obj \
+ $(OBJ)$/TxtConvertHelper.obj
+
+
+# DataObjectWrapper.obj, ImplHelper.obj, DTransHelper.obj, TransferableWrapper.obj have to be removed when Transferables are available as service
+
+
+#$(SLO)$/mimehlp.obj
+
+SHL1TARGET=$(TARGET)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ ole32.lib\
+ comsupp.lib\
+ oleaut32.lib
+
+SHL1DEPN=
+SHL1IMPLIB=i$(SHL1TARGET)
+
+#--- comment -----------------
+# for src614
+
+SHL1LIBS= \
+ $(SOLARLIBDIR)$/imtaolecb.lib\
+ $(SOLARLIBDIR)$/user9x.lib\
+ $(SOLARLIBDIR)$/tools32.lib \
+ $(LB)$/dtutils.lib
+
+#dtutils.lib is build in source/misc
+
+SHL1OBJS= $(SLOFILES)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/dtrans/source/win32/dnd/source.cxx b/dtrans/source/win32/dnd/source.cxx
new file mode 100644
index 000000000000..32c038bf972a
--- /dev/null
+++ b/dtrans/source/win32/dnd/source.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * $RCSfile: source.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:17 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_DNDCONSTANTS_HPP_
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#include "source.hxx"
+#include "target.hxx"
+#include "globals.hxx"
+#include "sourcecontext.hxx"
+#include "TransferableWrapper.hxx"
+#include <rtl/ustring.h>
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+using namespace com::sun::star::uno;
+
+DragSource::DragSource( const Reference<XMultiServiceFactory>& sf):
+ m_serviceFactory( sf),
+ WeakComponentImplHelper3<XInitialization,XDragSource,XDropTargetFactory>(m_mutex)
+{
+}
+
+DragSource::~DragSource()
+{
+}
+
+ // XInitialization
+
+// aArguments contains a machine id
+void SAL_CALL DragSource::initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException)
+{
+}
+
+// XDragSource
+sal_Bool SAL_CALL DragSource::isDragImageSupported( )
+ throw(RuntimeException)
+{
+ return 0;
+}
+
+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,
+ sal_Int32 image,
+ const Reference<XTransferable >& trans,
+ const Reference<XDragSourceListener >& listener )
+ throw( InvalidDNDOperationException, RuntimeException)
+{
+ m_sourceListener= listener;
+ m_sourceActions= sourceActions;
+
+ DWORD effect=0;
+ HRESULT hr;
+ hr= DoDragDrop(
+ static_cast<IDataObject*>( new CXTDataObject( trans)),
+ static_cast<IDropSource*>( this),
+ dndActionsToDropEffects( sourceActions),
+ &effect);
+
+ DragSourceDropEvent e;
+ if( hr == DRAGDROP_S_DROP)
+ {
+ e.DropAction= dndOleDropEffectsToActions( effect);
+ e.DropSuccess= sal_True;
+ }
+ else
+ {
+ e.DropAction= ACTION_NONE;
+ e.DropSuccess= sal_False;
+ }
+ e.DragSourceContext= static_cast<XDragSourceContext*>( new SourceContext(
+ static_cast<DragSource*>(this) ) );
+ m_sourceListener->dragDropEnd( e);
+
+}
+
+#ifdef DEBUG
+void SAL_CALL DragSource::release()
+{
+ if( m_refCount == 1)
+ {
+ int a = m_refCount;
+ }
+ WeakComponentImplHelper3<XInitialization,XDragSource,XDropTargetFactory>::release();
+
+}
+#endif
+
+// XDropTargetFactory -------------------------------------------------------------------
+
+Reference<XDropTarget > SAL_CALL DragSource::createDropTarget( const Sequence< sal_Int8 >& windowId )
+ throw( RuntimeException)
+{
+ Sequence<sal_Int8>& seqWin= const_cast<Sequence<sal_Int8> & >( windowId);
+ HWND h= *(HWND*) (const HWND*)seqWin.getConstArray();
+ DropTarget* pTarget= new DropTarget(m_serviceFactory, h);
+ return Reference<XDropTarget>(static_cast<XDropTarget*>( pTarget), UNO_QUERY);
+}
+
+
+//IDropTarget ---------------------------------------------------------------------------
+HRESULT STDMETHODCALLTYPE DragSource::QueryInterface( REFIID riid, void **ppvObject)
+{
+ if( !ppvObject)
+ return E_POINTER;
+ *ppvObject= NULL;
+
+ if( IsEqualGUID( riid, __uuidof( IUnknown)))
+ *ppvObject= static_cast<IUnknown*>( this);
+ else if ( IsEqualGUID( riid, __uuidof( IDropSource)))
+ *ppvObject= static_cast<IDropSource*>( this);
+
+ if(*ppvObject)
+ {
+ AddRef();
+ return S_OK;
+ }
+ else
+ return E_NOINTERFACE;
+
+}
+
+ULONG STDMETHODCALLTYPE DragSource::AddRef( void)
+{
+ acquire();
+ return (ULONG) m_refCount;
+}
+
+ULONG STDMETHODCALLTYPE DragSource::Release( void)
+{
+ release();
+ return (ULONG) m_refCount;
+}
+
+// IDropSource
+HRESULT STDMETHODCALLTYPE DragSource::QueryContinueDrag(
+/* [in] */ BOOL fEscapePressed,
+/* [in] */ DWORD grfKeyState)
+{
+ HRESULT retVal= S_OK; // default continue DnD
+
+ if (fEscapePressed)
+ {
+ retVal= DRAGDROP_S_CANCEL;
+ }
+ else
+ {
+ if (!(grfKeyState & MK_LBUTTON))
+ {
+// DragSourceDropEvent e;
+// e.DropAction= dndOleKeysToAction(grfKeyState);
+// e.DropSuccess= sal_True;
+// e.DragSourceContext= static_cast<XDragSourceContext*>( new SourceContext(
+// static_cast<DragSource*>(this) ) );
+//
+// m_sourceListener->dragDropEnd( e);
+
+ retVal= DRAGDROP_S_DROP;
+ }
+ }
+ return retVal;
+}
+
+HRESULT STDMETHODCALLTYPE DragSource::GiveFeedback(
+/* [in] */ DWORD dwEffect)
+{
+ return DRAGDROP_S_USEDEFAULTCURSORS;
+} \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/source.hxx b/dtrans/source/win32/dnd/source.hxx
new file mode 100644
index 000000000000..55ebf6e95fc8
--- /dev/null
+++ b/dtrans/source/win32/dnd/source.hxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * $RCSfile: source.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:17 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SOURCE_HXX_
+#define _SOURCE_HXX_
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGSOURCE_HPP_
+#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETFACTORY_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _OSL_MUTEX_H_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE3_HXX_
+#include <cppuhelper/compbase3.hxx>
+#endif
+
+
+
+#include <wtypes.h>
+#include <oleidl.h>
+// the service names
+#define DNDTARGET_SERVICE_NAME "com.sun.star.datatransfer.dnd.OleDragAndDrop"
+
+// the implementation names
+#define DNDTARGET_IMPL_NAME "com.sun.star.comp.datatransfer.dnd.OleDragAndDrop_V1"
+
+// the registry key names
+// a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
+// < Implementation-Name ></UNO/SERVICES/>< Service-Name
+// TargetW32 >
+#define DNDTARGET_REGKEY_NAME "/com.sun.star.comp.datatransfer.dnd.OleDragAndDrop_V1/UNO/SERVICES/com.sun.star.datatransfer.dnd.OleDragAndDrop"
+
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+
+struct MutexDummy
+{
+ Mutex m_mutex;
+};
+
+
+// RIGHT MOUSE BUTTON drag and drop not supportet currently.
+// ALT modifier is considered to effect a user selection of effects
+class DragSource:
+ public MutexDummy,
+ public WeakComponentImplHelper3<XInitialization, XDragSource,
+ XDropTargetFactory>,
+ public IDropSource
+
+{
+ Reference<XMultiServiceFactory> m_serviceFactory;
+ Reference<XDragSourceListener > m_sourceListener;
+ sal_Int8 m_sourceActions;
+
+
+
+ DragSourcet();
+ DragSource(const DragSource&);
+ DragSource &operator= ( const DragSource&);
+
+public:
+ DragSource(const Reference<XMultiServiceFactory>& sf);
+ virtual ~DragSource();
+
+#ifdef DEBUG
+ virtual void SAL_CALL release();
+#endif
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException);
+
+ // XDragSource
+ virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction )
+ throw( IllegalArgumentException, RuntimeException);
+ virtual void SAL_CALL startDrag( const DragGestureEvent& trigger,
+ sal_Int8 sourceActions,
+ sal_Int32 cursor,
+ sal_Int32 image,
+ const Reference<XTransferable >& trans,
+ const Reference<XDragSourceListener >& listener )
+ throw( InvalidDNDOperationException, RuntimeException);
+
+ // XDropTargetFactory
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( );
+
+ virtual ULONG STDMETHODCALLTYPE Release( );
+
+ virtual Reference<XDropTarget > SAL_CALL createDropTarget( const Sequence< sal_Int8 >& windowId )
+ throw( RuntimeException);
+
+ // IDropSource
+ virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
+ /* [in] */ BOOL fEscapePressed,
+ /* [in] */ DWORD grfKeyState);
+
+ virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
+ /* [in] */ DWORD dwEffect);
+
+};
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/sourcecontext.cxx b/dtrans/source/win32/dnd/sourcecontext.cxx
new file mode 100644
index 000000000000..92831ab7d24d
--- /dev/null
+++ b/dtrans/source/win32/dnd/sourcecontext.cxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * $RCSfile: sourcecontext.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+
+
+
+
+#include "sourcecontext.hxx"
+
+SourceContext::SourceContext( DragSource* pSource): m_pDragSource( pSource)
+{
+}
+
+SourceContext::~SourceContext()
+{
+}
+
+void SAL_CALL SourceContext::addDragSourceListener( const Reference<XDragSourceListener >& dsl )
+ throw( RuntimeException)
+{
+}
+
+void SAL_CALL SourceContext::removeDragSourceListener( const Reference<XDragSourceListener >& dsl )
+ throw( RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL SourceContext::getCurrentCursor( )
+ throw( RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL SourceContext::setCursor( sal_Int32 cursorId )
+ throw( IllegalArgumentException, RuntimeException)
+{
+}
+
+void SAL_CALL SourceContext::setImage( sal_Int32 imageId )
+ throw( IllegalArgumentException, RuntimeException)
+{
+}
+
+void SAL_CALL SourceContext::transferablesFlavorsChanged( )
+ throw( RuntimeException)
+{
+}
+
+
diff --git a/dtrans/source/win32/dnd/sourcecontext.hxx b/dtrans/source/win32/dnd/sourcecontext.hxx
new file mode 100644
index 000000000000..1c3124265256
--- /dev/null
+++ b/dtrans/source/win32/dnd/sourcecontext.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * $RCSfile: sourcecontext.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SOURCECONTEXT_HXX_
+#define _SOURCECONTEXT_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGSOURCECONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
+#endif
+
+#include "source.hxx"
+
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+class SourceContext: public WeakImplHelper1<XDragSourceContext>
+{
+ DragSource* m_pDragSource;
+
+
+ SourceContext();
+ SourceContext( const SourceContext&);
+ SourceContext &operator= (const SourceContext& );
+public:
+ SourceContext( DragSource* pSource);
+ ~SourceContext();
+
+ virtual void SAL_CALL addDragSourceListener( const Reference<XDragSourceListener >& dsl )
+ throw( RuntimeException);
+ virtual void SAL_CALL removeDragSourceListener( const Reference<XDragSourceListener >& dsl )
+ throw( RuntimeException);
+ virtual sal_Int32 SAL_CALL getCurrentCursor( )
+ throw( RuntimeException);
+ virtual void SAL_CALL setCursor( sal_Int32 cursorId )
+ throw( IllegalArgumentException, RuntimeException);
+ virtual void SAL_CALL setImage( sal_Int32 imageId )
+ throw( IllegalArgumentException, RuntimeException);
+ virtual void SAL_CALL transferablesFlavorsChanged( )
+ throw( RuntimeException);
+
+};
+
+
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/target.cxx b/dtrans/source/win32/dnd/target.cxx
new file mode 100644
index 000000000000..ba3b711f152f
--- /dev/null
+++ b/dtrans/source/win32/dnd/target.cxx
@@ -0,0 +1,571 @@
+/*************************************************************************
+ *
+ * $RCSfile: target.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_DNDCONSTANTS_HPP_
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#include "target.hxx"
+#include "globals.hxx"
+#include "targetdropcontext.hxx"
+#include "targetdragcontext.hxx"
+#include "DataObjectWrapper.hxx"
+//#include "windroptarget.hxx"
+#include <rtl/ustring.h>
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+
+DropTarget::DropTarget( const Reference<XMultiServiceFactory>& sf, HWND hwin):
+ m_hWnd( hwin),
+ m_serviceFactory( sf),
+ WeakComponentImplHelper1<XDropTarget>(m_mutex),
+ m_bDropTargetRegistered(sal_False),
+ m_nDefaultActions(ACTION_COPY|ACTION_MOVE|ACTION_LINK),
+ m_nListenerDropAction( ACTION_NONE),
+ m_currentEventId(0)
+{
+ OSL_ASSERT( IsWindow(m_hWnd));
+}
+
+DropTarget::~DropTarget()
+{
+
+}
+
+#ifdef DEBUG
+void SAL_CALL DropTarget::release()
+{
+ if( m_refCount == 1)
+ {
+ int a = m_refCount;
+ }
+ WeakComponentImplHelper1<XDropTarget>::release();
+
+}
+#endif
+
+void SAL_CALL DropTarget::disposing()
+{
+ if( m_bDropTargetRegistered)
+ {
+ RevokeDragDrop(m_hWnd);
+ CoLockObjectExternal( static_cast<IDropTarget*>(this), FALSE, TRUE);
+ }
+}
+
+// XInitialization
+//void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
+// throw(Exception, RuntimeException)
+//{
+//
+//
+// m_hWnd= *(HWND*)aArguments[0].getValue();
+// OSL_ASSERT( IsWindow(m_hWnd));
+//
+// if( ! IsWindow( m_hWnd))
+// throw Exception( OUString::createFromAscii("Initialization of DropTarget ")
+// + OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_SERVICE_NAME) )
+// + OUString::createFromAscii("service failed"),
+// Reference<XInterface>((XInitialization*)this, UNO_QUERY));
+//
+//}
+
+// XDropTarget
+void SAL_CALL DropTarget::addDropTargetListener( const Reference< XDropTargetListener >& dtl )
+ throw(RuntimeException)
+{
+ rBHelper.addListener( ::getCppuType( &dtl ), dtl );
+}
+
+void SAL_CALL DropTarget::removeDropTargetListener( const Reference< XDropTargetListener >& dtl )
+ throw(RuntimeException)
+{
+ rBHelper.addListener( ::getCppuType( &dtl ), dtl );
+}
+
+sal_Bool SAL_CALL DropTarget::isActive( ) throw(RuntimeException)
+{
+ return m_bDropTargetRegistered;
+}
+
+void SAL_CALL DropTarget::setActive( sal_Bool _b ) throw(RuntimeException)
+{
+ MutexGuard g(m_mutex);
+
+ if( _b == sal_True)
+ {
+ if( SUCCEEDED( CoLockObjectExternal( static_cast<IDropTarget*>(this), TRUE, FALSE)))
+ if( SUCCEEDED( RegisterDragDrop( m_hWnd, static_cast<IDropTarget*>(this))))
+ m_bDropTargetRegistered= sal_True;
+ else
+ CoLockObjectExternal( static_cast<IDropTarget*>(this), FALSE, FALSE);
+
+ OSL_ASSERT( m_bDropTargetRegistered);
+ }
+ else
+ {
+ if( m_bDropTargetRegistered)
+ {
+ HRESULT hr1= RevokeDragDrop(m_hWnd);
+ OSL_ASSERT(SUCCEEDED(hr1));
+ HRESULT hr2= CoLockObjectExternal( static_cast<IDropTarget*>(this), FALSE, FALSE);
+ OSL_ASSERT(SUCCEEDED(hr2));
+ m_bDropTargetRegistered= sal_False;
+ }
+ }
+}
+
+sal_Int8 SAL_CALL DropTarget::getDefaultActions( ) throw(RuntimeException)
+{
+ return m_nDefaultActions;
+}
+
+void SAL_CALL DropTarget::setDefaultActions( sal_Int8 actions ) throw(RuntimeException)
+{
+ OSL_ENSURE( actions < 8, "No valid default actions");
+ m_nDefaultActions= actions;
+}
+
+
+//IDropTarget
+HRESULT STDMETHODCALLTYPE DropTarget::QueryInterface( REFIID riid, void **ppvObject)
+{
+ if( !ppvObject)
+ return E_POINTER;
+ *ppvObject= NULL;
+
+ if( IsEqualGUID( riid, __uuidof( IUnknown)))
+ *ppvObject= static_cast<IUnknown*>( this);
+ else if ( IsEqualGUID( riid, __uuidof( IDropTarget)))
+ *ppvObject= static_cast<IDropTarget*>( this);
+
+ if(*ppvObject)
+ {
+ AddRef();
+ return S_OK;
+ }
+ else
+ return E_NOINTERFACE;
+
+}
+
+ULONG STDMETHODCALLTYPE DropTarget::AddRef( void)
+{
+ acquire();
+ return (ULONG) m_refCount;
+}
+
+ULONG STDMETHODCALLTYPE DropTarget::Release( void)
+{
+ release();
+ return (ULONG) m_refCount;
+}
+
+// Per default COPY is allowed as long as as listener does not object.
+STDMETHODIMP DropTarget::DragEnter( IDataObject __RPC_FAR *pDataObj,
+ DWORD grfKeyState,
+ POINTL pt,
+ DWORD *pdwEffect)
+{
+ // Dont consider the allowed source action at this point. Because if pdwEffect is COPY
+ // and grfKeyState is only MK_LBUTTON ( default is ACTION_MOVE ) than we give the listener the chance to change
+ // the action to COPY or something. Otherwise the source would display a NONE from the beginning.
+ m_nListenerDropAction= getFilteredActions( grfKeyState);
+ m_userAction= m_nListenerDropAction;
+ if( m_nListenerDropAction != ACTION_NONE)
+ {
+ DropTargetDragEvent e;
+ e.DropAction= m_nListenerDropAction;
+ e.Source= Reference<XInterface>( static_cast<XDropTarget*>(this),UNO_QUERY);
+ e.Context= static_cast<XDropTargetDragContext*>( new TargetDragContext( static_cast<DropTarget*>(this),
+ m_currentEventId ));
+ POINT point={ pt.x, pt.y};
+ ScreenToClient( m_hWnd, &point);
+ e.Location.X= point.x;
+ e.Location.Y= point.y;
+ e.SourceActions= dndOleDropEffectsToActions( *pdwEffect);
+
+ m_currentData= static_cast<XTransferable*>( new DNDTransferable( pDataObj) );
+
+ // The Event contains a XDropTargetDragContext Implementation. A listener is only allowd to call
+ // on it in the same thread and in event handler where it receives that event.
+ // m_currentEventId is used to verify the callback's validity.
+ fire_dragEnter( e);
+ m_currentEventId++;
+
+ // Check if the action derived from grfKeyState (m_nListenerDropAction) or the action set
+ // by the listener (m_nListenerDropAction) is allowed by the source. Only a allowed action is set
+ // in pdwEffect.
+ // If there is more then one valid action which is the case when ALT or RIGHT MOUSE BUTTON is pressed
+ // then getDropEffect returns DROPEFFECT_MOVE which is the default value if no other modifier is pressed.
+ // On drop the target should present the user a dialog from which the user may change the action.
+ sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect);
+ *pdwEffect= dndActionsToSingleDropEffect( m_nListenerDropAction & allowedActions);
+ }
+ else
+ {
+ *pdwEffect= DROPEFFECT_NONE;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP DropTarget::DragOver( DWORD grfKeyState,
+ POINTL pt,
+ DWORD *pdwEffect)
+{
+ // A listener can change this value during fire_dragOver
+ m_nListenerDropAction= getFilteredActions( grfKeyState);
+
+ if( m_nListenerDropAction)
+ {
+ DropTargetDragEvent e;
+ e.DropAction= m_nListenerDropAction;
+ e.Source= Reference<XInterface>(static_cast<XDropTarget*>(this),UNO_QUERY);
+ e.Context= static_cast<XDropTargetDragContext*>( new TargetDragContext( static_cast<DropTarget*>(this),
+ m_currentEventId));
+ POINT point={ pt.x, pt.y};
+ ScreenToClient( m_hWnd, &point);
+ e.Location.X= point.x;
+ e.Location.Y= point.y;
+ e.SourceActions= dndOleDropEffectsToActions( *pdwEffect);
+
+ // if grfKeyState has changed since the last DragOver then fire events.
+ // A listener might change m_nListenerDropAction by calling the
+ // XDropTargetDragContext::acceptDrag function. But this is not important
+ // because in the afterwards fired dragOver event the action reflects
+ // grgKeyState again.
+ sal_Int8 tmpAction= m_nListenerDropAction;
+ if( m_nListenerDropAction != m_userAction)
+ fire_dropActionChanged( e);
+ m_nListenerDropAction= tmpAction;
+
+ // The Event contains a XDropTargetDragContext Implementation. A listener is only allowd to call
+ // on it in the same thread and in event handler where it receives that envent.
+ // m_currentEventId is used to verify the callback's validity.
+ fire_dragOver( e);
+ m_currentEventId++;
+ // Check if the action derived from grfKeyState (m_nListenerDropAction) or the action set
+ // by the listener (m_nListenerDropAction) is allowed by the source. Only a allowed action is set
+ // in pdwEffect.
+ // If there is more then one valid action which is the case when ALT or RIGHT MOUSE BUTTON is pressed
+ // then getDropEffect returns DROPEFFECT_MOVE which is the default value if no other modifier is pressed.
+ // On drop the target should present the user a dialog from which the user may change the action.
+ sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect);
+ *pdwEffect= dndActionsToSingleDropEffect( m_nListenerDropAction & allowedActions);
+ }
+ else
+ {
+ *pdwEffect= DROPEFFECT_NONE;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP DropTarget::DragLeave( void)
+{
+ m_currentData=0;
+ if( m_nDefaultActions != ACTION_NONE)
+ {
+ DropTargetEvent e;
+ e.Source= static_cast<XDropTarget*>(this);
+
+ fire_dragExit( e);
+ }
+ return S_OK;
+}
+
+STDMETHODIMP DropTarget::Drop( IDataObject *pDataObj,
+ DWORD grfKeyState,
+ POINTL pt,
+ DWORD __RPC_FAR *pdwEffect)
+{
+ m_bDropComplete= sal_False;
+
+ m_nListenerDropAction= getFilteredActions( grfKeyState);
+
+ if( m_nListenerDropAction)
+ {
+ DropTargetDropEvent e;
+ e.DropAction= m_nListenerDropAction;
+ e.Source= Reference<XInterface>( static_cast<XDropTarget*>(this), UNO_QUERY);
+ e.Context= static_cast<XDropTargetDropContext*>( new TargetDropContext( static_cast<DropTarget*>(this ), m_currentEventId) );
+ POINT point={ pt.x, pt.y};
+ ScreenToClient( m_hWnd, &point);
+ e.Location.X= point.x;
+ e.Location.Y= point.y;
+ e.SourceActions= dndOleDropEffectsToActions( *pdwEffect);
+ e.Transferable= m_currentData;
+ fire_drop( e);
+ m_currentEventId++;
+
+ //if fire_drop returns than a listener might have modified m_nListenerDropAction
+ // XDropTargetDropContext::dropComplete or the other functions
+ if( m_bDropComplete == sal_True)
+ {
+ sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect);
+ *pdwEffect= dndActionsToSingleDropEffect( m_nListenerDropAction & allowedActions);
+ }
+ else
+ *pdwEffect= DROPEFFECT_NONE;
+ }
+ else
+ *pdwEffect= DROPEFFECT_NONE;
+
+ m_currentData= 0;
+ return S_OK;
+}
+
+
+
+void DropTarget::fire_drop( const DropTargetDropEvent& dte)
+{
+ OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (Reference<XDropTargetListener>* )0 ) );
+ if( pContainer)
+ {
+ OInterfaceIteratorHelper iter( *pContainer);
+ while( iter.hasMoreElements())
+ {
+ Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
+ listener->drop( dte);
+ }
+ }
+}
+
+void DropTarget::fire_dragEnter( const DropTargetDragEvent& dtde )
+{
+ OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (Reference<XDropTargetListener>* )0 ) );
+ if( pContainer)
+ {
+ OInterfaceIteratorHelper iter( *pContainer);
+ while( iter.hasMoreElements())
+ {
+ Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
+ listener->dragEnter( dtde);
+ }
+ }
+}
+
+void DropTarget::fire_dragExit( const DropTargetEvent& dte )
+{
+ OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (Reference<XDropTargetListener>* )0 ) );
+
+ if( pContainer)
+ {
+ OInterfaceIteratorHelper iter( *pContainer);
+ while( iter.hasMoreElements())
+ {
+ Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
+ listener->dragExit( dte);
+ }
+ }
+}
+
+void DropTarget::fire_dragOver( const DropTargetDragEvent& dtde )
+{
+ OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (Reference<XDropTargetListener>* )0 ) );
+ if( pContainer)
+ {
+ OInterfaceIteratorHelper iter( *pContainer );
+ while( iter.hasMoreElements())
+ {
+ Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
+ listener->dragOver( dtde);
+ }
+ }
+}
+
+void DropTarget::fire_dropActionChanged( const DropTargetDragEvent& dtde )
+{
+ OInterfaceContainerHelper* pContainer= rBHelper.getContainer( getCppuType( (Reference<XDropTargetListener>* )0 ) );
+ if( pContainer)
+ {
+ OInterfaceIteratorHelper iter( *pContainer);
+ while( iter.hasMoreElements())
+ {
+ Reference<XDropTargetListener> listener( static_cast<XDropTargetListener*>( iter.next()));
+ listener->dropActionChanged( dtde);
+ }
+ }
+}
+
+// Non - interface functions ============================================================
+// DropTarget fires events to XDropTargetListeners. The event object contains an
+// XDropTargetDropContext implementaion. When the listener calls on that interface
+// then the calls are delegated from DropContext (XDropTargetDropContext) to these
+// functions.
+// Only one listener which visible area is affected is allowed to call on
+// XDropTargetDropContext
+// Returning sal_False would cause the XDropTargetDropContext or ..DragContext implementation
+// to throw an InvalidDNDOperationException, meaning that a Drag is not currently performed.
+// return sal_False results in throwing a InvalidDNDOperationException in the caller.
+
+void DropTarget::_acceptDrop(sal_Int8 dropOperation, sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ if( m_currentEventId == id)
+ {
+ m_nListenerDropAction= dropOperation;
+ }
+ else
+ throw InvalidDNDOperationException();
+}
+
+void DropTarget::_rejectDrop(sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ if( m_currentEventId == id)
+ {
+ m_nListenerDropAction= ACTION_NONE;
+ }
+ else
+ throw InvalidDNDOperationException();
+}
+
+void DropTarget::_dropComplete(sal_Bool success, sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ if( m_currentEventId == id)
+ {
+ m_bDropComplete= success;
+ }
+ else
+ throw InvalidDNDOperationException();
+}
+// --------------------------------------------------------------------------------------
+// DropTarget fires events to XDropTargetListeners. The event object can contains an
+// XDropTargetDagContext implementaion. When the listener calls on that interface
+// then the calls are delegated from DragContext (XDropTargetDragContext) to these
+// functions.
+// Only one listener which visible area is affected is allowed to call on
+// XDropTargetDragContext
+void DropTarget::_acceptDrag( sal_Int8 dragOperation, sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ if( m_currentEventId == id)
+ {
+ m_nListenerDropAction= dragOperation;
+ }
+ else
+ throw InvalidDNDOperationException();
+}
+
+void DropTarget::_rejectDrag( sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ if( m_currentEventId == id)
+ {
+ m_nListenerDropAction= ACTION_NONE;
+ }
+ else
+ throw InvalidDNDOperationException();
+}
+
+Sequence<DataFlavor> DropTarget::_getCurrentDataFlavors( sal_uInt32 id)
+ throw( InvalidDNDOperationException)
+{
+ Sequence<DataFlavor> retVal;
+ if( m_currentEventId == id)
+ {
+ if( m_currentData.is())
+ retVal= m_currentData->getTransferDataFlavors();
+ }
+ else
+ throw InvalidDNDOperationException();
+ return retVal;
+}
+
+sal_Bool DropTarget::_isDataFlavorSupported( const DataFlavor& df, sal_uInt32 id)
+ throw(InvalidDNDOperationException)
+{
+ sal_Bool ret= sal_False;
+ if( m_currentEventId == id)
+ {
+ if( m_currentData.is())
+ ret= m_currentData->isDataFlavorSupported( df);
+ }
+ else
+ throw InvalidDNDOperationException();
+ return ret;
+}
+//--------------------------------------------------------------------------------------
+
+
+// This function determines the action dependend on the pressed
+// key modifiers ( CTRL, SHIFT, ALT, Right Mouse Button). The result
+// is then checked against the allowed actions which can be set through
+// XDropTarget::setDefaultActions. Only those values which are also
+// default actions are returned. If setDefaultActions has not been called
+// beforehand the the default actions comprise all possible actions.
+// params: grfKeyState - the modifier keys and mouse buttons currently pressed
+inline sal_Int8 DropTarget::getFilteredActions( DWORD grfKeyState)
+{
+// sal_Int8 actions= getDropAction( grfKeyState);
+ sal_Int8 actions= dndOleKeysToAction( grfKeyState);
+ return actions & m_nDefaultActions;
+}
+
+
diff --git a/dtrans/source/win32/dnd/target.hxx b/dtrans/source/win32/dnd/target.hxx
new file mode 100644
index 000000000000..af2e28c10876
--- /dev/null
+++ b/dtrans/source/win32/dnd/target.hxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: target.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TARGET_HXX_
+#define _TARGET_HXX_
+
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGET_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _OSL_MUTEX_H_
+#include <osl/mutex.hxx>
+#endif
+
+#include <wtypes.h>
+#include <oleidl.h>
+#include "source.hxx"
+// the service names
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+
+
+
+//struct MutexDummy
+//{
+// Mutex m_mutex;
+//};
+
+
+// DropTarget is a singleton, that is one cannot count on its destructor
+// do do the cleanup because the factory will hold a reference. The client
+// has to call XComponent::dispose before the HWND becomes invalid.
+class DropTarget: public MutexDummy,
+ public WeakComponentImplHelper1< XDropTarget>,
+ public IDropTarget
+{
+private:
+ HWND m_hWnd; // set by initialize
+ IDataObject* m_pData;
+ Reference<XMultiServiceFactory> m_serviceFactory;
+ sal_Bool m_bDropTargetRegistered;
+ sal_Int8 m_nDefaultActions;
+
+ // This value is set when a XDropTargetListener calls acceptDrop or rejectDrop on
+ // the XDropTargetDropContext or acceptDrag or rejectDrag on XDropTargetDragContext.
+ // The values are from the DNDConstants group.
+ sal_Int8 m_nListenerDropAction;
+ Reference<XTransferable> m_currentData;
+ // The current action is used to determine if the USER
+ // action has changed (dropActionChanged)
+ sal_Int8 m_userAction;
+ // Set by listeners when they call XDropTargetDropContext::dropComplete
+ sal_Bool m_bDropComplete;
+
+ // Used to find out wheter the listeners callbacks through the Context interfaces
+ // contained in the event objects are valid.
+ sal_uInt32 m_currentEventId;
+
+
+private:
+ DropTarget();
+ DropTarget(DropTarget&);
+ DropTarget &operator= (DropTarget&);
+
+public:
+ DropTarget(const Reference<XMultiServiceFactory>& sf, HWND);
+ virtual ~DropTarget();
+
+#ifdef DEBUG
+ virtual void SAL_CALL release();
+#endif
+ // overriding WeakComponentImplHelper, called from XComponent::dispose
+ void SAL_CALL disposing();
+
+ // XInitialization
+// virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+// throw(Exception, RuntimeException);
+
+ // XDropTarget
+ virtual void SAL_CALL addDropTargetListener( const Reference< XDropTargetListener >& dtl )
+ throw(RuntimeException);
+ virtual void SAL_CALL removeDropTargetListener( const Reference< XDropTargetListener >& dtl )
+ throw(RuntimeException);
+ // Default is not active
+ virtual sal_Bool SAL_CALL isActive( ) throw(RuntimeException);
+ virtual void SAL_CALL setActive( sal_Bool isActive ) throw(RuntimeException);
+ virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(RuntimeException);
+ virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(RuntimeException);
+
+
+ // IDropTarget
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef( );
+
+ virtual ULONG STDMETHODCALLTYPE Release( );
+
+ virtual HRESULT STDMETHODCALLTYPE DragEnter(
+ /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+
+ virtual HRESULT STDMETHODCALLTYPE DragOver(
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+
+ virtual HRESULT STDMETHODCALLTYPE DragLeave( ) ;
+
+ virtual HRESULT STDMETHODCALLTYPE Drop(
+ /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+
+
+// Non - interface functions --------------------------------------------------
+// XDropTargetDropContext delegated from DropContext
+
+ // return false signifies the caller to throw a InvalidDNDOperationException
+ void _acceptDrop( sal_Int8 dropOperation, sal_uInt32 id)
+ throw (InvalidDNDOperationException);
+ // return false signifies the caller to throw a InvalidDNDOperationException
+ void _rejectDrop( sal_uInt32 id)
+ throw (InvalidDNDOperationException);
+ // return false signifies the caller to throw a InvalidDNDOperationException
+ void _dropComplete( sal_Bool success, sal_uInt32)
+ throw (InvalidDNDOperationException);
+
+// XDropTargetDragContext delegated from DragContext
+ // return false signifies the caller to throw a InvalidDNDOperationException
+ void _acceptDrag( sal_Int8 dragOperation, sal_uInt32)
+ throw (InvalidDNDOperationException);
+ // return false signifies the caller to throw a InvalidDNDOperationException
+ void _rejectDrag( sal_uInt32)throw (InvalidDNDOperationException);
+ Sequence<DataFlavor> _getCurrentDataFlavors( sal_uInt32 id)
+ throw (InvalidDNDOperationException);
+ sal_Bool _isDataFlavorSupported( const DataFlavor& df, sal_uInt32 id)
+ throw (InvalidDNDOperationException);
+
+
+protected:
+ // Gets the current action dependend on the pressed modifiers, the effects
+ // supported by the drop source (IDropSource) and the default actions of the
+ // drop target (XDropTarget, this class))
+ inline sal_Int8 getFilteredActions( DWORD grfKeyState, DWORD sourceActions);
+ // Only filters with the default actions
+ inline sal_Int8 getFilteredActions( DWORD grfKeyState);
+
+
+
+ void fire_drop( const DropTargetDropEvent& dte);
+ void fire_dragEnter( const DropTargetDragEvent& dtde );
+ void fire_dragExit( const DropTargetEvent& dte );
+ void fire_dragOver( const DropTargetDragEvent& dtde );
+ void fire_dropActionChanged( const DropTargetDragEvent& dtde );
+
+
+
+
+};
+
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/targetdragcontext.cxx b/dtrans/source/win32/dnd/targetdragcontext.cxx
new file mode 100644
index 000000000000..bcc137e25e1c
--- /dev/null
+++ b/dtrans/source/win32/dnd/targetdragcontext.cxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * $RCSfile: targetdragcontext.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "targetdragcontext.hxx"
+
+
+TargetDragContext::TargetDragContext( DropTarget* p, sal_uInt32 id): m_id( id)
+{
+ m_pDropTarget= p;
+ p->acquire();
+}
+
+TargetDragContext::~TargetDragContext()
+{
+ m_pDropTarget->release();
+}
+
+void SAL_CALL TargetDragContext::acceptDrag( sal_Int8 dragOperation )
+ throw(InvalidDNDOperationException, RuntimeException)
+{
+ m_pDropTarget->_acceptDrag( dragOperation, m_id);
+
+}
+void SAL_CALL TargetDragContext::rejectDrag( )
+ throw(InvalidDNDOperationException, RuntimeException)
+{
+ m_pDropTarget->_rejectDrag( m_id);
+}
+
+Sequence< DataFlavor > SAL_CALL TargetDragContext::getCurrentDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_pDropTarget->_getCurrentDataFlavors( m_id);
+}
+
+sal_Bool SAL_CALL TargetDragContext::isDataFlavorSupported( const DataFlavor& df )
+ throw(RuntimeException)
+{
+ return m_pDropTarget->_isDataFlavorSupported( df, m_id);
+}
diff --git a/dtrans/source/win32/dnd/targetdragcontext.hxx b/dtrans/source/win32/dnd/targetdragcontext.hxx
new file mode 100644
index 000000000000..4648689dd577
--- /dev/null
+++ b/dtrans/source/win32/dnd/targetdragcontext.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * $RCSfile: targetdragcontext.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _TARGETDRAGCONTEXT_HXX_
+#define _TARGETDRAGCONTEXT_HXX_
+
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETDRAGCONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DATAFLAVOR_HPP_
+#include <com/sun/star/datatransfer/DataFlavor.hpp>
+#endif
+
+#include "target.hxx"
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+class TargetDragContext: public WeakImplHelper1<XDropTargetDragContext>
+{
+ // some calls to the functions of XDropTargetDragContext are delegated
+ // to non-interface functions of m_pDropTarget
+ DropTarget* m_pDropTarget;
+ sal_uInt32 m_id;
+
+ TargetDragContext();
+ TargetDragContext( const TargetDragContext&);
+ TargetDragContext &operator= ( const TargetDragContext&);
+public:
+ TargetDragContext( DropTarget* pTarget, sal_uInt32 id);
+ ~TargetDragContext();
+
+ virtual void SAL_CALL acceptDrag( sal_Int8 dragOperation )
+ throw(InvalidDNDOperationException, RuntimeException);
+ virtual void SAL_CALL rejectDrag( )
+ throw(InvalidDNDOperationException, RuntimeException);
+ virtual Sequence< DataFlavor > SAL_CALL getCurrentDataFlavors( )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& df )
+ throw(RuntimeException);
+};
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dnd/targetdropcontext.cxx b/dtrans/source/win32/dnd/targetdropcontext.cxx
new file mode 100644
index 000000000000..4cbdc5aa96cd
--- /dev/null
+++ b/dtrans/source/win32/dnd/targetdropcontext.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * $RCSfile: targetdropcontext.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:19 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "targetdropcontext.hxx"
+
+TargetDropContext::TargetDropContext( DropTarget* p, sal_uInt32 id): m_id( id)
+{
+ m_pDropTarget= p;
+ p->acquire();
+}
+
+TargetDropContext::~TargetDropContext()
+{
+ m_pDropTarget->release();
+}
+
+void SAL_CALL TargetDropContext::acceptDrop( sal_Int8 dropOperation )
+ throw(InvalidDNDOperationException, RuntimeException)
+{
+ m_pDropTarget->_acceptDrop( dropOperation, m_id);
+}
+
+void SAL_CALL TargetDropContext::rejectDrop( )
+ throw(InvalidDNDOperationException, RuntimeException)
+{
+ m_pDropTarget->_rejectDrop( m_id);
+}
+
+void SAL_CALL TargetDropContext::dropComplete( sal_Bool success )
+ throw(InvalidDNDOperationException, RuntimeException)
+{
+ m_pDropTarget->_dropComplete( success, m_id);
+}
diff --git a/dtrans/source/win32/dnd/targetdropcontext.hxx b/dtrans/source/win32/dnd/targetdropcontext.hxx
new file mode 100644
index 000000000000..a79994d990de
--- /dev/null
+++ b/dtrans/source/win32/dnd/targetdropcontext.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: targetdropcontext.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:20 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _TARGETDROPCONTEXT_HXX_
+#define _TARGETDROPCONTEXT_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETDROPCONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp>
+#endif
+
+#include "target.hxx"
+
+using namespace ::com::sun::star::datatransfer::dnd;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+class TargetDropContext: public WeakImplHelper1<XDropTargetDropContext>
+{
+ // calls to the functions of XDropTargetDropContext are delegated
+ // to non-interface functions of m_pDropTarget
+ DropTarget* m_pDropTarget;
+ sal_uInt32 m_id;
+
+ TargetDropContext();
+ TargetDropContext( const TargetDropContext&);
+ TargetDropContext &operator= ( const TargetDropContext&);
+public:
+ TargetDropContext( DropTarget* pTarget, sal_uInt32 id);
+ ~TargetDropContext();
+
+ virtual void SAL_CALL acceptDrop( sal_Int8 dropOperation )
+ throw(InvalidDNDOperationException, RuntimeException);
+ virtual void SAL_CALL rejectDrop( )
+ throw(InvalidDNDOperationException, RuntimeException);
+ virtual void SAL_CALL dropComplete( sal_Bool success )
+ throw(InvalidDNDOperationException, RuntimeException);
+};
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/workbench/XTDo.cxx b/dtrans/source/win32/workbench/XTDo.cxx
new file mode 100644
index 000000000000..4ccc964827c2
--- /dev/null
+++ b/dtrans/source/win32/workbench/XTDo.cxx
@@ -0,0 +1,459 @@
+/*************************************************************************
+ *
+ * $RCSfile: XTDo.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include "..\DTransHelper.hxx"
+
+#ifndef _TWRAPPERDATAOBJECT_HXX_
+#include "XTDo.hxx"
+#endif
+
+#include <windows.h>
+#include <ole2.h>
+#include <stl/memory>
+#include <tchar.h>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+using namespace ::std;
+
+//============================================================================
+// OTWrapperDataObject
+//============================================================================
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+/*
+ in the constructor we enumerate all formats offered by the transferable
+ and convert the formats into formatetc structures
+ if the transferable supports text in different charsets we use either
+ the charset equal to the charset of the current thread or an arbitrary
+ charset supported by the transferable and the system
+ if the transferable supports only unicodetext we offer in addition to
+ this text in the charset of the current thread
+ in order to allow the consumer of the clipboard to query for the charset
+ of the text in the clipboard we offer a CF_LOCALE
+*/
+CXTDataObject::CXTDataObject( ) :
+ m_nRefCnt( 0 )
+{
+
+}
+
+//------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ OSL_ASSERT( NULL != ppvObject );
+
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ ( (LPUNKNOWN)*ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IUnknown->AddRef
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::AddRef( )
+{
+ return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
+}
+
+//------------------------------------------------------------------------
+// IUnknown->Release
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::Release( )
+{
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
+
+ if ( 0 == nRefCnt )
+ {
+ delete this;
+ }
+
+ return nRefCnt;
+}
+
+/*------------------------------------------------------------------------
+
+ IDataObject->GetData
+ we deliver data only into global memory
+
+ algo:
+ 1. convert the given formatect struct into a valid dataflavor
+ 2. if the transferable directly supports the requested format
+ 2.1. if text data requested add a trailing '\0' in order to prevent
+ problems (windows needs '\0' terminated strings
+ 2.2. we expect unicode data as Sequence< sal_Unicode > and all other
+ text and raw data as Sequence< sal_Int8 >
+
+------------------------------------------------------------------------*/
+
+STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
+{
+ if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+ char pBuff[] = "Test OleClipboard";
+
+ if ( CF_TEXT == pFormatetc->cfFormat )
+ {
+ CHGlobalHelper hGlobHlp( TRUE );
+
+ hGlobHlp.Write( pBuff, sizeof( pBuff ), NULL );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlobHlp.GetHGlobal( );
+ pmedium->pUnkForRelease = NULL;
+
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
+{
+ if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
+ return E_INVALIDARG;
+
+ *ppenumFormatetc = NULL;
+
+ HRESULT hr = E_FAIL;
+
+ if ( DATADIR_GET == dwDirection )
+ {
+ *ppenumFormatetc = new CEnumFormatEtc( this );
+ static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->QueryGetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetDataHere
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetCanonicalFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->SetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DUnadvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DUnadvise( DWORD )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumDAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// for our convenience
+//------------------------------------------------------------------------
+
+CXTDataObject::operator IDataObject*( )
+{
+ return static_cast< IDataObject* >( this );
+}
+
+
+//============================================================================
+// CEnumFormatEtc
+//============================================================================
+
+//----------------------------------------------------------------------------
+// ctor
+//----------------------------------------------------------------------------
+
+CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) :
+ m_nRefCnt( 0 ),
+ m_pUnkDataObj( pUnkDataObj ),
+ m_nCurrPos( 0 )
+{
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ static_cast< LPUNKNOWN >( *ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->AddRef
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( )
+{
+ // keep the dataobject alive
+ m_pUnkDataObj->AddRef( );
+ return InterlockedIncrement( &m_nRefCnt );
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->Release
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
+{
+ // release the outer dataobject
+ m_pUnkDataObj->Release( );
+
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt );
+ if ( 0 == nRefCnt )
+ delete this;
+
+ return nRefCnt;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Next
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched )
+{
+ if ( ( 0 != celt ) && ( NULL == rgelt ) )
+ return E_INVALIDARG;
+
+ ULONG ulFetched = 0;
+ ULONG ulToFetch = celt;
+ HRESULT hr = S_FALSE;
+
+ while( m_nCurrPos < 1 )
+ {
+ rgelt->cfFormat = CF_TEXT;
+ rgelt->ptd = NULL;
+ rgelt->dwAspect = DVASPECT_CONTENT;
+ rgelt->lindex = -1;
+ rgelt->tymed = TYMED_HGLOBAL;
+
+ ++m_nCurrPos;
+ ++rgelt;
+ --ulToFetch;
+ ++ulFetched;
+ }
+
+ if ( ulFetched == celt )
+ hr = S_OK;
+
+ if ( NULL != pceltFetched )
+ {
+ *pceltFetched = ulFetched;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Skip
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt )
+{
+ HRESULT hr = S_FALSE;
+
+ /*
+ if ( ( m_nCurrPos + celt ) < m_nClipFormats )
+ {
+ m_nCurrPos += celt;
+ hr = S_OK;
+ }
+ */
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Reset
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Reset( )
+{
+ m_nCurrPos = 0;
+ return S_OK;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Clone
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
+{
+ OSL_ASSERT( NULL != ppenum );
+
+ if ( NULL == ppenum )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ *ppenum = NULL;
+
+ CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj );
+ if ( NULL != pCEnumFEtc )
+ {
+ pCEnumFEtc->m_nCurrPos = m_nCurrPos;
+ *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
+ static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
+ hr = NOERROR;
+ }
+
+ return hr;
+}
diff --git a/dtrans/source/win32/workbench/XTDo.hxx b/dtrans/source/win32/workbench/XTDo.hxx
new file mode 100644
index 000000000000..f1b79875430d
--- /dev/null
+++ b/dtrans/source/win32/workbench/XTDo.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: XTDo.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _XTDATAOBJECT_HXX_
+#define _XTDATAOBJECT_HXX_
+
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#include <windows.h>
+#include <ole2.h>
+#include <objidl.h>
+
+#include <stl/vector>
+
+// forward declaration
+//class CWinClipbImpl;
+class EnumFormatEtc;
+
+/*--------------------------------------------------------------------------
+ - the function principle of the windows clipboard:
+ a data provider offers all formats he can deliver on the clipboard
+ a clipboard client ask for the available formats on the clipboard
+ and decides if there is a format he can use
+ if there is one, he requests the data in this format
+
+ - This class inherits from IDataObject an so can be placed on the
+ OleClipboard. The class wrapps a transferable object which is the
+ original DataSource
+ - DataFlavors offerd by this transferable will be translated into
+ appropriate clipboard formats
+ - if the transferable contains text data always text and unicodetext
+ will be offered or vice versa
+ - text data will be automaticaly converted between text und unicode text
+ - although the transferable may support text in different charsets
+ (codepages) only text in one codepage can be offered by the clipboard
+
+----------------------------------------------------------------------------*/
+
+class CXTDataObject : public IDataObject
+{
+public:
+ CXTDataObject( );
+
+ //-----------------------------------------------------------------
+ // ole interface implementation
+ //-----------------------------------------------------------------
+
+ //IUnknown interface methods
+ STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ // IDataObject interface methods
+ STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
+ STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
+ STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
+ STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
+ STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
+ STDMETHODIMP DUnadvise( DWORD dwConnection );
+ STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
+
+ operator IDataObject*( );
+
+private:
+
+private:
+ LONG m_nRefCnt;
+};
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+class CEnumFormatEtc : public IEnumFORMATETC
+{
+public:
+ CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
+
+ // IUnknown
+ STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject );
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IEnumFORMATETC
+ STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
+ STDMETHODIMP Skip( ULONG celt );
+ STDMETHODIMP Reset( );
+ STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
+
+private:
+ LONG m_nRefCnt;
+ LPUNKNOWN m_pUnkDataObj;
+ ULONG m_nCurrPos;
+};
+
+typedef CEnumFormatEtc *PCEnumFormatEtc;
+
+#endif \ No newline at end of file
diff --git a/dtrans/source/win32/workbench/makefile.mk b/dtrans/source/win32/workbench/makefile.mk
new file mode 100644
index 000000000000..93cb266c415f
--- /dev/null
+++ b/dtrans/source/win32/workbench/makefile.mk
@@ -0,0 +1,130 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: mh $ $Date: 2001-01-31 15:37:21 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (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.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME= dtrans
+TARGET= testwincb
+TARGET1= testmshl
+LIBTARGET= NO
+TARGETTYPE= CUI
+USE_BOUNDCHK=
+TESTCB=TRUE
+
+.IF "$(USE_BOUNDCHK)"=="TR"
+bndchk=tr
+stoponerror=tr
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.INCLUDE : settings.mk
+
+.IF "$(TESTCB)"=="TRUE"
+
+.INCLUDE : ..$/..$/cppumaker.mk
+
+CFLAGS+=/D_WIN32_DCOM /EHsc
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= $(OBJ)$/test_wincb.obj
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/test_wincb.obj\
+ $(OBJ)$/ImplHelper.obj
+
+APP1STDLIBS= $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ user32.lib \
+ ole32.lib
+
+APP1LIBS= $(LB)$/dtutils.lib\
+ $(SOLARLIBDIR)$/user9x.lib\
+ $(SOLARLIBDIR)$/tools32.lib
+
+APP1NOSAL= TRUE
+
+.ENDIF
+
+.IF "$(TESTCB)"==""
+
+OBJFILES= $(OBJ)$/testmarshal.obj
+APP1TARGET= $(TARGET1)
+APP1OBJS= $(OBJ)$/testmarshal.obj\
+ $(OBJ)$/XTDo.obj\
+ $(OBJ)$/DTransHelper.obj
+
+APP1STDLIBS= $(SALLIB)\
+ user32.lib\
+ ole32.lib
+
+APP1LIBS=
+
+APP1NOSAL= TRUE
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+#.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/dtrans/source/win32/workbench/test_wincb.cxx b/dtrans/source/win32/workbench/test_wincb.cxx
new file mode 100644
index 000000000000..ba6d3b340d02
--- /dev/null
+++ b/dtrans/source/win32/workbench/test_wincb.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * $RCSfile: test_wincb.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:22 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+//_________________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________________
+
+
+#include "..\ImplHelper.hxx"
+
+//_________________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________________
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDOWNER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDNOTIFIER_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include <stdio.h>
+#include <windows.h>
+#include <objbase.h>
+
+#include <stl/memory>
+
+#include <process.h>
+
+//-------------------------------------------------------------
+// my defines
+//-------------------------------------------------------------
+
+#define TEST_CLIPBOARD
+#define RDB_SYSPATH "d:\\projects\\src616\\dtrans\\wntmsci7\\bin\\applicat.rdb"
+#define WINCLIPBOARD_SERVICE_NAME L"com.sun.star.datatransfer.clipboard.SystemClipboard"
+#define WRITE_CB
+#define EVT_MANUAL_RESET TRUE
+#define EVT_INIT_NONSIGNALED FALSE
+#define EVT_NONAME ""
+
+//------------------------------------------------------------
+// namesapces
+//------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+//------------------------------------------------------------
+// globales
+//------------------------------------------------------------
+
+Reference< XTransferable > rXTransfRead;
+HANDLE g_hEvtThreadWakeup;
+
+//------------------------------------------------------------
+//
+//------------------------------------------------------------
+
+class CTransferable : public WeakImplHelper2< XClipboardOwner, XTransferable >
+{
+public:
+ CTransferable( );
+
+ //-------------------------------------------------
+ // XTransferable
+ //-------------------------------------------------
+
+ virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException);
+ virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
+
+ //-------------------------------------------------
+ // XClipboardOwner
+ //-------------------------------------------------
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+private:
+ Sequence< DataFlavor > m_seqDFlv;
+ OUString m_Data;
+};
+
+//----------------------------------------------------------------
+// ctor
+//----------------------------------------------------------------
+
+CTransferable::CTransferable( ) :
+ m_seqDFlv( 1 ),
+ m_Data( L"Ich habe mir ein neues Fahrrad gekauft!" )
+{
+ DataFlavor df;
+
+ /*
+ df.MimeType = L"text/plain; charset=unicode";
+ df.DataType = getCppuType( ( OUString* )0 );
+
+ m_seqDFlv[0] = df;
+ */
+
+ //df.MimeType = L"text/plain; charset=windows1252";
+ df.MimeType = L"text/html";
+ df.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 );
+
+ m_seqDFlv[0] = df;
+}
+
+//----------------------------------------------------------------
+// getTransferData
+//----------------------------------------------------------------
+
+Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any anyData;
+
+ /*if ( aFlavor == m_seqDFlv[0] )
+ {
+ anyData = makeAny( m_Data );
+ }
+ else*/ if ( aFlavor == m_seqDFlv[0] )
+ {
+ OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
+ Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
+ sal_Int32 lenStr = aStr.getLength( );
+
+ for ( sal_Int32 i = 0; i < lenStr; ++i )
+ sOfChars[i] = aStr[i];
+
+ anyData = makeAny( sOfChars );
+ }
+
+ return anyData;
+}
+
+//----------------------------------------------------------------
+// getTransferDataFlavors
+//----------------------------------------------------------------
+
+Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_seqDFlv;
+}
+
+//----------------------------------------------------------------
+// isDataFlavorSupported
+//----------------------------------------------------------------
+
+sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ sal_Int32 nLength = m_seqDFlv.getLength( );
+ sal_Bool bRet = sal_False;
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ if ( m_seqDFlv[i] == aFlavor )
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+//----------------------------------------------------------------
+// lostOwnership
+//----------------------------------------------------------------
+
+void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+}
+
+//################################################################
+// a thread in another apartment to test apartment transparency
+
+unsigned int _stdcall ThreadProc(LPVOID pParam)
+{
+ // setup another apartment
+ HRESULT hr = CoInitialize( NULL );
+ //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+
+ WaitForSingleObject( g_hEvtThreadWakeup, INFINITE );
+
+ Sequence< DataFlavor > flavorList = rXTransfRead->getTransferDataFlavors( );
+ sal_Int32 nFlavors = flavorList.getLength( );
+ OUString mimeType;
+ OUString hpName;
+ for ( sal_Int32 i = 0; i < nFlavors; ++i )
+ {
+ mimeType = flavorList[i].MimeType;
+ hpName = flavorList[i].HumanPresentableName;
+ }
+
+ /*
+ try
+ {
+ DataFlavor flv;
+ flv.MimeType = L"text/html";
+ flv.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 );
+
+ rXTransfRead->getTransferData( flv );
+ }
+ catch( UnsupportedFlavorException& ex )
+ {
+ OSL_ENSURE( false, "### DataFlavor not supported" );
+ }
+ */
+
+ CoUninitialize( );
+
+ return 0;
+}
+
+//################################################################
+
+//----------------------------------------------------------------
+// main
+//----------------------------------------------------------------
+
+int SAL_CALL main( int nArgc, char* Argv[] )
+{
+ // create a multi-threaded apartment; we can test only
+ // with a multithreaded apartment because for a single
+ // threaded apartment we need a message loop to deliver
+ // messages to our XTDataObject
+ //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+ HRESULT hr = CoInitialize( NULL );
+
+
+#ifndef WRITE_CB
+
+ g_hEvtThreadWakeup = CreateEvent( 0,
+ EVT_MANUAL_RESET,
+ EVT_INIT_NONSIGNALED,
+ EVT_NONAME );
+
+ unsigned uThreadId;
+ HANDLE hThread;
+
+ // create a thread in another apartment
+ hThread = (void*)_beginthreadex( NULL, 0, ThreadProc, NULL, 0, &uThreadId );
+
+#endif
+
+ //-------------------------------------------------
+ // get the global service-manager
+ //-------------------------------------------------
+ OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) );
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) );
+
+ // Print a message if an error occured.
+ if ( !g_xFactory.is( ) )
+ {
+ OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ //-------------------------------------------------
+ // try to get an Interface to a XFilePicker Service
+ //-------------------------------------------------
+
+ Reference< XTransferable > rXTransf( static_cast< XTransferable* >( new CTransferable ) );
+
+ Reference< XClipboard > xClipboard( g_xFactory->createInstance( OUString( WINCLIPBOARD_SERVICE_NAME ) ), UNO_QUERY );
+ if ( !xClipboard.is( ) )
+ {
+ OSL_ENSURE( sal_False, "Error creating FolderPicker Service" );
+ return(-1);
+ }
+
+ Reference< XTypeProvider > rXTypProv( xClipboard, UNO_QUERY );
+
+ if ( rXTypProv.is( ) )
+ {
+ Sequence< Type > seqType = rXTypProv->getTypes( );
+ sal_Int32 nLen = seqType.getLength( );
+ for ( sal_Int32 i = 0; i < nLen; ++nLen )
+ {
+ Type nxtType = seqType[i];
+ }
+
+ Sequence< sal_Int8 > seqInt8 = rXTypProv->getImplementationId( );
+ }
+
+#ifdef WRITE_CB
+
+ xClipboard->setContents( rXTransf, Reference< XClipboardOwner >( rXTransf, UNO_QUERY ) );
+
+#else
+
+ rXTransfRead = xClipboard->getContents( );
+
+ // wakeup the thread and waiting util it ends
+ SetEvent( g_hEvtThreadWakeup );
+
+ // wait for thread end
+ WaitForSingleObject( hThread, INFINITE );
+
+ // destroy the transferable explicitly
+ rXTransfRead = Reference< XTransferable>( );
+
+#endif
+
+ // destroy the clipboard
+ xClipboard = Reference< XClipboard >( );
+
+ CoUninitialize( );
+
+ //--------------------------------------------------
+ // shutdown the service manager
+ //--------------------------------------------------
+
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
+
+ if ( !xComponent.is() )
+ OSL_ENSURE(sal_False, "Error shuting down");
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ g_xFactory.clear();
+ g_xFactory = Reference< XMultiServiceFactory >();
+
+ return 0;
+}
diff --git a/dtrans/source/win32/workbench/testmarshal.cxx b/dtrans/source/win32/workbench/testmarshal.cxx
new file mode 100644
index 000000000000..a716e5ab6738
--- /dev/null
+++ b/dtrans/source/win32/workbench/testmarshal.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * $RCSfile: testmarshal.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: mh $ $Date: 2001-01-31 15:37:22 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+//_________________________________________________________________________________________________________________________
+// interface includes
+//_________________________________________________________________________________________________________________________
+
+//_________________________________________________________________________________________________________________________
+// other includes
+//_________________________________________________________________________________________________________________________
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#include <stdio.h>
+#include <windows.h>
+#include <objbase.h>
+
+#include <stl/memory>
+
+#include <process.h>
+#include "XTDo.hxx"
+
+//-------------------------------------------------------------
+// my defines
+//-------------------------------------------------------------
+
+#define WRITE_CB
+#define EVT_MANUAL_RESET TRUE
+#define EVT_INIT_NONSIGNALED FALSE
+#define EVT_NONAME ""
+#define WAIT_MSGLOOP
+#define RAW_MARSHALING
+
+//------------------------------------------------------------
+// namesapces
+//------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::std;
+
+//------------------------------------------------------------
+// globales
+//------------------------------------------------------------
+
+HANDLE g_hEvtThreadWakeup;
+
+#ifdef RAW_MARSHALING
+ HGLOBAL g_hGlob;
+#else
+ IStream* g_pStm;
+#endif
+
+//################################################################
+// a thread in another apartment to test apartment transparency
+
+unsigned int _stdcall ThreadProc(LPVOID pParam)
+{
+ // setup another apartment
+ HRESULT hr = OleInitialize( NULL );
+
+ WaitForSingleObject( g_hEvtThreadWakeup, INFINITE );
+
+ IDataObject* pIDo;
+
+#ifdef RAW_MARSHALING
+
+ IStream* pStm = NULL;
+ hr = CreateStreamOnHGlobal( g_hGlob, FALSE, &pStm );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = CoUnmarshalInterface(
+ pStm,
+ __uuidof( IDataObject ),
+ (void**)&pIDo );
+
+ hr = pStm->Release( );
+ }
+
+#else
+
+ hr = CoGetInterfaceAndReleaseStream(
+ g_pStm,
+ __uuidof( IDataObject ),
+ (void**)&pIDo
+ );
+
+#endif
+
+ IEnumFORMATETC* pIEEtc;
+ hr = pIDo->EnumFormatEtc( DATADIR_GET, &pIEEtc );
+
+ hr = OleIsCurrentClipboard( pIDo );
+
+ hr = OleFlushClipboard( );
+
+ OleUninitialize( );
+
+ return 0;
+}
+
+//################################################################
+
+//----------------------------------------------------------------
+// main
+//----------------------------------------------------------------
+
+int SAL_CALL main( int nArgc, char* Argv[] )
+{
+ HRESULT hr = OleInitialize( NULL );
+
+ g_hEvtThreadWakeup = CreateEvent( 0,
+ EVT_MANUAL_RESET,
+ EVT_INIT_NONSIGNALED,
+ EVT_NONAME );
+
+ unsigned uThreadId;
+ HANDLE hThread;
+
+ // create a thread in another apartment
+ hThread = (void*)_beginthreadex( NULL, 0, ThreadProc, NULL, 0, &uThreadId );
+
+ IDataObject* pIDo = new CXTDataObject( );
+
+ hr = OleSetClipboard( pIDo );
+ hr = E_FAIL;
+
+ hr = OleIsCurrentClipboard( pIDo );
+
+ //hr = OleGetClipboard( &pIDo );
+ if ( SUCCEEDED( hr ) )
+ {
+#ifdef RAW_MARSHALING
+
+ IStream* pStm = NULL;
+
+ hr = CreateStreamOnHGlobal( 0, FALSE, &pStm );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = CoMarshalInterface(
+ pStm,
+ __uuidof( IDataObject ),
+ pIDo,
+ MSHCTX_INPROC,
+ 0,
+ MSHLFLAGS_NORMAL );
+ if ( SUCCEEDED( hr ) )
+ hr = GetHGlobalFromStream( pStm, &g_hGlob );
+
+ hr = pStm->Release( );
+ }
+
+#else
+
+ hr = CoMarshalInterThreadInterfaceInStream(
+ __uuidof( IDataObject ),
+ pIDo,
+ &g_pStm );
+
+#endif
+
+ if ( SUCCEEDED( hr ) )
+ {
+ // wakeup the thread and waiting util it ends
+ SetEvent( g_hEvtThreadWakeup );
+
+#ifdef WAIT_MSGLOOP
+
+ BOOL bContinue = TRUE;
+
+ while( bContinue )
+ {
+ DWORD dwResult = WaitForMultipleObjects(
+ 1,
+ &hThread,
+ TRUE,
+ 0 );
+
+ if ( WAIT_OBJECT_0 == dwResult )
+ {
+ bContinue = FALSE;
+ }
+ else
+ {
+ MSG msg;
+ while( PeekMessage(
+ &msg,
+ NULL,
+ 0,
+ 0,
+ PM_REMOVE ) )
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ } // while
+
+#endif
+
+ } // if
+ } // if
+
+ OleFlushClipboard( );
+
+ OleUninitialize( );
+
+ return 0;
+}