diff options
Diffstat (limited to 'sal/workben/clipboardwben')
26 files changed, 2564 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 Binary files differnew file mode 100644 index 000000000000..255ff3be4fba --- /dev/null +++ b/sal/workben/clipboardwben/testcopy/TestWin32.ico 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 Binary files differnew file mode 100644 index 000000000000..8f94d9aa8285 --- /dev/null +++ b/sal/workben/clipboardwben/testcopy/small.ico diff --git a/sal/workben/clipboardwben/testpaste/StdAfx.cpp b/sal/workben/clipboardwben/testpaste/StdAfx.cpp new file mode 100644 index 000000000000..cb07d603f28f --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/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/testpaste/StdAfx.h b/sal/workben/clipboardwben/testpaste/StdAfx.h new file mode 100644 index 000000000000..bb762adbdc36 --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/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/testpaste/TestWin32.ico b/sal/workben/clipboardwben/testpaste/TestWin32.ico Binary files differnew file mode 100644 index 000000000000..255ff3be4fba --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/TestWin32.ico diff --git a/sal/workben/clipboardwben/testpaste/cbptest.cxx b/sal/workben/clipboardwben/testpaste/cbptest.cxx new file mode 100644 index 000000000000..f26d51ec6d72 --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/cbptest.cxx @@ -0,0 +1,428 @@ +/************************************************************************* + * + * 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 + +#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 "resource.h" + +#define MAX_LOADSTRING 100 + +// Globale Variablen: +HINSTANCE hInst; // aktuelle Instanz +WCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile +WCHAR 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 PasteClipboardData(HWND hwndParent); +void PasteClipboardData2(HWND hwndParent); + +LPSTREAM g_pStm = NULL; +char* pTextBuff = NULL; +DWORD lData = 0; + +//---------------------------------------------------- +// a thread function +//---------------------------------------------------- + +unsigned int _stdcall ThreadProc(LPVOID pParam) +{ + IDataObject* pIDataObj = NULL; + FORMATETC formatETC; + STGMEDIUM stgMedium; + LPVOID pGlobMem; + HWND hwnd; + DWORD sizeGlobBuff; + HRESULT hr; + + hwnd = (HWND)pParam; + + OleInitialize( NULL ); + + hr = OleGetClipboard( &pIDataObj ); + + hr = CoGetInterfaceAndReleaseStream( + g_pStm, + __uuidof(IDataObject), + reinterpret_cast<LPVOID*>(&pIDataObj)); + + formatETC.cfFormat = CF_TEXT; + formatETC.ptd = NULL; + formatETC.dwAspect = DVASPECT_CONTENT; + formatETC.lindex = -1; + formatETC.tymed = TYMED_HGLOBAL; + + hr = pIDataObj->GetData( &formatETC, &stgMedium ); + pGlobMem = GlobalLock( stgMedium.hGlobal ); + if ( NULL != pGlobMem ) + { + if ( NULL != pTextBuff ) + { + free( pTextBuff ); + } + + sizeGlobBuff = GlobalSize( stgMedium.hGlobal ); + pTextBuff = (char*)malloc( sizeGlobBuff + 1 ); + ZeroMemory( pTextBuff, sizeGlobBuff + 1 ); + + memcpy( pTextBuff, pGlobMem, sizeGlobBuff ); + lData = sizeGlobBuff; + + InvalidateRect( hwnd, NULL, TRUE ); + UpdateWindow( hwnd ); + } + + GlobalUnlock( stgMedium.hGlobal ); + + ReleaseStgMedium( &stgMedium ); + + pIDataObj->Release(); + + //CoUninitialize( ); + + OleUninitialize( ); + + 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; + + // it's important to initialize ole + // in order to use the clipboard + //hr = OleInitialize( NULL ); + hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); + //hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); + + // Globale Zeichenfolgen initialisieren + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(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 + //OleUninitialize( ); + CoUninitialize( ); + + 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 ) +{ + WNDCLASSEXW 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 = (LPCWSTR)IDC_TESTWIN32; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + return RegisterClassExW(&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 ) +{ + HWND hWnd; + + hInst = hInstance; // Instanzzugriffsnummer in unserer globalen Variable speichern + + hWnd = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if( !hWnd ) + { + return FALSE; + } + + ShowWindow( hWnd, nCmdShow ); + UpdateWindow( 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_PASTE: + //PasteClipboardData(hWnd); + PasteClipboardData2(hWnd); + 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: + PostQuitMessage( 0 ); + break; + + default: + return DefWindowProc( hWnd, message, wParam, lParam ); + } + return 0; +} + +void PasteClipboardData2(HWND hwndParent) +{ + IDataObject* pIDataObject; + HRESULT hr; + FORMATETC formatETC; + STGMEDIUM stgMedium; + LPVOID pGlobMem; + HWND hwnd; + DWORD sizeGlobBuff; + + hr = MTAGetClipboard( &pIDataObject ); + if ( SUCCEEDED( hr ) ) + { + formatETC.cfFormat = CF_TEXT; + formatETC.ptd = NULL; + formatETC.dwAspect = DVASPECT_CONTENT; + formatETC.lindex = -1; + formatETC.tymed = TYMED_HGLOBAL; + + hr = pIDataObject->GetData( &formatETC, &stgMedium ); + pGlobMem = GlobalLock( stgMedium.hGlobal ); + if ( NULL != pGlobMem ) + { + if ( NULL != pTextBuff ) + { + free( pTextBuff ); + } + + sizeGlobBuff = GlobalSize( stgMedium.hGlobal ); + pTextBuff = (char*)malloc( sizeGlobBuff + 1 ); + ZeroMemory( pTextBuff, sizeGlobBuff + 1 ); + + memcpy( pTextBuff, pGlobMem, sizeGlobBuff ); + lData = sizeGlobBuff; + + InvalidateRect( hwndParent, NULL, TRUE ); + UpdateWindow( hwndParent ); + } + + GlobalUnlock( stgMedium.hGlobal ); + + ReleaseStgMedium( &stgMedium ); + + pIDataObject->Release(); + } +} + +//---------------------------------------------------- +// clipboard handling +//---------------------------------------------------- + +/* +void PasteClipboardData(HWND hwndParent) +{ + IDataObject* pIDataObj = NULL; + HRESULT hr = E_FAIL; + unsigned int dwId; + + hr = OleGetClipboard( &pIDataObj ); + if ( SUCCEEDED( hr ) ) + { + HRESULT hr = CoMarshalInterThreadInterfaceInStream( + __uuidof(IDataObject), //The IID of inteface to be marshaled + pIDataObj, //The interface pointer + &g_pStm //IStream pointer + ); + + HANDLE hThread = (HANDLE)_beginthreadex( + NULL, //Security + 0, //Stack Size + ThreadProc, //Start Address + NULL, //Parmeter + (unsigned int)hwndParent, //Creation Flag + &dwId //Thread Id + ); + + //Wait for the thread to finish execution + //A thread handle is signaled is thread execution + //is complete + for(;;) + { + DWORD dwRet = ::MsgWaitForMultipleObjects( + 1, //Count of objects + &hThread, //pointer to the array of objects + FALSE, //Wait for all objects? + INFINITE, //Wait How Long? + QS_ALLINPUT //Wait for all messges + ); + + //This means that the object is signaled + if ( dwRet != WAIT_OBJECT_0 + 1 ) + break; + + //Remove the messages from the queue + MSG msg; + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) + { + //Not essential + TranslateMessage(&msg); + //Let the windowproc handle the message + DispatchMessage(&msg); + } + } + + CloseHandle( hThread ); + pIDataObj->Release(); + } +} +*/ diff --git a/sal/workben/clipboardwben/testpaste/cbptest.rc b/sal/workben/clipboardwben/testpaste/cbptest.rc new file mode 100644 index 000000000000..2deeb86a93a2 --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/cbptest.rc @@ -0,0 +1,120 @@ +//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 "&Paste", IDD_PASTE + 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/testpaste/makefile.mk b/sal/workben/clipboardwben/testpaste/makefile.mk new file mode 100644 index 000000000000..5514d7c569b0 --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/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=cbptest +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGS+= $(LFS_CFLAGS) +CXXFLAGS+= $(LFS_CFLAGS) + +# --- Files -------------------------------------------------------- + +# +# test clipboard paste +# + # --- Resources ---------------------------------------------------- + RCFILES= cbptest.rc + + OBJFILES= $(OBJ)$/cbptest.obj + + APP1TARGET= $(TARGET) + APP1OBJS= $(OBJFILES) + APP1NOSAL= TRUE + APP1NOSVRES= $(RES)$/$(TARGET).res + + APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) + + APP1LIBS=$(LB)$/ole9x.lib \ + $(LB)$/tools32.lib + + APP1DEPN= makefile.mk $(APP1NOSVRES) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/sal/workben/clipboardwben/testpaste/resource.h b/sal/workben/clipboardwben/testpaste/resource.h new file mode 100644 index 000000000000..5206e911eabf --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/resource.h @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by mtacb.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 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 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/sal/workben/clipboardwben/testpaste/small.ico b/sal/workben/clipboardwben/testpaste/small.ico Binary files differnew file mode 100644 index 000000000000..8f94d9aa8285 --- /dev/null +++ b/sal/workben/clipboardwben/testpaste/small.ico diff --git a/sal/workben/clipboardwben/testviewer/StdAfx.cpp b/sal/workben/clipboardwben/testviewer/StdAfx.cpp new file mode 100644 index 000000000000..cb07d603f28f --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/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/testviewer/StdAfx.h b/sal/workben/clipboardwben/testviewer/StdAfx.h new file mode 100644 index 000000000000..bb762adbdc36 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/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/testviewer/TestWin32.ico b/sal/workben/clipboardwben/testviewer/TestWin32.ico Binary files differnew file mode 100644 index 000000000000..255ff3be4fba --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/TestWin32.ico diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.cxx b/sal/workben/clipboardwben/testviewer/cbvtest.cxx new file mode 100644 index 000000000000..d79758971728 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/cbvtest.cxx @@ -0,0 +1,351 @@ +/************************************************************************* + * + * 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 + +#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 <crtdbg.h> +#include <..\..\inc\systools\win32\MtaOleClipb.h> + +#include "resource.h" + +#define MAX_LOADSTRING 100 + +// Globale Variablen: +HINSTANCE g_hInst; // aktuelle Instanz +HWND g_hwndMain; +WCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile +WCHAR szWindowClass[MAX_LOADSTRING]; // Text der Titelzeile +LPSTREAM g_pStm = NULL; +char* pTextBuff = NULL; +DWORD lData = 0; +UINT g_nCBChanges = 0; + +// forward declaration +ATOM MyRegisterClass( HINSTANCE hInstance ); +BOOL InitInstance( HINSTANCE, int ); +HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex ); +BOOL IsClipboardViewer( HWND hwndParent ); +void SwitchMenuState( HWND hwndParent ); +void RegisterClipboardViewer( BOOL bRegister ); +void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd ); +void ClearClipboardContent( HWND hWnd ); + +void CALLBACK OnClipboardContentChange( void ); +LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); +LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM ); + +//---------------------------------------------------- +// 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; + + // it's important to initialize ole + // in order to use the clipboard + //hr = OleInitialize( NULL ); + hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); + + g_hInst = hInstance; + + // Globale Zeichenfolgen initialisieren + LoadStringW(g_hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(g_hInst, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(g_hInst); + + // Initialisierung der Anwendung durchführen: + if( !InitInstance( g_hInst, 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 + //OleUninitialize( ); + CoUninitialize( ); + + 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 ) +{ + WNDCLASSEXW 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 = (LPCWSTR)IDC_TESTWIN32; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + return RegisterClassExW(&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 ) +{ + g_hwndMain = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if( !IsWindow( g_hwndMain ) ) + { + return FALSE; + } + + ShowWindow( g_hwndMain, nCmdShow ); + UpdateWindow( g_hwndMain ); + + 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; + WCHAR szHello[MAX_LOADSTRING]; + + + LoadStringW(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING); + + switch( message ) + { + case WM_CREATE: + ClearClipboardContent( hWnd ); + break; + + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + // Menüauswahlen analysieren: + switch( wmId ) + { + case IDD_CBVIEWER: + SwitchMenuState( hWnd ); + RegisterClipboardViewer( IsClipboardViewer( hWnd ) ); + 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 ( IsClipboardViewer( g_hwndMain ) ) + { + ShowAvailableClipboardFormats( hWnd, hdc, ps, rt ); + } + else + { + WCHAR wcString[MAX_LOADSTRING]; + LoadStringW(g_hInst, IDS_MSG_CBVIEWER_IS_OFF, wcString, MAX_LOADSTRING); + DrawTextW( hdc, wcString, wcslen( wcString ), &rt, DT_CENTER ); + } + + EndPaint( hWnd, &ps ); + break; + + case WM_DESTROY: + PostQuitMessage( 0 ); + break; + + default: + return DefWindowProc( hWnd, message, wParam, lParam ); + } + return 0; +} + +HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex ) +{ + HMENU hMenuMain = GetMenu( hwndParent ); + _ASSERT( IsMenu( hMenu ) ); + + HMENU hSubMenu = GetSubMenu( hMenuMain, uiTopLevelIndex ); + _ASSERT( IsMenu( hSubMenu ) ); + + return hSubMenu; +} + +BOOL IsClipboardViewer( HWND hwndParent ) +{ + HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 ); + UINT uiMState = GetMenuState( hSubMenu, 0, MF_BYPOSITION ); + return ( MF_CHECKED == uiMState ); +} + +void SwitchMenuState( HWND hwndParent ) +{ + HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 ); + WCHAR wcMenuString[MAX_LOADSTRING]; + + if ( IsClipboardViewer( hwndParent ) ) + { + LoadStringW(g_hInst, IDS_CBVIEWER_OFF, wcMenuString, MAX_LOADSTRING); + ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString ); + CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_UNCHECKED ); + } + else + { + LoadStringW(g_hInst, IDS_CBVIEWER_ON, wcMenuString, MAX_LOADSTRING); + ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString ); + CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_CHECKED ); + } +} + +void RegisterClipboardViewer( BOOL bRegister ) +{ + if ( bRegister ) + MTARegisterClipboardViewer( OnClipboardContentChange ); + else // unregister + MTARegisterClipboardViewer( NULL ); + + InvalidateRect( g_hwndMain, NULL, TRUE ); + UpdateWindow( g_hwndMain ); +} + +void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd ) +{ + if ( !OpenClipboard( hWnd ) ) + { + WCHAR szErrMsg[] = { L"Couldn't open the clipboard" }; + DrawTextW( hdc, szErrMsg, wcslen( szErrMsg ), &rcWnd, DT_CENTER ); + return; + } + else + { + WCHAR szCBChangedMsg[100]; + + wsprintfW( szCBChangedMsg, L"Clipboard content changed %d", g_nCBChanges ); + DrawTextW( hdc, szCBChangedMsg, wcslen( szCBChangedMsg ), &rcWnd, DT_CENTER ); + + CloseClipboard( ); + } +} + +void ClearClipboardContent( HWND hWnd ) +{ + if ( OpenClipboard( hWnd ) ) + { + EmptyClipboard( ); + CloseClipboard( ); + } +} + +// clipboard viewer callback function +void CALLBACK OnClipboardContentChange( void ) +{ + ++g_nCBChanges; + InvalidateRect( g_hwndMain, NULL, TRUE ); + UpdateWindow( g_hwndMain ); +} + diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.rc b/sal/workben/clipboardwben/testviewer/cbvtest.rc new file mode 100644 index 000000000000..b6c5163f7261 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/cbvtest.rc @@ -0,0 +1,127 @@ +//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 "&CB Viewer off", IDD_CBVIEWER + 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" + IDS_CBVIEWER_ON "CB Viewer on" + IDS_CBVIEWER_OFF "CB Viewer off" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_MSG_CBVIEWER_IS_OFF "Clipboard Viewer inactive!" +END + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/sal/workben/clipboardwben/testviewer/makefile.mk b/sal/workben/clipboardwben/testviewer/makefile.mk new file mode 100644 index 000000000000..fa3e47cb48b2 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/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=cbvtest +LIBTARGET=NO + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGS+= $(LFS_CFLAGS) +CXXFLAGS+= $(LFS_CFLAGS) + +# --- Files -------------------------------------------------------- + +# +# test clipboard paste +# + # --- Resources ---------------------------------------------------- + RCFILES= cbvtest.rc + + OBJFILES= $(OBJ)$/cbvtest.obj + + APP1TARGET= $(TARGET) + APP1OBJS= $(OBJFILES) + APP1NOSAL= TRUE + APP1NOSVRES= $(RES)$/$(TARGET).res + + APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) + + APP1LIBS=$(LB)$/iole9x.lib \ + $(LB)$/tools32.lib + + APP1DEPN= makefile.mk $(APP1NOSVRES) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/sal/workben/clipboardwben/testviewer/resource.h b/sal/workben/clipboardwben/testviewer/resource.h new file mode 100644 index 000000000000..fa4a79779aa9 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/resource.h @@ -0,0 +1,32 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by cbvtest.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 IDS_CBVIEWER_ON 110 +#define IDS_CBVIEWER_OFF 111 +#define IDS_MSG_CBVIEWER_IS_OFF 112 +#define IDR_MAINFRAME 128 +#define IDD_PASTE 32771 +#define IDD_CBVIEWER 32771 +#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 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/sal/workben/clipboardwben/testviewer/small.ico b/sal/workben/clipboardwben/testviewer/small.ico Binary files differnew file mode 100644 index 000000000000..8f94d9aa8285 --- /dev/null +++ b/sal/workben/clipboardwben/testviewer/small.ico |