Use poll() on the client-side during server waits to implement
[wine.git] / windows / clipboard.c
blobd51e063a9e6969397fe629cfd64b1dc83916855b
1 /*
2 * WIN32 clipboard implementation
4 * Copyright 1994 Martin Ayotte
5 * 1996 Alex Korobka
6 * 1999 Noel Borthwick
8 * NOTES:
9 * This file contains the implementation for the WIN32 Clipboard API
10 * and Wine's internal clipboard cache.
11 * The actual contents of the clipboard are held in the clipboard cache.
12 * The internal implementation talks to a "clipboard driver" to fill or
13 * expose the cache to the native device. (Currently only the X11 and
14 * TTY clipboard driver are available)
16 * TODO:
20 #include <stdlib.h>
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include <fcntl.h>
24 #include <unistd.h>
25 #include <string.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "wine/winuser16.h"
32 #include "wine/winbase16.h"
33 #include "heap.h"
34 #include "message.h"
35 #include "queue.h"
36 #include "user.h"
37 #include "clipboard.h"
38 #include "debugtools.h"
40 DEFAULT_DEBUG_CHANNEL(clipboard);
42 #define CF_REGFORMATBASE 0xC000
44 /**************************************************************************
45 * Clipboard context global variables
48 static HANDLE hClipLock = 0;
49 static BOOL bCBHasChanged = FALSE;
51 HWND hWndClipWindow = 0; /* window that last opened clipboard */
52 HWND hWndClipOwner = 0; /* current clipboard owner */
53 HANDLE16 hTaskClipOwner = 0; /* clipboard owner's task */
54 static HWND hWndViewer = 0; /* start of viewers chain */
56 static WORD LastRegFormat = CF_REGFORMATBASE;
58 /* Clipboard cache initial data.
59 * WARNING: This data ordering is dependent on the WINE_CLIPFORMAT structure
60 * declared in clipboard.h
62 WINE_CLIPFORMAT ClipFormats[] = {
63 { CF_TEXT, 1, 0, "Text", 0, 0, 0, 0, NULL, &ClipFormats[1]},
64 { CF_BITMAP, 1, 0, "Bitmap", 0, 0, 0, 0, &ClipFormats[0], &ClipFormats[2]},
65 { CF_METAFILEPICT, 1, 0, "MetaFile Picture", 0, 0, 0, 0, &ClipFormats[1], &ClipFormats[3]},
66 { CF_SYLK, 1, 0, "Sylk", 0, 0, 0, 0, &ClipFormats[2], &ClipFormats[4]},
67 { CF_DIF, 1, 0, "DIF", 0, 0, 0, 0, &ClipFormats[3], &ClipFormats[5]},
68 { CF_TIFF, 1, 0, "TIFF", 0, 0, 0, 0, &ClipFormats[4], &ClipFormats[6]},
69 { CF_OEMTEXT, 1, 0, "OEM Text", 0, 0, 0, 0, &ClipFormats[5], &ClipFormats[7]},
70 { CF_DIB, 1, 0, "DIB", 0, 0, 0, 0, &ClipFormats[6], &ClipFormats[8]},
71 { CF_PALETTE, 1, 0, "Palette", 0, 0, 0, 0, &ClipFormats[7], &ClipFormats[9]},
72 { CF_PENDATA, 1, 0, "PenData", 0, 0, 0, 0, &ClipFormats[8], &ClipFormats[10]},
73 { CF_RIFF, 1, 0, "RIFF", 0, 0, 0, 0, &ClipFormats[9], &ClipFormats[11]},
74 { CF_WAVE, 1, 0, "Wave", 0, 0, 0, 0, &ClipFormats[10], &ClipFormats[12]},
75 { CF_UNICODETEXT, 1, 0, "Unicode Text", 0, 0, 0, 0, &ClipFormats[11], &ClipFormats[13]},
76 { CF_OWNERDISPLAY, 1, 0, "Owner Display", 0, 0, 0, 0, &ClipFormats[12], &ClipFormats[14]},
77 { CF_DSPTEXT, 1, 0, "DSPText", 0, 0, 0, 0, &ClipFormats[13], &ClipFormats[15]},
78 { CF_DSPMETAFILEPICT, 1, 0, "DSPMetaFile Picture", 0, 0, 0, 0, &ClipFormats[14], &ClipFormats[16]},
79 { CF_DSPBITMAP, 1, 0, "DSPBitmap", 0, 0, 0, 0, &ClipFormats[15], &ClipFormats[17]},
80 { CF_HDROP, 1, 0, "HDROP", 0, 0, 0, 0, &ClipFormats[16], NULL}
84 /**************************************************************************
85 * Internal Clipboard implementation methods
86 **************************************************************************/
89 /**************************************************************************
90 * CLIPBOARD_LookupFormat
92 static LPWINE_CLIPFORMAT __lookup_format( LPWINE_CLIPFORMAT lpFormat, WORD wID )
94 while(TRUE)
96 if (lpFormat == NULL ||
97 lpFormat->wFormatID == wID) break;
98 lpFormat = lpFormat->NextFormat;
100 return lpFormat;
103 LPWINE_CLIPFORMAT CLIPBOARD_LookupFormat( WORD wID )
105 return __lookup_format( ClipFormats, wID );
108 /**************************************************************************
109 * CLIPBOARD_IsLocked
110 * Check if the clipboard cache is available to the caller
112 BOOL CLIPBOARD_IsLocked()
114 BOOL bIsLocked = TRUE;
115 HANDLE16 hTaskCur = GetCurrentTask();
118 * The clipboard is available:
119 * 1. if the caller's task has opened the clipboard,
120 * or
121 * 2. if the caller is the clipboard owners task, AND is responding to a
122 * WM_RENDERFORMAT message.
124 if ( hClipLock == hTaskCur )
125 bIsLocked = FALSE;
127 else if ( hTaskCur == hTaskClipOwner )
129 /* Check if we're currently executing inside a window procedure
130 * called in response to a WM_RENDERFORMAT message. A WM_RENDERFORMAT
131 * handler is not permitted to open the clipboard since it has been opened
132 * by another client. However the handler must have access to the
133 * clipboard in order to update data in response to this message.
135 MESSAGEQUEUE *queue = QUEUE_Lock( GetFastQueue16() );
137 if ( queue
138 && queue->smWaiting
139 && queue->smWaiting->msg == WM_RENDERFORMAT
140 && queue->smWaiting->hSrcQueue
142 bIsLocked = FALSE;
144 QUEUE_Unlock( queue );
147 return bIsLocked;
150 /**************************************************************************
151 * CLIPBOARD_ReleaseOwner
152 * Gives up ownership of the clipboard
154 void CLIPBOARD_ReleaseOwner()
156 hWndClipOwner = 0;
157 hTaskClipOwner = 0;
160 /**************************************************************************
161 * CLIPBOARD_GlobalFreeProc
163 * This is a callback mechanism to allow HGLOBAL data to be released in
164 * the context of the process which allocated it. We post a WM_TIMER message
165 * to the owner window(in CLIPBOARD_DeleteRecord) and destroy the data(in idEvent)
166 * in this WndProc, which is invoked when the apps message loop calls DispatchMessage.
167 * This technique is discussed in Matt Pietrek's "Under the Hood".
168 * An article describing the same may be found in MSDN by searching for WM_TIMER.
169 * Note that this mechanism will probably stop working when WINE supports
170 * address space separation. When "queue events" are implemented in Wine we
171 * should switch to using that mechanism, since it is more robust and does not
172 * require a procedure address to be passed. See the SetWinEventHook API for
173 * more info on this.
175 VOID CALLBACK CLIPBOARD_GlobalFreeProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
177 /* idEvent is the HGLOBAL to be deleted */
178 GlobalFree( (HGLOBAL)idEvent );
181 /**************************************************************************
182 * CLIPBOARD_DeleteRecord
184 void CLIPBOARD_DeleteRecord(LPWINE_CLIPFORMAT lpFormat, BOOL bChange)
186 if( (lpFormat->wFormatID >= CF_GDIOBJFIRST &&
187 lpFormat->wFormatID <= CF_GDIOBJLAST) || lpFormat->wFormatID == CF_BITMAP
188 || lpFormat->wFormatID == CF_PALETTE)
190 if (lpFormat->hData32)
191 DeleteObject(lpFormat->hData32);
192 if (lpFormat->hData16)
193 DeleteObject(lpFormat->hData16);
195 else if( lpFormat->wFormatID == CF_METAFILEPICT )
197 if (lpFormat->hData32)
199 DeleteMetaFile( ((METAFILEPICT *)GlobalLock( lpFormat->hData32 ))->hMF );
200 PostMessageA(hWndClipOwner, WM_TIMER,
201 (WPARAM)lpFormat->hData32, (LPARAM)CLIPBOARD_GlobalFreeProc);
202 if (lpFormat->hDataSrc32)
204 /* Release lpFormat->hData32 in the context of the process which created it.
205 * See CLIPBOARD_GlobalFreeProc for more details about this technique.
206 * GlobalFree(lpFormat->hDataSrc32);
208 PostMessageA(hWndClipOwner, WM_TIMER,
209 (WPARAM)lpFormat->hDataSrc32, (LPARAM)CLIPBOARD_GlobalFreeProc);
212 if (lpFormat->hData16)
213 /* HMETAFILE16 and HMETAFILE32 are apparently the same thing,
214 and a shallow copy is enough to share a METAFILEPICT
215 structure between 16bit and 32bit clipboards. The MetaFile
216 should of course only be deleted once. */
217 GlobalFree16(lpFormat->hData16);
219 if (lpFormat->hData16)
221 DeleteMetaFile16( ((METAFILEPICT16 *)GlobalLock16( lpFormat->hData16 ))->hMF );
222 GlobalFree16(lpFormat->hData16);
225 else
227 if (lpFormat->hData32)
229 /* Release lpFormat->hData32 in the context of the process which created it.
230 * See CLIPBOARD_GlobalFreeProc for more details about this technique.
231 * GlobalFree( lpFormat->hData32 );
233 PostMessageA(hWndClipOwner, WM_TIMER,
234 (WPARAM)lpFormat->hData32, (LPARAM)CLIPBOARD_GlobalFreeProc);
236 if (lpFormat->hDataSrc32)
238 /* Release lpFormat->hData32 in the context of the process which created it.
239 * See CLIPBOARD_GlobalFreeProc for more details about this technique.
240 * GlobalFree(lpFormat->hDataSrc32);
242 PostMessageA(hWndClipOwner, WM_TIMER,
243 (WPARAM)lpFormat->hDataSrc32, (LPARAM)CLIPBOARD_GlobalFreeProc);
245 if (lpFormat->hData16)
246 GlobalFree16(lpFormat->hData16);
249 lpFormat->wDataPresent = 0;
250 lpFormat->hData16 = 0;
251 lpFormat->hData32 = 0;
252 lpFormat->hDataSrc32 = 0;
253 lpFormat->drvData = 0;
255 if( bChange ) bCBHasChanged = TRUE;
258 /**************************************************************************
259 * CLIPBOARD_EmptyCache
261 void CLIPBOARD_EmptyCache( BOOL bChange )
263 LPWINE_CLIPFORMAT lpFormat = ClipFormats;
265 while(lpFormat)
267 if ( lpFormat->wDataPresent || lpFormat->hData16 || lpFormat->hData32 )
268 CLIPBOARD_DeleteRecord( lpFormat, bChange );
270 lpFormat = lpFormat->NextFormat;
274 /**************************************************************************
275 * CLIPBOARD_IsPresent
277 BOOL CLIPBOARD_IsPresent(WORD wFormat)
279 /* special case */
281 if( wFormat == CF_TEXT || wFormat == CF_OEMTEXT || wFormat == CF_UNICODETEXT )
282 return ClipFormats[CF_TEXT-1].wDataPresent ||
283 ClipFormats[CF_OEMTEXT-1].wDataPresent ||
284 ClipFormats[CF_UNICODETEXT-1].wDataPresent;
285 else
287 LPWINE_CLIPFORMAT lpFormat = __lookup_format( ClipFormats, wFormat );
288 if( lpFormat ) return (lpFormat->wDataPresent);
290 return FALSE;
293 /**************************************************************************
294 * CLIPBOARD_IsCacheRendered
295 * Checks if any data needs to be rendered to the clipboard cache
296 * RETURNS:
297 * TRUE - All clipboard data is available in the cache
298 * FALSE - Some data is marked for delayed render and needs rendering
300 BOOL CLIPBOARD_IsCacheRendered()
302 LPWINE_CLIPFORMAT lpFormat = ClipFormats;
304 /* check if all formats were rendered */
305 while(lpFormat)
307 if( lpFormat->wDataPresent && !lpFormat->hData16 && !lpFormat->hData32 )
308 return FALSE;
310 lpFormat = lpFormat->NextFormat;
313 return TRUE;
317 /**************************************************************************
318 * CLIPBOARD_IsMemoryObject
319 * Tests if the clipboard format specifies a memory object
321 BOOL CLIPBOARD_IsMemoryObject( WORD wFormat )
323 switch(wFormat)
325 case CF_BITMAP:
326 case CF_METAFILEPICT:
327 case CF_DSPTEXT:
328 case CF_ENHMETAFILE:
329 case CF_HDROP:
330 case CF_PALETTE:
331 case CF_PENDATA:
332 return FALSE;
333 default:
334 return TRUE;
338 /***********************************************************************
339 * CLIPBOARD_GlobalDupMem( HGLOBAL )
340 * Helper method to duplicate an HGLOBAL chunk of memory into shared memory
342 HGLOBAL CLIPBOARD_GlobalDupMem( HGLOBAL hGlobalSrc )
344 HGLOBAL hGlobalDest;
345 PVOID pGlobalSrc, pGlobalDest;
346 DWORD cBytes;
348 if ( !hGlobalSrc )
349 return 0;
351 cBytes = GlobalSize(hGlobalSrc);
352 if ( 0 == cBytes )
353 return 0;
355 /* Turn on the DDESHARE and _MOVEABLE flags explicitly */
356 hGlobalDest = GlobalAlloc( GlobalFlags(hGlobalSrc) | GMEM_DDESHARE | GMEM_MOVEABLE,
357 cBytes );
358 if ( !hGlobalDest )
359 return 0;
361 pGlobalSrc = GlobalLock(hGlobalSrc);
362 pGlobalDest = GlobalLock(hGlobalDest);
363 if ( !pGlobalSrc || !pGlobalDest )
364 return 0;
366 memcpy(pGlobalDest, pGlobalSrc, cBytes);
368 GlobalUnlock(hGlobalSrc);
369 GlobalUnlock(hGlobalDest);
371 return hGlobalDest;
374 /**************************************************************************
375 * CLIPBOARD_GetFormatName
376 * Gets the format name associated with an ID
378 char * CLIPBOARD_GetFormatName(UINT wFormat)
380 LPWINE_CLIPFORMAT lpFormat = __lookup_format( ClipFormats, wFormat );
381 return (lpFormat) ? lpFormat->Name : NULL;
385 /**************************************************************************
386 * CLIPBOARD_RenderFormat
388 static BOOL CLIPBOARD_RenderFormat(LPWINE_CLIPFORMAT lpFormat)
391 * If WINE is not the selection owner, and the format is available
392 * we must ask the driver to render the data to the clipboard cache.
394 TRACE("enter format=%d\n", lpFormat->wFormatID);
395 if ( !USER_Driver.pIsSelectionOwner()
396 && USER_Driver.pIsClipboardFormatAvailable( lpFormat->wFormatID ) )
398 if ( !USER_Driver.pGetClipboardData( lpFormat->wFormatID ) )
399 return FALSE;
402 * If Wine owns the clipboard, and the data is marked for delayed render,
403 * render it now.
405 else if( lpFormat->wDataPresent && !lpFormat->hData16 && !lpFormat->hData32 )
407 if( IsWindow(hWndClipOwner) )
409 /* Send a WM_RENDERFORMAT message to notify the owner to render the
410 * data requested into the clipboard.
412 TRACE("Sending WM_RENDERFORMAT message\n");
413 SendMessage16(hWndClipOwner,WM_RENDERFORMAT,
414 (WPARAM16)lpFormat->wFormatID,0L);
416 else
418 WARN("\thWndClipOwner (%04x) is lost!\n",
419 hWndClipOwner);
420 CLIPBOARD_ReleaseOwner();
421 lpFormat->wDataPresent = 0;
422 return FALSE;
426 return (lpFormat->hData16 || lpFormat->hData32) ? TRUE : FALSE;
429 /**************************************************************************
430 * CLIPBOARD_ConvertText
431 * Returns number of required/converted characters - not bytes!
433 static INT CLIPBOARD_ConvertText(WORD src_fmt, void const *src, INT src_size,
434 WORD dst_fmt, void *dst, INT dst_size)
436 UINT cp;
438 if(src_fmt == CF_UNICODETEXT)
440 switch(dst_fmt)
442 case CF_TEXT:
443 cp = CP_ACP;
444 break;
445 case CF_OEMTEXT:
446 cp = CP_OEMCP;
447 break;
448 default:
449 return 0;
451 return WideCharToMultiByte(cp, 0, src, src_size, dst, dst_size, NULL, NULL);
454 if(dst_fmt == CF_UNICODETEXT)
456 switch(src_fmt)
458 case CF_TEXT:
459 cp = CP_ACP;
460 break;
461 case CF_OEMTEXT:
462 cp = CP_OEMCP;
463 break;
464 default:
465 return 0;
467 return MultiByteToWideChar(cp, 0, src, src_size, dst, dst_size);
470 if(!dst_size) return src_size;
472 if(dst_size > src_size) dst_size = src_size;
474 if(src_fmt == CF_TEXT )
475 CharToOemBuffA(src, dst, dst_size);
476 else
477 OemToCharBuffA(src, dst, dst_size);
479 return dst_size;
482 /**************************************************************************
483 * CLIPBOARD_RenderText
485 * Renders text to the clipboard buffer converting between UNIX and DOS formats.
487 * RETURNS: pointer to the WINE_CLIPFORMAT if successful, NULL otherwise
489 * FIXME: Should be a pair of driver functions that convert between OEM text and Windows.
492 static LPWINE_CLIPFORMAT CLIPBOARD_RenderText( UINT wFormat )
494 LPWINE_CLIPFORMAT lpSource = ClipFormats;
495 LPWINE_CLIPFORMAT lpTarget = NULL;
496 BOOL foundData = FALSE;
498 /* Asked for CF_TEXT */
499 if( wFormat == CF_TEXT)
501 if(ClipFormats[CF_TEXT-1].wDataPresent)
503 lpSource = &ClipFormats[CF_TEXT-1];
504 lpTarget = &ClipFormats[CF_TEXT-1];
505 foundData = TRUE;
506 TRACE("\t TEXT -> TEXT\n");
508 else if(ClipFormats[CF_UNICODETEXT-1].wDataPresent)
510 /* Convert UNICODETEXT -> TEXT */
511 lpSource = &ClipFormats[CF_UNICODETEXT-1];
512 lpTarget = &ClipFormats[CF_TEXT-1];
513 foundData = TRUE;
514 TRACE("\tUNICODETEXT -> TEXT\n");
516 else if(ClipFormats[CF_OEMTEXT-1].wDataPresent)
518 /* Convert OEMTEXT -> TEXT */
519 lpSource = &ClipFormats[CF_OEMTEXT-1];
520 lpTarget = &ClipFormats[CF_TEXT-1];
521 foundData = TRUE;
522 TRACE("\tOEMTEXT -> TEXT\n");
525 /* Asked for CF_OEMTEXT */
526 else if( wFormat == CF_OEMTEXT)
528 if(ClipFormats[CF_OEMTEXT-1].wDataPresent)
530 lpSource = &ClipFormats[CF_OEMTEXT-1];
531 lpTarget = &ClipFormats[CF_OEMTEXT-1];
532 foundData = TRUE;
533 TRACE("\tOEMTEXT -> OEMTEXT\n");
535 else if(ClipFormats[CF_UNICODETEXT-1].wDataPresent)
537 /* Convert UNICODETEXT -> OEMTEXT */
538 lpSource = &ClipFormats[CF_UNICODETEXT-1];
539 lpTarget = &ClipFormats[CF_OEMTEXT-1];
540 foundData = TRUE;
541 TRACE("\tUNICODETEXT -> OEMTEXT\n");
543 else if(ClipFormats[CF_TEXT-1].wDataPresent)
545 /* Convert TEXT -> OEMTEXT */
546 lpSource = &ClipFormats[CF_TEXT-1];
547 lpTarget = &ClipFormats[CF_OEMTEXT-1];
548 foundData = TRUE;
549 TRACE("\tTEXT -> OEMTEXT\n");
552 /* Asked for CF_UNICODETEXT */
553 else if( wFormat == CF_UNICODETEXT )
555 if(ClipFormats[CF_UNICODETEXT-1].wDataPresent)
557 lpSource = &ClipFormats[CF_UNICODETEXT-1];
558 lpTarget = &ClipFormats[CF_UNICODETEXT-1];
559 foundData = TRUE;
560 TRACE("\tUNICODETEXT -> UNICODETEXT\n");
562 else if(ClipFormats[CF_TEXT-1].wDataPresent)
564 /* Convert TEXT -> UNICODETEXT */
565 lpSource = &ClipFormats[CF_TEXT-1];
566 lpTarget = &ClipFormats[CF_UNICODETEXT-1];
567 foundData = TRUE;
568 TRACE("\tTEXT -> UNICODETEXT\n");
570 else if(ClipFormats[CF_OEMTEXT-1].wDataPresent)
572 /* Convert OEMTEXT -> UNICODETEXT */
573 lpSource = &ClipFormats[CF_OEMTEXT-1];
574 lpTarget = &ClipFormats[CF_UNICODETEXT-1];
575 foundData = TRUE;
576 TRACE("\tOEMTEXT -> UNICODETEXT\n");
579 if (!foundData)
581 if ((wFormat == CF_TEXT) || (wFormat == CF_OEMTEXT))
583 lpSource = &ClipFormats[CF_UNICODETEXT-1];
584 lpTarget = __lookup_format( ClipFormats, wFormat );
586 else
588 lpSource = __lookup_format( ClipFormats, wFormat );
589 lpTarget = lpSource;
593 /* First render the source text format */
594 if ( !lpSource || !CLIPBOARD_RenderFormat(lpSource) ) return NULL;
596 /* Convert to the desired target text format, if necessary */
597 if( lpTarget != lpSource && !lpTarget->hData16 && !lpTarget->hData32 )
599 INT src_chars, dst_chars, alloc_size;
600 LPCSTR lpstrS;
601 LPSTR lpstrT;
603 if (lpSource->hData32)
605 lpstrS = (LPSTR)GlobalLock(lpSource->hData32);
607 else
609 lpstrS = (LPSTR)GlobalLock16(lpSource->hData16);
612 if( !lpstrS ) return NULL;
614 /* Text always NULL terminated */
615 if(lpSource->wFormatID == CF_UNICODETEXT)
616 src_chars = strlenW((LPCWSTR)lpstrS)+1;
617 else
618 src_chars = strlen(lpstrS)+1;
620 /* Calculate number of characters in the destination buffer */
621 dst_chars = CLIPBOARD_ConvertText(lpSource->wFormatID, lpstrS, src_chars,
622 lpTarget->wFormatID, NULL, 0);
623 if(!dst_chars) return NULL;
625 TRACE("\tconverting from '%s' to '%s', %i chars\n",
626 lpSource->Name, lpTarget->Name, src_chars);
628 /* Convert characters to bytes */
629 if(lpTarget->wFormatID == CF_UNICODETEXT)
630 alloc_size = dst_chars * sizeof(WCHAR);
631 else
632 alloc_size = dst_chars;
634 lpTarget->hData32 = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE, alloc_size);
635 lpstrT = (LPSTR)GlobalLock(lpTarget->hData32);
637 if( lpstrT )
639 CLIPBOARD_ConvertText(lpSource->wFormatID, lpstrS, src_chars,
640 lpTarget->wFormatID, lpstrT, dst_chars);
641 GlobalUnlock(lpTarget->hData32);
643 else
644 lpTarget->hData32 = 0;
646 /* Unlock source */
647 if (lpSource->hData32)
648 GlobalUnlock(lpSource->hData32);
649 else
650 GlobalUnlock16(lpSource->hData16);
653 return (lpTarget->hData16 || lpTarget->hData32) ? lpTarget : NULL;
656 /**************************************************************************
657 * CLIPBOARD_EnumClipboardFormats (internal)
659 static UINT CLIPBOARD_EnumClipboardFormats( UINT wFormat )
661 LPWINE_CLIPFORMAT lpFormat = ClipFormats;
662 BOOL bFormatPresent;
664 if (wFormat == 0) /* start from the beginning */
665 lpFormat = ClipFormats;
666 else
668 /* walk up to the specified format record */
670 if( !(lpFormat = __lookup_format( lpFormat, wFormat )) )
671 return 0;
672 lpFormat = lpFormat->NextFormat; /* right */
675 while(TRUE)
677 if (lpFormat == NULL) return 0;
679 if(CLIPBOARD_IsPresent(lpFormat->wFormatID))
680 break;
682 /* Query the driver if not yet in the cache */
683 if (!USER_Driver.pIsSelectionOwner())
685 if(lpFormat->wFormatID == CF_UNICODETEXT ||
686 lpFormat->wFormatID == CF_TEXT ||
687 lpFormat->wFormatID == CF_OEMTEXT)
689 if(USER_Driver.pIsClipboardFormatAvailable(CF_UNICODETEXT) ||
690 USER_Driver.pIsClipboardFormatAvailable(CF_TEXT) ||
691 USER_Driver.pIsClipboardFormatAvailable(CF_OEMTEXT))
692 bFormatPresent = TRUE;
693 else
694 bFormatPresent = FALSE;
696 else
697 bFormatPresent = USER_Driver.pIsClipboardFormatAvailable(lpFormat->wFormatID);
699 if(bFormatPresent)
700 break;
703 lpFormat = lpFormat->NextFormat;
706 TRACE("Next available format %d\n", lpFormat->wFormatID);
708 return lpFormat->wFormatID;
712 /**************************************************************************
713 * WIN32 Clipboard implementation
714 **************************************************************************/
716 /**************************************************************************
717 * OpenClipboard (USER.137)
719 BOOL16 WINAPI OpenClipboard16( HWND16 hWnd )
721 return OpenClipboard( hWnd );
725 /**************************************************************************
726 * OpenClipboard (USER32.@)
728 * Note: Netscape uses NULL hWnd to open the clipboard.
730 BOOL WINAPI OpenClipboard( HWND hWnd )
732 BOOL bRet;
734 TRACE("(%04x)...\n", hWnd);
736 if (!hClipLock)
738 hClipLock = GetCurrentTask();
740 /* Save current user of the clipboard */
741 hWndClipWindow = hWnd;
742 bCBHasChanged = FALSE;
743 bRet = TRUE;
745 else bRet = FALSE;
747 TRACE(" returning %i\n", bRet);
748 return bRet;
752 /**************************************************************************
753 * CloseClipboard (USER.138)
755 BOOL16 WINAPI CloseClipboard16(void)
757 return CloseClipboard();
761 /**************************************************************************
762 * CloseClipboard (USER32.@)
764 BOOL WINAPI CloseClipboard(void)
766 TRACE("()\n");
768 if (hClipLock == GetCurrentTask())
770 hWndClipWindow = 0;
772 if (bCBHasChanged && hWndViewer)
773 SendMessage16(hWndViewer, WM_DRAWCLIPBOARD, 0, 0L);
774 hClipLock = 0;
776 return TRUE;
780 /**************************************************************************
781 * EmptyClipboard (USER.139)
783 BOOL16 WINAPI EmptyClipboard16(void)
785 return EmptyClipboard();
789 /**************************************************************************
790 * EmptyClipboard (USER32.@)
791 * Empties and acquires ownership of the clipboard
793 BOOL WINAPI EmptyClipboard(void)
795 TRACE("()\n");
797 if (hClipLock != GetCurrentTask())
799 WARN("Clipboard not opened by calling task!");
800 return FALSE;
803 /* destroy private objects */
805 if (hWndClipOwner)
806 SendMessage16(hWndClipOwner, WM_DESTROYCLIPBOARD, 0, 0L);
808 /* empty the cache */
809 CLIPBOARD_EmptyCache(TRUE);
811 /* Assign ownership of the clipboard to the current client */
812 hWndClipOwner = hWndClipWindow;
814 /* Save the current task */
815 hTaskClipOwner = GetCurrentTask();
817 /* Tell the driver to acquire the selection */
818 USER_Driver.pAcquireClipboard();
820 return TRUE;
824 /**************************************************************************
825 * GetClipboardOwner (USER.140)
826 * FIXME: Can't return the owner if the clipbard is owned by an external app
828 HWND16 WINAPI GetClipboardOwner16(void)
830 TRACE("()\n");
831 return hWndClipOwner;
835 /**************************************************************************
836 * GetClipboardOwner (USER32.@)
837 * FIXME: Can't return the owner if the clipbard is owned by an external app
839 HWND WINAPI GetClipboardOwner(void)
841 TRACE("()\n");
842 return hWndClipOwner;
846 /**************************************************************************
847 * SetClipboardData (USER.141)
849 HANDLE16 WINAPI SetClipboardData16( UINT16 wFormat, HANDLE16 hData )
851 LPWINE_CLIPFORMAT lpFormat = __lookup_format( ClipFormats, wFormat );
853 TRACE("(%04X, %04x) !\n", wFormat, hData);
855 /* NOTE: If the hData is zero and current owner doesn't match
856 * the window that opened the clipboard then this application
857 * is screwed because WM_RENDERFORMAT will go to the owner.
858 * (to become the owner it must call EmptyClipboard() before
859 * adding new data).
862 if( CLIPBOARD_IsLocked() || !lpFormat ||
863 (!hData && (!hWndClipOwner || (hWndClipOwner != hWndClipWindow))) )
865 WARN("Invalid hData or clipboard not opened by calling task!\n");
866 return 0;
869 /* Pass on the request to the driver */
870 USER_Driver.pSetClipboardData(wFormat);
872 if ( lpFormat->wDataPresent || lpFormat->hData16 || lpFormat->hData32 )
874 CLIPBOARD_DeleteRecord(lpFormat, TRUE);
876 /* delete existing CF_UNICODETEXT/CF_TEXT/CF_OEMTEXT aliases */
877 if(wFormat == CF_UNICODETEXT)
879 CLIPBOARD_DeleteRecord(&ClipFormats[CF_TEXT-1], TRUE);
880 CLIPBOARD_DeleteRecord(&ClipFormats[CF_OEMTEXT-1], TRUE);
882 else if(wFormat == CF_TEXT)
884 CLIPBOARD_DeleteRecord(&ClipFormats[CF_UNICODETEXT-1], TRUE);
885 CLIPBOARD_DeleteRecord(&ClipFormats[CF_OEMTEXT-1], TRUE);
887 else if(wFormat == CF_OEMTEXT)
889 CLIPBOARD_DeleteRecord(&ClipFormats[CF_UNICODETEXT-1], TRUE);
890 CLIPBOARD_DeleteRecord(&ClipFormats[CF_TEXT-1], TRUE);
894 bCBHasChanged = TRUE;
895 lpFormat->wDataPresent = 1;
896 lpFormat->hData16 = hData; /* 0 is legal, see WM_RENDERFORMAT */
897 lpFormat->hData32 = 0;
899 return lpFormat->hData16;
903 /**************************************************************************
904 * SetClipboardData (USER32.@)
906 HANDLE WINAPI SetClipboardData( UINT wFormat, HANDLE hData )
908 LPWINE_CLIPFORMAT lpFormat = __lookup_format( ClipFormats, wFormat );
910 TRACE("(%08X, %08x) !\n", wFormat, hData);
912 /* NOTE: If the hData is zero and current owner doesn't match
913 * the window that opened the clipboard then this application
914 * is screwed because WM_RENDERFORMAT will go to the owner.
915 * (to become the owner it must call EmptyClipboard() before
916 * adding new data).
919 if( CLIPBOARD_IsLocked() || !lpFormat ||
920 (!hData && (!hWndClipOwner || (hWndClipOwner != hWndClipWindow))) )
922 WARN("Invalid hData or clipboard not opened by calling task!\n");
923 return 0;
926 /* Tell the driver to acquire the selection */
927 USER_Driver.pAcquireClipboard();
929 if ( lpFormat->wDataPresent &&
930 (lpFormat->hData16 || lpFormat->hData32) )
932 CLIPBOARD_DeleteRecord(lpFormat, TRUE);
934 /* delete existing CF_UNICODETEXT/CF_TEXT/CF_OEMTEXT aliases */
935 if(wFormat == CF_UNICODETEXT)
937 CLIPBOARD_DeleteRecord(&ClipFormats[CF_TEXT-1], TRUE);
938 CLIPBOARD_DeleteRecord(&ClipFormats[CF_OEMTEXT-1], TRUE);
940 else if(wFormat == CF_TEXT)
942 CLIPBOARD_DeleteRecord(&ClipFormats[CF_UNICODETEXT-1], TRUE);
943 CLIPBOARD_DeleteRecord(&ClipFormats[CF_OEMTEXT-1], TRUE);
945 else if(wFormat == CF_OEMTEXT)
947 CLIPBOARD_DeleteRecord(&ClipFormats[CF_UNICODETEXT-1], TRUE);
948 CLIPBOARD_DeleteRecord(&ClipFormats[CF_TEXT-1], TRUE);
952 bCBHasChanged = TRUE;
953 lpFormat->wDataPresent = 1;
954 lpFormat->hDataSrc32 = hData; /* Save the source handle */
957 * Make a shared duplicate if the memory is not shared
958 * TODO: What should be done for non-memory objects
960 if ( CLIPBOARD_IsMemoryObject(wFormat) && hData && !(GlobalFlags(hData) & GMEM_DDESHARE) )
961 lpFormat->hData32 = CLIPBOARD_GlobalDupMem( hData );
962 else
963 lpFormat->hData32 = hData; /* 0 is legal, see WM_RENDERFORMAT */
965 lpFormat->hData16 = 0;
967 return lpFormat->hData32; /* Should we return lpFormat->hDataSrc32 */
971 /**************************************************************************
972 * GetClipboardData (USER.142)
974 HANDLE16 WINAPI GetClipboardData16( UINT16 wFormat )
976 LPWINE_CLIPFORMAT lpRender = ClipFormats;
978 TRACE("(%04X)\n", wFormat);
980 if (CLIPBOARD_IsLocked())
982 WARN("Clipboard not opened by calling task!\n");
983 return 0;
986 if( wFormat == CF_UNICODETEXT || wFormat == CF_TEXT || wFormat == CF_OEMTEXT )
988 lpRender = CLIPBOARD_RenderText(wFormat);
989 if ( !lpRender ) return 0;
991 else
993 lpRender = __lookup_format( ClipFormats, wFormat );
994 if( !lpRender || !CLIPBOARD_RenderFormat(lpRender) ) return 0;
997 /* Convert between 32 -> 16 bit data, if necessary */
998 if( lpRender->hData32 && !lpRender->hData16
999 && CLIPBOARD_IsMemoryObject(wFormat) )
1001 int size;
1002 if( lpRender->wFormatID == CF_METAFILEPICT )
1003 size = sizeof( METAFILEPICT16 );
1004 else
1005 size = GlobalSize(lpRender->hData32);
1007 lpRender->hData16 = GlobalAlloc16(GMEM_ZEROINIT, size);
1008 if( !lpRender->hData16 )
1009 ERR("(%04X) -- not enough memory in 16b heap\n", wFormat);
1010 else
1012 if( lpRender->wFormatID == CF_METAFILEPICT )
1014 FIXME("\timplement function CopyMetaFilePict32to16\n");
1015 FIXME("\tin the appropriate file.\n");
1016 #ifdef SOMEONE_IMPLEMENTED_ME
1017 CopyMetaFilePict32to16( GlobalLock16(lpRender->hData16),
1018 GlobalLock(lpRender->hData32) );
1019 #endif
1021 else
1023 memcpy( GlobalLock16(lpRender->hData16),
1024 GlobalLock(lpRender->hData32),
1025 size );
1027 GlobalUnlock16(lpRender->hData16);
1028 GlobalUnlock(lpRender->hData32);
1032 TRACE("\treturning %04x (type %i)\n",
1033 lpRender->hData16, lpRender->wFormatID);
1034 return lpRender->hData16;
1038 /**************************************************************************
1039 * GetClipboardData (USER32.@)
1041 HANDLE WINAPI GetClipboardData( UINT wFormat )
1043 LPWINE_CLIPFORMAT lpRender = ClipFormats;
1045 TRACE("(%08X)\n", wFormat);
1047 if (CLIPBOARD_IsLocked())
1049 WARN("Clipboard not opened by calling task!");
1050 return 0;
1053 if( wFormat == CF_UNICODETEXT || wFormat == CF_TEXT || wFormat == CF_OEMTEXT )
1055 lpRender = CLIPBOARD_RenderText(wFormat);
1056 if ( !lpRender ) return 0;
1058 else
1060 lpRender = __lookup_format( ClipFormats, wFormat );
1061 if( !lpRender || !CLIPBOARD_RenderFormat(lpRender) ) return 0;
1064 /* Convert between 16 -> 32 bit data, if necessary */
1065 if( lpRender->hData16 && !lpRender->hData32
1066 && CLIPBOARD_IsMemoryObject(wFormat) )
1068 int size;
1069 if( lpRender->wFormatID == CF_METAFILEPICT )
1070 size = sizeof( METAFILEPICT );
1071 else
1072 size = GlobalSize16(lpRender->hData16);
1073 lpRender->hData32 = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE,
1074 size);
1075 if( lpRender->wFormatID == CF_METAFILEPICT )
1077 FIXME("\timplement function CopyMetaFilePict16to32\n");
1078 FIXME("\tin the appropriate file.\n");
1079 #ifdef SOMEONE_IMPLEMENTED_ME
1080 CopyMetaFilePict16to32( GlobalLock16(lpRender->hData32),
1081 GlobalLock(lpRender->hData16) );
1082 #endif
1084 else
1086 memcpy( GlobalLock(lpRender->hData32),
1087 GlobalLock16(lpRender->hData16),
1088 size );
1090 GlobalUnlock(lpRender->hData32);
1091 GlobalUnlock16(lpRender->hData16);
1094 TRACE("\treturning %04x (type %i)\n",
1095 lpRender->hData32, lpRender->wFormatID);
1096 return lpRender->hData32;
1100 /**************************************************************************
1101 * CountClipboardFormats (USER.143)
1103 INT16 WINAPI CountClipboardFormats16(void)
1105 return CountClipboardFormats();
1109 /**************************************************************************
1110 * CountClipboardFormats (USER32.@)
1112 INT WINAPI CountClipboardFormats(void)
1114 INT FormatCount = 0;
1115 LPWINE_CLIPFORMAT lpFormat = ClipFormats;
1117 TRACE("()\n");
1119 while(TRUE)
1121 if (lpFormat == NULL) break;
1123 if( lpFormat->wFormatID != CF_TEXT ) /* Don't count CF_TEXT */
1126 * The format is available if either:
1127 * 1. The data is already in the cache.
1128 * 2. The selection is not owned by us(WINE) and the data is
1129 * available to the clipboard driver.
1131 if ( lpFormat->wDataPresent ||
1132 ( !USER_Driver.pIsSelectionOwner()
1133 && USER_Driver.pIsClipboardFormatAvailable( lpFormat->wFormatID ) ) )
1135 TRACE("\tdata found for format 0x%04x(%s)\n",
1136 lpFormat->wFormatID, CLIPBOARD_GetFormatName(lpFormat->wFormatID));
1137 FormatCount++;
1141 lpFormat = lpFormat->NextFormat;
1144 /* these are equivalent, adjust the total */
1145 FormatCount += (ClipFormats[CF_UNICODETEXT-1].wDataPresent ||
1146 ClipFormats[CF_TEXT-1].wDataPresent ||
1147 ClipFormats[CF_OEMTEXT-1].wDataPresent) ? 1 : 0;
1149 TRACE("\ttotal %d\n", FormatCount);
1150 return FormatCount;
1153 /**************************************************************************
1154 * EnumClipboardFormats (USER.144)
1156 UINT16 WINAPI EnumClipboardFormats16( UINT16 wFormat )
1158 return EnumClipboardFormats( wFormat );
1162 /**************************************************************************
1163 * EnumClipboardFormats (USER32.@)
1165 UINT WINAPI EnumClipboardFormats( UINT wFormat )
1167 TRACE("(%04X)\n", wFormat);
1169 if (CLIPBOARD_IsLocked())
1171 WARN("Clipboard not opened by calling task!");
1172 return 0;
1175 return CLIPBOARD_EnumClipboardFormats(wFormat);
1179 /**************************************************************************
1180 * RegisterClipboardFormat (USER.145)
1182 UINT16 WINAPI RegisterClipboardFormat16( LPCSTR FormatName )
1184 LPWINE_CLIPFORMAT lpNewFormat;
1185 LPWINE_CLIPFORMAT lpFormat = ClipFormats;
1187 if (FormatName == NULL) return 0;
1189 TRACE("('%s') !\n", FormatName);
1191 /* walk format chain to see if it's already registered */
1193 while(TRUE)
1195 if ( !strcmp(lpFormat->Name,FormatName) )
1197 lpFormat->wRefCount++;
1198 return lpFormat->wFormatID;
1201 if ( lpFormat->NextFormat == NULL ) break;
1203 lpFormat = lpFormat->NextFormat;
1206 /* allocate storage for new format entry */
1208 lpNewFormat = (LPWINE_CLIPFORMAT)HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_CLIPFORMAT));
1209 if(lpNewFormat == NULL) {
1210 WARN("No more memory for a new format!");
1211 return 0;
1213 lpFormat->NextFormat = lpNewFormat;
1214 lpNewFormat->wFormatID = LastRegFormat;
1215 lpNewFormat->wRefCount = 1;
1217 lpNewFormat->Name = (LPSTR)HEAP_strdupA(GetProcessHeap(), 0, FormatName);
1218 if(lpNewFormat->Name == NULL) {
1219 WARN("No more memory for the new format name!");
1220 HeapFree(GetProcessHeap(), 0, lpNewFormat);
1221 return 0;
1224 lpNewFormat->wDataPresent = 0;
1225 lpNewFormat->hData16 = 0;
1226 lpNewFormat->hDataSrc32 = 0;
1227 lpNewFormat->hData32 = 0;
1228 lpNewFormat->drvData = 0;
1229 lpNewFormat->PrevFormat = lpFormat;
1230 lpNewFormat->NextFormat = NULL;
1232 /* Pass on the registration request to the driver */
1233 USER_Driver.pRegisterClipboardFormat( FormatName );
1235 return LastRegFormat++;
1239 /**************************************************************************
1240 * RegisterClipboardFormatA (USER32.@)
1242 UINT WINAPI RegisterClipboardFormatA( LPCSTR formatName )
1244 return RegisterClipboardFormat16( formatName );
1248 /**************************************************************************
1249 * RegisterClipboardFormatW (USER32.@)
1251 UINT WINAPI RegisterClipboardFormatW( LPCWSTR formatName )
1253 LPSTR aFormat = HEAP_strdupWtoA( GetProcessHeap(), 0, formatName );
1254 UINT ret = RegisterClipboardFormatA( aFormat );
1255 HeapFree( GetProcessHeap(), 0, aFormat );
1256 return ret;
1260 /**************************************************************************
1261 * GetClipboardFormatName (USER.146)
1263 INT16 WINAPI GetClipboardFormatName16( UINT16 wFormat, LPSTR retStr, INT16 maxlen )
1265 return GetClipboardFormatNameA( wFormat, retStr, maxlen );
1269 /**************************************************************************
1270 * GetClipboardFormatNameA (USER32.@)
1272 INT WINAPI GetClipboardFormatNameA( UINT wFormat, LPSTR retStr, INT maxlen )
1274 LPWINE_CLIPFORMAT lpFormat = __lookup_format( ClipFormats, wFormat );
1276 TRACE("(%04X, %p, %d) !\n", wFormat, retStr, maxlen);
1278 if (lpFormat == NULL || lpFormat->Name == NULL ||
1279 lpFormat->wFormatID < CF_REGFORMATBASE) return 0;
1281 TRACE("Name='%s' !\n", lpFormat->Name);
1283 lstrcpynA( retStr, lpFormat->Name, maxlen );
1284 return strlen(retStr);
1288 /**************************************************************************
1289 * GetClipboardFormatNameW (USER32.@)
1291 INT WINAPI GetClipboardFormatNameW( UINT wFormat, LPWSTR retStr, INT maxlen )
1293 INT ret;
1294 LPSTR p = HeapAlloc( GetProcessHeap(), 0, maxlen );
1295 if(p == NULL) return 0; /* FIXME: is this the correct failure value? */
1297 ret = GetClipboardFormatNameA( wFormat, p, maxlen );
1299 if (maxlen > 0 && !MultiByteToWideChar( CP_ACP, 0, p, -1, retStr, maxlen ))
1300 retStr[maxlen-1] = 0;
1301 HeapFree( GetProcessHeap(), 0, p );
1302 return ret;
1306 /**************************************************************************
1307 * SetClipboardViewer (USER.147)
1309 HWND16 WINAPI SetClipboardViewer16( HWND16 hWnd )
1311 TRACE("(%04x)\n", hWnd);
1312 return SetClipboardViewer( hWnd );
1316 /**************************************************************************
1317 * SetClipboardViewer (USER32.@)
1319 HWND WINAPI SetClipboardViewer( HWND hWnd )
1321 HWND hwndPrev = hWndViewer;
1323 TRACE("(%04x): returning %04x\n", hWnd, hwndPrev);
1325 hWndViewer = hWnd;
1326 return hwndPrev;
1330 /**************************************************************************
1331 * GetClipboardViewer (USER.148)
1333 HWND16 WINAPI GetClipboardViewer16(void)
1335 TRACE("()\n");
1336 return hWndViewer;
1340 /**************************************************************************
1341 * GetClipboardViewer (USER32.@)
1343 HWND WINAPI GetClipboardViewer(void)
1345 TRACE("()\n");
1346 return hWndViewer;
1350 /**************************************************************************
1351 * ChangeClipboardChain (USER.149)
1353 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hWnd, HWND16 hWndNext)
1355 return ChangeClipboardChain(hWnd, hWndNext);
1359 /**************************************************************************
1360 * ChangeClipboardChain (USER32.@)
1362 BOOL WINAPI ChangeClipboardChain(HWND hWnd, HWND hWndNext)
1364 BOOL bRet = 0;
1366 FIXME("(0x%04x, 0x%04x): stub?\n", hWnd, hWndNext);
1368 if( hWndViewer )
1369 bRet = !SendMessage16( hWndViewer, WM_CHANGECBCHAIN,
1370 (WPARAM16)hWnd, (LPARAM)hWndNext);
1371 else
1372 WARN("hWndViewer is lost\n");
1374 if( hWnd == hWndViewer ) hWndViewer = hWndNext;
1376 return bRet;
1380 /**************************************************************************
1381 * IsClipboardFormatAvailable (USER.193)
1383 BOOL16 WINAPI IsClipboardFormatAvailable16( UINT16 wFormat )
1385 return IsClipboardFormatAvailable( wFormat );
1389 /**************************************************************************
1390 * IsClipboardFormatAvailable (USER32.@)
1392 BOOL WINAPI IsClipboardFormatAvailable( UINT wFormat )
1394 BOOL bRet;
1396 if (wFormat == 0) /* Reject this case quickly */
1397 bRet = FALSE;
1398 else
1400 UINT iret = CLIPBOARD_EnumClipboardFormats(wFormat - 1);
1401 if ((wFormat == CF_TEXT) || (wFormat == CF_OEMTEXT) || (wFormat == CF_UNICODETEXT))
1402 bRet = ((iret == CF_TEXT) || (iret == CF_OEMTEXT) || (iret == CF_UNICODETEXT));
1403 else
1404 bRet = iret == wFormat;
1406 TRACE("(%04X)- ret(%d)\n", wFormat, bRet);
1407 return bRet;
1411 /**************************************************************************
1412 * GetOpenClipboardWindow (USER.248)
1413 * FIXME: This wont work if an external app owns the selection
1415 HWND16 WINAPI GetOpenClipboardWindow16(void)
1417 TRACE("()\n");
1418 return hWndClipWindow;
1422 /**************************************************************************
1423 * GetOpenClipboardWindow (USER32.@)
1424 * FIXME: This wont work if an external app owns the selection
1426 HWND WINAPI GetOpenClipboardWindow(void)
1428 TRACE("()\n");
1429 return hWndClipWindow;
1433 /**************************************************************************
1434 * GetPriorityClipboardFormat (USER.402)
1436 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *lpPriorityList, INT16 nCount)
1438 FIXME("(%p,%d): stub\n", lpPriorityList, nCount );
1439 return 0;
1443 /**************************************************************************
1444 * GetPriorityClipboardFormat (USER32.@)
1446 INT WINAPI GetPriorityClipboardFormat( UINT *lpPriorityList, INT nCount )
1448 int Counter;
1449 TRACE("()\n");
1451 if(CountClipboardFormats() == 0)
1453 return 0;
1456 for(Counter = 0; Counter <= nCount; Counter++)
1458 if(IsClipboardFormatAvailable(*(lpPriorityList+sizeof(INT)*Counter)))
1459 return *(lpPriorityList+sizeof(INT)*Counter);
1462 return -1;
1466 /**************************************************************************
1467 * GetClipboardSequenceNumber (USER32.@)
1468 * Supported on Win2k/Win98
1469 * MSDN: Windows clipboard code keeps a serial number for the clipboard
1470 * for each window station. The number is incremented whenever the
1471 * contents change or are emptied.
1472 * If you do not have WINSTA_ACCESSCLIPBOARD then the function returns 0
1474 DWORD WINAPI GetClipboardSequenceNumber(VOID)
1476 FIXME("Returning 0, see windows/clipboard.c\n");
1477 /* FIXME: Use serial numbers */
1478 return 0;