diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-09-20 15:39:13 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-09-20 15:39:13 +0000 |
commit | 48509165584c8468fe4e2481cb7705754f86da82 (patch) | |
tree | 6915b85815b7ed5847806f14d6aaca4941a37017 /dtrans | |
parent | 8d7592618e16d1ea6e76a06dc7dbb768e6cea54a (diff) |
INTEGRATION: CWS os2port01 (1.1.2); FILE ADDED
2007/01/24 16:52:23 ydario 1.1.2.1: OS/2 clipboard bitmap support.
Diffstat (limited to 'dtrans')
-rw-r--r-- | dtrans/source/os2/clipb/Os2Clipboard.cxx | 445 | ||||
-rw-r--r-- | dtrans/source/os2/clipb/Os2Clipboard.hxx | 201 | ||||
-rw-r--r-- | dtrans/source/os2/clipb/Os2Service.cxx | 151 |
3 files changed, 797 insertions, 0 deletions
diff --git a/dtrans/source/os2/clipb/Os2Clipboard.cxx b/dtrans/source/os2/clipb/Os2Clipboard.cxx new file mode 100644 index 000000000000..fab60eb742b7 --- /dev/null +++ b/dtrans/source/os2/clipb/Os2Clipboard.cxx @@ -0,0 +1,445 @@ +/************************************************************************* + * + * $RCSfile: Os2Clipboard.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-09-20 16:38:54 $ + * + * 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 _OS2CLIPBOARD_HXX_ +#include "Os2Clipboard.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using namespace com::sun::star::datatransfer; +using namespace com::sun::star::datatransfer::clipboard; +using namespace com::sun::star::datatransfer::clipboard::RenderingCapabilities; +using namespace com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace cppu; +using namespace osl; +using namespace rtl; +using namespace os2; + +const Type CPPUTYPE_SEQINT8 = getCppuType( ( Sequence< sal_Int8 >* )0 ); +const Type CPPUTYPE_OUSTRING = getCppuType( (OUString*)0 ); + +#define DTRANS_OBJ_CLASSNAME "DTRANSOBJWND" + +// ----------------------------------------------------------------------- + +inline void SetWindowPtr( HWND hWnd, Os2Clipboard* pThis ) +{ + WinSetWindowULong( hWnd, QWL_USER, (ULONG)pThis ); +} + +inline Os2Clipboard* GetWindowPtr( HWND hWnd ) +{ + return (Os2Clipboard*)WinQueryWindowULong( hWnd, QWL_USER ); +} + +// ----------------------------------------------------------------------- + +MRESULT EXPENTRY DtransObjWndProc( HWND hWnd, ULONG nMsg, MPARAM nMP1, MPARAM nMP2 ) +{ + + switch ( nMsg ) + { + case WM_DRAWCLIPBOARD: // clipboard content has changed + { + Os2Clipboard* os2Clipboard = GetWindowPtr( hWnd); + if (os2Clipboard) + { + //MutexGuard aGuard(os2Clipboard->m_aMutex); + debug_printf("WM_DRAWCLIPBOARD os2Clipboard %08x\n", os2Clipboard); + if (os2Clipboard->m_bInSetClipboardData) + { + debug_printf("WM_DRAWCLIPBOARD our change\n"); + } + else + { + // notify listener for clipboard change + debug_printf("WM_DRAWCLIPBOARD notify change\n"); + os2Clipboard->notifyAllClipboardListener(); + } + } + } + break; + } + + return WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); +} + +// ----------------------------------------------------------------------- + +Os2Clipboard::Os2Clipboard() : + m_aMutex(), + WeakComponentImplHelper4< XClipboardEx, XClipboardNotifier, XServiceInfo, XInitialization > (m_aMutex), + m_bInitialized(sal_False), + m_bInSetClipboardData(sal_False) +{ + MutexGuard aGuard(m_aMutex); + + debug_printf("Os2Clipboard::Os2Clipboard\n"); + hAB = WinQueryAnchorBlock( HWND_DESKTOP ); + + // register object class + if ( WinRegisterClass( hAB, (PSZ)DTRANS_OBJ_CLASSNAME, + (PFNWP)DtransObjWndProc, 0, sizeof(ULONG) )) + { + APIRET rc; + // create object window to get clip viewer messages + hObjWnd = WinCreateWindow( HWND_OBJECT, (PCSZ)DTRANS_OBJ_CLASSNAME, + (PCSZ)"", 0, 0, 0, 0, 0, + HWND_OBJECT, HWND_TOP, + 222, NULL, NULL); + // store pointer + SetWindowPtr( hObjWnd, this); + // register the viewer window + rc = WinOpenClipbrd(hAB); + rc = WinSetClipbrdViewer(hAB, hObjWnd); + rc = WinCloseClipbrd(hAB); + } +} + +Os2Clipboard::~Os2Clipboard() +{ + debug_printf("Os2Clipboard::~Os2Clipboard\n"); +} + +void SAL_CALL Os2Clipboard::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 Os2Clipboard::getImplementationName() throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::getImplementationName\n"); + return OUString::createFromAscii( OS2_CLIPBOARD_IMPL_NAME ); +} + +sal_Bool SAL_CALL Os2Clipboard::supportsService( const OUString& ServiceName ) throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::supportsService\n"); + Sequence < OUString > SupportedServicesNames = Os2Clipboard_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + if (SupportedServicesNames[n].compareTo(ServiceName) == 0) + return sal_True; + + return sal_False; +} + +Sequence< OUString > SAL_CALL Os2Clipboard::getSupportedServiceNames() throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::getSupportedServiceNames\n"); + return Os2Clipboard_getSupportedServiceNames(); +} + +Reference< XTransferable > SAL_CALL Os2Clipboard::getContents() throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::getContents\n"); + MutexGuard aGuard(m_aMutex); + + if( ! m_aContents.is() ) + m_aContents = new Os2Transferable( static_cast< OWeakObject* >(this) ); + + return m_aContents; +} + +void SAL_CALL Os2Clipboard::setContents( const Reference< XTransferable >& xTrans, const Reference< XClipboardOwner >& xClipboardOwner ) throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::setContents\n"); + // 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); + } + } + +#if OSL_DEBUG_LEVEL>0 + // dump list of available mimetypes + Sequence< DataFlavor > aFlavors( m_aContents->getTransferDataFlavors() ); + for( int i = 0; i < aFlavors.getLength(); i++ ) + debug_printf("Os2Clipboard::setContents available mimetype: %d %s\n", + i, CHAR_POINTER(aFlavors.getConstArray()[i].MimeType)); +#endif + + // we can only export text or bitmap + DataFlavor nFlavorText( OUString::createFromAscii( "text/plain;charset=utf-16" ), + OUString::createFromAscii( "Unicode-Text" ), CPPUTYPE_OUSTRING); + DataFlavor nFlavorBitmap( OUString::createFromAscii( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" ), + OUString::createFromAscii( "Bitmap" ), CPPUTYPE_DEFAULT); + + // try text transfer data (if any) + try + { + Any aAny = m_aContents->getTransferData( nFlavorText ); + if (aAny.hasValue()) + { + // copy unicode text to clipboard + OUString aString; + aAny >>= aString; + // share text + if ( UWinOpenClipbrd( hAB) ) + { + PSZ pSharedText; + // set the flag, so we will ignore the next WM_DRAWCLIPBOARD + // since we generate it with following code. + m_bInSetClipboardData = sal_True; + DosAllocSharedMem( (PPVOID) &pSharedText, NULL, + aString.getLength() + 1, + PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_ANY); + memcpy( pSharedText, aString.getStr(), aString.getLength() * 2 + 2 ); + UWinEmptyClipbrd( hAB); + // give pointer to clipboard (it will become owner of pSharedText!) + UWinSetClipbrdData( hAB, (ULONG) pSharedText, UCLIP_CF_UNICODETEXT, CFI_POINTER); + UWinCloseClipbrd( hAB); + // reset the flag, so we will not ignore next WM_DRAWCLIPBOARD + m_bInSetClipboardData = sal_False; + } + debug_printf("Os2Clipboard::setContents SetClipbrdData text done\n"); + } + } catch ( UnsupportedFlavorException&) { + debug_printf("Os2Clipboard::setContents UnsupportedFlavorException (no text)\n"); + } + + // try bitmap transfer data (if any) + try + { + Any aAnyB = m_aContents->getTransferData( nFlavorBitmap ); + if (aAnyB.hasValue()) + { + HBITMAP hbm = OOoBmpToOS2Handle( aAnyB); + // share bitmap handle + if ( hbm && UWinOpenClipbrd( hAB) ) + { + // set the flag, so we will ignore the next WM_DRAWCLIPBOARD + // since we generate it with following code. + m_bInSetClipboardData = sal_True; + UWinEmptyClipbrd( hAB); + // give pointer to clipboard (it will become owner of pSharedText!) + UWinSetClipbrdData( hAB, (ULONG) hbm, UCLIP_CF_BITMAP, CFI_HANDLE); + UWinCloseClipbrd( hAB); + // reset the flag, so we will not ignore next WM_DRAWCLIPBOARD + m_bInSetClipboardData = sal_False; + } + debug_printf("Os2Clipboard::setContents SetClipbrdData bitmap done\n"); + } + } catch ( UnsupportedFlavorException&) { + debug_printf("Os2Clipboard::setContents UnsupportedFlavorException (no bitmap)\n"); + } +} + +OUString SAL_CALL Os2Clipboard::getName() throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::getName\n"); + return m_aName; +} + +sal_Int8 SAL_CALL Os2Clipboard::getRenderingCapabilities() throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::getRenderingCapabilities\n"); + return Delayed; +} + +//======================================================================== +// XClipboardNotifier +//======================================================================== + +void SAL_CALL Os2Clipboard::addClipboardListener( const Reference< XClipboardListener >& listener ) throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::addClipboardListener\n"); + 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 Os2Clipboard::removeClipboardListener( const Reference< XClipboardListener >& listener ) throw( RuntimeException ) +{ + debug_printf("Os2Clipboard::removeClipboardListener\n"); + 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 ); \ +} + +// ------------------------------------------------------------------------ + +void SAL_CALL Os2Clipboard::notifyAllClipboardListener( ) +{ + if ( !rBHelper.bDisposed ) + { + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if ( !rBHelper.bDisposed ) + { + aGuard.clear( ); + + ClearableMutexGuard aGuard(m_aMutex); + // copy member references on stack so they can be called + // without having the mutex + Reference< XClipboardOwner > xOwner( m_aOwner ); + Reference< XTransferable > xTrans( m_aContents ); + // clear members + m_aOwner.clear(); + m_aContents.clear(); + // release the mutex + aGuard.clear(); + + // inform previous owner of lost ownership + if ( xOwner.is() ) + xOwner->lostOwnership(static_cast < XClipboard * > (this), m_aContents); + + OInterfaceContainerHelper* pICHelper = rBHelper.aLC.getContainer( + getCppuType( ( Reference< XClipboardListener > * ) 0 ) ); + + if ( pICHelper ) + { + try + { + OInterfaceIteratorHelper iter(*pICHelper); + m_aContents = 0; + m_aContents = new Os2Transferable( static_cast< OWeakObject* >(this) ); + ClipboardEvent aClipbEvent(static_cast<XClipboard*>(this), m_aContents); + + while(iter.hasMoreElements()) + { + try + { + Reference<XClipboardListener> xCBListener(iter.next(), UNO_QUERY); + if (xCBListener.is()) + xCBListener->changedContents(aClipbEvent); + } + catch(RuntimeException&) + { + OSL_ENSURE( false, "RuntimeException caught" ); + debug_printf( "RuntimeException caught" ); + } + } + } + catch(const ::com::sun::star::lang::DisposedException&) + { + OSL_ENSURE(false, "Service Manager disposed"); + debug_printf( "Service Manager disposed"); + + // no further clipboard changed notifications + //m_pImpl->unregisterClipboardViewer(); + } + + } // end if + } // end if + } // end if +} + +// ------------------------------------------------------------------------ + +Sequence< OUString > SAL_CALL Os2Clipboard_getSupportedServiceNames() +{ + Sequence< OUString > aRet(1); + aRet[0] = OUString::createFromAscii( OS2_CLIPBOARD_SERVICE_NAME ); + return aRet; +} + +// ------------------------------------------------------------------------ + +Reference< XInterface > SAL_CALL Os2Clipboard_createInstance( + const Reference< XMultiServiceFactory > & xMultiServiceFactory) +{ + return Reference < XInterface >( ( OWeakObject * ) new Os2Clipboard()); +} + diff --git a/dtrans/source/os2/clipb/Os2Clipboard.hxx b/dtrans/source/os2/clipb/Os2Clipboard.hxx new file mode 100644 index 000000000000..9b043bda3262 --- /dev/null +++ b/dtrans/source/os2/clipb/Os2Clipboard.hxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: Os2Clipboard.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ + * + * 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 _OS2CLIPBOARD_HXX_ +#define _OS2CLIPBOARD_HXX_ + +#ifndef _RTL_USTRING_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#include <cppuhelper/compbase4.hxx> +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_ +#include <com/sun/star/datatransfer/clipboard/XClipboardEx.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_XCLIPBOARDLISTENER_HPP_ +#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> +#endif + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_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 + +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_RENDERINGCAPABILITIES_HPP_ +#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp> +#endif + +#ifndef _DTRANS_OS2_TRANSFERABLE_HXX_ +#include "Os2Transferable.hxx" +#endif + +// the service names +#define OS2_CLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard" + +// the implementation names +#define OS2_CLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.Os2Clipboard" + +// the registry key names +#define OS2_CLIPBOARD_REGKEY_NAME "/com.sun.star.datatransfer.clipboard.Os2Clipboard/UNO/SERVICES/com.sun.star.datatransfer.clipboard.SystemClipboard" + +namespace os2 { + +class Os2Clipboard : + //public cppu::WeakComponentImplHelper3< ::com::sun::star::datatransfer::clipboard::XClipboardEx, ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, ::com::sun::star::lang::XServiceInfo > + 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 > +{ + +public: + Os2Clipboard(); + ~Os2Clipboard(); + + /* + * 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 >& 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 ); + + /* + * 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 ); + void SAL_CALL notifyAllClipboardListener( ); + +public: + sal_Bool m_bInSetClipboardData; + +private: + HAB hAB; + HWND hObjWnd; + + ::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; + +}; + +} // namespace Os2 + +// ------------------------------------------------------------------------ + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Os2Clipboard_getSupportedServiceNames(); +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Os2Clipboard_createInstance( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory); + +#endif + diff --git a/dtrans/source/os2/clipb/Os2Service.cxx b/dtrans/source/os2/clipb/Os2Service.cxx new file mode 100644 index 000000000000..1ec677dd2bd2 --- /dev/null +++ b/dtrans/source/os2/clipb/Os2Service.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: Os2Service.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-09-20 16:39:13 $ + * + * 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 _OS2CLIPBOARD_HXX_ +#include "Os2Clipboard.hxx" +#endif + +#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 + +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; +using namespace os2; + +namespace os2 { + +Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) +{ + return Reference< XInterface >( static_cast< XClipboard* >( new Os2Clipboard() ) ); +} + +} // namespace os2 + +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 ) +{ + sal_Bool bRetVal = sal_False; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_CLIPBOARD_REGKEY_NAME ) ) ); + bRetVal = sal_True; + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE(sal_False, "InvalidRegistryException caught"); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +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, OS2_CLIPBOARD_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_CLIPBOARD_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" |