summaryrefslogtreecommitdiff
path: root/dtrans/source/os2/clipb
diff options
context:
space:
mode:
Diffstat (limited to 'dtrans/source/os2/clipb')
-rw-r--r--dtrans/source/os2/clipb/OS2Bitmap.cxx248
-rw-r--r--dtrans/source/os2/clipb/Os2Clipboard.cxx447
-rw-r--r--dtrans/source/os2/clipb/Os2Clipboard.hxx136
-rw-r--r--dtrans/source/os2/clipb/Os2Service.cxx106
-rw-r--r--dtrans/source/os2/clipb/Os2Transferable.cxx176
-rw-r--r--dtrans/source/os2/clipb/Os2Transferable.hxx99
-rw-r--r--dtrans/source/os2/clipb/exports.dxp4
-rw-r--r--dtrans/source/os2/clipb/makefile.mk59
-rw-r--r--dtrans/source/os2/clipb/sysdtrans.xml43
9 files changed, 1318 insertions, 0 deletions
diff --git a/dtrans/source/os2/clipb/OS2Bitmap.cxx b/dtrans/source/os2/clipb/OS2Bitmap.cxx
new file mode 100644
index 000000000000..53b78c7afaef
--- /dev/null
+++ b/dtrans/source/os2/clipb/OS2Bitmap.cxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * This code is property of Serenity Systems Intl
+ * All rights reserverd.
+ *
+ ************************************************************************/
+
+#define INCL_WIN
+#include <svpm.h>
+
+#ifndef _OS2CLIPBOARD_HXX_
+#include "Os2Clipboard.hxx"
+#endif
+
+// same typedefs from win32 sdk
+typedef unsigned short WORD;
+typedef unsigned long DWORD;
+
+#pragma pack(push, 1)
+
+typedef struct {
+ PM_BYTE rgbBlue;
+ PM_BYTE rgbGreen;
+ PM_BYTE rgbRed;
+ PM_BYTE rgbReserved;
+} RGBQUAD, *LPRGBQUAD;
+
+typedef struct
+{
+ WORD bfType;
+ DWORD bfSize;
+ WORD bfReserved1;
+ WORD bfReserved2;
+ DWORD bfOffBits;
+} W32_BITMAPFILEHEADER, *PW32_BITMAPFILEHEADER;
+
+typedef struct
+{
+ DWORD biSize;
+ LONG biWidth;
+ LONG biHeight;
+ WORD biPlanes;
+ WORD biBitCount;
+ DWORD biCompression;
+ DWORD biSizeImage;
+ LONG biXPelsPerMeter;
+ LONG biYPelsPerMeter;
+ DWORD biClrUsed;
+ DWORD biClrImportant;
+} W32_BITMAPINFOHEADER, *PW32_BITMAPINFOHEADER;
+
+#pragma pack(pop)
+
+// store screen bitcount
+LONG lBitCountScreen;
+
+/*
+ * Convert an OOo bitmap to an OS/2 bitmap handle
+ *
+ * An OOo bitmap is a BITMAPFILEHEADER structure followed by a Windows DIB
+ *
+ * OS/2 InfoHeader is a superset of Win32 InhoHeader, so we can just copy
+ * the win32 memory over the os2 memory and fix the cbFix field.
+ * colortable and bitmap data share the same format.
+ *
+*/
+HBITMAP OOoBmpToOS2Handle( Any &aAnyB)
+{
+ // copy bitmap to clipboard
+ Sequence<sal_Int8> ByteStream;
+ aAnyB >>= ByteStream;
+
+ // get w32 file header data
+ PW32_BITMAPFILEHEADER pbfh = (PW32_BITMAPFILEHEADER)ByteStream.getArray();
+ // get w32 info header
+ PW32_BITMAPINFOHEADER pbih = (PW32_BITMAPINFOHEADER) (pbfh+1);
+
+ // create os2 infoheader2 (same fields of w32)
+ BITMAPINFOHEADER2 bih2;
+ memset( &bih2, 0, sizeof( bih2));
+ memcpy( &bih2, pbih, pbih->biSize);
+ bih2.cbFix = sizeof(bih2);
+
+ // Determine size of color table
+ int iNumColors, numbits=bih2.cPlanes * bih2.cBitCount;
+ if (numbits != 24)
+ iNumColors = bih2.cclrUsed ? bih2.cclrUsed : 2<<numbits;
+ else
+ iNumColors = bih2.cclrUsed;
+ int iColorTableSize = iNumColors*sizeof(RGB2);
+
+ // allocate bitmap info2 (header2+colortable)
+ PBITMAPINFO2 pbi2=(PBITMAPINFO2) malloc( sizeof(BITMAPINFOHEADER2)+iColorTableSize);
+ // setup header fields
+ memcpy( pbi2, &bih2, sizeof(BITMAPINFOHEADER2));
+ // copy color palette (follows pbih)
+ memcpy( &pbi2->argbColor[0], (pbih+1), iColorTableSize);
+
+ // get bitmap data
+ PBYTE pbPelData = (PBYTE)ByteStream.getArray() + pbfh->bfOffBits;
+ HPS hps = WinGetPS(HWND_DESKTOP);
+ HBITMAP hbm = GpiCreateBitmap( hps, &bih2, CBM_INIT, pbPelData, pbi2);
+ debug_printf( "OOoBmpToOS2Handle hbm %x\n", hbm);
+ WinReleasePS(hps);
+
+ // return handle
+ return hbm;
+}
+
+/*
+ * Convert an OS/2 bitmap handle to OOo bitmap
+ *
+ * First we need to copy the bitmap to a PS, then we can get bitmap data.
+ *
+*/
+int OS2HandleToOOoBmp( HBITMAP hbm, Sequence< sal_Int8 >* OOoDIBStream)
+{
+ HAB hab = WinQueryAnchorBlock(HWND_DESKTOP);
+ HDC hdc;
+ SIZEL sizl;
+ HPS hps;
+ PM_BYTE* pbBuffer;
+ ULONG cbBuffer;
+
+ struct {
+ BITMAPINFOHEADER2 bmp2;
+ RGB2 argb2Color[0x100];
+ } bm;
+
+ if (!lBitCountScreen) {
+ HPS hps = WinGetPS(HWND_DESKTOP);
+ HDC hdc = GpiQueryDevice(hps);
+ DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &lBitCountScreen);
+ WinReleasePS(hps);
+ }
+
+ // STEP 1: get OS/2 bitmap data and header
+ // get bitmap header
+ memset(&(bm.bmp2), 0, sizeof(bm.bmp2));
+ bm.bmp2.cbFix = 16;
+ GpiQueryBitmapInfoHeader(hbm, &bm.bmp2);
+
+ /* Data only actually stored in clipboard quality */
+ if ( lBitCountScreen < bm.bmp2.cBitCount )
+ bm.bmp2.cBitCount = lBitCountScreen;
+
+ if ( bm.bmp2.cBitCount == 16 )
+ bm.bmp2.cBitCount = 24;
+
+ if ( bm.bmp2.cPlanes != 1 ) {
+ return 0;
+ }
+
+ if ( (hdc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, (HDC) NULL)) == (HDC) NULL ) {
+ return 0;
+ }
+
+ sizl.cx = bm.bmp2.cx;
+ sizl.cy = bm.bmp2.cy;
+ if ( (hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC)) == (HPS) NULL ) {
+ DevCloseDC(hdc);
+ return 0;
+ }
+ // copy bitmap to hps
+ GpiSetBitmap(hps, hbm);
+
+ // buffer lengths
+ cbBuffer = (((bm.bmp2.cBitCount * bm.bmp2.cx) + 31) / 32) * 4 * bm.bmp2.cy * bm.bmp2.cPlanes;
+ pbBuffer = (PM_BYTE*) malloc( cbBuffer);
+ // now get bitmap data
+ GpiQueryBitmapBits(hps, 0L, (LONG) bm.bmp2.cy, pbBuffer, (BITMAPINFO2*)&bm);
+ // free OS/2 resources
+ GpiSetBitmap(hps, (HBITMAP) NULL);
+ GpiDestroyPS(hps);
+ DevCloseDC(hdc);
+
+ // STEP 2: now convert to Win32 DIB
+ // Determine size of color table
+ int iNumColors, numbits=bm.bmp2.cPlanes * bm.bmp2.cBitCount;
+ if (numbits != 24)
+ iNumColors = bm.bmp2.cclrUsed ? bm.bmp2.cclrUsed : 2<<numbits;
+ else
+ iNumColors = bm.bmp2.cclrUsed;
+ int iColorTableSize = iNumColors*sizeof(RGBQUAD);
+
+ // reallocate data stream object size
+ OOoDIBStream->realloc( sizeof( W32_BITMAPFILEHEADER )
+ + sizeof( W32_BITMAPINFOHEADER) + iColorTableSize + cbBuffer);
+
+ // fill w32 file header data
+ PW32_BITMAPFILEHEADER pbfh = (PW32_BITMAPFILEHEADER) OOoDIBStream->getArray();
+ memset( pbfh, 0, sizeof( W32_BITMAPFILEHEADER));
+ pbfh->bfType = 'MB';
+ pbfh->bfSize = sizeof( W32_BITMAPFILEHEADER )
+ + sizeof( W32_BITMAPINFOHEADER) + iColorTableSize + cbBuffer;
+ pbfh->bfOffBits = sizeof( W32_BITMAPFILEHEADER) + sizeof( W32_BITMAPINFOHEADER) + iColorTableSize;
+
+ // fill w32 info header
+ PW32_BITMAPINFOHEADER pbih = (PW32_BITMAPINFOHEADER) (pbfh+1);
+ // copy header fields (only win32 ones) and fix size
+ memcpy( pbih, &bm.bmp2, sizeof(W32_BITMAPINFOHEADER));
+ pbih->biSize = sizeof(W32_BITMAPINFOHEADER);
+
+ // fill color palette (follows pbih)
+ memcpy( (pbih+1), &bm.argb2Color[0], iColorTableSize);
+
+ // fill bitmap data
+ memcpy( (char*) pbfh + pbfh->bfOffBits, pbBuffer, cbBuffer);
+
+ // done
+ free( pbBuffer);
+ return 1;
+}
+
+#ifdef TESTBMP
+
+#include <io.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main( void)
+{
+ HAB hAB = WinQueryAnchorBlock( HWND_DESKTOP );
+
+ // query clipboard data to get mimetype
+ if( WinOpenClipbrd( hAB ) )
+ {
+ ULONG handle = WinQueryClipbrdData( hAB, CF_BITMAP);
+ if (handle) {
+ Sequence< sal_Int8 > winDIBStream;
+ // convert to oustring and return it
+ if (OS2HandleToOOoBmp( handle, &winDIBStream) == 1) {
+ printf( "Conversion ok.\n");
+ int fd = open( "test.bmp", O_BINARY | O_CREAT | O_TRUNC | O_RDWR);
+ printf( "writing to fd %d\n", fd);
+ write( fd, winDIBStream.getArray(), winDIBStream.getLength());
+ close( fd);
+ } else
+ printf( "failed conversion.\n");
+
+ }
+ WinCloseClipbrd( hAB);
+ }
+ return 0;
+}
+
+#endif //TESTBMP
+
diff --git a/dtrans/source/os2/clipb/Os2Clipboard.cxx b/dtrans/source/os2/clipb/Os2Clipboard.cxx
new file mode 100644
index 000000000000..494df04b640a
--- /dev/null
+++ b/dtrans/source/os2/clipb/Os2Clipboard.cxx
@@ -0,0 +1,447 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#include "Os2Clipboard.hxx"
+
+//------------------------------------------------------------------------
+// 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 );
+ hText = 0;
+ hBitmap = 0;
+
+#if 0
+ // 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);
+ }
+#endif
+
+}
+
+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);
+
+ // os2 can have only one viewer at time, and we don't get a notification
+ // when the viewer changes. So we need to check handles of clipboard
+ // data and compare with previous handles
+ if (UWinOpenClipbrd(hAB)) {
+ sal_Bool fireChanged = sal_False;
+ ULONG handle = UWinQueryClipbrdData( hAB, UCLIP_CF_UNICODETEXT);
+ if (handle) {
+ if (handle != hText) {
+ hText = handle;
+ fireChanged = sal_True;
+ }
+ }
+ handle = UWinQueryClipbrdData( hAB, UCLIP_CF_BITMAP);
+ if (handle) {
+ if (handle != hBitmap) {
+ hBitmap = handle;
+ fireChanged = sal_True;
+ }
+ }
+ UWinCloseClipbrd( hAB);
+ if (fireChanged)
+ {
+ // notify listener for clipboard change
+ debug_printf("Os2Clipboard::getContents notify change\n");
+ notifyAllClipboardListener();
+ }
+ }
+
+ 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)
+ PSZ pSharedText = NULL;
+ HBITMAP hbm = NULL;
+ try
+ {
+ Any aAny = m_aContents->getTransferData( nFlavorText );
+ if (aAny.hasValue())
+ {
+ APIRET rc;
+ // copy unicode text to clipboard
+ OUString aString;
+ aAny >>= aString;
+ // share text
+ rc = DosAllocSharedMem( (PPVOID) &pSharedText, NULL,
+ aString.getLength() * 2 + 2,
+ PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_ANY);
+ if (!rc)
+ memcpy( pSharedText, aString.getStr(), aString.getLength() * 2 + 2 );
+ else
+ pSharedText = NULL;
+ 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())
+ {
+ hbm = OOoBmpToOS2Handle( aAnyB);
+ debug_printf("Os2Clipboard::setContents SetClipbrdData bitmap done\n");
+ }
+ } catch ( UnsupportedFlavorException&) {
+ debug_printf("Os2Clipboard::setContents UnsupportedFlavorException (no bitmap)\n");
+ }
+
+ // copy to clipboard
+ if ( UWinOpenClipbrd( hAB) && (pSharedText || hbm))
+ {
+ // 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!)
+ if (pSharedText) {
+ UWinSetClipbrdData( hAB, (ULONG) pSharedText, UCLIP_CF_UNICODETEXT, CFI_POINTER);
+ // update internal handle to avoid detection of this text as new data
+ hText = (ULONG)pSharedText;
+ }
+ // give bitmap to clipboard
+ if (hbm) {
+ UWinSetClipbrdData( hAB, (ULONG) hbm, UCLIP_CF_BITMAP, CFI_HANDLE);
+ // update internal handle to avoid detection of this bitmap as new data
+ hBitmap = hbm;
+ }
+ // reset the flag, so we will not ignore next WM_DRAWCLIPBOARD
+ m_bInSetClipboardData = sal_False;
+ UWinCloseClipbrd( hAB);
+ }
+
+}
+
+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..0a9f4d117464
--- /dev/null
+++ b/dtrans/source/os2/clipb/Os2Clipboard.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * 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 _OS2CLIPBOARD_HXX_
+#define _OS2CLIPBOARD_HXX_
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <cppuhelper/compbase4.hxx>
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
+#include "Os2Transferable.hxx"
+
+// 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;
+ ULONG hText, hBitmap; // handles to previous clipboard data
+
+ ::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..cc3e1e9a9b94
--- /dev/null
+++ b/dtrans/source/os2/clipb/Os2Service.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "Os2Clipboard.hxx"
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/container/XSet.hpp>
+#include <osl/diagnose.h>
+
+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"
diff --git a/dtrans/source/os2/clipb/Os2Transferable.cxx b/dtrans/source/os2/clipb/Os2Transferable.cxx
new file mode 100644
index 000000000000..fe8c77105e90
--- /dev/null
+++ b/dtrans/source/os2/clipb/Os2Transferable.cxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+
+#define INCL_WIN
+#include <svpm.h>
+
+#include <string.h>
+#include <com/sun/star/io/IOException.hpp>
+#include "Os2Transferable.hxx"
+
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+using namespace os2;
+
+// =======================================================================
+
+Os2Transferable::Os2Transferable(
+ const Reference< XInterface >& xCreator ) :
+ m_xCreator( xCreator )
+{
+ debug_printf("Os2Transferable::Os2Transferable %08x\n", this);
+ hAB = WinQueryAnchorBlock( HWND_DESKTOP );
+
+ // query clipboard data to get mimetype
+ if( UWinOpenClipbrd( hAB ) )
+ {
+ ULONG handle = UWinQueryClipbrdData( hAB, UCLIP_CF_UNICODETEXT);
+ if (handle) {
+ aFlavor.MimeType = OUString::createFromAscii( "text/plain;charset=utf-16" );
+ aFlavor.DataType = getCppuType( (OUString*)0 );
+ //debug_printf("Os2Transferable::Os2Transferable pszText %s\n", pszText);
+ }
+ handle = UWinQueryClipbrdData( hAB, UCLIP_CF_BITMAP);
+ if (handle) {
+ aFlavor.MimeType = OUString::createFromAscii( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" );
+ aFlavor.DataType = getCppuType( (OUString*)0 );
+ //debug_printf("Os2Transferable::Os2Transferable pszText %s\n", pszText);
+ }
+ UWinCloseClipbrd( hAB);
+ }
+ else
+ {
+ debug_printf("Os2Transferable::Os2Transferable failed to open clipboard\n");
+ }
+
+}
+
+//==================================================================================================
+
+Os2Transferable::~Os2Transferable()
+{
+ debug_printf("Os2Transferable::~Os2Transferable %08x\n", this);
+}
+
+//==================================================================================================
+
+Any SAL_CALL Os2Transferable::getTransferData( const DataFlavor& rFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ debug_printf("Os2Transferable::getTransferData %08x\n", this);
+ debug_printf("Os2Transferable::getTransferData mimetype: %s\n", CHAR_POINTER(rFlavor.MimeType));
+ Any aRet;
+ Sequence< sal_Int8 > aData;
+
+ // retrieve unicode text
+ if( rFlavor.MimeType.equalsIgnoreAsciiCase( OUString::createFromAscii( "text/plain;charset=utf-16" ) ) )
+ {
+ if( UWinOpenClipbrd( hAB ) )
+ {
+ // check if clipboard has text format
+ sal_Unicode* pszText = (sal_Unicode*) UWinQueryClipbrdData( hAB, UCLIP_CF_UNICODETEXT);
+ if (pszText) {
+ // convert to oustring and return it
+ OUString aString( pszText);
+ aRet <<= aString;
+ }
+ UWinCloseClipbrd( hAB );
+ if (pszText)
+ return aRet;
+ }
+ }
+
+ // retrieve bitmap
+ if( rFlavor.MimeType.equalsIgnoreAsciiCase( OUString::createFromAscii( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" ) ) )
+ {
+ if( UWinOpenClipbrd( hAB ) )
+ {
+ // check if clipboard has text format
+ ULONG handle = UWinQueryClipbrdData( hAB, UCLIP_CF_BITMAP);
+ if (handle) {
+ Sequence< sal_Int8 > winDIBStream;
+ // convert to oustring and return it
+ if (OS2HandleToOOoBmp( handle, &winDIBStream))
+ aRet <<= winDIBStream;
+ else
+ handle = 0;
+ }
+ UWinCloseClipbrd( hAB );
+ if (handle)
+ return aRet;
+ }
+ }
+
+ // clipboard format unsupported, throw exception
+ throw UnsupportedFlavorException( rFlavor.MimeType, static_cast < XTransferable * > ( this ) );
+}
+
+//==================================================================================================
+
+Sequence< DataFlavor > SAL_CALL Os2Transferable::getTransferDataFlavors()
+ throw(RuntimeException)
+{
+ debug_printf("Os2Transferable::getTransferDataFlavors %08x\n", this);
+ Sequence< DataFlavor > aFlavorList(1);
+ aFlavorList[0] = aFlavor;
+ debug_printf("Os2Transferable::getTransferDataFlavors mimetype: %s\n", CHAR_POINTER(aFlavor.MimeType));
+ return aFlavorList;
+}
+
+//==================================================================================================
+
+sal_Bool SAL_CALL Os2Transferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ debug_printf("Os2Transferable::isDataFlavorSupported %08x\n", this);
+ debug_printf("Os2Transferable::isDataFlavorSupported %s\n", CHAR_POINTER(aFlavor.MimeType));
+
+ if( aFlavor.DataType != getCppuType( (Sequence< sal_Int8 >*)0 ) )
+ {
+ if( ! aFlavor.MimeType.equalsIgnoreAsciiCase( OUString::createFromAscii( "text/plain;charset=utf-16" ) ) &&
+ aFlavor.DataType == getCppuType( (OUString*)0 ) )
+ return false;
+ }
+
+ Sequence< DataFlavor > aFlavors( getTransferDataFlavors() );
+ for( int i = 0; i < aFlavors.getLength(); i++ )
+ if( aFlavor.MimeType.equalsIgnoreAsciiCase( aFlavors.getConstArray()[i].MimeType ) &&
+ aFlavor.DataType == aFlavors.getConstArray()[i].DataType )
+ return sal_True;
+
+ return sal_False;
+}
+
diff --git a/dtrans/source/os2/clipb/Os2Transferable.hxx b/dtrans/source/os2/clipb/Os2Transferable.hxx
new file mode 100644
index 000000000000..833aa2680a8a
--- /dev/null
+++ b/dtrans/source/os2/clipb/Os2Transferable.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * 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_OS2_TRANSFERABLE_HXX_
+#define _DTRANS_OS2_TRANSFERABLE_HXX_
+
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+
+#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HDL_
+#include <com/sun/star/lang/XEventListener.hpp>
+#endif
+#include <cppuhelper/implbase1.hxx>
+#include <osl/thread.h>
+
+#include <errno.h>
+
+#include <uclip.h>
+
+#define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer
+
+#if OSL_DEBUG_LEVEL>1
+//extern "C" int debug_printf(const char *f, ...);
+#define debug_printf( ...) { 1; }
+#else
+#define debug_printf( ...) { 1; }
+#endif
+
+#define CPPUTYPE_SEQSALINT8 getCppuType( (const Sequence< sal_Int8 >*) 0 )
+#define CPPUTYPE_DEFAULT CPPUTYPE_SEQSALINT8
+
+#ifdef OOO_VENDOR
+using namespace com::sun::star::uno;
+HBITMAP OOoBmpToOS2Handle( Any &aAnyB);
+int OS2HandleToOOoBmp( HBITMAP hbm, Sequence< sal_Int8 >* winDIBStream);
+#else
+#define OOoBmpToOS2Handle(a) 0
+#define OS2HandleToOOoBmp(a,b) 0
+#endif
+
+namespace os2 {
+
+ class Os2Transferable : public ::cppu::WeakImplHelper1 <
+ ::com::sun::star::datatransfer::XTransferable >
+ {
+ HAB hAB;
+ ::rtl::OUString clipText;
+ ::com::sun::star::datatransfer::DataFlavor aFlavor;
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Reference< XInterface > m_xCreator;
+
+ public:
+ Os2Transferable( const ::com::sun::star::uno::Reference< XInterface >& xCreator);
+ virtual ~Os2Transferable();
+
+ /*
+ * XTransferable
+ */
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw(::com::sun::star::datatransfer::UnsupportedFlavorException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::uno::RuntimeException
+ );
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
+ throw(::com::sun::star::uno::RuntimeException);
+ };
+
+} // namespace
+
+#endif
+
diff --git a/dtrans/source/os2/clipb/exports.dxp b/dtrans/source/os2/clipb/exports.dxp
new file mode 100644
index 000000000000..f72beb0fcb31
--- /dev/null
+++ b/dtrans/source/os2/clipb/exports.dxp
@@ -0,0 +1,4 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+
diff --git a/dtrans/source/os2/clipb/makefile.mk b/dtrans/source/os2/clipb/makefile.mk
new file mode 100644
index 000000000000..a1ccc1ae87ec
--- /dev/null
+++ b/dtrans/source/os2/clipb/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# 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=sysdtrans
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+COMPRDB=$(SOLARBINDIR)$/types.rdb
+USE_BOUNDCHK=
+
+.IF "$(USE_BOUNDCHK)"=="TR"
+bndchk=tr
+stoponerror=tr
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+SLOFILES= $(SLO)$/Os2Clipboard.obj \
+ $(SLO)$/Os2Service.obj \
+ $(SLO)$/Os2Transferable.obj
+
+.IF "$(OOO_VENDOR)"=="Serenity Systems Intl"
+SLOFILES+= $(SLO)$/OS2Bitmap.obj
+CDEFS+=-DOOO_VENDOR
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/dtrans/source/os2/clipb/sysdtrans.xml b/dtrans/source/os2/clipb/sysdtrans.xml
new file mode 100644
index 000000000000..a6dec8a03a42
--- /dev/null
+++ b/dtrans/source/os2/clipb/sysdtrans.xml
@@ -0,0 +1,43 @@
+<?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> sysdtrans </module-name>
+ <component-description>
+ <author> Tino Rachui </author>
+ <name> com.sun.star.comp.datatransfer.SystemClipboard </name>
+ <description>
+ The win32 implementation of the datatransfer service.
+</description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.datatransfer.clipboard.SystemClipboard </supported-service>
+ <service-dependency> ... </service-dependency>
+ <type> com.sun.star.datatransfer.clipboard.XClipboardEx </type>
+ <type> com.sun.star.datatransfer.XTransferable </type>
+ <type> com.sun.star.datatransfer.XTransferableEx </type>
+ <type> com.sun.star.datatransfer.clipboard.XClipboardOwner</type>
+ <type> com.sun.star.datatransfer.clipboard.XClipboardListener</type>
+ <type> com.sun.star.datatransfer.clipboard.XClipboardNotifier</type>
+ <type> com.sun.star.datatransfer.clipboard.XFlushableClipboard</type>
+ <type> com.sun.star.datatransfer.clipboard.RenderingCapabilities</type>
+ <type> com.sun.star.datatransfer.XTransferDataAccess </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.container.XSet </type>
+ </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>