[WIN32SS:CLIPBOARD]

- Reduce indentation level of some code.
- No need to initialize pWinStaObj when it is reinitialized just after.
- Fix some comments.

svn path=/trunk/; revision=70354
This commit is contained in:
Hermès Bélusca-Maïto 2015-12-16 00:10:58 +00:00
parent 875158be3e
commit 4e929985de
2 changed files with 35 additions and 37 deletions

View file

@ -125,13 +125,8 @@ static BOOL FASTCALL
IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta) IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
{ {
/* Check if current thread has opened the clipboard */ /* Check if current thread has opened the clipboard */
if (pWinSta->ptiClipLock && return (pWinSta->ptiClipLock &&
pWinSta->ptiClipLock == PsGetCurrentThreadWin32Thread()) pWinSta->ptiClipLock == PsGetCurrentThreadWin32Thread());
{
return TRUE;
}
return FALSE;
} }
static VOID NTAPI static VOID NTAPI
@ -385,7 +380,7 @@ UserEnumClipboardFormats(UINT fmt)
{ {
UINT Ret = 0; UINT Ret = 0;
PCLIP pElement; PCLIP pElement;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
pWinStaObj = IntGetWinStaForCbAccess(); pWinStaObj = IntGetWinStaForCbAccess();
if (!pWinStaObj) if (!pWinStaObj)
@ -440,11 +435,11 @@ UserOpenClipboard(HWND hWnd)
if (pWinStaObj->ptiClipLock) if (pWinStaObj->ptiClipLock)
{ {
/* Clipboard is already open */ /* Clipboard is already opened */
if (pWinStaObj->spwndClipOpen != pWindow) if (pWinStaObj->spwndClipOpen != pWindow)
{ {
EngSetLastError(ERROR_ACCESS_DENIED);
ERR("Access denied!\n"); ERR("Access denied!\n");
EngSetLastError(ERROR_ACCESS_DENIED);
goto cleanup; goto cleanup;
} }
} }
@ -477,12 +472,13 @@ BOOL NTAPI
UserCloseClipboard(VOID) UserCloseClipboard(VOID)
{ {
BOOL bRet = FALSE; BOOL bRet = FALSE;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
pWinStaObj = IntGetWinStaForCbAccess(); pWinStaObj = IntGetWinStaForCbAccess();
if (!pWinStaObj) if (!pWinStaObj)
goto cleanup; goto cleanup;
/* Check if clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj)) if (!IntIsClipboardOpenByMe(pWinStaObj))
{ {
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
@ -589,7 +585,7 @@ DWORD APIENTRY
NtUserCountClipboardFormats(VOID) NtUserCountClipboardFormats(VOID)
{ {
DWORD cFormats = 0; DWORD cFormats = 0;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
UserEnterShared(); UserEnterShared();
@ -617,30 +613,31 @@ UserEmptyClipboard(VOID)
if (!pWinStaObj) if (!pWinStaObj)
return FALSE; return FALSE;
if (IntIsClipboardOpenByMe(pWinStaObj)) /* Check if clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj))
{ {
UserEmptyClipboardData(pWinStaObj); EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
goto cleanup;
}
if (pWinStaObj->spwndClipOwner) UserEmptyClipboardData(pWinStaObj);
{
TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h); if (pWinStaObj->spwndClipOwner)
co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0); {
} TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
}
pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen; pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
pWinStaObj->iClipSequenceNumber++; pWinStaObj->iClipSequenceNumber++;
pWinStaObj->fClipboardChanged = TRUE; pWinStaObj->fClipboardChanged = TRUE;
bRet = TRUE; bRet = TRUE;
}
else
{
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
ERR("Access denied!\n");
}
ObDereferenceObject(pWinStaObj); cleanup:
if (pWinStaObj)
ObDereferenceObject(pWinStaObj);
return bRet; return bRet;
} }
@ -825,7 +822,7 @@ NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
{ {
HANDLE hRet = NULL; HANDLE hRet = NULL;
PCLIP pElement; PCLIP pElement;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
TRACE("NtUserGetClipboardData(%x, %p)\n", fmt, pgcd); TRACE("NtUserGetClipboardData(%x, %p)\n", fmt, pgcd);
@ -835,6 +832,7 @@ NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
if (!pWinStaObj) if (!pWinStaObj)
goto cleanup; goto cleanup;
/* Check if clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj)) if (!IntIsClipboardOpenByMe(pWinStaObj))
{ {
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
@ -856,7 +854,6 @@ NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
if (!pElement || IS_DATA_DELAYED(pElement)) if (!pElement || IS_DATA_DELAYED(pElement))
goto cleanup; goto cleanup;
if (IS_DATA_SYNTHESIZED(pElement)) if (IS_DATA_SYNTHESIZED(pElement))
{ {
/* Note: Data is synthesized in usermode */ /* Note: Data is synthesized in usermode */
@ -927,7 +924,7 @@ HANDLE NTAPI
UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd) UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
{ {
HANDLE hRet = NULL; HANDLE hRet = NULL;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
pWinStaObj = IntGetWinStaForCbAccess(); pWinStaObj = IntGetWinStaForCbAccess();
if (!pWinStaObj) if (!pWinStaObj)
@ -946,7 +943,7 @@ UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
if (scd->fIncSerialNumber) if (scd->fIncSerialNumber)
pWinStaObj->iClipSerialNumber++; pWinStaObj->iClipSerialNumber++;
/* Is it a delayed render? */ /* Is it a delayed rendering? */
if (hData) if (hData)
{ {
/* Is it a bitmap? */ /* Is it a bitmap? */
@ -967,7 +964,7 @@ UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
} }
else else
{ {
/* This is a delayed render */ /* This is a delayed rendering */
IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE); IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
TRACE("SetClipboardData delayed format: %u\n", fmt); TRACE("SetClipboardData delayed format: %u\n", fmt);
} }
@ -1018,7 +1015,7 @@ HWND APIENTRY
NtUserSetClipboardViewer(HWND hWndNewViewer) NtUserSetClipboardViewer(HWND hWndNewViewer)
{ {
HWND hWndNext = NULL; HWND hWndNext = NULL;
PWINSTATION_OBJECT pWinStaObj = NULL; PWINSTATION_OBJECT pWinStaObj;
PWND pWindow; PWND pWindow;
UserEnterExclusive(); UserEnterExclusive();

View file

@ -18,8 +18,6 @@
#include <wine/debug.h> #include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(user32); WINE_DEFAULT_DEBUG_CHANNEL(user32);
#define QUERY_SIZE 0
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/* /*
@ -263,7 +261,7 @@ GetClipboardData(UINT uFormat)
pData = pNewData; pData = pNewData;
} }
/* Save synthesized format in clibboard */ /* Save synthesized format in clipboard */
if (pData) if (pData)
{ {
HANDLE hMem; HANDLE hMem;
@ -296,7 +294,7 @@ SetClipboardData(UINT uFormat, HANDLE hMem)
HANDLE hRet = NULL; HANDLE hRet = NULL;
SETCLIPBDATA scd = {FALSE, FALSE}; SETCLIPBDATA scd = {FALSE, FALSE};
/* Check if this is delayed render */ /* Check if this is a delayed rendering */
if (hMem == NULL) if (hMem == NULL)
return NtUserSetClipboardData(uFormat, NULL, &scd); return NtUserSetClipboardData(uFormat, NULL, &scd);
@ -308,7 +306,10 @@ SetClipboardData(UINT uFormat, HANDLE hMem)
/* Meta files are probably checked for validity */ /* Meta files are probably checked for validity */
else if (uFormat == CF_DSPMETAFILEPICT || uFormat == CF_METAFILEPICT || else if (uFormat == CF_DSPMETAFILEPICT || uFormat == CF_METAFILEPICT ||
uFormat == CF_DSPENHMETAFILE || uFormat == CF_ENHMETAFILE) uFormat == CF_DSPENHMETAFILE || uFormat == CF_ENHMETAFILE)
{
UNIMPLEMENTED;
hRet = NULL; // not supported yet hRet = NULL; // not supported yet
}
else else
{ {
/* Some formats accept only global handles, other accept global handles or integer values */ /* Some formats accept only global handles, other accept global handles or integer values */