2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * PURPOSE: Clipboard routines
23 * FILE: subsys/win32k/ntuser/clipboard.c
24 * PROGRAMER: Filip Navara <xnavara@volny.cz>
33 if (ClipboardThread && ClipboardThread != PsGetWin32Thread()) \
35 SetLastWin32Error(ERROR_LOCKED); \
39 PW32THREAD ClipboardThread
;
41 HWND tempClipboardWindow
;
46 IntGetClipboardFormatName(UINT format
, PUNICODE_STRING FormatName
)
49 return IntGetAtomName((RTL_ATOM
)format
, FormatName
->Buffer
,
50 FormatName
->MaximumLength
);
54 IntEnumClipboardFormats(UINT format
)
66 NtUserOpenClipboard(HWND hWnd
, DWORD Unknown1
)
70 tempClipboardWindow
= hWnd
;
71 ClipboardThread
= PsGetWin32Thread();
76 NtUserCloseClipboard(VOID
)
81 ClipboardThread
= NULL
;
89 NtUserGetOpenClipboardWindow(VOID
)
95 return ClipboardWindow
;
99 NtUserChangeClipboardChain(HWND hWndRemove
, HWND hWndNewNext
)
106 NtUserCountClipboardFormats(VOID
)
113 NtUserEmptyClipboard(VOID
)
121 // GlobalUnlock(hCBData);
122 // GlobalFree(hCBData);
125 ClipboardWindow
= tempClipboardWindow
;
131 NtUserGetClipboardData(UINT uFormat
, DWORD Unknown1
)
135 if ((uFormat
==1 && uCBFormat
==13) || (uFormat
==13 && uCBFormat
==1))
138 if (uFormat
!= uCBFormat
)
145 NtUserGetClipboardFormatName(UINT format
, PUNICODE_STRING FormatName
,
150 UNICODE_STRING SafeFormatName
, BufFormatName
;
153 if((cchMaxCount
< 1) || !FormatName
)
155 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
159 /* copy the FormatName UNICODE_STRING structure */
160 Status
= MmCopyFromCaller(&SafeFormatName
, FormatName
, sizeof(UNICODE_STRING
));
161 if(!NT_SUCCESS(Status
))
163 SetLastNtError(Status
);
167 /* Allocate memory for the string */
168 Buf
= ExAllocatePoolWithTag(PagedPool
, cchMaxCount
* sizeof(WCHAR
), TAG_STRING
);
171 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
175 /* Setup internal unicode string */
176 BufFormatName
.Length
= 0;
177 BufFormatName
.MaximumLength
= min(cchMaxCount
* sizeof(WCHAR
), SafeFormatName
.MaximumLength
);
178 BufFormatName
.Buffer
= Buf
;
180 if(BufFormatName
.MaximumLength
< sizeof(WCHAR
))
183 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
187 if (format
>= 0xC000)
189 Ret
= IntGetClipboardFormatName(format
, &BufFormatName
);
193 SetLastNtError(NO_ERROR
);
197 /* copy the UNICODE_STRING buffer back to the user */
198 Status
= MmCopyToCaller(SafeFormatName
.Buffer
, BufFormatName
.Buffer
, BufFormatName
.MaximumLength
);
199 if(!NT_SUCCESS(Status
))
202 SetLastNtError(Status
);
206 BufFormatName
.MaximumLength
= SafeFormatName
.MaximumLength
;
207 BufFormatName
.Buffer
= SafeFormatName
.Buffer
;
209 /* update the UNICODE_STRING structure (only the Length member should change) */
210 Status
= MmCopyToCaller(FormatName
, &BufFormatName
, sizeof(UNICODE_STRING
));
211 if(!NT_SUCCESS(Status
))
214 SetLastNtError(Status
);
223 NtUserGetClipboardOwner(VOID
)
225 return ClipboardWindow
;
229 NtUserGetClipboardSequenceNumber(VOID
)
236 NtUserGetClipboardViewer(VOID
)
243 NtUserGetPriorityClipboardFormat(UINT
*paFormatPriorityList
, INT cFormats
)
250 NtUserIsClipboardFormatAvailable(UINT format
)
254 if (format
!= 1 && format
!= 13)
256 DbgPrint("Clipboard Format unavailable (%d)\n", format
);
260 if ((format
==1 && uCBFormat
==13) || (format
==13 && uCBFormat
==1))
263 if (format
!= uCBFormat
)
269 //SetClipboardData(CF_UNICODETEXT, hdst);
271 NtUserSetClipboardData(UINT uFormat
, HANDLE hMem
, DWORD Unknown2
)
277 if (uFormat
!= 1 && uFormat
!= 13)
279 DbgPrint("Clipboard unsupported format (%d)\n", uFormat
);
287 //pMem = GlobalLock(hMem);
291 DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
295 case CF_UNICODETEXT: // 13
299 case CF_OEMTEXT: // 7
305 //the window provides data in the specified format
311 NtUserSetClipboardViewer(HWND hWndNewViewer
)
314 DbgPrint("NtUserSetClipboardViewer is UNIMPLEMENTED (%p): returning %p\n", hWndNewViewer
, hwndPrev
);