From 553c0ce1a5a0993c7474ad8e7e17f5c99628bbcf Mon Sep 17 00:00:00 2001 From: Tino Rachui Date: Fri, 2 Mar 2001 14:38:15 +0000 Subject: *** empty log message *** --- dtrans/source/win32/clipb/APNDataObject.hxx | 127 +++++++++++ dtrans/source/win32/clipb/WinClipbImpl.cxx | 255 +++++++++++++++++++++ dtrans/source/win32/clipb/WinClipbImpl.hxx | 152 +++++++++++++ dtrans/source/win32/clipb/WinClipboard.cxx | 342 ++++++++++++++++++++++++++++ dtrans/source/win32/clipb/WinClipboard.hxx | 204 +++++++++++++++++ dtrans/source/win32/clipb/exports.dxp | 3 + dtrans/source/win32/clipb/makefile.mk | 124 ++++++++++ dtrans/source/win32/clipb/sysdtrans.xml | 57 +++++ dtrans/source/win32/clipb/wcbentry.cxx | 202 ++++++++++++++++ 9 files changed, 1466 insertions(+) create mode 100644 dtrans/source/win32/clipb/APNDataObject.hxx create mode 100644 dtrans/source/win32/clipb/WinClipbImpl.cxx create mode 100644 dtrans/source/win32/clipb/WinClipbImpl.hxx create mode 100644 dtrans/source/win32/clipb/WinClipboard.cxx create mode 100644 dtrans/source/win32/clipb/WinClipboard.hxx create mode 100644 dtrans/source/win32/clipb/exports.dxp create mode 100644 dtrans/source/win32/clipb/makefile.mk create mode 100644 dtrans/source/win32/clipb/sysdtrans.xml create mode 100644 dtrans/source/win32/clipb/wcbentry.cxx (limited to 'dtrans/source') diff --git a/dtrans/source/win32/clipb/APNDataObject.hxx b/dtrans/source/win32/clipb/APNDataObject.hxx new file mode 100644 index 000000000000..e0c395ef82ea --- /dev/null +++ b/dtrans/source/win32/clipb/APNDataObject.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: APNDataObject.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 15:36:06 $ + * + * 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 _APNDATAOBJECT_HXX_ +#define _APNDATAOBJECT_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +/* + an APartment Neutral dataobject wrapper; this wrapper of a IDataObject + pointer can be used from any apartment without RPC_E_WRONG_THREAD + which normally occurs if an apartment tries to use an interface + pointer of another apartment; we use containment to hold the original + DataObject +*/ +class CAPNDataObject : public IDataObject +{ +public: + CAPNDataObject( IDataObjectPtr rIDataObject ); + ~CAPNDataObject( ); + + //----------------------------------------------------------------- + //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: + HRESULT MarshalIDataObjectIntoCurrentApartment( IDataObject** ppIDataObj ); + +private: + IDataObjectPtr m_rIDataObjectOrg; + HGLOBAL m_hGlobal; + LONG m_nRefCnt; + +// prevent copy and assignment +private: + CAPNDataObject( const CAPNDataObject& theOther ); + CAPNDataObject& operator=( const CAPNDataObject& theOther ); +}; + +#endif \ No newline at end of file diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx new file mode 100644 index 000000000000..3a6d30743525 --- /dev/null +++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * + * $RCSfile: WinClipbImpl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 15:37:30 $ + * + * 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 +#endif + +#ifndef _WINCLIPBIMPL_HXX_ +#include "WinClipbImpl.hxx" +#endif + +#ifndef _DTOBJFACTORY_HXX_ +#include "..\..\inc\DtObjFactory.hxx" +#endif + +#ifndef _MTAOLECLIPB_H_ +#include +#endif + +#ifndef _APNDATAOBJECT_HXX_ +#include "APNDataObject.hxx" +#endif + +#ifndef _WINCLIPBOARD_HXX_ +#include "WinClipboard.hxx" +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_RENDERINGCAPABILITIES_HPP_ +#include +#endif + +#include +#include +#include + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using namespace rtl; +using namespace osl; +using namespace std; +using namespace cppu; + +using namespace com::sun::star::uno; +using namespace com::sun::star::datatransfer; +using namespace com::sun::star::datatransfer::clipboard; +using namespace com::sun::star::datatransfer::clipboard::RenderingCapabilities; + +//------------------------------------------------------------------------ +// deklarations +//------------------------------------------------------------------------ + +// definition of static members +CWinClipbImpl* CWinClipbImpl::s_pCWinClipbImpl = NULL; + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* theWinClipboard ) : + m_itsName( aClipboardName ), + m_pClipboardContent( NULL ), + m_pWinClipboard( theWinClipboard ), + m_bInDispose( sal_False ) +{ + OSL_ASSERT( NULL != m_pWinClipboard ); + + // necessary to reassociate from + // the static callback function + s_pCWinClipbImpl = this; +} + +//------------------------------------------------------------------------ +// getContent +//------------------------------------------------------------------------ + +Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( RuntimeException ) +{ + if ( NULL != m_pClipboardContent ) + { + //return Reference< XTransferable >( m_pClipbContent->m_rXTDataSource ); + //return m_pClipboardContent->m_rXTDataSource; + return Reference< XTransferable >( ); + } + else + { + // get the current dataobject from clipboard + IDataObjectPtr pIDataObject; + MTAGetClipboard( &pIDataObject ); + + // create an apartment neutral dataobject and initialize it with a + // com smart pointer to the IDataObject from clipboard + IDataObjectPtr pIDo = ( new CAPNDataObject( pIDataObject ) ); + + CDTransObjFactory objFactory; + + // remeber pIDo destroys itself due to the smart pointer + //return Reference< XTransferable >( static_cast< XTransferable* >( new CDOTransferable( pIDo ) ) ); + return objFactory.createTransferableFromDataObj( m_pWinClipboard->m_SrvMgr, pIDo ); + } +} + +//------------------------------------------------------------------------ +// setContent +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipbImpl::setContents( const Reference< XTransferable >& xTransferable, + const Reference< XClipboardOwner >& xClipboardOwner ) + throw( RuntimeException ) +{ + CDTransObjFactory objFactory; + + IDataObjectPtr pIDataObj( objFactory.createDataObjFromTransferable( + m_pWinClipboard->m_SrvMgr , xTransferable ) ); + + MTASetClipboard( pIDataObj ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +OUString SAL_CALL CWinClipbImpl::getName( ) throw( RuntimeException ) +{ + return m_itsName; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +sal_Int8 SAL_CALL CWinClipbImpl::getRenderingCapabilities( ) throw( RuntimeException ) +{ + return ( Delayed | Persistant ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipbImpl::flushClipboard( ) throw( RuntimeException ) +{ + MTAFlushClipboard( ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipbImpl::registerClipboardViewer( ) const +{ + if ( m_pWinClipboard->hasClipboardListener( ) ) + MTARegisterClipboardViewer( CWinClipbImpl::onClipboardContentChanged ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( ) const +{ + if ( !m_pWinClipboard->hasClipboardListener( ) ) + MTARegisterClipboardViewer( NULL ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException ) +{ +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + +void CALLBACK CWinClipbImpl::onClipboardContentChanged( void ) +{ + // reassocition to instance through static member + s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( ); +} + +//------------------------------------------------------------------------ +// returns wether we are in dispose or not, is important for the +// XTDataObject so that we ignore the "Link" format during FlushClipboard +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CWinClipbImpl::isInDispose( ) const +{ + return m_bInDispose; +} diff --git a/dtrans/source/win32/clipb/WinClipbImpl.hxx b/dtrans/source/win32/clipb/WinClipbImpl.hxx new file mode 100644 index 000000000000..8b8fea0ef726 --- /dev/null +++ b/dtrans/source/win32/clipb/WinClipbImpl.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: WinClipbImpl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 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 _WINCLIPBIMPL_HXX_ +#define _WINCLIPBIMPL_HXX_ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _SAL_TYPES_H_ +#include +#endif + +#ifndef _RTL_USTRING_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDLISTENER_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDOWNER_HPP_ +#include +#endif + +#include +#include + +class CWinClipboard; + +//--------------------------------------------------- +// impl class to avoid deadlocks between XTDataObject +// and the clipboard implementation +//--------------------------------------------------- + +class CWinClipbImpl +{ +protected: + CWinClipbImpl( const ::rtl::OUString& aClipboardName, CWinClipboard* theWinClipboard ); + + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents( ) + throw( ::com::sun::star::uno::RuntimeException ); + + void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ) + throw( ::com::sun::star::uno::RuntimeException ); + + ::rtl::OUString SAL_CALL getName( ) throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------ + // XClipboardEx + //------------------------------------------------ + + sal_Int8 SAL_CALL getRenderingCapabilities( ) throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------ + // XFlushableClipboard + //------------------------------------------------ + + void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException ); + + //------------------------------------------------ + // XComponent + //------------------------------------------------ + + void SAL_CALL dispose( ) throw( ::com::sun::star::uno::RuntimeException ); + + //------------------------------------------------ + // member functions + //------------------------------------------------ + + void SAL_CALL registerClipboardViewer( ) const; + void SAL_CALL unregisterClipboardViewer( ) const; + + static void CALLBACK onClipboardContentChanged( void ); + + sal_Bool SAL_CALL isInDispose( ) const; + + ::rtl::OUString m_itsName; + IDataObjectPtr m_pClipboardContent; + static CWinClipbImpl* s_pCWinClipbImpl; + CWinClipboard* m_pWinClipboard; + sal_Bool m_bInDispose; + + friend class CWinClipboard; +}; + +#endif \ No newline at end of file diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx new file mode 100644 index 000000000000..f72fb50b7b27 --- /dev/null +++ b/dtrans/source/win32/clipb/WinClipboard.cxx @@ -0,0 +1,342 @@ +/************************************************************************* + * + * $RCSfile: WinClipboard.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 15:37: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 +#endif + +#ifndef _WINCLIPBOARD_HXX_ +#include "WinClipboard.hxx" +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_CLIPBOARDEVENT_HPP_ +#include +#endif + +#ifndef _WINCLIPBIMPL_HXX_ +#include "WinClipbImpl.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using namespace rtl; +using namespace osl; +using namespace std; +using namespace cppu; + +using namespace com::sun::star::uno; +using namespace com::sun::star::datatransfer; +using namespace com::sun::star::datatransfer::clipboard; +using namespace com::sun::star::lang; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace +{ + Sequence< OUString > SAL_CALL WinClipboard_getSupportedServiceNames() + { + Sequence< OUString > aRet(1); + aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard"); + return aRet; + } +} + +//------------------------------------------------------------------------ +// ctor +//------------------------------------------------------------------------ + +CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceManager, const OUString& aClipboardName ) : + WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >( m_aMutex ), + m_SrvMgr( rServiceManager ) +{ + m_pImpl.reset( new CWinClipbImpl( aClipboardName, this ) ); +} + +//======================================================================== +// XClipboard +//======================================================================== + +//------------------------------------------------------------------------ +// getContent +// to avoid unecessary traffic we check first if there is a clipboard +// content which was set via setContent, in this case we don't need +// to query the content from the clipboard, create a new wrapper object +// and so on, we simply return the orignial XTransferable instead of our +// DOTransferable +//------------------------------------------------------------------------ + +Reference< XTransferable > SAL_CALL CWinClipboard::getContents( ) throw( RuntimeException ) +{ + MutexGuard aGuard( m_aMutex ); + + OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + return m_pImpl->getContents( ); +} + +//------------------------------------------------------------------------ +// setContent +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTransferable, + const Reference< XClipboardOwner >& xClipboardOwner ) + throw( RuntimeException ) +{ + MutexGuard aGuard( m_aMutex ); + + OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + m_pImpl->setContents( xTransferable, xClipboardOwner ); +} + +//------------------------------------------------------------------------ +// getName +//------------------------------------------------------------------------ + +OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException ) +{ + return m_pImpl->getName( ); +} + +//======================================================================== +// XFlushableClipboard +//======================================================================== + +void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException ) +{ + MutexGuard aGuard( m_aMutex ); + OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + + m_pImpl->flushClipboard( ); +} + +//======================================================================== +// XClipboardEx +//======================================================================== + +sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeException ) +{ + return m_pImpl->getRenderingCapabilities( ); +} + +//======================================================================== +// XClipboardNotifier +//======================================================================== + +//------------------------------------------------------------------------ +// getName +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipboard::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 already disposed" ); + + if ( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + rBHelper.aLC.addInterface( getCppuType( ( Reference< XClipboardListener > * ) 0 ), listener ); + m_pImpl->registerClipboardViewer( ); + } +} + +//------------------------------------------------------------------------ +// getName +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipboard::removeClipboardListener( 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 already disposed" ); + + if ( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + rBHelper.aLC.removeInterface( getCppuType( ( Reference< XClipboardListener > * ) 0 ), listener ); + m_pImpl->unregisterClipboardViewer( ); + } +} + +//------------------------------------------------------------------------ +// getName +//------------------------------------------------------------------------ + +void SAL_CALL CWinClipboard::notifyAllClipboardListener( ) const +{ + OInterfaceContainerHelper* pICHelper = rBHelper.aLC.getContainer( + getCppuType( ( Reference< XClipboardListener > * ) 0 ) ); + + if ( pICHelper ) + { + OInterfaceIteratorHelper iter( *pICHelper ); + + // todo !!! + // have to construct a transferable ... + ClipboardEvent aCBEvent; + + while( iter.hasMoreElements( ) ) + { + try + { + Reference< XClipboardListener > xCBListener( iter.next( ), UNO_QUERY ); + if ( xCBListener.is( ) ) + xCBListener->changedContents( aCBEvent ); + } + catch( ... ) + { + OSL_ENSURE( false, "Exception during event dispatching" ); + } + } + } +} + +//------------------------------------------------------------------------ +// determine if there are any clipboard listener +//------------------------------------------------------------------------ + +sal_Bool SAL_CALL CWinClipboard::hasClipboardListener( ) const +{ + sal_Bool bRet = sal_False; + + OInterfaceContainerHelper* pICHelper = + rBHelper.aLC.getContainer( getCppuType( ( Reference< XClipboardListener > * ) 0 ) ); + + if ( pICHelper ) + bRet = ( pICHelper->getLength( ) > 0 ); + + return bRet; +} + +//------------------------------------------------ +// dispose +// we can't aquire a mutext in this method because +// dispose may flush the clipboard and that leads +// to a lostOwnership message send to the clipboard +// owner, if the clipboard owner would access the +// clipboard and we had aquire a lock here we would +// have a deadlock +//------------------------------------------------ + +void SAL_CALL CWinClipboard::dispose() throw(RuntimeException) +{ + MutexGuard aGuard( m_aMtxForDispose ); + + if ( !( rBHelper.bInDispose || rBHelper.bDisposed ) ) + { + // do my own stuff + m_pImpl->dispose( ); + + // call the base class implementation first + WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >::dispose( ); + } +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL CWinClipboard::getImplementationName( ) + throw(RuntimeException) +{ + return OUString::createFromAscii( WINCLIPBOARD_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL CWinClipboard::supportsService( const OUString& ServiceName ) + throw(RuntimeException) +{ + Sequence < OUString > SupportedServicesNames = WinClipboard_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 CWinClipboard::getSupportedServiceNames( ) + throw(RuntimeException) +{ + return WinClipboard_getSupportedServiceNames(); +} \ No newline at end of file diff --git a/dtrans/source/win32/clipb/WinClipboard.hxx b/dtrans/source/win32/clipb/WinClipboard.hxx new file mode 100644 index 000000000000..aac9afaadf70 --- /dev/null +++ b/dtrans/source/win32/clipb/WinClipboard.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * $RCSfile: WinClipboard.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 15:38: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): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _WINCLIPBOARD_HXX_ +#define _WINCLIPBOARD_HXX_ + + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _RTL_USTRING_ +#include +#endif + +#ifndef _SAL_TYPES_H_ +#include +#endif + +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDOWNER_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDLISTENER_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDNOTIFIER_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XFLUSHABLECLIPBOARD_HPP_ +#include +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include +#endif + +#include + +// forward +class CWinClipbImpl; + +//------------------------------------------------------------------------ +// implements the XClipboard[Ex] ... interfaces +// for the clipboard viewer mechanism we need a static callback function +// and a static member to reasocciate from this static function to the +// class instance +// watch out: we are using only one static member variable and not a list +// because we assume to be instanciated only once +// this will be asured by an OneInstanceFactory of the service and not +// by this class! +//------------------------------------------------------------------------ + +class CWinClipboard : + public cppu::WeakComponentImplHelper4< + ::com::sun::star::datatransfer::clipboard::XClipboardEx, \ + ::com::sun::star::datatransfer::clipboard::XFlushableClipboard, + ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, + ::com::sun::star::lang::XServiceInfo > +{ +public: + CWinClipboard( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager, + const ::rtl::OUString& aClipboardName ); + + //------------------------------------------------ + // 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 >& xTransferable, + 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 ); + + //------------------------------------------------ + // XFlushableClipboard + //------------------------------------------------ + + virtual void SAL_CALL flushClipboard( ) 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 ); + + //------------------------------------------------ + // XComponent + //------------------------------------------------ + + virtual void SAL_CALL dispose() throw(::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: + void SAL_CALL notifyAllClipboardListener( ) const; + sal_Bool SAL_CALL hasClipboardListener( ) const; + +private: + ::osl::Mutex m_aMutex; + ::osl::Mutex m_aMtxForDispose; + ::std::auto_ptr< CWinClipbImpl > m_pImpl; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; + + friend class CWinClipbImpl; +}; + + +#endif \ No newline at end of file diff --git a/dtrans/source/win32/clipb/exports.dxp b/dtrans/source/win32/clipb/exports.dxp new file mode 100644 index 000000000000..028ac4175990 --- /dev/null +++ b/dtrans/source/win32/clipb/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/dtrans/source/win32/clipb/makefile.mk b/dtrans/source/win32/clipb/makefile.mk new file mode 100644 index 000000000000..bdb225d31df4 --- /dev/null +++ b/dtrans/source/win32/clipb/makefile.mk @@ -0,0 +1,124 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-03-02 15:38: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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=dtrans +TARGET=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=$(SLO)$/WinClipboard.obj \ + $(SLO)$/WinClipbImpl.obj \ + $(SLO)$/wcbentry.obj\ + $(SLO)$/APNDataObject.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS= \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + ole32.lib\ + comsupp.lib\ + oleaut32.lib\ + gdi32.lib + +SHL1DEPN= +SHL1IMPLIB=i$(SHL1TARGET) + +#--- comment ----------------- + +SHL1LIBS= \ + $(SOLARLIBDIR)$/imtaolecb.lib\ + $(SOLARLIBDIR)$/user9x.lib\ + $(SOLARLIBDIR)$/tools32.lib\ + $(SLB)$/dtutils.lib\ + $(SLB)$/dtobjfact.lib + +SHL1OBJS= $(SLOFILES) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/dtrans/source/win32/clipb/sysdtrans.xml b/dtrans/source/win32/clipb/sysdtrans.xml new file mode 100644 index 000000000000..b2ef549f3f37 --- /dev/null +++ b/dtrans/source/win32/clipb/sysdtrans.xml @@ -0,0 +1,57 @@ + + + + + + Tino Rachui + + com.sun.star.comp.datatransfer.clipboard + + + The win32 implementation of the datatransfer service. + + + sysdtrans + + com.sun.star.loader.SharedLibrary + + c++ + + + + com.sun.star.datatransfer.clipboard.SystemClipboard + + ... + + cppuhelper + cppu + sal + + cppuhelper + cppu2 + sal2 + + com.sun.star.datatransfer.clipboard.XClipboardEx + com.sun.star.datatransfer.clipboard.XFlushableClipboard + com.sun.star.datatransfer.XTransferable + com.sun.star.datatransfer.XTransferableEx + com.sun.star.datatransfer.clipboard.XClipboardOwner + com.sun.star.datatransfer.clipboard.XClipboardListener + com.sun.star.datatransfer.clipboard.XClipboardNotifier + com.sun.star.datatransfer.clipboard.RenderingCapabilities + com.sun.star.datatransfer.XTransferDataAccess + com.sun.star.lang.XComponent + com.sun.star.lang.XMultiServiceFactory + com.sun.star.lang.XSingleServiceFactory + com.sun.star.lang.XServiceInfo + com.sun.star.lang.XTypeProvider + com.sun.star.lang.IllegalArgumentException + com.sun.star.uno.TypeClass + com.sun.star.uno.XWeak + com.sun.star.uno.XAggregation + com.sun.star.registry.XRegistryKey + com.sun.star.container.XSet + + + diff --git a/dtrans/source/win32/clipb/wcbentry.cxx b/dtrans/source/win32/clipb/wcbentry.cxx new file mode 100644 index 000000000000..62ce0925d6fe --- /dev/null +++ b/dtrans/source/win32/clipb/wcbentry.cxx @@ -0,0 +1,202 @@ +/************************************************************************* + * + * $RCSfile: wcbentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-03-02 15:36:46 $ + * + * 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 +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include +#endif + +#ifndef _WINCLIPBOARD_HXX_ +#include "WinClipboard.hxx" +#endif + +//----------------------------------------------------------------- +// some defines +//----------------------------------------------------------------- + +// the service names +#define WINCLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard" + +// the implementation names +#define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32" + +// the registry key names +// a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName" +// < Implementation-Name >< Service-Name > +#define WINCLIPBOARD_REGKEY_NAME "/com.sun.star.datatransfer.clipboard.ClipboardW32/UNO/SERVICES/com.sun.star.datatransfer.clipboard.SystemClipboard" + +//----------------------------------------------------------------------------------------------------------- +// 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 +//----------------------------------------------------------------- + +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< XClipboard* >( new CWinClipboard( rServiceManager, L"" ) ) ); + } +} + +//----------------------------------------------------------------------------------------------------------- +// 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( WINCLIPBOARD_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, WINCLIPBOARD_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( WINCLIPBOARD_SERVICE_NAME ) ); + + //OUString( RTL_CONSTASCII_USTRINGPARAM( FPS_IMPL_NAME ) ) + Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" -- cgit v1.2.3