summaryrefslogtreecommitdiff
path: root/sal/workben/clipboardwben/testcopy
diff options
context:
space:
mode:
Diffstat (limited to 'sal/workben/clipboardwben/testcopy')
-rw-r--r--sal/workben/clipboardwben/testcopy/StdAfx.cpp8
-rw-r--r--sal/workben/clipboardwben/testcopy/StdAfx.h32
-rw-r--r--sal/workben/clipboardwben/testcopy/TestWin32.icobin0 -> 1590 bytes
-rw-r--r--sal/workben/clipboardwben/testcopy/XTDataObject.cxx470
-rw-r--r--sal/workben/clipboardwben/testcopy/XTDataObject.hxx132
-rw-r--r--sal/workben/clipboardwben/testcopy/cbcpytest.cxx402
-rw-r--r--sal/workben/clipboardwben/testcopy/cbcpytest.rc122
-rw-r--r--sal/workben/clipboardwben/testcopy/makefile.mk67
-rw-r--r--sal/workben/clipboardwben/testcopy/resource.h31
-rw-r--r--sal/workben/clipboardwben/testcopy/small.icobin0 -> 318 bytes
10 files changed, 1264 insertions, 0 deletions
diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.cpp b/sal/workben/clipboardwben/testcopy/StdAfx.cpp
new file mode 100644
index 000000000000..cb07d603f28f
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet
+// TestWin32.pch ist die vorkompilierte Header-Datei
+// stdafx.obj enthält die vorkompilierte Typinformation
+
+#include "stdafx.h"
+
+// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H
+// und nicht in dieser Datei benötigen
diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.h b/sal/workben/clipboardwben/testcopy/StdAfx.h
new file mode 100644
index 000000000000..bb762adbdc36
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/StdAfx.h
@@ -0,0 +1,32 @@
+// stdafx.h : Include-Datei für Standard-System-Include-Dateien,
+// oder projektspezifische Include-Dateien, die häufig benutzt, aber
+// in unregelmäßigen Abständen geändert werden.
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden
+
+
+// Windows-Header-Dateien:
+#include <windows.h>
+
+// Header-Dateien der C-Laufzeit
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+// Lokale Header-Dateien
+
+// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/sal/workben/clipboardwben/testcopy/TestWin32.ico b/sal/workben/clipboardwben/testcopy/TestWin32.ico
new file mode 100644
index 000000000000..255ff3be4fba
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/TestWin32.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
new file mode 100644
index 000000000000..14887dd9021c
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
@@ -0,0 +1,470 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+
+#ifndef _TWRAPPERDATAOBJECT_HXX_
+#include "XTDataObject.hxx"
+#endif
+
+#include <windows.h>
+#include <ole2.h>
+#include <memory>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+
+//============================================================================
+// OTWrapperDataObject
+//============================================================================
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+CXTDataObject::CXTDataObject( LONG nRefCntInitVal ) :
+ m_nRefCnt( nRefCntInitVal )
+{
+}
+
+//------------------------------------------------------------------------
+// dtor
+//------------------------------------------------------------------------
+
+CXTDataObject::~CXTDataObject( )
+{
+}
+
+//------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ OSL_ASSERT( NULL != ppvObject );
+
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ ( (LPUNKNOWN)*ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IUnknown->AddRef
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::AddRef( )
+{
+ return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
+}
+
+//------------------------------------------------------------------------
+// IUnknown->Release
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::Release( )
+{
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
+
+ if ( 0 == nRefCnt )
+ {
+ delete this;
+ }
+
+ return nRefCnt;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetData
+// warning: 'goto' ahead (to easy error handling without using exceptions)
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
+{
+ OSL_ASSERT( ( NULL != pFormatetc ) &&
+ ( !IsBadReadPtr( (LPVOID)pFormatetc, sizeof( FORMATETC ) ) ) );
+ OSL_ASSERT( ( NULL != pmedium ) &&
+ ( !IsBadWritePtr( (LPVOID)pmedium, sizeof( STGMEDIUM ) ) ) );
+
+ if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ if ( CF_TEXT == pFormatetc->cfFormat )
+ {
+ char buff[] = "Hello World, How are you!";
+ LPSTREAM lpStream;
+
+ hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = lpStream->Write( buff, sizeof( buff ) * sizeof( char ), NULL );
+ if ( SUCCEEDED( hr ) )
+ {
+ HGLOBAL hGlob;
+
+ GetHGlobalFromStream( lpStream, &hGlob );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlob;
+ pmedium->pUnkForRelease = NULL;
+ }
+ lpStream->Release( );
+ hr = S_OK;
+ }
+ else
+ {
+ pmedium->tymed = TYMED_NULL;
+ }
+ }
+ else if ( CF_UNICODETEXT == pFormatetc->cfFormat )
+ {
+ WCHAR buff[] = L"Hello World, How are you!";
+ LPSTREAM lpStream;
+
+ hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = lpStream->Write( buff, sizeof( buff ) * sizeof( WCHAR ), NULL );
+ if ( SUCCEEDED( hr ) )
+ {
+ HGLOBAL hGlob;
+
+ GetHGlobalFromStream( lpStream, &hGlob );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlob;
+ pmedium->pUnkForRelease = NULL;
+ }
+ lpStream->Release( );
+ hr = S_OK;
+ }
+ else
+ {
+ pmedium->tymed = TYMED_NULL;
+ }
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
+{
+ if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
+ return E_INVALIDARG;
+
+ *ppenumFormatetc = NULL;
+
+ HRESULT hr = E_FAIL;
+
+ if ( DATADIR_GET == dwDirection )
+ {
+ *ppenumFormatetc = new CEnumFormatEtc( this );
+ static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->QueryGetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetDataHere
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetCanonicalFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->SetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DUnadvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DUnadvise( DWORD )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumDAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// for our convenience
+//------------------------------------------------------------------------
+
+CXTDataObject::operator IDataObject*( )
+{
+ return static_cast< IDataObject* >( this );
+}
+
+
+//============================================================================
+// CEnumFormatEtc
+//============================================================================
+
+
+//----------------------------------------------------------------------------
+// ctor
+//----------------------------------------------------------------------------
+
+CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) :
+ m_nRefCnt( 0 ),
+ m_pUnkDataObj( pUnkDataObj ),
+ m_nCurrentPos( 0 )
+{
+ m_cfFormats[0] = CF_UNICODETEXT;
+ m_cfFormats[1] = CF_TEXT;
+}
+
+//----------------------------------------------------------------------------
+// dtor
+//----------------------------------------------------------------------------
+
+CEnumFormatEtc::~CEnumFormatEtc( )
+{
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ static_cast< LPUNKNOWN >( *ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->AddRef
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( )
+{
+ // keep the dataobject alive
+ m_pUnkDataObj->AddRef( );
+ return InterlockedIncrement( &m_nRefCnt );
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->Release
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
+{
+ // release the outer dataobject
+ m_pUnkDataObj->Release( );
+
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt );
+ if ( 0 == nRefCnt )
+ delete this;
+
+ return nRefCnt;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Next
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched )
+{
+ OSL_ASSERT( ( ( celt > 0 ) && ( NULL != rgelt ) ) ||
+ ( ( 0 == celt ) && ( NULL == rgelt ) ) );
+
+ if ( ( 0 != celt ) && ( NULL == rgelt ) )
+ return E_INVALIDARG;
+
+ ULONG ulFetched = 0;
+ ULONG ulToFetch = celt;
+ HRESULT hr = S_FALSE;
+
+ while( ( m_nCurrentPos < sizeof( m_cfFormats ) ) && ( ulToFetch > 0 ) )
+ {
+ OSL_ASSERT( !IsBadWritePtr( (LPVOID)rgelt, sizeof( FORMATETC ) ) );
+
+ rgelt->cfFormat = m_cfFormats[m_nCurrentPos];
+ rgelt->ptd = NULL;
+ rgelt->dwAspect = DVASPECT_CONTENT;
+ rgelt->lindex = -1;
+ rgelt->tymed = TYMED_HGLOBAL;
+
+ ++m_nCurrentPos;
+ ++rgelt;
+ --ulToFetch;
+ ++ulFetched;
+ }
+
+ if ( ulFetched == celt )
+ hr = S_OK;
+
+ if ( NULL != pceltFetched )
+ {
+ OSL_ASSERT( !IsBadWritePtr( (LPVOID)pceltFetched, sizeof( ULONG ) ) );
+ *pceltFetched = ulFetched;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Skip
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt )
+{
+ HRESULT hr = S_FALSE;
+
+ if ( ( m_nCurrentPos + celt ) < sizeof( m_cfFormats ) )
+ {
+ m_nCurrentPos += celt;
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Reset
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Reset( )
+{
+ m_nCurrentPos = 0;
+ return S_OK;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Clone
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
+{
+ OSL_ASSERT( NULL != ppenum );
+
+ if ( NULL == ppenum )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ *ppenum = NULL;
+
+ CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj );
+ if ( NULL != pCEnumFEtc )
+ {
+ pCEnumFEtc->m_nCurrentPos = m_nCurrentPos;
+ *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
+ static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
+ hr = NOERROR;
+ }
+
+ return hr;
+}
+
diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.hxx b/sal/workben/clipboardwben/testcopy/XTDataObject.hxx
new file mode 100644
index 000000000000..d2639b591590
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/XTDataObject.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * 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 _XTDATAOBJECT_HXX_
+#define _XTDATAOBJECT_HXX_
+
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+/*
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include "WinClipboard.hxx"
+*/
+
+#include <windows.h>
+#include <ole2.h>
+#include <objidl.h>
+
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+class EnumFormatEtc;
+
+class CXTDataObject : public IDataObject
+{
+public:
+ CXTDataObject( LONG nRefCntInitVal = 0);
+ ~CXTDataObject( );
+
+ //-----------------------------------------------------------------
+ // ole interface implementation
+ //-----------------------------------------------------------------
+
+ //IUnknown
+ STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IDataObject
+ 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*( );
+
+ // notification handler
+ //void SAL_CALL LostOwnership( );
+
+ //sal_Int64 SAL_CALL QueryDataSize( );
+
+ // retrieve the data from the source
+ // necessary so that
+ //void SAL_CALL GetAllDataFromSource( );
+
+private:
+ LONG m_nRefCnt;
+ //CWinClipboard& m_rCWinClipboard;
+ //const const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& m_rXClipboardOwner;
+ //const const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& m_rXTDataSource;
+
+ //friend class CWinClipboard;
+ friend class CEnumFormatEtc;
+};
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+class CEnumFormatEtc : public IEnumFORMATETC
+{
+public:
+ CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
+ ~CEnumFormatEtc( );
+
+ // IUnknown
+ STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject );
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IEnumFORMATETC
+ STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
+ STDMETHODIMP Skip( ULONG celt );
+ STDMETHODIMP Reset( );
+ STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
+
+private:
+ LONG m_nRefCnt;
+ LPUNKNOWN m_pUnkDataObj;
+ ULONG m_nCurrentPos;
+ CLIPFORMAT m_cfFormats[2];
+};
+
+
+typedef CEnumFormatEtc *PCEnumFormatEtc;
+
+#endif
diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.cxx b/sal/workben/clipboardwben/testcopy/cbcpytest.cxx
new file mode 100644
index 000000000000..1ce6c8cd2d76
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/cbcpytest.cxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+// TestWin32.cpp : Definiert den Einsprungpunkt für die Anwendung.
+//
+
+#define _WIN32_DCOM
+#undef _UNICODE
+
+#include "stdafx.h"
+
+#include <windows.h>
+
+#include <ole2.h>
+#include <objidl.h>
+#include <objbase.h>
+#include <process.h>
+#include <olectl.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <..\..\inc\systools\win32\MtaOleClipb.h>
+#include "XTDataObject.hxx"
+
+#include "resource.h"
+
+#define MAX_LOADSTRING 100
+#undef USE_MTACB
+
+#define MSG_FLUSHCLIPBOARD WM_USER + 1
+
+// Globale Variablen:
+HINSTANCE hInst; // aktuelle Instanz
+TCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile
+TCHAR szWindowClass[MAX_LOADSTRING]; // Text der Titelzeile
+ATOM MyRegisterClass( HINSTANCE hInstance );
+BOOL InitInstance( HINSTANCE, int );
+LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
+LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM );
+void CopyClipboardData(HWND hwndParent);
+void FlushClipboard( );
+void PasteData( HWND hWnd );
+void SetLocale();
+
+
+LPSTREAM g_pStm = NULL;
+char* pTextBuff = NULL;
+DWORD lData = 0;
+CXTDataObject* g_xtDo = NULL;
+HWND g_hWnd;
+HANDLE g_hEvent;
+BOOL g_bEnd;
+
+//----------------------------------------------------
+// a thread function
+//----------------------------------------------------
+
+unsigned int _stdcall ThreadProc(LPVOID pParam)
+{
+ while( !g_bEnd )
+ {
+ WaitForSingleObject( g_hEvent, INFINITE );
+ SendMessage( g_hWnd, MSG_FLUSHCLIPBOARD, WPARAM(0), LPARAM(0) );
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------
+// WinMain
+//----------------------------------------------------
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow )
+{
+ // ZU ERLEDIGEN: Fügen Sie hier den Code ein.
+ MSG msg;
+ HACCEL hAccelTable;
+ HRESULT hr = E_FAIL;
+
+ /*
+ g_hEvent = CreateEvent( 0,
+ FALSE,
+ FALSE,
+ NULL
+ );
+
+ g_bEnd = FALSE;
+
+ _beginthreadex( ThreadProc,
+ 0,
+ NULL,
+ 0,
+ 0,
+ NULL );
+ */
+
+ // it's important to initialize ole
+ // in order to use the clipboard
+#ifdef USE_MTACB
+ hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+#else
+ hr = OleInitialize( NULL );
+#endif
+
+
+ // Globale Zeichenfolgen initialisieren
+ LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ LoadString(hInstance, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(hInstance);
+
+ // Initialisierung der Anwendung durchführen:
+ if( !InitInstance( hInstance, nCmdShow ) )
+ {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32);
+
+ // Hauptnachrichtenschleife:
+ while( GetMessage(&msg, NULL, 0, 0) )
+ {
+ if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) )
+ {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ }
+
+ // uninitializing the ole libraries
+#ifdef USE_MTACB
+ CoUninitialize( );
+#else
+ OleUninitialize( );
+#endif
+
+ CloseHandle( g_hEvent );
+
+ return msg.wParam;
+}
+
+
+
+//----------------------------------------------------------------
+// FUNKTION: MyRegisterClass()
+//
+// AUFGABE: Registriert die Fensterklasse.
+//
+// KOMMENTARE:
+//
+// Diese Funktion und ihre Verwendung sind nur notwendig, wenn dieser Code
+// mit Win32-Systemen vor der 'RegisterClassEx'-Funktion kompatibel sein soll,
+// die zu Windows 95 hinzugefügt wurde. Es ist wichtig diese Funktion aufzurufen,
+// damit der Anwendung kleine Symbole mit den richtigen Proportionen zugewiesen
+// werden.
+//----------------------------------------------------------------
+
+ATOM MyRegisterClass( HINSTANCE hInstance )
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = (LPCTSTR)IDC_TESTWIN32;
+ wcex.lpszClassName = _T(szWindowClass);
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassEx(&wcex);
+}
+
+//----------------------------------------------------------------
+// FUNKTION: InitInstance(HANDLE, int)
+//
+// AUFGABE: Speichert die Instanzzugriffsnummer und erstellt das Hauptfenster
+//
+// KOMMENTARE:
+//
+// In dieser Funktion wird die Instanzzugriffsnummer in einer globalen Variable
+// gespeichert und das Hauptprogrammfenster erstellt und angezeigt.
+//----------------------------------------------------------------
+
+BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
+{
+ hInst = hInstance; // Instanzzugriffsnummer in unserer globalen Variable speichern
+
+ g_hWnd = CreateWindowEx(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ if( !g_hWnd )
+ {
+ return FALSE;
+ }
+
+ ShowWindow( g_hWnd, nCmdShow );
+ UpdateWindow( g_hWnd );
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------
+// FUNKTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// AUFGABE: Verarbeitet Nachrichten für das Hauptfenster.
+//
+// WM_COMMAND - Anwendungsmenü verarbeiten
+// WM_PAINT - Hauptfenster darstellen
+// WM_DESTROY - Beendigungsnachricht ausgeben und zurückkehren
+//----------------------------------------------------------------
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId;
+ int wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ TCHAR szHello[MAX_LOADSTRING];
+
+
+ LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+
+ switch( message )
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ // Menüauswahlen analysieren:
+ switch( wmId )
+ {
+ case IDD_COPY:
+ CopyClipboardData(hWnd);
+ break;
+ case IDD_PASTE2:
+ PasteData(hWnd);
+ break;
+ case IDD_LOCALE:
+ SetLocale();
+ break;
+ case IDM_EXIT:
+ DestroyWindow( hWnd );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ break;
+
+ case WM_PAINT:
+ hdc = BeginPaint (hWnd, &ps);
+ // ZU ERLEDIGEN: Hier beliebigen Code zum Zeichnen hinzufügen...
+ RECT rt;
+ GetClientRect( hWnd, &rt );
+
+ if ( NULL != pTextBuff )
+ {
+ DrawText( hdc, pTextBuff, lData, &rt, DT_CENTER );
+ }
+ else
+ {
+ DrawText( hdc, szHello, strlen(szHello), &rt, DT_CENTER );
+ }
+
+ EndPaint( hWnd, &ps );
+ break;
+
+ case WM_DESTROY:
+ g_bEnd = TRUE;
+ SetEvent( g_hEvent );
+ FlushClipboard( );
+ PostQuitMessage( 0 );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ return 0;
+}
+
+//----------------------------------------------
+// copy data into the clipboard
+//----------------------------------------------
+
+void CopyClipboardData( HWND hWnd )
+{
+ g_xtDo = new CXTDataObject( 1 );
+#ifdef USE_MTACB
+ MTASetClipboard( static_cast< IDataObject* >( g_xtDo ) );
+#else
+ OleSetClipboard( static_cast< IDataObject* >( g_xtDo ) );
+#endif
+}
+
+//----------------------------------------------
+// flush the content into the clipboard
+//----------------------------------------------
+
+void FlushClipboard( )
+{
+ if ( NULL != g_xtDo )
+ {
+#ifdef USE_MTACB
+ HRESULT hr = MTAIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) );
+ if ( S_OK == hr )
+ MTAFlushClipboard( );
+#else
+ HRESULT hr = OleIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) );
+ if ( S_OK == hr )
+ OleFlushClipboard( );
+#endif
+
+ static_cast< IDataObject* >( g_xtDo )->Release( );
+ }
+}
+
+
+void PasteData(HWND hWnd)
+{
+ IDataObject* pDataObj;
+
+ //FlushClipboard( );
+
+ HRESULT hr = OleGetClipboard( &pDataObj );
+ if ( SUCCEEDED( hr ) )
+ {
+ FORMATETC fetc;
+ STGMEDIUM stgmedium;
+
+ fetc.cfFormat = CF_LOCALE;
+ fetc.ptd = NULL;
+ fetc.dwAspect = DVASPECT_CONTENT;
+ fetc.lindex = -1;
+ fetc.tymed = TYMED_HGLOBAL;
+
+ hr = pDataObj->GetData( &fetc, &stgmedium );
+ if ( SUCCEEDED( hr ) )
+ {
+ LPVOID lpData = GlobalLock( stgmedium.hGlobal );
+
+ if ( NULL != lpData )
+ {
+ LCID lcid = *( (WORD*)lpData );
+
+ WORD langID = LANGIDFROMLCID( lcid );
+ WORD sublangID = SUBLANGID( langID );
+
+ TCHAR buff[6];
+ int cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) );
+ cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTCODEPAGE, buff, sizeof( buff ) );
+
+ GlobalUnlock( stgmedium.hGlobal );
+ }
+ else
+ {
+ DWORD dwLastError = GetLastError( );
+ }
+
+ ReleaseStgMedium( &stgmedium );
+ }
+ }
+}
+
+
+void SetLocale()
+{
+ LCID threadLcid = GetThreadLocale();
+}
+
diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.rc b/sal/workben/clipboardwben/testcopy/cbcpytest.rc
new file mode 100644
index 000000000000..a9db008536ac
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/cbcpytest.rc
@@ -0,0 +1,122 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO"
+IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_TESTWIN32 MENU DISCARDABLE
+BEGIN
+ POPUP "&Datei"
+ BEGIN
+ MENUITEM "&Copy", IDD_COPY
+ MENUITEM "Paste", IDD_PASTE2
+ MENUITEM "Set Locale", IDD_LOCALE
+ MENUITEM SEPARATOR
+ MENUITEM "&Beenden", IDM_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_APP_TITLE "TestWin32"
+ IDS_HELLO "Hallo Welt!"
+ IDC_TESTWIN32 "TESTWIN32"
+END
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/sal/workben/clipboardwben/testcopy/makefile.mk b/sal/workben/clipboardwben/testcopy/makefile.mk
new file mode 100644
index 000000000000..7c1454f05db8
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sal
+TARGET=cbcpytest
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+# --- Files --------------------------------------------------------
+
+#
+# test clipboard paste
+#
+ # --- Resources ----------------------------------------------------
+ RCFILES= cbcpytest.rc
+
+ OBJFILES= $(OBJ)$/cbcpytest.obj $(OBJ)$/XTDataObject.obj
+
+ APP1TARGET= $(TARGET)
+ APP1OBJS= $(OBJFILES)
+ APP1NOSAL= TRUE
+ APP1NOSVRES= $(RES)$/$(TARGET).res
+
+ APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) $(SALLIB)
+
+ APP1LIBS=$(LB)$/iole9x.lib \
+ $(LB)$/tools32.lib
+
+ APP1DEPN= makefile.mk $(APP1NOSVRES)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sal/workben/clipboardwben/testcopy/resource.h b/sal/workben/clipboardwben/testcopy/resource.h
new file mode 100644
index 000000000000..5f70db1bb13f
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/resource.h
@@ -0,0 +1,31 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by cbcpytest.rc
+//
+#define IDC_MYICON 2
+#define IDD_TESTWIN32_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDS_HELLO 106
+#define IDI_TESTWIN32 107
+#define IDI_SMALL 108
+#define IDC_TESTWIN32 109
+#define IDR_MAINFRAME 128
+#define IDD_PASTE 32771
+#define IDD_COPY 32771
+#define IDD_PASTE2 32772
+#define IDD_LOCALE 32773
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32774
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/sal/workben/clipboardwben/testcopy/small.ico b/sal/workben/clipboardwben/testcopy/small.ico
new file mode 100644
index 000000000000..8f94d9aa8285
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/small.ico
Binary files differ