summaryrefslogtreecommitdiff
path: root/dtrans/source/generic
diff options
context:
space:
mode:
Diffstat (limited to 'dtrans/source/generic')
-rw-r--r--dtrans/source/generic/clipboardmanager.cxx268
-rw-r--r--dtrans/source/generic/clipboardmanager.hxx128
-rw-r--r--dtrans/source/generic/dtrans.cxx134
-rw-r--r--dtrans/source/generic/dtrans.xml44
-rw-r--r--dtrans/source/generic/exports.dxp3
-rw-r--r--dtrans/source/generic/generic_clipboard.cxx208
-rw-r--r--dtrans/source/generic/generic_clipboard.hxx134
-rw-r--r--dtrans/source/generic/makefile.mk67
8 files changed, 986 insertions, 0 deletions
diff --git a/dtrans/source/generic/clipboardmanager.cxx b/dtrans/source/generic/clipboardmanager.cxx
new file mode 100644
index 000000000000..1221cd20f046
--- /dev/null
+++ b/dtrans/source/generic/clipboardmanager.cxx
@@ -0,0 +1,268 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dtrans.hxx"
+
+#include <clipboardmanager.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+
+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 std;
+
+using ::dtrans::ClipboardManager;
+using ::rtl::OUString;
+
+// ------------------------------------------------------------------------
+
+ClipboardManager::ClipboardManager():
+ WeakComponentImplHelper3< XClipboardManager, XEventListener, XServiceInfo > (m_aMutex),
+ m_aDefaultName(OUString::createFromAscii("default"))
+{
+}
+
+// ------------------------------------------------------------------------
+
+ClipboardManager::~ClipboardManager()
+{
+}
+
+// ------------------------------------------------------------------------
+
+OUString SAL_CALL ClipboardManager::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(CLIPBOARDMANAGER_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ClipboardManager::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 ClipboardManager::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return ClipboardManager_getSupportedServiceNames();
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XClipboard > SAL_CALL ClipboardManager::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_aDefaultName);
+
+ if (iter != m_aClipboardMap.end())
+ return iter->second;
+
+ throw NoSuchElementException(aName, static_cast < XClipboardManager * > (this));
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL ClipboardManager::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_aDefaultName.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_aDefaultName,
+ 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 ClipboardManager::removeClipboard( const OUString& aName )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if (!rBHelper.bDisposed)
+ m_aClipboardMap.erase(aName.getLength() ? aName : m_aDefaultName );
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ClipboardManager::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 ClipboardManager::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 ClipboardManager::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 ClipboardManager());
+}
+
+// ------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ClipboardManager_getSupportedServiceNames()
+{
+ Sequence < OUString > SupportedServicesNames( 1 );
+ SupportedServicesNames[0] =
+ OUString::createFromAscii("com.sun.star.datatransfer.clipboard.ClipboardManager");
+ return SupportedServicesNames;
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/generic/clipboardmanager.hxx b/dtrans/source/generic/clipboardmanager.hxx
new file mode 100644
index 000000000000..54ac5941728b
--- /dev/null
+++ b/dtrans/source/generic/clipboardmanager.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_CLIPBOARDMANAGER_HXX_
+#define _DTRANS_CLIPBOARDMANAGER_HXX_
+
+#include <cppuhelper/compbase3.hxx>
+
+#include <com/sun/star/datatransfer/clipboard/XClipboardManager.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <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;
+
+// ------------------------------------------------------------------------
+
+namespace dtrans
+{
+
+ class ClipboardManager : 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_aDefaultName;
+
+ virtual ~ClipboardManager();
+ protected:
+ using WeakComponentImplHelperBase::disposing;
+ public:
+
+ ClipboardManager();
+
+ /*
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/generic/dtrans.cxx b/dtrans/source/generic/dtrans.cxx
new file mode 100644
index 000000000000..40eb6967adb3
--- /dev/null
+++ b/dtrans/source/generic/dtrans.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dtrans.hxx"
+
+
+#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();
+ sal_Int32 nPos;
+ for ( 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_ENSURE( 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;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/generic/dtrans.xml b/dtrans/source/generic/dtrans.xml
new file mode 100644
index 000000000000..58ae60cae7c6
--- /dev/null
+++ b/dtrans/source/generic/dtrans.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> dtrans </module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name> com.sun.star.comp.datatransfer.generic </name>
+ <description> This module includes a generic clipboard implementation </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.datatransfer.clipboard.GenericClipboard </supported-service>
+ <supported-service> com.sun.star.datatransfer.clipboard.ClipboardManager </supported-service>
+ <service-dependency> ... </service-dependency>
+ <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.XSingleComponentFactory </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.XComponentContext </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+</module-description>
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/generic_clipboard.cxx b/dtrans/source/generic/generic_clipboard.cxx
new file mode 100644
index 000000000000..eacab35dc9f6
--- /dev/null
+++ b/dtrans/source/generic/generic_clipboard.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dtrans.hxx"
+
+#include <generic_clipboard.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
+
+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 ::dtrans::GenericClipboard;
+using ::rtl::OUString;
+
+GenericClipboard::GenericClipboard() :
+ WeakComponentImplHelper4< XClipboardEx, XClipboardNotifier, XServiceInfo, XInitialization > (m_aMutex),
+ m_bInitialized(sal_False)
+{
+}
+
+// ------------------------------------------------------------------------
+
+GenericClipboard::~GenericClipboard()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL GenericClipboard::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 GenericClipboard::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii(GENERIC_CLIPBOARD_IMPLEMENTATION_NAME);
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GenericClipboard::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 GenericClipboard::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return GenericClipboard_getSupportedServiceNames();
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XTransferable > SAL_CALL GenericClipboard::getContents()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_aContents;
+}
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL GenericClipboard::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 GenericClipboard::getName()
+ throw(RuntimeException)
+{
+ return m_aName;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL GenericClipboard::getRenderingCapabilities()
+ throw(RuntimeException)
+{
+ return RenderingCapabilities::Delayed;
+}
+
+
+// ------------------------------------------------------------------------
+
+void SAL_CALL GenericClipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSURE( !rBHelper.bInDispose, "do not add listeners in the dispose call" );
+ OSL_ENSURE( !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 GenericClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSURE( !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 GenericClipboard());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/generic/generic_clipboard.hxx b/dtrans/source/generic/generic_clipboard.hxx
new file mode 100644
index 000000000000..f0576933d59e
--- /dev/null
+++ b/dtrans/source/generic/generic_clipboard.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DTRANS_GENERIC_CLIPBOARD_HXX_
+#define _DTRANS_GENERIC_CLIPBOARD_HXX_
+
+#include <cppuhelper/compbase4.hxx>
+
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+// ------------------------------------------------------------------------
+
+#define GENERIC_CLIPBOARD_IMPLEMENTATION_NAME "com.sun.star.comp.datatransfer.clipboard.GenericClipboard"
+
+// ------------------------------------------------------------------------
+
+namespace dtrans
+{
+
+ class GenericClipboard : 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 ~GenericClipboard();
+
+ public:
+
+ GenericClipboard();
+
+ /*
+ * 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/generic/makefile.mk b/dtrans/source/generic/makefile.mk
new file mode 100644
index 000000000000..e015400c32d9
--- /dev/null
+++ b/dtrans/source/generic/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=dtrans
+TARGET=generic
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+COMP1TYPELIST=dtrans
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+# ------------------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/generic_clipboard.obj \
+ $(SLO)$/clipboardmanager.obj \
+ $(SLO)$/dtrans.obj
+
+SHL1TARGET= dtrans
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1OBJS= $(SLOFILES)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk