ReactOS  0.4.14-dev-77-gd9e7c48
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 UNIMPLEMENTED
Definition: debug.h:114

◆ 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:409
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 212 of file metafile.c.

213 {
214  HMETAFILE hMF;
215  UINT nSize;
216  HANDLE hmo = NULL;
217  BYTE * Buffer = NULL;
218  METAFILEPICT * pInfo = NULL;
219 
220  // get METAFILEPICT pointer
221  pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
222  if (pInfo == NULL)
223  goto Exit;
224 
225  // get metafile handle
226  hMF = pInfo->hMF;
227 
228  // get size of buffer
229  nSize = GetMetaFileBitsEx(hMF, 0, NULL);
230  if (nSize == 0)
231  goto Exit;
232 
233  // allocate buffer
235  if (Buffer == NULL)
236  goto Exit;
237 
238  // store to buffer
240  if (nSize == 0)
241  goto Exit;
242 
243  hmo = NtGdiCreateServerMetaFile( GDITAG_TYPE_MFP, nSize, Buffer, pInfo->mm, pInfo->xExt, pInfo->yExt);
244 
245 Exit:
246  // clean up
247  if (pInfo)
248  GlobalUnlock(hMetaFilePict);
249  if (Buffer)
250  LocalFree(Buffer);
251  return hmo; // success if non-NULL
252 }
HMETAFILE hMF
Definition: wingdi.h:2603
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:2024
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
UINT WINAPI GetMetaFileBitsEx(HMETAFILE hmf, UINT nSize, LPVOID buf)
Definition: metafile.c:1091
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:246
static void Exit(void)
Definition: sock.c:1331
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
unsigned char BYTE
Definition: mem.h:68
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by SetClipboardData().

◆ GdiCreateLocalEnhMetaFile()

HANDLE WINAPI GdiCreateLocalEnhMetaFile ( HANDLE  )

Definition at line 78 of file enhmfile.c.

79 {
80  HENHMETAFILE hEMF;
81  BYTE * Buffer = NULL;
82  UINT nSize;
83  DWORD iType, mm, xExt, yExt;
84 
86  if (nSize == 0)
87  goto Exit;
88 
89  // allocate buffer
91  if (Buffer == NULL)
92  goto Exit;
93 
94  // store to buffer
95  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, &mm, &xExt, &yExt);
96  if (nSize == 0)
97  goto Exit;
98 
99  if ( iType == GDITAG_TYPE_MFP ) // handle conversion to EMF
100  {
102 
103  Info.hMF = NULL;
104  Info.mm = mm;
105  Info.xExt = xExt;
106  Info.yExt = yExt;
107 
108  hEMF = SetWinMetaFileBits( nSize, Buffer, NULL, &Info ); // Translate from old style to new style.
109  if (hEMF == NULL)
110  goto Exit;
111  }
112  else
113  {
115  if (hEMF == NULL)
116  goto Exit;
117  }
118 
119 Exit:
120  // clean up
121  if (Buffer)
122  LocalFree(Buffer);
123  return hEMF;
124 }
_In_ ULONG iType
Definition: winddi.h:3748
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2024
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)
struct TraceInfo Info
HENHMETAFILE WINAPI SetWinMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpMeta16Data, _In_opt_ HDC hdcRef, _In_opt_ const METAFILEPICT *lpMFP)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:246
static void Exit(void)
Definition: sock.c:1331
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by GetClipboardData().

◆ GdiCreateLocalMetaFilePict()

HANDLE WINAPI GdiCreateLocalMetaFilePict ( HANDLE  )

Definition at line 106 of file metafile.c.

107 {
108  HGLOBAL hMetaFilePict;
109  METAFILEPICT * pInfo;
110  HMETAFILE hMF = NULL;
111  BYTE * Buffer = NULL;
112  BYTE * BufNew = NULL;
113  HDC hDC = NULL;
114  UINT nSize, cSize;
115  DWORD iType;
116 
117  // NOTE: On Win32, there is no difference between the local heap and
118  // the global heap. GlobalAlloc and LocalAlloc have same effect.
119 
120  // allocate for METAFILEPICT
121  hMetaFilePict = GlobalAlloc(GHND | GMEM_SHARE, sizeof(METAFILEPICT));
122  pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
123  if (pInfo == NULL)
124  goto Exit;
125 
127 
128  // allocate buffer
130  if (Buffer == NULL)
131  goto Exit;
132 
133  // store to buffer
134  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, (PDWORD)&pInfo->mm, (PDWORD)&pInfo->xExt, (PDWORD)&pInfo->yExt );
135  if (nSize == 0)
136  goto Exit;
137 
138  if ( iType == GDITAG_TYPE_EMF ) // handle conversion to MFP
139  {
140  static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
141  HENHMETAFILE hEMF;
142  ENHMETAHEADER emh;
143 
145  if (hEMF == NULL)
146  goto Exit;
147 
148  if (!GetEnhMetaFileHeader( hEMF, sizeof(emh), &emh ))
149  {
150  DeleteEnhMetaFile(hEMF);
151  goto Exit;
152  }
153 
154  pInfo->mm = MM_ANISOTROPIC; // wine uses MM_ISOTROPIC.
155  pInfo->xExt = emh.rclFrame.right - emh.rclFrame.left; // Width
156  pInfo->yExt = emh.rclFrame.bottom - emh.rclFrame.top; // Height
157 
158  hDC = CreateDCW(szDisplayW, NULL, NULL, NULL);
159  if (hDC)
160  {
161  cSize = GetWinMetaFileBits( hEMF, 0, NULL, MM_ANISOTROPIC, hDC );
162  if (cSize)
163  {
164  BufNew = (BYTE *)LocalAlloc(LPTR, cSize);
165  if (BufNew)
166  {
167  nSize = GetWinMetaFileBits( hEMF, cSize, (LPBYTE)BufNew, MM_ANISOTROPIC, hDC );
168  if (nSize == cSize)
169  {
170  if (Buffer) LocalFree(Buffer);
171  Buffer = BufNew;
172  }
173  }
174  }
175  DeleteDC(hDC);
176  }
177  DeleteEnhMetaFile(hEMF);
178 
179  if (Buffer != BufNew)
180  goto Exit;
181  }
182 
183  // create metafile from buffer
185  if (hMF == NULL)
186  goto Exit;
187 
188  // set metafile handle
189  pInfo->hMF = hMF;
190 
191 Exit:
192  // clean up
193  if (Buffer)
194  LocalFree(Buffer);
195  if (pInfo)
196  GlobalUnlock(hMetaFilePict);
197  if (hMF == NULL)
198  {
199  // failure
200  GlobalFree(hMetaFilePict);
201  hMetaFilePict = NULL;
202  }
203 
204  return hMetaFilePict; // success if non-NULL
205 }
HMETAFILE hMF
Definition: wingdi.h:2603
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:2024
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:52
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
long left
Definition: polytest.cpp:53
RECTL rclFrame
Definition: wingdi.h:2318
__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:866
unsigned char BYTE
Definition: mem.h:68
#define GDITAG_TYPE_EMF
Definition: ntgdityp.h:245
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:1259
unsigned int UINT
Definition: ndis.h:50
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:362
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 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
HANDLE WINAPI GdiCreateLocalMetaFilePict(HANDLE)
Definition: metafile.c:106
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)
HANDLE APIENTRY NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
Definition: clipboard.c:894
#define FIXME(fmt,...)
Definition: debug.h:110
#define CF_DSPENHMETAFILE
Definition: constants.h:417
BOOL fGlobalHandle
Definition: ntuser.h:1117
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS APIENTRY NtUserCreateLocalMemHandle(HANDLE hMem, PVOID pData, DWORD cbData, DWORD *pcbData)
Definition: clipboard.c:1229
#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:1081
HANDLE APIENTRY NtUserConvertMemHandle(PVOID pData, DWORD cbData)
Definition: clipboard.c:1184
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
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:78
#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:733
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
int32_t INT
Definition: typedefs.h:56
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define ANSI_NULL
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
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:409
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:733

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 UNIMPLEMENTED
Definition: debug.h:114

◆ 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:101
#define CP_ACP
Definition: compat.h:99
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define GMEM_DDESHARE
Definition: winbase.h:295
#define CP_OEMCP
Definition: winnls.h:228
#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:99
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define MultiByteToWideChar
Definition: compat.h:100
#define GMEM_DDESHARE
Definition: winbase.h:295
#define CP_OEMCP
Definition: winnls.h:228
#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:91
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
int ret
UINT NTAPI NtUserRegisterWindowMessage(PUNICODE_STRING MessageName)
Definition: window.c:4084
unsigned int UINT
Definition: ndis.h:50
#define ERROR_INVALID_NAME
Definition: compat.h:93

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:91
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
UINT NTAPI NtUserRegisterWindowMessage(PUNICODE_STRING MessageName)
Definition: window.c:4084
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ERROR_INVALID_NAME
Definition: compat.h:93

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 UNIMPLEMENTED
Definition: debug.h:114

◆ 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:91
#define TRUE
Definition: types.h:120
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define CF_METAFILEPICT
Definition: constants.h:398
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define CF_DSPENHMETAFILE
Definition: constants.h:417
BOOL fGlobalHandle
Definition: ntuser.h:1117
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_BITMAP
Definition: constants.h:397
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
HANDLE APIENTRY NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd)
Definition: clipboard.c:1081
HANDLE APIENTRY NtUserConvertMemHandle(PVOID pData, DWORD cbData)
Definition: clipboard.c:1184
#define CF_DSPBITMAP
Definition: constants.h:415
HANDLE WINAPI GdiConvertMetaFilePict(HANDLE)
Definition: metafile.c:212
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
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:109
#define CF_OEMTEXT
Definition: constants.h:402
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:54
#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  )