Patch by Pablo Borobia <pablog7@argentina.com>

Work on clipboard.

svn path=/trunk/; revision=9590
This commit is contained in:
Gé van Geldorp 2004-06-02 18:29:21 +00:00
parent 08108f008e
commit 07320b09dd

View file

@ -29,14 +29,23 @@
#define NDEBUG
#include <debug.h>
#if 0
#define CHECK_LOCK \
if (ClipboardThread && ClipboardThread != PsGetWin32Thread()) \
{ \
SetLastWin32Error(ERROR_LOCKED); \
return FALSE; \
}
PW32THREAD ClipboardThread;
HWND ClipboardWindow;
#endif
HWND tempClipboardWindow;
HANDLE hCBData;
UINT uCBFormat;
ULONG FASTCALL
IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
{
return IntGetAtomName((RTL_ATOM)format, FormatName->Buffer,
FormatName->MaximumLength);
}
@ -44,44 +53,33 @@ IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
UINT FASTCALL
IntEnumClipboardFormats(UINT format)
{
UNIMPLEMENTED;
return 0;
CHECK_LOCK
if (!hCBData)
return FALSE;
//UNIMPLEMENTED;
return 1;
}
BOOL STDCALL
NtUserOpenClipboard(HWND hWnd, DWORD Unknown1)
{
#if 0
if (ClipboardThread && ClipboardThread != PsGetWin32Thread())
{
SetLastWin32Error(ERROR_LOCKED);
return FALSE;
}
ClipboardWindow = hWnd;
CHECK_LOCK
tempClipboardWindow = hWnd;
ClipboardThread = PsGetWin32Thread();
return TRUE;
#else
DPRINT1("NtUserOpenClipboard is unimplemented\n");
return FALSE;
#endif
}
BOOL STDCALL
NtUserCloseClipboard(VOID)
{
#if 0
if (ClipboardThread && ClipboardThread != PsGetWin32Thread())
{
SetLastWin32Error(ERROR_LOCKED);
return FALSE;
}
CHECK_LOCK
ClipboardWindow = 0;
ClipboardThread = NULL;
return TRUE;
#else
UNIMPLEMENTED
return FALSE;
#endif
}
/*
@ -90,8 +88,11 @@ NtUserCloseClipboard(VOID)
HWND STDCALL
NtUserGetOpenClipboardWindow(VOID)
{
/*
UNIMPLEMENTED
return 0;
*/
return ClipboardWindow;
}
BOOL STDCALL
@ -111,33 +112,50 @@ NtUserCountClipboardFormats(VOID)
DWORD STDCALL
NtUserEmptyClipboard(VOID)
{
UNIMPLEMENTED
return 0;
CHECK_LOCK
// if (!hCBData)
// return FALSE;
// FIXME!
// GlobalUnlock(hCBData);
// GlobalFree(hCBData);
hCBData = NULL;
uCBFormat = 0;
ClipboardWindow = tempClipboardWindow;
return TRUE;
}
HANDLE STDCALL
NtUserGetClipboardData(UINT uFormat, DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
CHECK_LOCK
if ((uFormat==1 && uCBFormat==13) || (uFormat==13 && uCBFormat==1))
uCBFormat = uFormat;
if (uFormat != uCBFormat)
return FALSE;
return hCBData;
}
INT STDCALL
NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
INT cchMaxCount)
{
#if 1
NTSTATUS Status;
PWSTR Buf;
UNICODE_STRING SafeFormatName, BufFormatName;
ULONG Ret;
if((cchMaxCount < 1) || !FormatName)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
/* copy the FormatName UNICODE_STRING structure */
Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
@ -145,7 +163,7 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
SetLastNtError(Status);
return 0;
}
/* Allocate memory for the string */
Buf = ExAllocatePoolWithTag(NonPagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
if(!Buf)
@ -153,21 +171,29 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* Setup internal unicode string */
BufFormatName.Length = 0;
BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
BufFormatName.Buffer = Buf;
if(BufFormatName.MaximumLength < sizeof(WCHAR))
{
ExFreePool(Buf);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
Ret = IntGetClipboardFormatName(format, &BufFormatName);
if (format >= 0xC000)
{
Ret = IntGetClipboardFormatName(format, &BufFormatName);
}
else
{
SetLastNtError(NO_ERROR);
return 0;
}
/* copy the UNICODE_STRING buffer back to the user */
Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
if(!NT_SUCCESS(Status))
@ -176,10 +202,10 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
SetLastNtError(Status);
return 0;
}
BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
BufFormatName.Buffer = SafeFormatName.Buffer;
/* update the UNICODE_STRING structure (only the Length member should change) */
Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
@ -188,12 +214,9 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
SetLastNtError(Status);
return 0;
}
ExFreePool(Buf);
return Ret;
#else
return IntGetClipboardFormatName(format, FormatName);
#endif
}
HWND STDCALL
@ -227,15 +250,60 @@ NtUserGetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
BOOL STDCALL
NtUserIsClipboardFormatAvailable(UINT format)
{
DPRINT1("FIXME: NtUserIsClipboardFormatAvailable() is not implemented\n");
return 0;
//UNIMPLEMENTED
if (format != 1 && format != 13) {
DbgPrint("Clipboard Format unavailable (%d)\n", format);
return FALSE;
}
if ((format==1 && uCBFormat==13) || (format==13 && uCBFormat==1))
uCBFormat = format;
if (format != uCBFormat)
return FALSE;
return TRUE;
}
//SetClipboardData(CF_UNICODETEXT, hdst);
HANDLE STDCALL
NtUserSetClipboardData(UINT uFormat, HANDLE hMem, DWORD Unknown2)
{
UNIMPLEMENTED
return 0;
// LPVOID pMem;
CHECK_LOCK
if (uFormat != 1 && uFormat != 13) {
DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
return FALSE;
}
if (hMem)
{
uCBFormat = uFormat;
hCBData = hMem;
//pMem = GlobalLock(hMem);
/*
switch (uFormat) {
default:
DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
return FALSE;
case CF_TEXT: // 1
break;
case CF_UNICODETEXT: // 13
break;
case CF_BITMAP: // 2
break;
case CF_OEMTEXT: // 7
break;
} */
}
else
{
//the window provides data in the specified format
}
return hMem;
}
HWND STDCALL