ReactOS  0.4.15-dev-3324-gda4e15f
clipboard.c File Reference
#include <user32.h>
Include dependency graph for clipboard.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
HANDLE WINAPI GdiConvertMetaFilePict (HANDLE)
 
HANDLE WINAPI GdiConvertEnhMetaFile (HANDLE)
 
HANDLE WINAPI GdiCreateLocalEnhMetaFile (HANDLE)
 
HANDLE WINAPI GdiCreateLocalMetaFilePict (HANDLE)
 
BOOL WINAPI OpenClipboard (HWND hWndNewOwner)
 
UINT WINAPI EnumClipboardFormats (UINT format)
 
INT WINAPI GetClipboardFormatNameA (UINT format, LPSTR lpszFormatName, int cchMaxCount)
 
INT WINAPI GetClipboardFormatNameW (UINT uFormat, LPWSTR lpszFormatName, INT cchMaxCount)
 
UINT WINAPI RegisterClipboardFormatA (LPCSTR lpszFormat)
 
UINT WINAPI RegisterClipboardFormatW (LPCWSTR lpszFormat)
 
static PVOID WINAPI IntSynthesizeMultiByte (PVOID pwStr, DWORD cbStr, BOOL bOem)
 
static PVOID WINAPI IntSynthesizeWideChar (PVOID pwStr, DWORD cbStr, BOOL bOem)
 
HANDLE WINAPI GetClipboardData (UINT uFormat)
 
HANDLE WINAPI SetClipboardData (UINT uFormat, HANDLE hMem)
 
BOOL WINAPI AddClipboardFormatListener (HWND hwnd)
 
BOOL WINAPI RemoveClipboardFormatListener (HWND hwnd)
 
BOOL WINAPI GetUpdatedClipboardFormats (PUINT lpuiFormats, UINT cFormats, PUINT pcFormatsOut)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file clipboard.c.

Function Documentation

◆ AddClipboardFormatListener()

BOOL WINAPI AddClipboardFormatListener ( HWND  hwnd)

Definition at line 382 of file clipboard.c.

383 {
385  return FALSE;
386 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115

◆ EnumClipboardFormats()

UINT WINAPI EnumClipboardFormats ( UINT  format)

Definition at line 39 of file clipboard.c.

40 {
43 }
#define NO_ERROR
Definition: dderror.h:5
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define SetLastError(x)
Definition: compat.h:611
EXTINLINE UINT NtUserxEnumClipboardFormats(UINT format)
Definition: ntwrapper.h:611

Referenced by get_priv_data(), test_cf_dataobject(), test_RegisterClipboardFormatA(), and test_synthesized().

◆ GdiConvertEnhMetaFile()

HANDLE WINAPI GdiConvertEnhMetaFile ( HANDLE  )

Referenced by SetClipboardData().

◆ GdiConvertMetaFilePict()

HANDLE WINAPI GdiConvertMetaFilePict ( HANDLE  )

Definition at line 201 of file metafile.c.

202 {
203  HMETAFILE hMF;
204  UINT nSize;
205  HANDLE hmo = NULL;
206  BYTE * Buffer = NULL;
207  METAFILEPICT * pInfo = NULL;
208 
209  // get METAFILEPICT pointer
210  pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
211  if (pInfo == NULL)
212  goto Exit;
213 
214  // get metafile handle
215  hMF = pInfo->hMF;
216 
217  // get size of buffer
218  nSize = GetMetaFileBitsEx(hMF, 0, NULL);
219  if (nSize == 0)
220  goto Exit;
221 
222  // allocate buffer
224  if (Buffer == NULL)
225  goto Exit;
226 
227  // store to buffer
229  if (nSize == 0)
230  goto Exit;
231 
232  hmo = NtGdiCreateServerMetaFile( GDITAG_TYPE_MFP, nSize, Buffer, pInfo->mm, pInfo->xExt, pInfo->yExt);
233 
234 Exit:
235  // clean up
236  if (pInfo)
237  GlobalUnlock(hMetaFilePict);
238  if (Buffer)
239  LocalFree(Buffer);
240  return hmo; // success if non-NULL
241 }
HMETAFILE hMF
Definition: wingdi.h:2608
HANDLE APIENTRY NtGdiCreateServerMetaFile(IN DWORD iType, IN ULONG cjData, IN PBYTE pjData, IN DWORD mm, IN DWORD xExt, IN DWORD yExt)
Definition: metafile.c:51
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2053
Definition: bufpool.h:45
UINT WINAPI GetMetaFileBitsEx(HMETAFILE hmf, UINT nSize, LPVOID buf)
Definition: metafile.c:1091
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:247
static void Exit(void)
Definition: sock.c:1331
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
unsigned char BYTE
Definition: xxhash.c:193
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define LPTR
Definition: winbase.h:378
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by SetClipboardData().

◆ GdiCreateLocalEnhMetaFile()

HANDLE WINAPI GdiCreateLocalEnhMetaFile ( HANDLE  )

Definition at line 74 of file enhmfile.c.

75 {
76  HENHMETAFILE hEMF;
77  BYTE * Buffer = NULL;
78  UINT nSize;
79  DWORD iType, mm, xExt, yExt;
80 
82  if (nSize == 0)
83  goto Exit;
84 
85  // allocate buffer
87  if (Buffer == NULL)
88  goto Exit;
89 
90  // store to buffer
91  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, &mm, &xExt, &yExt);
92  if (nSize == 0)
93  goto Exit;
94 
95  if ( iType == GDITAG_TYPE_MFP ) // handle conversion to EMF
96  {
98 
99  Info.hMF = NULL;
100  Info.mm = mm;
101  Info.xExt = xExt;
102  Info.yExt = yExt;
103 
104  hEMF = SetWinMetaFileBits( nSize, Buffer, NULL, &Info ); // Translate from old style to new style.
105  if (hEMF == NULL)
106  goto Exit;
107  }
108  else
109  {
111  if (hEMF == NULL)
112  goto Exit;
113  }
114 
115 Exit:
116  // clean up
117  if (Buffer)
118  LocalFree(Buffer);
119  return hEMF;
120 }
_In_ ULONG iType
Definition: winddi.h:3748
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2053
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
__kernel_entry W32KAPI ULONG APIENTRY NtGdiGetServerMetaFileBits(_In_ HANDLE hmo, _In_ ULONG cjData, _Out_writes_bytes_opt_(cjData) LPBYTE pjData, _Out_ PDWORD piType, _Out_ PDWORD pmm, _Out_ PDWORD pxExt, _Out_ PDWORD pyExt)
HENHMETAFILE WINAPI SetWinMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpMeta16Data, _In_opt_ HDC hdcRef, _In_opt_ const METAFILEPICT *lpMFP)
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
Definition: bufpool.h:45
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:247
static void Exit(void)
Definition: sock.c:1331
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: xxhash.c:193
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define LPTR
Definition: winbase.h:378
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by GetClipboardData().

◆ GdiCreateLocalMetaFilePict()

HANDLE WINAPI GdiCreateLocalMetaFilePict ( HANDLE  )

Definition at line 95 of file metafile.c.

96 {
97  HGLOBAL hMetaFilePict;
98  METAFILEPICT * pInfo;
99  HMETAFILE hMF = NULL;
100  BYTE * Buffer = NULL;
101  BYTE * BufNew = NULL;
102  HDC hDC = NULL;
103  UINT nSize, cSize;
104  DWORD iType;
105 
106  // NOTE: On Win32, there is no difference between the local heap and
107  // the global heap. GlobalAlloc and LocalAlloc have same effect.
108 
109  // allocate for METAFILEPICT
110  hMetaFilePict = GlobalAlloc(GHND | GMEM_SHARE, sizeof(METAFILEPICT));
111  pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
112  if (pInfo == NULL)
113  goto Exit;
114 
116 
117  // allocate buffer
119  if (Buffer == NULL)
120  goto Exit;
121 
122  // store to buffer
123  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, (PDWORD)&pInfo->mm, (PDWORD)&pInfo->xExt, (PDWORD)&pInfo->yExt );
124  if (nSize == 0)
125  goto Exit;
126 
127  if ( iType == GDITAG_TYPE_EMF ) // handle conversion to MFP
128  {
129  static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
130  HENHMETAFILE hEMF;
131  ENHMETAHEADER emh;
132 
134  if (hEMF == NULL)
135  goto Exit;
136 
137  if (!GetEnhMetaFileHeader( hEMF, sizeof(emh), &emh ))
138  {
139  DeleteEnhMetaFile(hEMF);
140  goto Exit;
141  }
142 
143  pInfo->mm = MM_ANISOTROPIC; // wine uses MM_ISOTROPIC.
144  pInfo->xExt = emh.rclFrame.right - emh.rclFrame.left; // Width
145  pInfo->yExt = emh.rclFrame.bottom - emh.rclFrame.top; // Height
146 
147  hDC = CreateDCW(szDisplayW, NULL, NULL, NULL);
148  if (hDC)
149  {
150  cSize = GetWinMetaFileBits( hEMF, 0, NULL, MM_ANISOTROPIC, hDC );
151  if (cSize)
152  {
153  BufNew = (BYTE *)LocalAlloc(LPTR, cSize);
154  if (BufNew)
155  {
156  nSize = GetWinMetaFileBits( hEMF, cSize, (LPBYTE)BufNew, MM_ANISOTROPIC, hDC );
157  if (nSize == cSize)
158  {
159  if (Buffer) LocalFree(Buffer);
160  Buffer = BufNew;
161  }
162  }
163  }
164  DeleteDC(hDC);
165  }
166  DeleteEnhMetaFile(hEMF);
167 
168  if (Buffer != BufNew)
169  goto Exit;
170  }
171 
172  // create metafile from buffer
174  if (hMF == NULL)
175  goto Exit;
176 
177  // set metafile handle
178  pInfo->hMF = hMF;
179 
180 Exit:
181  // clean up
182  if (Buffer)
183  LocalFree(Buffer);
184  if (pInfo)
185  GlobalUnlock(hMetaFilePict);
186  if (hMF == NULL)
187  {
188  // failure
189  GlobalFree(hMetaFilePict);
190  hMetaFilePict = NULL;
191  }
192 
193  return hMetaFilePict; // success if non-NULL
194 }
HMETAFILE hMF
Definition: wingdi.h:2608
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
ULONG APIENTRY NtGdiGetServerMetaFileBits(IN HANDLE hmo, IN ULONG cjData, OUT OPTIONAL PBYTE pjData, OUT PDWORD piType, OUT PDWORD pmm, OUT PDWORD pxExt, OUT PDWORD pyExt)
Definition: metafile.c:107
_In_ ULONG iType
Definition: winddi.h:3748
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2053
static HDC
Definition: imagelist.c:92
long bottom
Definition: polytest.cpp:53
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
#define GMEM_SHARE
Definition: winbase.h:302
long right
Definition: polytest.cpp:53
#define GHND
Definition: winbase.h:294
HMETAFILE WINAPI SetMetaFileBitsEx(UINT size, const BYTE *lpData)
Definition: metafile.c:1049
unsigned char * LPBYTE
Definition: typedefs.h:53
long top
Definition: polytest.cpp:53
Definition: bufpool.h:45
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
long left
Definition: polytest.cpp:53
RECTL rclFrame
Definition: wingdi.h:2323
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void Exit(void)
Definition: sock.c:1331
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define MM_ANISOTROPIC
Definition: wingdi.h:867
#define GDITAG_TYPE_EMF
Definition: ntgdityp.h:246
unsigned char BYTE
Definition: xxhash.c:193
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
UINT WINAPI GetWinMetaFileBits(HENHMETAFILE hemf, UINT cbBuffer, LPBYTE lpbBuffer, INT map_mode, HDC hdcRef)
Definition: metafile.c:1257
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
DWORD * PDWORD
Definition: pedump.c:68
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
#define LPTR
Definition: winbase.h:378
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by GetClipboardData().

◆ GetClipboardData()

HANDLE WINAPI GetClipboardData ( UINT  uFormat)

Definition at line 198 of file clipboard.c.

199 {
200  HANDLE hData = NULL;
201  PVOID pData = NULL;
202  DWORD cbData = 0;
204 
205  hData = NtUserGetClipboardData(uFormat, &gcd);
206  if (!hData)
207  return NULL;
208 
209  switch (uFormat)
210  {
211  case CF_DSPMETAFILEPICT:
212  case CF_METAFILEPICT:
213  return GdiCreateLocalMetaFilePict(hData);
214  case CF_DSPENHMETAFILE:
215  case CF_ENHMETAFILE:
216  return GdiCreateLocalEnhMetaFile(hData);
217  }
218 
219  if (gcd.fGlobalHandle)
220  {
221  HANDLE hGlobal;
222 
223  NtUserCreateLocalMemHandle(hData, NULL, 0, &cbData);
224  hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbData);
225  pData = GlobalLock(hGlobal);
226  NtUserCreateLocalMemHandle(hData, pData, cbData, NULL);
227  hData = hGlobal;
228  }
229 
230  if (gcd.uFmtRet != uFormat)
231  {
232  SETCLIPBDATA scd = {FALSE, FALSE};
233  HANDLE hNewData = NULL;
234  PVOID pNewData = NULL;
235 
236  /* Synthesize requested format */
237  switch (uFormat)
238  {
239  case CF_TEXT:
240  if (gcd.uFmtRet == CF_UNICODETEXT)
241  pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
242  else // CF_OEMTEXT
243  OemToCharBuffA(pData, pData, cbData);
244  break;
245  case CF_OEMTEXT:
246  if (gcd.uFmtRet == CF_UNICODETEXT)
247  pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
248  else
249  CharToOemBuffA(pData, pData, cbData);
250  break;
251  case CF_UNICODETEXT:
252  pNewData = IntSynthesizeWideChar(pData, cbData, gcd.uFmtRet == CF_OEMTEXT);
253  break;
254  default:
255  FIXME("Format: %u != %u\n", uFormat, gcd.uFmtRet);
256  }
257 
258  /* Is it a global handle? */
259  if (pNewData)
260  hNewData = GlobalHandle(pNewData);
261 
262  if (hNewData)
263  {
264  /* Free old data */
265  if (pData)
266  {
267  GlobalUnlock(hData);
268  GlobalFree(hData);
269  }
270  hData = hNewData;
271  pData = pNewData;
272  }
273 
274  /* Save synthesized format in clipboard */
275  if (pData)
276  {
277  HANDLE hMem;
278 
279  scd.fGlobalHandle = TRUE;
280  hMem = NtUserConvertMemHandle(pData, GlobalSize(hData));
281  NtUserSetClipboardData(uFormat, hMem, &scd);
282  }
283  else if (hData)
284  NtUserSetClipboardData(uFormat, hData, &scd);
285  }
286 
287  /* Unlock global handle */
288  if (pData)
289  GlobalUnlock(hData);
290 
291  return hData;
292 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define CF_ENHMETAFILE
Definition: constants.h:409
#define TRUE
Definition: types.h:120
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
HANDLE WINAPI GdiCreateLocalMetaFilePict(HANDLE)
Definition: metafile.c:95
HGLOBAL NTAPI GlobalHandle(LPCVOID pMem)
Definition: heapmem.c:705
#define CF_METAFILEPICT
Definition: constants.h:398
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
BOOL WINAPI CharToOemBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
#define FALSE
Definition: types.h:117
HANDLE APIENTRY NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
Definition: clipboard.c:897
#define FIXME(fmt,...)
Definition: debug.h:111
#define CF_DSPENHMETAFILE
Definition: constants.h:417
BOOL fGlobalHandle
Definition: ntuser.h:1126
#define CF_UNICODETEXT
Definition: constants.h:408
NTSTATUS APIENTRY NtUserCreateLocalMemHandle(HANDLE hMem, PVOID pData, DWORD cbData, DWORD *pcbData)
Definition: clipboard.c:1232
#define CF_TEXT
Definition: constants.h:396
static PVOID WINAPI IntSynthesizeMultiByte(PVOID pwStr, DWORD cbStr, BOOL bOem)
Definition: clipboard.c:154
static PVOID WINAPI IntSynthesizeWideChar(PVOID pwStr, DWORD cbStr, BOOL bOem)
Definition: clipboard.c:175
HANDLE APIENTRY NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd)
Definition: clipboard.c:1084
HANDLE APIENTRY NtUserConvertMemHandle(PVOID pData, DWORD cbData)
Definition: clipboard.c:1187
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define CF_OEMTEXT
Definition: constants.h:402
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_DDESHARE
Definition: winbase.h:295
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
BOOL WINAPI OemToCharBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
HANDLE WINAPI GdiCreateLocalEnhMetaFile(HANDLE)
Definition: enhmfile.c:74
#define GMEM_MOVEABLE
Definition: winbase.h:291
static int gcd(int, int)
Definition: getopt.c:86

Referenced by clipboard_thread(), get_clipboard_data_process(), get_current_dataobject(), get_current_ole_clip_window(), get_priv_data(), set_clipboard_data_thread(), snapshot_GetData(), snapshot_GetDataHere(), test_cf_dataobject(), test_ClipboardOwner(), test_data_handles(), test_handles(), test_handles_process(), test_handles_process_dib(), test_handles_thread2(), test_no_cf_dataobject(), test_set_clipboard(), test_string_data_process(), and test_synthesized().

◆ GetClipboardFormatNameA()

INT WINAPI GetClipboardFormatNameA ( UINT  format,
LPSTR  lpszFormatName,
int  cchMaxCount 
)

Definition at line 50 of file clipboard.c.

53 {
55  INT Length;
56 
57  lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR));
58  if (!lpBuffer)
59  {
61  return 0;
62  }
63 
64  /* we need a UNICODE string */
66 
67  if (Length != 0)
68  {
69  if (!WideCharToMultiByte(CP_ACP, 0, lpBuffer, Length, lpszFormatName, cchMaxCount, NULL, NULL))
70  {
71  /* clear result string */
72  Length = 0;
73  }
74  lpszFormatName[Length] = ANSI_NULL;
75  }
76 
77  RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer);
78  return Length;
79 }
INT APIENTRY NtUserGetClipboardFormatName(UINT fmt, LPWSTR lpszFormatName, INT cchMaxCount)
Definition: clipboard.c:736
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
int32_t INT
Definition: typedefs.h:58
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define ANSI_NULL
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by test_RegisterClipboardFormatA().

◆ GetClipboardFormatNameW()

INT WINAPI GetClipboardFormatNameW ( UINT  uFormat,
LPWSTR  lpszFormatName,
INT  cchMaxCount 
)

Definition at line 86 of file clipboard.c.

89 {
90  return NtUserGetClipboardFormatName(uFormat, lpszFormatName, cchMaxCount);
91 }
INT APIENTRY NtUserGetClipboardFormatName(UINT fmt, LPWSTR lpszFormatName, INT cchMaxCount)
Definition: clipboard.c:736

Referenced by get_priv_data().

◆ GetUpdatedClipboardFormats()

BOOL WINAPI GetUpdatedClipboardFormats ( PUINT  lpuiFormats,
UINT  cFormats,
PUINT  pcFormatsOut 
)

Definition at line 403 of file clipboard.c.

406 {
408  return FALSE;
409 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115

◆ IntSynthesizeMultiByte()

static PVOID WINAPI IntSynthesizeMultiByte ( PVOID  pwStr,
DWORD  cbStr,
BOOL  bOem 
)
static

Definition at line 154 of file clipboard.c.

155 {
156  HANDLE hGlobal;
157  PVOID pGlobal;
158  INT cbGlobal;
159 
160  cbGlobal = WideCharToMultiByte(bOem ? CP_OEMCP : CP_ACP,
161  0, pwStr, cbStr / sizeof(WCHAR),
162  NULL, 0, NULL, NULL);
163  hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbGlobal);
164  if (!hGlobal)
165  return NULL;
166 
167  pGlobal = GlobalLock(hGlobal);
169  0, pwStr, cbStr / sizeof(WCHAR),
170  pGlobal, cbGlobal, NULL, NULL);
171  return pGlobal;
172 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define NULL
Definition: types.h:112
#define GMEM_DDESHARE
Definition: winbase.h:295
#define CP_OEMCP
Definition: winnls.h:231
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by GetClipboardData().

◆ IntSynthesizeWideChar()

static PVOID WINAPI IntSynthesizeWideChar ( PVOID  pwStr,
DWORD  cbStr,
BOOL  bOem 
)
static

Definition at line 175 of file clipboard.c.

176 {
177  HANDLE hGlobal;
178  PVOID pGlobal;
179  INT cbGlobal;
180 
181  cbGlobal = MultiByteToWideChar(bOem ? CP_OEMCP : CP_ACP,
182  0, pwStr, cbStr, NULL, 0) * sizeof(WCHAR);
183  hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbGlobal);
184  if (!hGlobal)
185  return NULL;
186 
187  pGlobal = GlobalLock(hGlobal);
189  0, pwStr, cbStr, pGlobal, cbGlobal);
190  return pGlobal;
191 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define CP_ACP
Definition: compat.h:109
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define GMEM_DDESHARE
Definition: winbase.h:295
#define CP_OEMCP
Definition: winnls.h:231
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by GetClipboardData().

◆ OpenClipboard()

◆ RegisterClipboardFormatA()

UINT WINAPI RegisterClipboardFormatA ( LPCSTR  lpszFormat)

Definition at line 98 of file clipboard.c.

99 {
100  UINT ret;
101  UNICODE_STRING usFormat = {0};
102 
103  if (lpszFormat == NULL)
104  {
106  return 0;
107  }
108 
109  if (*lpszFormat == ANSI_NULL)
110  {
112  return 0;
113  }
114 
115  if (!RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat))
116  {
118  return 0;
119  }
120 
121  ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR)
122 
123  RtlFreeUnicodeString(&usFormat);
124 
125  return ret;
126 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ANSI_NULL
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:611
int ret
UINT NTAPI NtUserRegisterWindowMessage(PUNICODE_STRING MessageName)
Definition: window.c:4046
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define ERROR_INVALID_NAME
Definition: compat.h:103

Referenced by ME_GetDataObject(), test_cf_dataobject(), test_data_handles(), test_handles(), test_handles_process(), test_no_cf_dataobject(), test_RegisterClipboardFormatA(), and test_set_clipboard().

◆ RegisterClipboardFormatW()

UINT WINAPI RegisterClipboardFormatW ( LPCWSTR  lpszFormat)

Definition at line 133 of file clipboard.c.

134 {
135  UNICODE_STRING usFormat = {0};
136 
137  if (lpszFormat == NULL)
138  {
140  return 0;
141  }
142 
143  if (*lpszFormat == UNICODE_NULL)
144  {
146  return 0;
147  }
148 
149  RtlInitUnicodeString(&usFormat, lpszFormat);
150  return NtUserRegisterWindowMessage(&usFormat);
151 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define UNICODE_NULL
#define SetLastError(x)
Definition: compat.h:611
UINT NTAPI NtUserRegisterWindowMessage(PUNICODE_STRING MessageName)
Definition: window.c:4046
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ERROR_INVALID_NAME
Definition: compat.h:103

Referenced by register_clipboard_formats().

◆ RemoveClipboardFormatListener()

BOOL WINAPI RemoveClipboardFormatListener ( HWND  hwnd)

Definition at line 392 of file clipboard.c.

393 {
395  return FALSE;
396 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115

◆ SetClipboardData()

HANDLE WINAPI SetClipboardData ( UINT  uFormat,
HANDLE  hMem 
)

Definition at line 299 of file clipboard.c.

300 {
301  DWORD dwSize;
302  HANDLE hGlobal;
303  LPVOID pMem;
304  HANDLE hRet = NULL, hTemp;
305  SETCLIPBDATA scd = {FALSE, FALSE};
306 
307  /* Check if this is a delayed rendering */
308  if (hMem == NULL)
309  return NtUserSetClipboardData(uFormat, NULL, &scd);
310 
311  if (hMem <= (HANDLE)4)
313  /* Bitmaps and palette does not use global handles */
314  else if (uFormat == CF_BITMAP || uFormat == CF_DSPBITMAP || uFormat == CF_PALETTE)
315  hRet = NtUserSetClipboardData(uFormat, hMem, &scd);
316  /* Meta files are probably checked for validity */
317  else if (uFormat == CF_DSPMETAFILEPICT || uFormat == CF_METAFILEPICT )
318  {
319  hTemp = GdiConvertMetaFilePict( hMem );
320  hRet = NtUserSetClipboardData(uFormat, hTemp, &scd); // Note : LOL, it returns a BOOL not a HANDLE!!!!
321  if (hRet == hTemp) hRet = hMem; // If successful "TRUE", return the original handle.
322  }
323  else if (uFormat == CF_DSPENHMETAFILE || uFormat == CF_ENHMETAFILE)
324  {
325  hTemp = GdiConvertEnhMetaFile( hMem );
326  hRet = NtUserSetClipboardData(uFormat, hTemp, &scd);
327  if (hRet == hTemp) hRet = hMem;
328  }
329  else
330  {
331  /* Some formats accept only global handles, other accept global handles or integer values */
332  pMem = GlobalLock(hMem);
333  dwSize = GlobalSize(hMem);
334 
335  if (pMem || uFormat == CF_DIB || uFormat == CF_DIBV5 ||
336  uFormat == CF_DSPTEXT || uFormat == CF_LOCALE ||
337  uFormat == CF_OEMTEXT || uFormat == CF_TEXT ||
338  uFormat == CF_UNICODETEXT)
339  {
340  if (pMem)
341  {
342  /* This is a local memory. Make global memory object */
343  hGlobal = NtUserConvertMemHandle(pMem, dwSize);
344 
345  /* Unlock memory */
346  GlobalUnlock(hMem);
347  /* FIXME: free hMem when CloseClipboard is called */
348 
349  if (hGlobal)
350  {
351  /* Save data */
352  scd.fGlobalHandle = TRUE;
353  hRet = NtUserSetClipboardData(uFormat, hGlobal, &scd);
354  }
355 
356  /* On success NtUserSetClipboardData returns pMem
357  however caller expects us to return hMem */
358  if (hRet == hGlobal)
359  hRet = hMem;
360  }
361  else
363  }
364  else
365  {
366  /* Save a number */
367  hRet = NtUserSetClipboardData(uFormat, hMem, &scd);
368  }
369  }
370 
371  if (!hRet)
372  ERR("SetClipboardData(%u, %p) failed\n", uFormat, hMem);
373 
374  return hRet;
375 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CF_ENHMETAFILE
Definition: constants.h:409
#define TRUE
Definition: types.h:120
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CF_METAFILEPICT
Definition: constants.h:398
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define FALSE
Definition: types.h:117
#define CF_DSPENHMETAFILE
Definition: constants.h:417
BOOL fGlobalHandle
Definition: ntuser.h:1126
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_BITMAP
Definition: constants.h:397
#define CF_TEXT
Definition: constants.h:396
HANDLE APIENTRY NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd)
Definition: clipboard.c:1084
HANDLE APIENTRY NtUserConvertMemHandle(PVOID pData, DWORD cbData)
Definition: clipboard.c:1187
#define CF_DSPBITMAP
Definition: constants.h:415
HANDLE WINAPI GdiConvertMetaFilePict(HANDLE)
Definition: metafile.c:201
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define CF_PALETTE
Definition: constants.h:404
#define CF_LOCALE
Definition: constants.h:411
#define ERR(fmt,...)
Definition: debug.h:110
#define CF_OEMTEXT
Definition: constants.h:402
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define CF_DSPTEXT
Definition: constants.h:414
HANDLE WINAPI GdiConvertEnhMetaFile(HANDLE)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define CF_DIB
Definition: constants.h:403

Referenced by clipboard_render_data_thread(), clipboard_thread(), clipboard_wnd_proc(), expose_marshalled_dataobject(), grab_clipboard_process(), render_embed_source_hack(), render_format(), set_clipboard_data_process(), set_clipboard_data_thread(), set_clipboard_formats(), set_clipboard_thread(), set_dataobject_format(), test_ClipboardOwner(), test_data_handles(), test_GetUpdatedClipboardFormats(), test_handles(), test_handles_process_open(), test_nonole_clipboard(), test_RegisterClipboardFormatA(), test_set_clipboard(), test_string_data(), and test_synthesized().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )