diff options
Diffstat (limited to 'sal/workben/clipboardwben/testviewer')
-rw-r--r-- | sal/workben/clipboardwben/testviewer/StdAfx.cpp | 8 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/StdAfx.h | 32 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/TestWin32.ico | bin | 0 -> 1590 bytes | |||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/cbvtest.cxx | 351 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/cbvtest.rc | 127 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/makefile.mk | 67 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/resource.h | 32 | ||||
-rw-r--r-- | sal/workben/clipboardwben/testviewer/small.ico | bin | 0 -> 318 bytes |
8 files changed, 617 insertions, 0 deletions
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 |