ReactOS 0.4.16-dev-122-g325d74c
cliputils.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

LRESULT SendClipboardOwnerMessage (IN BOOL bUnicode, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
void RetrieveClipboardFormatName (HINSTANCE hInstance, UINT uFormat, BOOL Unicode, PVOID lpszFormat, UINT cch)
 
void DeleteClipboardContent (void)
 
UINT GetAutomaticClipboardFormat (void)
 
BOOL IsClipboardFormatSupported (UINT uFormat)
 
SIZE_T GetLineExtentW (IN LPCWSTR lpText, OUT LPCWSTR *lpNextLine)
 
SIZE_T GetLineExtentA (IN LPCSTR lpText, OUT LPCSTR *lpNextLine)
 
BOOL GetClipboardDataDimensions (UINT uFormat, PRECT pRc)
 

Function Documentation

◆ DeleteClipboardContent()

void DeleteClipboardContent ( void  )

Definition at line 134 of file cliputils.c.

135{
137 {
139 return;
140 }
141
142 if (!EmptyClipboard())
143 {
145 }
146
148}
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11

Referenced by MainWndProc(), and OnCommand().

◆ GetAutomaticClipboardFormat()

UINT GetAutomaticClipboardFormat ( void  )

Definition at line 150 of file cliputils.c.

151{
152 static UINT uFormatList[] =
153 {
156 CF_TEXT,
160 CF_DIBV5,
161 CF_DIB,
162 CF_BITMAP,
169 };
170
171 return GetPriorityClipboardFormat(uFormatList, ARRAYSIZE(uFormatList));
172}
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_METAFILEPICT
Definition: constants.h:398
#define CF_BITMAP
Definition: constants.h:397
#define CF_PALETTE
Definition: constants.h:404
#define CF_DSPENHMETAFILE
Definition: constants.h:417
#define CF_OWNERDISPLAY
Definition: constants.h:413
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define CF_HDROP
Definition: constants.h:410
#define CF_DSPBITMAP
Definition: constants.h:415
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_TEXT
Definition: constants.h:396
#define CF_DSPTEXT
Definition: constants.h:414
#define CF_DIB
Definition: constants.h:403
#define CF_OEMTEXT
Definition: constants.h:402
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
unsigned int UINT
Definition: ndis.h:50
int WINAPI GetPriorityClipboardFormat(_In_reads_(cFormats) UINT *paFormatPriorityList, _In_ int cFormats)

Referenced by SetDisplayFormat().

◆ GetClipboardDataDimensions()

BOOL GetClipboardDataDimensions ( UINT  uFormat,
PRECT  pRc 
)

Definition at line 249 of file cliputils.c.

250{
251 SetRectEmpty(pRc);
252
254 {
255 return FALSE;
256 }
257
258 switch (uFormat)
259 {
260 case CF_DSPBITMAP:
261 case CF_BITMAP:
262 {
264 BITMAP bmp;
265
267 GetObjectW(hBitmap, sizeof(bmp), &bmp);
268 SetRect(pRc, 0, 0, bmp.bmWidth, bmp.bmHeight);
269 break;
270 }
271
272 case CF_DIB:
273 case CF_DIBV5:
274 {
275 HGLOBAL hGlobal;
276 LPBITMAPINFOHEADER lpInfoHeader;
277
278 hGlobal = GetClipboardData(uFormat);
279 if (!hGlobal)
280 break;
281
282 lpInfoHeader = GlobalLock(hGlobal);
283 if (!lpInfoHeader)
284 break;
285
286 if (lpInfoHeader->biSize == sizeof(BITMAPCOREHEADER))
287 {
288 LPBITMAPCOREHEADER lpCoreHeader = (LPBITMAPCOREHEADER)lpInfoHeader;
289 SetRect(pRc, 0, 0,
290 lpCoreHeader->bcWidth,
291 lpCoreHeader->bcHeight);
292 }
293 else if ((lpInfoHeader->biSize == sizeof(BITMAPINFOHEADER)) ||
294 (lpInfoHeader->biSize == sizeof(BITMAPV4HEADER)) ||
295 (lpInfoHeader->biSize == sizeof(BITMAPV5HEADER)))
296 {
297 SetRect(pRc, 0, 0,
298 lpInfoHeader->biWidth,
299 /* NOTE: biHeight < 0 for bottom-up DIBs, or > 0 for top-down DIBs */
300 (lpInfoHeader->biHeight > 0) ? lpInfoHeader->biHeight
301 : -lpInfoHeader->biHeight);
302 }
303 else
304 {
305 /* Invalid format */
306 }
307
308 GlobalUnlock(hGlobal);
309 break;
310 }
311
312 case CF_DSPTEXT:
313 case CF_TEXT:
314 case CF_OEMTEXT:
315 case CF_UNICODETEXT:
316 {
317 HDC hDC;
318 HGLOBAL hGlobal;
319 PVOID lpText, ptr;
321 SIZE txtSize = {0, 0};
322 SIZE_T lineSize;
323
324 hGlobal = GetClipboardData(uFormat);
325 if (!hGlobal)
326 break;
327
328 lpText = GlobalLock(hGlobal);
329 if (!lpText)
330 break;
331
333
334 /* Find the size of the rectangle enclosing the text */
335 for (;;)
336 {
337 if (uFormat == CF_UNICODETEXT)
338 {
339 if (*(LPCWSTR)lpText == UNICODE_NULL)
340 break;
341 lineSize = GetLineExtentW(lpText, (LPCWSTR*)&ptr);
342 dwSize = GetTabbedTextExtentW(hDC, lpText, lineSize, 0, NULL);
343 }
344 else
345 {
346 if (*(LPCSTR)lpText == ANSI_NULL)
347 break;
348 lineSize = GetLineExtentA(lpText, (LPCSTR*)&ptr);
349 dwSize = GetTabbedTextExtentA(hDC, lpText, lineSize, 0, NULL);
350 }
351 txtSize.cx = max(txtSize.cx, LOWORD(dwSize));
352 txtSize.cy += HIWORD(dwSize);
353 lpText = ptr;
354 }
355
357
358 GlobalUnlock(hGlobal);
359
360 SetRect(pRc, 0, 0, txtSize.cx, txtSize.cy);
361 break;
362 }
363
364 default:
365 {
366 break;
367 }
368 }
369
371
372 return TRUE;
373}
static HDC hDC
Definition: 3dtext.c:33
SIZE_T GetLineExtentA(IN LPCSTR lpText, OUT LPCSTR *lpNextLine)
Definition: cliputils.c:225
SIZE_T GetLineExtentW(IN LPCWSTR lpText, OUT LPCWSTR *lpNextLine)
Definition: cliputils.c:200
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HBITMAP hBitmap
Definition: timezone.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
BITMAP bmp
Definition: alphablend.c:62
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define UNICODE_NULL
#define ANSI_NULL
#define LOWORD(l)
Definition: pedump.c:82
Definition: bl.h:1331
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define HIWORD(l)
Definition: typedefs.h:247
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
struct tagBITMAPCOREHEADER * LPBITMAPCOREHEADER
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetTabbedTextExtentA(_In_ HDC hdc, _In_reads_(chCount) LPCSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions)
DWORD WINAPI GetTabbedTextExtentW(_In_ HDC hdc, _In_reads_(chCount) LPCWSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions)
HANDLE WINAPI GetClipboardData(_In_ UINT)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by MainWndProc(), and SetDisplayFormat().

◆ GetLineExtentA()

SIZE_T GetLineExtentA ( IN LPCSTR  lpText,
OUT LPCSTR lpNextLine 
)

Definition at line 225 of file cliputils.c.

228{
229 LPCSTR ptr;
230
231 /* Find the next line of text (lpText is NULL-terminated) */
232 /* For newlines, focus only on '\n', not on '\r' */
233 ptr = strchr(lpText, '\n'); // Find the end of this line.
234 if (ptr)
235 {
236 /* We have the end of this line, go to the next line (ignore the endline in the count) */
237 *lpNextLine = ptr + 1;
238 }
239 else
240 {
241 /* This line was the last one, go pointing to the terminating NULL */
242 ptr = lpText + strlen(lpText);
243 *lpNextLine = ptr;
244 }
245
246 return (ptr - lpText);
247}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501

Referenced by DrawTextFromClipboard(), and GetClipboardDataDimensions().

◆ GetLineExtentW()

SIZE_T GetLineExtentW ( IN LPCWSTR  lpText,
OUT LPCWSTR lpNextLine 
)

Definition at line 200 of file cliputils.c.

203{
204 LPCWSTR ptr;
205
206 /* Find the next line of text (lpText is NULL-terminated) */
207 /* For newlines, focus only on '\n', not on '\r' */
208 ptr = wcschr(lpText, L'\n'); // Find the end of this line.
209 if (ptr)
210 {
211 /* We have the end of this line, go to the next line (ignore the endline in the count) */
212 *lpNextLine = ptr + 1;
213 }
214 else
215 {
216 /* This line was the last one, go pointing to the terminating NULL */
217 ptr = lpText + wcslen(lpText);
218 *lpNextLine = ptr;
219 }
220
221 return (ptr - lpText);
222}
#define wcschr
Definition: compat.h:17
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50

Referenced by DrawTextFromClipboard(), and GetClipboardDataDimensions().

◆ IsClipboardFormatSupported()

BOOL IsClipboardFormatSupported ( UINT  uFormat)

Definition at line 174 of file cliputils.c.

175{
176 switch (uFormat)
177 {
178 case CF_OWNERDISPLAY:
179 case CF_UNICODETEXT:
180 case CF_TEXT:
181 case CF_OEMTEXT:
182 case CF_BITMAP:
183 case CF_ENHMETAFILE:
184 case CF_METAFILEPICT:
185 case CF_DIB:
186 case CF_DIBV5:
187 case CF_HDROP:
188 {
189 return TRUE;
190 }
191
192 default:
193 {
194 return FALSE;
195 }
196 }
197}

Referenced by MainWndProc(), and UpdateDisplayMenu().

◆ RetrieveClipboardFormatName()

void RetrieveClipboardFormatName ( HINSTANCE  hInstance,
UINT  uFormat,
BOOL  Unicode,
PVOID  lpszFormat,
UINT  cch 
)

Definition at line 95 of file cliputils.c.

100{
101 ZeroMemory(lpszFormat, cch * (Unicode ? sizeof(WCHAR) : sizeof(CHAR)));
102
103 /* Check for predefined clipboard format */
104 if (GetPredefinedClipboardFormatName(hInstance, uFormat, Unicode, lpszFormat, cch) != 0)
105 return;
106
107 /* Check for owner-display format */
108 if (uFormat == CF_OWNERDISPLAY)
109 {
111 (WPARAM)cch, (LPARAM)lpszFormat) != 0)
112 {
113 if (Unicode)
115 else
117 }
118 return;
119 }
120
121 /* Fallback to registered clipboard format */
122 if (Unicode)
123 {
124 if (!GetClipboardFormatNameW(uFormat, (LPWSTR)lpszFormat, cch))
126 }
127 else
128 {
129 if (!GetClipboardFormatNameA(uFormat, (LPSTR)lpszFormat, cch))
131 }
132}
#define STRING_CF_UNKNOWN
Definition: resources.h:31
HINSTANCE hInstance
Definition: charmap.c:19
static int GetPredefinedClipboardFormatName(HINSTANCE hInstance, UINT uFormat, BOOL Unicode, PVOID lpszFormat, UINT cch)
Definition: cliputils.c:31
LRESULT SendClipboardOwnerMessage(IN BOOL bUnicode, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: cliputils.c:12
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI GetClipboardFormatNameA(_In_ UINT format, _Out_writes_(cchMaxCount) LPSTR lpszFormatName, _In_ int cchMaxCount)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
#define WM_ASKCBFORMATNAME
Definition: winuser.h:1876
int WINAPI GetClipboardFormatNameW(_In_ UINT format, _Out_writes_(cchMaxCount) LPWSTR lpszFormatName, _In_ int cchMaxCount)
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175

Referenced by UpdateDisplayMenu(), and WriteClipboardFile().

◆ SendClipboardOwnerMessage()

LRESULT SendClipboardOwnerMessage ( IN BOOL  bUnicode,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)

Definition at line 12 of file cliputils.c.

17{
18 HWND hwndOwner;
19
20 hwndOwner = GetClipboardOwner();
21 if (!hwndOwner)
22 return GetLastError();
23
24 if (bUnicode)
25 return SendMessageW(hwndOwner, uMsg, wParam, lParam);
26 else
27 return SendMessageA(hwndOwner, uMsg, wParam, lParam);
28}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HWND WINAPI GetClipboardOwner(void)
Definition: ntwrapper.h:196
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by MainWndProc(), OnPaint(), OnScroll(), and RetrieveClipboardFormatName().