return pWinStaObj;
}
-/* If format exists, returns a non zero value (pointing to formated object) */
+/* If format exists, returns a non-null value (pointing to formated object) */
static PCLIP FASTCALL
-IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
+IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
{
DWORD i;
return NULL;
}
+static BOOL FASTCALL
+IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
+{
+ return IntGetFormatElement(pWinStaObj, fmt) != NULL;
+}
+
static VOID FASTCALL
IntFreeElementData(PCLIP pElement)
{
/* Use existing entry with specified format */
if (!bEnd)
- pElement = IntIsFormatAvailable(pWinStaObj, fmt);
+ pElement = IntGetFormatElement(pWinStaObj, fmt);
/* Put new entry at the end if nothing was found */
if (!pElement)
}
/* Get information about the bitmap format */
+ pbmi->bmiHeader.biSize = sizeof(bmiBuffer.bmih);
iResult = GreGetDIBitsInternal(hdc,
hbm,
0,
NULL,
&hMem,
TYPE_CLIPDATA,
- cjDataSize);
+ sizeof(CLIPBOARDDATA) + cjDataSize);
if (!pClipboardData)
{
goto cleanup;
TRACE("IntSynthesizeBitmap(%p, %p)\n", pWinStaObj, pBmEl);
- pDibEl = IntIsFormatAvailable(pWinStaObj, CF_DIB);
+ pDibEl = IntGetFormatElement(pWinStaObj, CF_DIB);
ASSERT(pDibEl && !IS_DATA_SYNTHESIZED(pDibEl));
if (!pDibEl->fGlobalHandle)
return;
static VOID NTAPI
IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
{
- PCLIP pTextEl, pUniTextEl, pOemTextEl, pLocaleEl, pBmEl, pDibEl;
+ BOOL bHaveText, bHaveUniText, bHaveOemText, bHaveLocale, bHaveBm, bHaveDib;
- pTextEl = IntIsFormatAvailable(pWinStaObj, CF_TEXT);
- pOemTextEl = IntIsFormatAvailable(pWinStaObj, CF_OEMTEXT);
- pUniTextEl = IntIsFormatAvailable(pWinStaObj, CF_UNICODETEXT);
- pLocaleEl = IntIsFormatAvailable(pWinStaObj, CF_LOCALE);
- pBmEl = IntIsFormatAvailable(pWinStaObj, CF_BITMAP);
- pDibEl = IntIsFormatAvailable(pWinStaObj, CF_DIB);
+ bHaveText = IntIsFormatAvailable(pWinStaObj, CF_TEXT);
+ bHaveOemText = IntIsFormatAvailable(pWinStaObj, CF_OEMTEXT);
+ bHaveUniText = IntIsFormatAvailable(pWinStaObj, CF_UNICODETEXT);
+ bHaveLocale = IntIsFormatAvailable(pWinStaObj, CF_LOCALE);
+ bHaveBm = IntIsFormatAvailable(pWinStaObj, CF_BITMAP);
+ bHaveDib = IntIsFormatAvailable(pWinStaObj, CF_DIB);
/* Add CF_LOCALE format if we have CF_TEXT */
- if (!pLocaleEl && pTextEl)
+ if (!bHaveLocale && bHaveText)
{
PCLIPBOARDDATA pMemObj;
HANDLE hMem;
}
/* Add CF_TEXT. Note: it is synthesized in user32.dll */
- if (!pTextEl && (pUniTextEl || pOemTextEl))
+ if (!bHaveText && (bHaveUniText || bHaveOemText))
IntAddFormatedData(pWinStaObj, CF_TEXT, DATA_SYNTH_USER, FALSE, TRUE);
/* Add CF_OEMTEXT. Note: it is synthesized in user32.dll */
- if (!pOemTextEl && (pUniTextEl || pTextEl))
+ if (!bHaveOemText && (bHaveUniText || bHaveText))
IntAddFormatedData(pWinStaObj, CF_OEMTEXT, DATA_SYNTH_USER, FALSE, TRUE);
/* Add CF_UNICODETEXT. Note: it is synthesized in user32.dll */
- if (!pUniTextEl && (pTextEl || pOemTextEl))
+ if (!bHaveUniText && (bHaveText || bHaveOemText))
IntAddFormatedData(pWinStaObj, CF_UNICODETEXT, DATA_SYNTH_USER, FALSE, TRUE);
/* Add CF_BITMAP. Note: it is synthesized on demand */
- if (!pBmEl && pDibEl)
+ if (!bHaveBm && bHaveDib)
IntAddFormatedData(pWinStaObj, CF_BITMAP, DATA_SYNTH_KRNL, FALSE, TRUE);
/* Note: We need to render the DIB or DIBV5 format as soon as possible
because pallette information may change */
- if (!pDibEl && pBmEl)
- IntSynthesizeDib(pWinStaObj, pBmEl->hData);
+ if (!bHaveDib && bHaveBm)
+ IntSynthesizeDib(pWinStaObj, IntGetFormatElement(pWinStaObj, CF_BITMAP)->hData);
}
VOID NTAPI
else
{
/* Return next format */
- pElement = IntIsFormatAvailable(pWinStaObj, fmt);
- ++pElement;
- if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
- Ret = pElement->fmt;
+ pElement = IntGetFormatElement(pWinStaObj, fmt);
+ if (pElement != NULL)
+ {
+ ++pElement;
+ if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
+ {
+ Ret = pElement->fmt;
+ }
+ }
}
cleanup:
{
TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
// For 32-bit applications this message is sent as a notification
- co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
+ co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
}
pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
UserEnterShared();
/* If the format is built-in we fail */
- if (fmt < 0xc000)
+ if (fmt < 0xc000 || fmt > 0xffff)
{
/* Registetrated formats are >= 0xc000 */
goto cleanup;
goto cleanup;
}
- pElement = IntIsFormatAvailable(pWinStaObj, fmt);
+ pElement = IntGetFormatElement(pWinStaObj, fmt);
if (pElement && IS_DATA_DELAYED(pElement) && pWinStaObj->spwndClipOwner)
{
/* Send WM_RENDERFORMAT message */
pWinStaObj->fInDelayedRendering = FALSE;
/* Data should be in clipboard now */
- pElement = IntIsFormatAvailable(pWinStaObj, fmt);
+ pElement = IntGetFormatElement(pWinStaObj, fmt);
}
if (!pElement || IS_DATA_DELAYED(pElement))
case CF_UNICODETEXT:
case CF_TEXT:
case CF_OEMTEXT:
- pElement = IntIsFormatAvailable(pWinStaObj, CF_UNICODETEXT);
+ pElement = IntGetFormatElement(pWinStaObj, CF_UNICODETEXT);
if (IS_DATA_SYNTHESIZED(pElement))
- pElement = IntIsFormatAvailable(pWinStaObj, CF_TEXT);
+ pElement = IntGetFormatElement(pWinStaObj, CF_TEXT);
if (IS_DATA_SYNTHESIZED(pElement))
- pElement = IntIsFormatAvailable(pWinStaObj, CF_OEMTEXT);
+ pElement = IntGetFormatElement(pWinStaObj, CF_OEMTEXT);
break;
case CF_BITMAP:
IntSynthesizeBitmap(pWinStaObj, pElement);
{
PCLIP pLocaleEl;
- pLocaleEl = IntIsFormatAvailable(pWinStaObj, CF_LOCALE);
+ pLocaleEl = IntGetFormatElement(pWinStaObj, CF_LOCALE);
if (pLocaleEl && !IS_DATA_DELAYED(pLocaleEl))
pgcd->hLocale = pLocaleEl->hData;
}
{
PCLIP pPaletteEl;
- pPaletteEl = IntIsFormatAvailable(pWinStaObj, CF_PALETTE);
+ pPaletteEl = IntGetFormatElement(pWinStaObj, CF_PALETTE);
if (pPaletteEl && !IS_DATA_DELAYED(pPaletteEl))
pgcd->hPalette = pPaletteEl->hData;
}
if (!pWinStaObj)
goto cleanup;
- /*
- * Check if the clipboard is correctly opened:
- * - in case of normal rendering, we must have opened the clipboard;
- * - in case of delayed rendering, the clipboard must be already opened
- * by another application, but we need to be the clipboard owner.
- */
- if ((!pWinStaObj->fInDelayedRendering && !IntIsClipboardOpenByMe(pWinStaObj)) ||
- (pWinStaObj->fInDelayedRendering && !(pWinStaObj->ptiClipLock &&
- pWinStaObj->spwndClipOwner->head.pti == PsGetCurrentThreadWin32Thread())))
+ if (!fmt || !pWinStaObj->ptiClipLock)
{
ERR("Access denied!\n");
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);