35791228665abdceb2f25957b61ca9c45e9d044e
[reactos.git] / reactos / lib / user32 / windows / clipboard.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: clipboard.c,v 1.13 2004/01/26 08:44:51 weiden Exp $
20 *
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/clipboard.c
23 * PURPOSE: Input
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * UPDATE HISTORY:
26 * 09-05-2001 CSH Created
27 */
28
29 /* INCLUDES ******************************************************************/
30
31 #include <windows.h>
32 #include <user32.h>
33 #include <strpool.h>
34
35 #define NDEBUG
36 #include <debug.h>
37
38 /* FUNCTIONS *****************************************************************/
39
40 /*
41 * @implemented
42 */
43 BOOL STDCALL
44 OpenClipboard(HWND hWndNewOwner)
45 {
46 return NtUserOpenClipboard(hWndNewOwner, 0);
47 }
48
49 /*
50 * @implemented
51 */
52 BOOL STDCALL
53 CloseClipboard(VOID)
54 {
55 return NtUserCloseClipboard();
56 }
57
58 /*
59 * @implemented
60 */
61 INT STDCALL
62 CountClipboardFormats(VOID)
63 {
64 return NtUserCountClipboardFormats();
65 }
66
67 /*
68 * @implemented
69 */
70 BOOL STDCALL
71 EmptyClipboard(VOID)
72 {
73 return NtUserEmptyClipboard();
74 }
75
76 /*
77 * @implemented
78 */
79 UINT STDCALL
80 EnumClipboardFormats(UINT format)
81 {
82 return NtUserEnumClipboardFormats(format);
83 }
84
85 /*
86 * @implemented
87 */
88 HANDLE STDCALL
89 GetClipboardData(UINT uFormat)
90 {
91 return NtUserGetClipboardData(uFormat, 0);
92 }
93
94 /*
95 * @implemented
96 */
97 INT STDCALL
98 GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
99 {
100 LPWSTR lpBuffer;
101 UNICODE_STRING FormatName;
102 INT Length;
103
104 lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR));
105 if (!lpBuffer)
106 {
107 SetLastError(ERROR_OUTOFMEMORY);
108 return 0;
109 }
110 RtlInitUnicodeString(&FormatName, lpBuffer);
111 FormatName.Length = 0;
112 FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
113 FormatName.Buffer = lpBuffer;
114 Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
115 DPRINT("GetClipboardFormatNameA(%x): %S\n", format, lpBuffer);
116 HEAP_strcpyWtoA(lpszFormatName, lpBuffer, Length);
117 HEAP_free(lpBuffer);
118 DPRINT("GetClipboardFormatNameA(%x): returning %s\n", format, lpszFormatName);
119
120 return Length;
121 }
122
123 /*
124 * @implemented
125 */
126 INT STDCALL
127 GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount)
128 {
129 UNICODE_STRING FormatName;
130 ULONG Ret;
131
132 FormatName.Length = 0;
133 FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
134 FormatName.Buffer = (PWSTR)lpszFormatName;
135 Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
136 DPRINT("GetClipboardFormatNameW(%x): returning %S\n", format, lpszFormatName);
137 return Ret;
138 }
139
140 /*
141 * @implemented
142 */
143 HWND STDCALL
144 GetClipboardOwner(VOID)
145 {
146 return NtUserGetClipboardOwner();
147 }
148
149 /*
150 * @implemented
151 */
152 DWORD STDCALL
153 GetClipboardSequenceNumber(VOID)
154 {
155 return NtUserGetClipboardSequenceNumber();
156 }
157
158 /*
159 * @implemented
160 */
161 HWND STDCALL
162 GetClipboardViewer(VOID)
163 {
164 return NtUserGetClipboardViewer();
165 }
166
167 /*
168 * @implemented
169 */
170 HWND STDCALL
171 GetOpenClipboardWindow(VOID)
172 {
173 return NtUserGetOpenClipboardWindow();
174 }
175
176 /*
177 * @implemented
178 */
179 INT STDCALL
180 GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
181 {
182 return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
183 }
184
185 /*
186 * @implemented
187 */
188 BOOL STDCALL
189 IsClipboardFormatAvailable(UINT format)
190 {
191 return NtUserIsClipboardFormatAvailable(format);
192 }
193
194 /*
195 * @implemented
196 */
197 UINT STDCALL
198 RegisterClipboardFormatA(LPCSTR lpszFormat)
199 {
200 ULONG Ret = RegisterWindowMessageA(lpszFormat);
201 DPRINT("RegisterClipboardFormatA(%s) - %x\n", lpszFormat, Ret);
202 return Ret;
203 }
204
205 /*
206 * @implemented
207 */
208 UINT STDCALL
209 RegisterClipboardFormatW(LPCWSTR lpszFormat)
210 {
211 ULONG Ret = RegisterWindowMessageW(lpszFormat);
212 DPRINT("RegisterClipboardFormatW(%S) - %x\n", lpszFormat, Ret);
213 return Ret;
214 }
215
216 /*
217 * @implemented
218 */
219 HANDLE STDCALL
220 SetClipboardData(UINT uFormat, HANDLE hMem)
221 {
222 return NtUserSetClipboardData(uFormat, hMem, 0);
223 }
224
225 /*
226 * @implemented
227 */
228 HWND STDCALL
229 SetClipboardViewer(HWND hWndNewViewer)
230 {
231 return NtUserSetClipboardViewer(hWndNewViewer);
232 }
233
234 /*
235 * @implemented
236 */
237 BOOL STDCALL
238 ChangeClipboardChain(HWND hWndRemove, HWND hWndNewNext)
239 {
240 return NtUserChangeClipboardChain(hWndRemove, hWndNewNext);
241 }