Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1 | /* |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 2 | * WIN32 clipboard implementation |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1994 Martin Ayotte |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 5 | * 1996 Alex Korobka |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 6 | * 1999 Noel Borthwick |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 7 | * 2003 Ulrich Czekalla for CodeWeavers |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 8 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Lesser General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2.1 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public |
| 20 | * License along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 23 | * NOTES: |
| 24 | * This file contains the implementation for the WIN32 Clipboard API |
| 25 | * and Wine's internal clipboard cache. |
| 26 | * The actual contents of the clipboard are held in the clipboard cache. |
| 27 | * The internal implementation talks to a "clipboard driver" to fill or |
| 28 | * expose the cache to the native device. (Currently only the X11 and |
| 29 | * TTY clipboard driver are available) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 30 | */ |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 31 | |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 32 | #include "config.h" |
Patrik Stridvall | 51e6c0c | 2002-08-31 19:04:14 +0000 | [diff] [blame] | 33 | #include "wine/port.h" |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 34 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 35 | #include <stdarg.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 36 | #include <stdlib.h> |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 37 | #include <sys/types.h> |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 38 | #include <fcntl.h> |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 39 | #ifdef HAVE_UNISTD_H |
| 40 | # include <unistd.h> |
| 41 | #endif |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 42 | #include <string.h> |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 43 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 44 | #include "windef.h" |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 45 | #include "winbase.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 46 | #include "wingdi.h" |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 47 | #include "winuser.h" |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 48 | #include "winerror.h" |
Marcus Meissner | 219cfd8 | 1999-02-24 13:05:13 +0000 | [diff] [blame] | 49 | #include "wine/winuser16.h" |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 50 | #include "wine/winbase16.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 51 | #include "heap.h" |
Alexandre Julliard | 42d20f9 | 2000-08-10 01:16:19 +0000 | [diff] [blame] | 52 | #include "user.h" |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 53 | #include "win.h" |
Patrik Stridvall | cf07e10 | 2002-10-23 20:20:59 +0000 | [diff] [blame] | 54 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 55 | #include "wine/debug.h" |
Patrik Stridvall | cf07e10 | 2002-10-23 20:20:59 +0000 | [diff] [blame] | 56 | #include "wine/unicode.h" |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 57 | #include "wine/server.h" |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 58 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 59 | WINE_DEFAULT_DEBUG_CHANNEL(clipboard); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 60 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 61 | #define CF_REGFORMATBASE 0xC000 |
| 62 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 63 | typedef struct |
| 64 | { |
| 65 | HWND hWndOpen; |
| 66 | HWND hWndOwner; |
| 67 | HWND hWndViewer; |
| 68 | UINT seqno; |
| 69 | UINT flags; |
| 70 | } CLIPBOARDINFO, *LPCLIPBOARDINFO; |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 71 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 72 | /* |
| 73 | * Indicates if data has changed since open. |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 74 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 75 | static BOOL bCBHasChanged = FALSE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 76 | |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 77 | |
| 78 | /************************************************************************** |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 79 | * CLIPBOARD_SetClipboardOwner |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 80 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 81 | BOOL CLIPBOARD_SetClipboardOwner(HWND hWnd) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 82 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 83 | BOOL bRet = FALSE; |
| 84 | |
| 85 | TRACE(" hWnd(%p)\n", hWnd); |
| 86 | |
| 87 | SERVER_START_REQ( set_clipboard_info ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 88 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 89 | req->flags = SET_CB_OWNER; |
| 90 | req->owner = WIN_GetFullHandle( hWnd ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 91 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 92 | if (wine_server_call_err( req )) |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 93 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 94 | ERR("Failed to set clipboard.\n"); |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 95 | } |
| 96 | else |
| 97 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 98 | bRet = TRUE; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 99 | } |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 100 | } |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 101 | SERVER_END_REQ; |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 102 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 103 | return bRet; |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 106 | |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 107 | /************************************************************************** |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 108 | * CLIPBOARD_GetClipboardInfo |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 109 | */ |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 110 | static BOOL CLIPBOARD_GetClipboardInfo(LPCLIPBOARDINFO cbInfo) |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 111 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 112 | BOOL bRet = FALSE; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 113 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 114 | SERVER_START_REQ( set_clipboard_info ) |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 115 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 116 | req->flags = 0; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 117 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 118 | if (wine_server_call_err( req )) |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 119 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 120 | ERR("Failed to get clipboard owner.\n"); |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | cbInfo->hWndOpen = reply->old_clipboard; |
| 125 | cbInfo->hWndOwner = reply->old_owner; |
| 126 | cbInfo->hWndViewer = reply->old_viewer; |
| 127 | cbInfo->seqno = reply->seqno; |
| 128 | cbInfo->flags = reply->flags; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 129 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 130 | bRet = TRUE; |
| 131 | } |
| 132 | } |
| 133 | SERVER_END_REQ; |
| 134 | |
| 135 | return bRet; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | /************************************************************************** |
| 140 | * CLIPBOARD_ReleaseOwner |
| 141 | */ |
| 142 | BOOL CLIPBOARD_ReleaseOwner(void) |
| 143 | { |
| 144 | BOOL bRet = FALSE; |
| 145 | |
| 146 | SERVER_START_REQ( set_clipboard_info ) |
| 147 | { |
| 148 | req->flags = SET_CB_RELOWNER | SET_CB_SEQNO; |
| 149 | |
| 150 | if (wine_server_call_err( req )) |
| 151 | { |
| 152 | ERR("Failed to set clipboard.\n"); |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | bRet = TRUE; |
| 157 | } |
| 158 | } |
| 159 | SERVER_END_REQ; |
| 160 | |
| 161 | return bRet; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | /************************************************************************** |
| 166 | * CLIPBOARD_OpenClipboard |
| 167 | */ |
| 168 | static BOOL CLIPBOARD_OpenClipboard(HWND hWnd) |
| 169 | { |
| 170 | BOOL bRet = FALSE; |
| 171 | |
| 172 | SERVER_START_REQ( set_clipboard_info ) |
| 173 | { |
| 174 | req->flags = SET_CB_OPEN; |
| 175 | req->clipboard = WIN_GetFullHandle( hWnd ); |
| 176 | |
| 177 | if (wine_server_call_err( req )) |
| 178 | { |
| 179 | ERR("Failed to set clipboard.\n"); |
| 180 | } |
| 181 | else |
| 182 | { |
| 183 | bRet = TRUE; |
| 184 | } |
| 185 | } |
| 186 | SERVER_END_REQ; |
| 187 | |
| 188 | return bRet; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | /************************************************************************** |
| 193 | * CLIPBOARD_CloseClipboard |
| 194 | */ |
| 195 | static BOOL CLIPBOARD_CloseClipboard(void) |
| 196 | { |
| 197 | BOOL bRet = FALSE; |
| 198 | |
| 199 | TRACE(" Changed=%d\n", bCBHasChanged); |
| 200 | |
| 201 | SERVER_START_REQ( set_clipboard_info ) |
| 202 | { |
| 203 | req->flags = SET_CB_CLOSE; |
| 204 | |
| 205 | if (bCBHasChanged) |
| 206 | { |
| 207 | req->flags |= SET_CB_SEQNO; |
| 208 | TRACE("Clipboard data changed\n"); |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 211 | if (wine_server_call_err( req )) |
| 212 | { |
| 213 | ERR("Failed to set clipboard.\n"); |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | bRet = TRUE; |
| 218 | } |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 219 | } |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 220 | SERVER_END_REQ; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 221 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 222 | return bRet; |
Gerard Patel | 9289a5d | 2000-12-22 23:26:18 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | |
| 226 | /************************************************************************** |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 227 | * WIN32 Clipboard implementation |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 228 | **************************************************************************/ |
| 229 | |
| 230 | /************************************************************************** |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 231 | * RegisterClipboardFormatA (USER32.@) |
| 232 | */ |
| 233 | UINT WINAPI RegisterClipboardFormatA(LPCSTR FormatName) |
| 234 | { |
| 235 | UINT wFormatID = 0; |
| 236 | |
| 237 | TRACE("%s\n", debugstr_a(FormatName)); |
| 238 | |
| 239 | if (USER_Driver.pRegisterClipboardFormat) |
| 240 | wFormatID = USER_Driver.pRegisterClipboardFormat(FormatName); |
| 241 | |
| 242 | return wFormatID; |
| 243 | } |
| 244 | |
| 245 | |
| 246 | /************************************************************************** |
| 247 | * RegisterClipboardFormat (USER.145) |
| 248 | */ |
| 249 | UINT16 WINAPI RegisterClipboardFormat16(LPCSTR FormatName) |
| 250 | { |
| 251 | UINT wFormatID = 0; |
| 252 | |
| 253 | TRACE("%s\n", debugstr_a(FormatName)); |
| 254 | |
| 255 | if (USER_Driver.pRegisterClipboardFormat) |
| 256 | wFormatID = USER_Driver.pRegisterClipboardFormat(FormatName); |
| 257 | |
| 258 | return wFormatID; |
| 259 | } |
| 260 | |
| 261 | |
| 262 | /************************************************************************** |
| 263 | * RegisterClipboardFormatW (USER32.@) |
| 264 | */ |
| 265 | UINT WINAPI RegisterClipboardFormatW(LPCWSTR formatName) |
| 266 | { |
| 267 | LPSTR aFormat = HEAP_strdupWtoA( GetProcessHeap(), 0, formatName ); |
| 268 | UINT ret = RegisterClipboardFormatA( aFormat ); |
| 269 | HeapFree( GetProcessHeap(), 0, aFormat ); |
| 270 | return ret; |
| 271 | } |
| 272 | |
| 273 | |
| 274 | /************************************************************************** |
| 275 | * GetClipboardFormatName (USER.146) |
| 276 | */ |
| 277 | INT16 WINAPI GetClipboardFormatName16(UINT16 wFormat, LPSTR retStr, INT16 maxlen) |
| 278 | { |
| 279 | TRACE("%04x,%p,%d\n", wFormat, retStr, maxlen); |
| 280 | |
| 281 | return GetClipboardFormatNameA(wFormat, retStr, maxlen); |
| 282 | } |
| 283 | |
| 284 | |
| 285 | /************************************************************************** |
| 286 | * GetClipboardFormatNameA (USER32.@) |
| 287 | */ |
| 288 | INT WINAPI GetClipboardFormatNameA(UINT wFormat, LPSTR retStr, INT maxlen) |
| 289 | { |
| 290 | INT len = 0; |
| 291 | |
| 292 | TRACE("%04x,%p,%d\n", wFormat, retStr, maxlen); |
| 293 | |
| 294 | if (USER_Driver.pGetClipboardFormatName) |
| 295 | len = USER_Driver.pGetClipboardFormatName(wFormat, retStr, maxlen); |
| 296 | |
| 297 | return len; |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /************************************************************************** |
| 302 | * GetClipboardFormatNameW (USER32.@) |
| 303 | */ |
| 304 | INT WINAPI GetClipboardFormatNameW(UINT wFormat, LPWSTR retStr, INT maxlen) |
| 305 | { |
| 306 | INT ret; |
| 307 | LPSTR p = HeapAlloc( GetProcessHeap(), 0, maxlen ); |
| 308 | if(p == NULL) return 0; /* FIXME: is this the correct failure value? */ |
| 309 | |
| 310 | ret = GetClipboardFormatNameA( wFormat, p, maxlen ); |
| 311 | |
| 312 | if (maxlen > 0 && !MultiByteToWideChar( CP_ACP, 0, p, -1, retStr, maxlen )) |
| 313 | retStr[maxlen-1] = 0; |
| 314 | HeapFree( GetProcessHeap(), 0, p ); |
| 315 | return ret; |
| 316 | } |
| 317 | |
| 318 | |
| 319 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 320 | * OpenClipboard (USER32.@) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 321 | * |
| 322 | * Note: Netscape uses NULL hWnd to open the clipboard. |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 323 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 324 | BOOL WINAPI OpenClipboard( HWND hWnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 325 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 326 | BOOL bRet; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 327 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 328 | TRACE("(%p)...\n", hWnd); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 329 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 330 | bRet = CLIPBOARD_OpenClipboard(hWnd); |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 331 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 332 | TRACE(" returning %i\n", bRet); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 333 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 334 | return bRet; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | |
| 338 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 339 | * CloseClipboard (USER.138) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 340 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 341 | BOOL16 WINAPI CloseClipboard16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 342 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 343 | return CloseClipboard(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | |
| 347 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 348 | * CloseClipboard (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 349 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 350 | BOOL WINAPI CloseClipboard(void) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 351 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 352 | BOOL bRet = FALSE; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 353 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 354 | TRACE("(%d)\n", bCBHasChanged); |
| 355 | |
| 356 | if (CLIPBOARD_CloseClipboard()) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 357 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 358 | if (bCBHasChanged) |
| 359 | { |
| 360 | HWND hWndViewer = GetClipboardViewer(); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 361 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 362 | if (USER_Driver.pEndClipboardUpdate) |
| 363 | USER_Driver.pEndClipboardUpdate(); |
| 364 | |
| 365 | if (hWndViewer) |
| 366 | SendMessageW(hWndViewer, WM_DRAWCLIPBOARD, 0, 0); |
| 367 | |
| 368 | bCBHasChanged = FALSE; |
| 369 | } |
| 370 | |
| 371 | bRet = TRUE; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 372 | } |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 373 | |
| 374 | return bRet; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | |
| 378 | /************************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 379 | * EmptyClipboard (USER.139) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 380 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 381 | BOOL16 WINAPI EmptyClipboard16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 382 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 383 | return EmptyClipboard(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | |
| 387 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 388 | * EmptyClipboard (USER32.@) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 389 | * Empties and acquires ownership of the clipboard |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 390 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 391 | BOOL WINAPI EmptyClipboard(void) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 392 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 393 | CLIPBOARDINFO cbinfo; |
| 394 | |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 395 | TRACE("()\n"); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 396 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 397 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 398 | ~cbinfo.flags & CB_OPEN) |
| 399 | { |
Francois Gouget | e76218d | 2001-05-09 17:31:31 +0000 | [diff] [blame] | 400 | WARN("Clipboard not opened by calling task!\n"); |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 401 | SetLastError(ERROR_CLIPBOARD_NOT_OPEN); |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 402 | return FALSE; |
| 403 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 404 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 405 | /* Destroy private objects */ |
| 406 | if (cbinfo.hWndOwner) |
| 407 | SendMessageW(cbinfo.hWndOwner, WM_DESTROYCLIPBOARD, 0, 0); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 408 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 409 | /* Tell the driver to acquire the selection. The current owner |
| 410 | * will be signaled to delete it's own cache. */ |
| 411 | if (~cbinfo.flags & CB_OWNER) |
| 412 | { |
| 413 | /* Assign ownership of the clipboard to the current client. We do |
| 414 | * this before acquiring the selection so that when we do acquire the |
| 415 | * selection and the selection loser gets notified, it can check if |
| 416 | * it has lost the Wine clipboard ownership. If it did then it knows |
| 417 | * that a WM_DESTORYCLIPBOARD has already been sent. Otherwise it |
| 418 | * lost the selection to a X app and it should send the |
| 419 | * WM_DESTROYCLIPBOARD itself. */ |
| 420 | CLIPBOARD_SetClipboardOwner(cbinfo.hWndOpen); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 421 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 422 | /* Acquire the selection. This will notify the previous owner |
| 423 | * to clear it's cache. */ |
| 424 | if (USER_Driver.pAcquireClipboard) |
| 425 | USER_Driver.pAcquireClipboard(cbinfo.hWndOpen); |
| 426 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 427 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 428 | /* Empty the local cache */ |
| 429 | if (USER_Driver.pEmptyClipboard) |
Ulrich Czekalla | b41466b | 2004-05-06 23:40:30 +0000 | [diff] [blame] | 430 | USER_Driver.pEmptyClipboard(FALSE); |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 431 | |
| 432 | bCBHasChanged = TRUE; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 433 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 434 | return TRUE; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 439 | * GetClipboardOwner (USER32.@) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 440 | * FIXME: Can't return the owner if the clipboard is owned by an external X-app |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 441 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 442 | HWND WINAPI GetClipboardOwner(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 443 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 444 | HWND hWndOwner = 0; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 445 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 446 | SERVER_START_REQ( set_clipboard_info ) |
| 447 | { |
| 448 | req->flags = 0; |
| 449 | if (!wine_server_call_err( req )) hWndOwner = reply->old_owner; |
| 450 | } |
| 451 | SERVER_END_REQ; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 452 | |
| 453 | TRACE(" hWndOwner(%p)\n", hWndOwner); |
| 454 | |
| 455 | return hWndOwner; |
| 456 | } |
| 457 | |
| 458 | |
| 459 | /************************************************************************** |
| 460 | * GetOpenClipboardWindow (USER32.@) |
| 461 | */ |
| 462 | HWND WINAPI GetOpenClipboardWindow(void) |
| 463 | { |
| 464 | HWND hWndOpen = 0; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 465 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 466 | SERVER_START_REQ( set_clipboard_info ) |
| 467 | { |
| 468 | req->flags = 0; |
| 469 | if (!wine_server_call_err( req )) hWndOpen = reply->old_clipboard; |
| 470 | } |
| 471 | SERVER_END_REQ; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 472 | |
| 473 | TRACE(" hWndClipWindow(%p)\n", hWndOpen); |
| 474 | |
| 475 | return hWndOpen; |
| 476 | } |
| 477 | |
| 478 | |
| 479 | /************************************************************************** |
| 480 | * SetClipboardViewer (USER32.@) |
| 481 | */ |
| 482 | HWND WINAPI SetClipboardViewer( HWND hWnd ) |
| 483 | { |
| 484 | HWND hwndPrev = 0; |
| 485 | |
| 486 | SERVER_START_REQ( set_clipboard_info ) |
| 487 | { |
| 488 | req->flags = SET_CB_VIEWER; |
| 489 | req->viewer = WIN_GetFullHandle(hWnd); |
| 490 | |
| 491 | if (wine_server_call_err( req )) |
| 492 | { |
| 493 | ERR("Failed to set clipboard.\n"); |
| 494 | } |
| 495 | else |
| 496 | { |
| 497 | hwndPrev = reply->old_viewer; |
| 498 | } |
| 499 | } |
| 500 | SERVER_END_REQ; |
| 501 | |
| 502 | TRACE("(%p): returning %p\n", hWnd, hwndPrev); |
| 503 | |
| 504 | return hwndPrev; |
| 505 | } |
| 506 | |
| 507 | |
| 508 | /************************************************************************** |
| 509 | * GetClipboardViewer (USER32.@) |
| 510 | */ |
| 511 | HWND WINAPI GetClipboardViewer(void) |
| 512 | { |
| 513 | HWND hWndViewer = 0; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 514 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 515 | SERVER_START_REQ( set_clipboard_info ) |
| 516 | { |
| 517 | req->flags = 0; |
| 518 | if (!wine_server_call_err( req )) hWndViewer = reply->old_viewer; |
| 519 | } |
| 520 | SERVER_END_REQ; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 521 | |
| 522 | TRACE(" hWndViewer=%p\n", hWndViewer); |
| 523 | |
| 524 | return hWndViewer; |
| 525 | } |
| 526 | |
| 527 | |
| 528 | /************************************************************************** |
| 529 | * ChangeClipboardChain (USER32.@) |
| 530 | */ |
| 531 | BOOL WINAPI ChangeClipboardChain(HWND hWnd, HWND hWndNext) |
| 532 | { |
| 533 | BOOL bRet = TRUE; |
| 534 | HWND hWndViewer = GetClipboardViewer(); |
| 535 | |
| 536 | if (hWndViewer) |
| 537 | { |
| 538 | if (WIN_GetFullHandle(hWnd) == hWndViewer) |
| 539 | SetClipboardViewer(WIN_GetFullHandle(hWndNext)); |
| 540 | else |
| 541 | bRet = !SendMessageW(hWndViewer, WM_CHANGECBCHAIN, (WPARAM)hWnd, (LPARAM)hWndNext); |
| 542 | } |
| 543 | else |
| 544 | ERR("hWndViewer is lost\n"); |
| 545 | |
| 546 | return bRet; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | |
| 550 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 551 | * SetClipboardData (USER.141) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 552 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 553 | HANDLE16 WINAPI SetClipboardData16(UINT16 wFormat, HANDLE16 hData) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 554 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 555 | CLIPBOARDINFO cbinfo; |
| 556 | HANDLE16 hResult = 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 557 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 558 | TRACE("(%04X, %04x) !\n", wFormat, hData); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 559 | |
Ulrich Czekalla | b41466b | 2004-05-06 23:40:30 +0000 | [diff] [blame] | 560 | /* If it's not owned, data can only be set if the format doesn't exists |
| 561 | and its rendering is not delayed */ |
Ulrich Czekalla | 4e10f0e | 2004-05-10 19:59:36 +0000 | [diff] [blame] | 562 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 563 | (!(cbinfo.flags & CB_OWNER) && !hData)) |
Ulrich Czekalla | b41466b | 2004-05-06 23:40:30 +0000 | [diff] [blame] | 564 | { |
| 565 | WARN("Clipboard not owned by calling task. Operation failed.\n"); |
| 566 | return 0; |
| 567 | } |
| 568 | |
| 569 | if (USER_Driver.pSetClipboardData && |
| 570 | USER_Driver.pSetClipboardData(wFormat, hData, 0, cbinfo.flags & CB_OWNER)) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 571 | { |
| 572 | hResult = hData; |
| 573 | bCBHasChanged = TRUE; |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 574 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 575 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 576 | return hResult; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 577 | } |
| 578 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 579 | |
| 580 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 581 | * SetClipboardData (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 582 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 583 | HANDLE WINAPI SetClipboardData(UINT wFormat, HANDLE hData) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 584 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 585 | CLIPBOARDINFO cbinfo; |
| 586 | HANDLE hResult = 0; |
Pascal Cuoq | 724f190 | 1998-10-26 10:58:16 +0000 | [diff] [blame] | 587 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 588 | TRACE("(%04X, %p) !\n", wFormat, hData); |
Pascal Cuoq | 724f190 | 1998-10-26 10:58:16 +0000 | [diff] [blame] | 589 | |
Ulrich Czekalla | b41466b | 2004-05-06 23:40:30 +0000 | [diff] [blame] | 590 | /* If it's not owned, data can only be set if the format isn't |
| 591 | available and its rendering is not delayed */ |
Ulrich Czekalla | 4e10f0e | 2004-05-10 19:59:36 +0000 | [diff] [blame] | 592 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 593 | (!(cbinfo.flags & CB_OWNER) && !hData)) |
Ulrich Czekalla | b41466b | 2004-05-06 23:40:30 +0000 | [diff] [blame] | 594 | { |
| 595 | WARN("Clipboard not owned by calling task. Operation failed.\n"); |
| 596 | return 0; |
| 597 | } |
| 598 | |
| 599 | if (USER_Driver.pSetClipboardData && |
| 600 | USER_Driver.pSetClipboardData(wFormat, 0, hData, cbinfo.flags & CB_OWNER)) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 601 | { |
| 602 | hResult = hData; |
| 603 | bCBHasChanged = TRUE; |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 604 | } |
Pascal Cuoq | 724f190 | 1998-10-26 10:58:16 +0000 | [diff] [blame] | 605 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 606 | return hResult; |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 609 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 610 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 611 | * CountClipboardFormats (USER.143) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 612 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 613 | INT16 WINAPI CountClipboardFormats16(void) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 614 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 615 | return CountClipboardFormats(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | |
| 619 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 620 | * CountClipboardFormats (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 621 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 622 | INT WINAPI CountClipboardFormats(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 623 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 624 | INT count = 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 625 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 626 | if (USER_Driver.pCountClipboardFormats) |
| 627 | count = USER_Driver.pCountClipboardFormats(); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 628 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 629 | TRACE("returning %d\n", count); |
| 630 | return count; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 631 | } |
| 632 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 633 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 634 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 635 | * EnumClipboardFormats (USER.144) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 636 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 637 | UINT16 WINAPI EnumClipboardFormats16(UINT16 wFormat) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 638 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 639 | return EnumClipboardFormats(wFormat); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | |
| 643 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 644 | * EnumClipboardFormats (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 645 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 646 | UINT WINAPI EnumClipboardFormats(UINT wFormat) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 647 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 648 | UINT wFmt = 0; |
| 649 | CLIPBOARDINFO cbinfo; |
| 650 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 651 | TRACE("(%04X)\n", wFormat); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 652 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 653 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 654 | (~cbinfo.flags & CB_OPEN)) |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 655 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 656 | WARN("Clipboard not opened by calling task.\n"); |
| 657 | SetLastError(ERROR_CLIPBOARD_NOT_OPEN); |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 658 | return 0; |
| 659 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 660 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 661 | if (USER_Driver.pEnumClipboardFormats) |
| 662 | wFmt = USER_Driver.pEnumClipboardFormats(wFormat); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 663 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 664 | return wFmt; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | |
| 668 | /************************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 669 | * IsClipboardFormatAvailable (USER.193) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 670 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 671 | BOOL16 WINAPI IsClipboardFormatAvailable16(UINT16 wFormat) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 672 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 673 | return IsClipboardFormatAvailable(wFormat); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | |
| 677 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 678 | * IsClipboardFormatAvailable (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 679 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 680 | BOOL WINAPI IsClipboardFormatAvailable(UINT wFormat) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 681 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 682 | BOOL bret = FALSE; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 683 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 684 | if (USER_Driver.pIsClipboardFormatAvailable) |
| 685 | bret = USER_Driver.pIsClipboardFormatAvailable(wFormat); |
| 686 | |
| 687 | TRACE("%04x, returning %d\n", wFormat, bret); |
| 688 | return bret; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | |
| 692 | /************************************************************************** |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 693 | * GetClipboardData (USER.142) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 694 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 695 | HANDLE16 WINAPI GetClipboardData16(UINT16 wFormat) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 696 | { |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 697 | HANDLE16 hData = 0; |
| 698 | CLIPBOARDINFO cbinfo; |
| 699 | |
| 700 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 701 | (~cbinfo.flags & CB_OPEN)) |
| 702 | { |
| 703 | WARN("Clipboard not opened by calling task.\n"); |
| 704 | SetLastError(ERROR_CLIPBOARD_NOT_OPEN); |
| 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | if (USER_Driver.pGetClipboardData) |
| 709 | USER_Driver.pGetClipboardData(wFormat, &hData, NULL); |
| 710 | |
| 711 | return hData; |
| 712 | } |
| 713 | |
| 714 | |
| 715 | /************************************************************************** |
| 716 | * GetClipboardData (USER32.@) |
| 717 | */ |
| 718 | HANDLE WINAPI GetClipboardData(UINT wFormat) |
| 719 | { |
| 720 | HANDLE hData = 0; |
| 721 | CLIPBOARDINFO cbinfo; |
| 722 | |
| 723 | TRACE("%04x\n", wFormat); |
| 724 | |
| 725 | if (!CLIPBOARD_GetClipboardInfo(&cbinfo) || |
| 726 | (~cbinfo.flags & CB_OPEN)) |
| 727 | { |
| 728 | WARN("Clipboard not opened by calling task.\n"); |
| 729 | SetLastError(ERROR_CLIPBOARD_NOT_OPEN); |
| 730 | return 0; |
| 731 | } |
| 732 | |
| 733 | if (USER_Driver.pGetClipboardData) |
| 734 | USER_Driver.pGetClipboardData(wFormat, NULL, &hData); |
| 735 | |
| 736 | TRACE("returning %p\n", hData); |
| 737 | return hData; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | |
| 741 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 742 | * GetPriorityClipboardFormat (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 743 | */ |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 744 | INT WINAPI GetPriorityClipboardFormat(UINT *list, INT nCount) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 745 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 746 | int i; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 747 | |
Noel Borthwick | 2970067 | 1999-09-03 15:17:57 +0000 | [diff] [blame] | 748 | TRACE("()\n"); |
Alexandre Julliard | 0623a6f | 1998-01-18 18:01:49 +0000 | [diff] [blame] | 749 | |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 750 | if(CountClipboardFormats() == 0) |
| 751 | return 0; |
Alexandre Julliard | 0623a6f | 1998-01-18 18:01:49 +0000 | [diff] [blame] | 752 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 753 | for (i = 0; i < nCount; i++) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 754 | if (IsClipboardFormatAvailable(list[i])) |
| 755 | return list[i]; |
| 756 | |
Alexandre Julliard | 0623a6f | 1998-01-18 18:01:49 +0000 | [diff] [blame] | 757 | return -1; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 758 | } |
| 759 | |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 760 | |
| 761 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 762 | * GetClipboardSequenceNumber (USER32.@) |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 763 | * Supported on Win2k/Win98 |
| 764 | * MSDN: Windows clipboard code keeps a serial number for the clipboard |
| 765 | * for each window station. The number is incremented whenever the |
| 766 | * contents change or are emptied. |
| 767 | * If you do not have WINSTA_ACCESSCLIPBOARD then the function returns 0 |
| 768 | */ |
| 769 | DWORD WINAPI GetClipboardSequenceNumber(VOID) |
| 770 | { |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 771 | DWORD seqno = 0; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 772 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 773 | SERVER_START_REQ( set_clipboard_info ) |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 774 | { |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 775 | req->flags = 0; |
| 776 | if (!wine_server_call_err( req )) seqno = reply->seqno; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 777 | } |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 778 | SERVER_END_REQ; |
Ulrich Czekalla | b2df5f9 | 2003-06-23 23:02:02 +0000 | [diff] [blame] | 779 | |
Alexandre Julliard | 5329fc8 | 2003-12-05 04:45:50 +0000 | [diff] [blame] | 780 | TRACE("returning %lx\n", seqno); |
| 781 | return seqno; |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 782 | } |