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