20#include <winpr/config.h>
24#include <winpr/user.h>
25#include <winpr/image.h>
27#include "../utils/image.h"
31#define TAG WINPR_TAG("clipboard.synthetic")
33static const char mime_html[] =
"text/html";
34static const char mime_ms_html[] =
"HTML Format";
35static const char* mime_bitmap[] = {
"image/bmp",
"image/x-bmp",
"image/x-MS-bmp",
36 "image/x-win-bitmap" };
38static const char mime_webp[] =
"image/webp";
39static const char mime_png[] =
"image/png";
40static const char mime_jpeg[] =
"image/jpeg";
41static const char mime_tiff[] =
"image/tiff";
43static const BYTE enc_base64url[] =
44 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
46static inline char* b64_encode(
const BYTE* WINPR_RESTRICT data,
size_t length,
size_t* plen)
49 const BYTE* WINPR_RESTRICT alphabet = enc_base64url;
52 size_t outLen = (length + 3) * 4 / 3;
56 const size_t alen = outLen + extra + 1ull;
57 BYTE* p = malloc(alen);
76 blocks = length - (length % 3);
77 for (
size_t i = 0; i < blocks; i += 3, q += 3)
79 c = (q[0] << 16) + (q[1] << 8) + q[2];
81 *p++ = alphabet[(c & 0x00FC0000) >> 18];
82 *p++ = alphabet[(c & 0x0003F000) >> 12];
83 *p++ = alphabet[(c & 0x00000FC0) >> 6];
84 *p++ = alphabet[c & 0x0000003F];
94 *p++ = alphabet[(c & 0x00FC0000) >> 18];
95 *p++ = alphabet[(c & 0x0003F000) >> 12];
98 c = (q[0] << 16) + (q[1] << 8);
99 *p++ = alphabet[(c & 0x00FC0000) >> 18];
100 *p++ = alphabet[(c & 0x0003F000) >> 12];
101 *p++ = alphabet[(c & 0x00000FC0) >> 6];
108 *plen = WINPR_ASSERTING_INT_CAST(
size_t, p - ret);
124static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId,
const void* data,
128 char* pDstData =
nullptr;
130 if (formatId == CF_UNICODETEXT)
132 char* str = ConvertWCharNToUtf8Alloc(data, *pSize /
sizeof(WCHAR), &size);
134 if (!str || (size > UINT32_MAX))
140 pDstData = ConvertLineEndingToCRLF(str, &size);
142 *pSize = (UINT32)size;
145 else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
146 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
149 pDstData = ConvertLineEndingToCRLF(data, &size);
151 if (!pDstData || (size > *pSize))
157 *pSize = (UINT32)size;
170static void* clipboard_synthesize_cf_oemtext(wClipboard* clipboard, UINT32 formatId,
171 const void* data, UINT32* pSize)
173 return clipboard_synthesize_cf_text(clipboard, formatId, data, pSize);
182static void* clipboard_synthesize_cf_locale(WINPR_ATTR_UNUSED wClipboard* clipboard,
183 WINPR_ATTR_UNUSED UINT32 formatId,
184 WINPR_ATTR_UNUSED
const void* data,
185 WINPR_ATTR_UNUSED UINT32* pSize)
187 UINT32* pDstData =
nullptr;
188 pDstData = (UINT32*)malloc(
sizeof(UINT32));
194 return (
void*)pDstData;
203static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 formatId,
204 const void* data, UINT32* pSize)
207 char* crlfStr =
nullptr;
208 WCHAR* pDstData =
nullptr;
210 if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
211 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
214 if (!pSize || (*pSize > INT32_MAX))
218 crlfStr = ConvertLineEndingToCRLF((
const char*)data, &size);
223 pDstData = ConvertUtf8NToWCharAlloc(crlfStr, size, &len);
226 if ((len < 1) || ((len + 1) > UINT32_MAX /
sizeof(WCHAR)))
232 const size_t slen = (len + 1) *
sizeof(WCHAR);
233 *pSize = (UINT32)slen;
236 return (
void*)pDstData;
245static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 formatId,
246 const void* data, UINT32* pSize)
248 if (formatId == CF_UNICODETEXT)
251 char* pDstData = ConvertWCharNToUtf8Alloc(data, *pSize /
sizeof(WCHAR), &size);
256 const size_t rc = ConvertLineEndingToLF(pDstData, size);
257 WINPR_ASSERT(rc <= UINT32_MAX);
261 else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
262 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
264 const size_t size = *pSize;
265 char* pDstData = calloc(size + 1,
sizeof(
char));
270 CopyMemory(pDstData, data, size);
271 const size_t rc = ConvertLineEndingToLF(pDstData, size);
272 WINPR_ASSERT(rc <= UINT32_MAX);
280static BOOL is_format_bitmap(wClipboard* clipboard, UINT32 formatId)
282 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
284 const char* mime = mime_bitmap[x];
285 const UINT32 altFormatId = ClipboardGetFormatId(clipboard, mime);
286 if (altFormatId == formatId)
299static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
const void* data,
304 BYTE* pDstData =
nullptr;
307#if defined(WINPR_UTILS_IMAGE_DIBv5)
308 if (formatId == CF_DIBV5)
310 WLog_WARN(TAG,
"[DIB] Unsupported destination format %s",
311 ClipboardGetFormatName(clipboard, formatId));
315 if (is_format_bitmap(clipboard, formatId))
318 wStream sbuffer = WINPR_C_ARRAY_INIT;
319 wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
320 if (!readBitmapFileHeader(s, &pFileHeader))
324 pDstData = (BYTE*)malloc(DstSize);
330 CopyMemory(pDstData, data, DstSize);
336 WLog_WARN(TAG,
"[DIB] Unsupported destination format %s",
337 ClipboardGetFormatName(clipboard, formatId));
348#if defined(WINPR_UTILS_IMAGE_DIBv5)
349static void* clipboard_synthesize_cf_dibv5(wClipboard* clipboard, UINT32 formatId,
350 WINPR_ATTR_UNUSED
const void* data,
351 WINPR_ATTR_UNUSED UINT32* pSize)
353 if (formatId == CF_DIB)
355 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
356 ClipboardGetFormatName(clipboard, formatId));
358 else if (is_format_bitmap(clipboard, formatId))
360 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
361 ClipboardGetFormatName(clipboard, formatId));
365 BOOL handled = FALSE;
366#if defined(WINPR_UTILS_IMAGE_PNG)
368 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_png);
369 if (formatId == altFormatId)
374#if defined(WINPR_UTILS_IMAGE_JPEG)
376 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_jpeg);
377 if (formatId == altFormatId)
384 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
385 ClipboardGetFormatName(clipboard, formatId));
394 const void* data,
size_t size, UINT32* pSize)
396 WINPR_ASSERT(pInfoHeader);
400 if ((pInfoHeader->biBitCount < 1) || (pInfoHeader->biBitCount > 32))
404 if (DstSize > UINT32_MAX)
407 wStream* s = Stream_New(
nullptr, DstSize);
412 fileHeader.bfType[0] =
'B';
413 fileHeader.bfType[1] =
'M';
414 fileHeader.bfSize = (UINT32)DstSize;
416 if (!writeBitmapFileHeader(s, &fileHeader))
419 if (!Stream_EnsureRemainingCapacity(s, size))
421 Stream_Write(s, data, size);
424 const size_t len = Stream_GetPosition(s);
429 *pSize = (UINT32)DstSize;
432 BYTE* dst = Stream_Buffer(s);
433 Stream_Free(s, FALSE);
438 Stream_Free(s, TRUE);
448static void* clipboard_synthesize_image_bmp(WINPR_ATTR_UNUSED wClipboard* clipboard,
449 UINT32 formatId,
const void* data, UINT32* pSize)
451 UINT32 SrcSize = *pSize;
453 if (formatId == CF_DIB)
458 wStream sbuffer = WINPR_C_ARRAY_INIT;
461 wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
462 if (!readBitmapInfoHeader(s, &header, &offset))
465 return clipboard_prepend_bmp_header(&header, data, SrcSize, pSize);
467#if defined(WINPR_UTILS_IMAGE_DIBv5)
468 else if (formatId == CF_DIBV5)
470 WLog_WARN(TAG,
"[BMP] Unsupported destination format %s",
471 ClipboardGetFormatName(clipboard, formatId));
476 WLog_WARN(TAG,
"[BMP] Unsupported destination format %s",
477 ClipboardGetFormatName(clipboard, formatId));
483#if defined(WINPR_UTILS_IMAGE_PNG) || defined(WINPR_UTILS_IMAGE_WEBP) || \
484 defined(WINPR_UTILS_IMAGE_JPEG)
485static void* clipboard_synthesize_image_bmp_to_format(wClipboard* clipboard, UINT32 formatId,
486 UINT32 bmpFormat,
const void* data,
489 WINPR_ASSERT(clipboard);
494 void* result =
nullptr;
496 wImage* img = winpr_image_new();
497 void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, pSize);
498 const UINT32 SrcSize = *pSize;
504 if (winpr_image_read_buffer(img, bmp, SrcSize) <= 0)
507 result = winpr_image_write_buffer(img, bmpFormat, &dsize);
510 if (dsize <= UINT32_MAX)
511 *pSize = (UINT32)dsize;
521 winpr_image_free(img, TRUE);
526#if defined(WINPR_UTILS_IMAGE_PNG)
527static void* clipboard_synthesize_image_bmp_to_png(wClipboard* clipboard, UINT32 formatId,
528 const void* data, UINT32* pSize)
530 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_PNG, data,
535#if defined(WINPR_UTILS_IMAGE_PNG) || defined(WINPR_UTILS_IMAGE_WEBP) || \
536 defined(WINPR_UTILS_IMAGE_JPEG)
537static void* clipboard_synthesize_image_format_to_bmp(WINPR_ATTR_UNUSED wClipboard* clipboard,
538 WINPR_ATTR_UNUSED UINT32 srcFormatId,
539 const void* data, UINT32* pSize)
541 WINPR_ASSERT(clipboard);
546 const UINT32 SrcSize = *pSize;
548 wImage* image = winpr_image_new();
552 const int res = winpr_image_read_buffer(image, data, SrcSize);
556 dst = winpr_image_write_buffer(image, WINPR_IMAGE_BITMAP, &size);
563 *pSize = (UINT32)size;
566 winpr_image_free(image, TRUE);
575#if defined(WINPR_UTILS_IMAGE_PNG)
576static void* clipboard_synthesize_image_png_to_bmp(wClipboard* clipboard, UINT32 formatId,
577 const void* data, UINT32* pSize)
579 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
583#if defined(WINPR_UTILS_IMAGE_WEBP)
584static void* clipboard_synthesize_image_bmp_to_webp(wClipboard* clipboard, UINT32 formatId,
585 const void* data, UINT32* pSize)
587 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_WEBP, data,
591static void* clipboard_synthesize_image_webp_to_bmp(wClipboard* clipboard, UINT32 formatId,
592 const void* data, UINT32* pSize)
594 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
598#if defined(WINPR_UTILS_IMAGE_JPEG)
599static void* clipboard_synthesize_image_bmp_to_jpeg(wClipboard* clipboard, UINT32 formatId,
600 const void* data, UINT32* pSize)
602 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_JPEG, data,
606static void* clipboard_synthesize_image_jpeg_to_bmp(wClipboard* clipboard, UINT32 formatId,
607 const void* data, UINT32* pSize)
609 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
619static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 formatId,
620 const void* pData, UINT32* pSize)
629 char* pDstData =
nullptr;
631 pSrcData.cpv =
nullptr;
633 WINPR_ASSERT(clipboard);
636 if (formatId == ClipboardGetFormatId(clipboard, mime_html))
638 const size_t SrcSize = (size_t)*pSize;
639 const size_t DstSize = SrcSize + 200;
640 char* body =
nullptr;
641 char num[20] = WINPR_C_ARRAY_INIT;
644 pSrcData.pv = calloc(1, SrcSize + 1);
647 memcpy(pSrcData.pv, pData, SrcSize);
651 if (SrcSize > INT_MAX)
655 if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF))
657 if (!ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)))
662 if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))
665 ConvertWCharNToUtf8Alloc(&pSrcData.pv[1], SrcSize /
sizeof(WCHAR),
nullptr);
667 pSrcData.cpc = utfString;
673 pDstData = (
char*)calloc(1, DstSize);
678 (void)sprintf_s(pDstData, DstSize,
680 "StartHTML:0000000000\r\n"
681 "EndHTML:0000000000\r\n"
682 "StartFragment:0000000000\r\n"
683 "EndFragment:0000000000\r\n");
684 body = strstr(pSrcData.cpc,
"<body");
687 body = strstr(pSrcData.cpc,
"<BODY");
690 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
691 CopyMemory(&pDstData[23], num, 10);
695 if (!winpr_str_append(
"<HTML><BODY>", pDstData, DstSize,
nullptr))
699 if (!winpr_str_append(
"<!--StartFragment-->", pDstData, DstSize,
nullptr))
703 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
704 CopyMemory(&pDstData[69], num, 10);
706 if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize,
nullptr))
710 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
711 CopyMemory(&pDstData[93], num, 10);
713 if (!winpr_str_append(
"<!--EndFragment-->", pDstData, DstSize,
nullptr))
718 if (!winpr_str_append(
"</BODY></HTML>", pDstData, DstSize,
nullptr))
723 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
724 CopyMemory(&pDstData[43], num, 10);
725 *pSize = (UINT32)strnlen(pDstData, DstSize) + 1;
732static char* html_pre_write(
wStream* s,
const char* what)
734 const size_t len = strlen(what);
735 Stream_Write(s, what, len);
736 char* startHTML = Stream_PointerAs(s,
char);
737 for (
size_t x = 0; x < 10; x++)
738 Stream_Write_INT8(s,
'0');
739 Stream_Write(s,
"\r\n", 2);
743static void html_fill_number(
char* pos,
size_t val)
745 char str[11] = WINPR_C_ARRAY_INIT;
746 (void)_snprintf(str,
sizeof(str),
"%010" PRIuz, val);
747 memcpy(pos, str, 10);
750static void* clipboard_wrap_html(
const char* mime,
const char* idata,
size_t ilength,
759 char* b64 = b64_encode((
const BYTE*)idata, ilength, &b64len);
763 const size_t mimelen = strlen(mime);
764 wStream* s = Stream_New(
nullptr, b64len + 225 + mimelen);
771 char* startHTML = html_pre_write(s,
"Version:0.9\r\nStartHTML:");
772 char* endHTML = html_pre_write(s,
"EndHTML:");
773 char* startFragment = html_pre_write(s,
"StartFragment:");
774 char* endFragment = html_pre_write(s,
"EndFragment:");
776 html_fill_number(startHTML, Stream_GetPosition(s));
777 const char html[] =
"<html><!--StartFragment-->";
778 Stream_Write(s, html, strnlen(html,
sizeof(html)));
780 html_fill_number(startFragment, Stream_GetPosition(s));
782 const char body[] =
"<body><img alt=\"FreeRDP clipboard image\" src=\"data:";
783 Stream_Write(s, body, strnlen(body,
sizeof(body)));
785 Stream_Write(s, mime, mimelen);
787 const char base64[] =
";base64,";
788 Stream_Write(s, base64, strnlen(base64,
sizeof(base64)));
789 Stream_Write(s, b64, b64len);
791 const char end[] =
"\"/></body>";
792 Stream_Write(s, end, strnlen(end,
sizeof(end)));
794 html_fill_number(endFragment, Stream_GetPosition(s));
796 const char fragend[] =
"<!--EndFragment--></html>";
797 Stream_Write(s, fragend, strnlen(fragend,
sizeof(fragend)));
798 html_fill_number(endHTML, Stream_GetPosition(s));
800 void* res = Stream_Buffer(s);
801 const size_t pos = Stream_GetPosition(s);
802 *plen = WINPR_ASSERTING_INT_CAST(uint32_t, pos);
803 Stream_Free(s, FALSE);
808static void* clipboard_wrap_format_to_html(uint32_t bmpFormat,
const char* idata,
size_t ilength,
812 wImage* img = winpr_image_new();
816 if (winpr_image_read_buffer(img, (
const BYTE*)idata, ilength) <= 0)
821 void* bmp = winpr_image_write_buffer(img, bmpFormat, &bmpsize);
825 res = clipboard_wrap_html(winpr_image_format_mime(bmpFormat), bmp, bmpsize, plen);
829 winpr_image_free(img, TRUE);
833static void* clipboard_wrap_bmp_to_html(
const char* idata,
size_t ilength, uint32_t* plen)
835 const uint32_t formats[] = { WINPR_IMAGE_WEBP, WINPR_IMAGE_PNG, WINPR_IMAGE_JPEG };
837 for (
size_t x = 0; x < ARRAYSIZE(formats); x++)
839 const uint32_t format = formats[x];
840 if (winpr_image_format_is_supported(format))
842 return clipboard_wrap_format_to_html(format, idata, ilength, plen);
845 const uint32_t bmpFormat = WINPR_IMAGE_BITMAP;
846 return clipboard_wrap_html(winpr_image_format_mime(bmpFormat), idata, ilength, plen);
849static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipboard,
850 UINT32 formatId,
const void* data, UINT32* pSize)
854 const size_t datalen = *pSize;
859 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
863 uint32_t bmplen = *pSize;
864 void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, &bmplen);
867 WLog_WARN(TAG,
"failed to convert formatId 0x%08" PRIx32
" [%s]", formatId,
868 ClipboardGetFormatName(clipboard, formatId));
873 void* res = clipboard_wrap_bmp_to_html(bmp, bmplen, pSize);
879 const uint32_t idWebp = ClipboardRegisterFormat(clipboard, mime_webp);
880 const uint32_t idPng = ClipboardRegisterFormat(clipboard, mime_png);
881 const uint32_t idJpeg = ClipboardRegisterFormat(clipboard, mime_jpeg);
882 const uint32_t idTiff = ClipboardRegisterFormat(clipboard, mime_tiff);
883 if (formatId == idWebp)
885 return clipboard_wrap_html(mime_webp, data, datalen, pSize);
887 else if (formatId == idPng)
889 return clipboard_wrap_html(mime_png, data, datalen, pSize);
891 else if (formatId == idJpeg)
893 return clipboard_wrap_html(mime_jpeg, data, datalen, pSize);
895 else if (formatId == idTiff)
897 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
901 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
903 const char* mime = mime_bitmap[x];
904 const uint32_t
id = ClipboardRegisterFormat(clipboard, mime);
907 return clipboard_wrap_bmp_to_html(data, datalen, pSize);
911 WLog_WARN(TAG,
"Unsupported image format id 0x%08" PRIx32
" [%s]", formatId,
912 ClipboardGetFormatName(clipboard, formatId));
925static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 formatId,
926 const void* data, UINT32* pSize)
928 char* pDstData =
nullptr;
930 if (formatId == ClipboardGetFormatId(clipboard, mime_ms_html))
932 const char* str = (
const char*)data;
933 const size_t SrcSize = *pSize;
934 const char* begStr = strstr(str,
"StartHTML:");
935 const char* endStr = strstr(str,
"EndHTML:");
937 if (!begStr || !endStr)
941 const long beg = strtol(&begStr[10],
nullptr, 10);
946 const long end = strtol(&endStr[8],
nullptr, 10);
948 if ((beg < 0) || (end < 0) || ((
size_t)beg > SrcSize) || ((
size_t)end > SrcSize) ||
949 (beg >= end) || (errno != 0))
952 const size_t DstSize = (size_t)(end - beg);
953 pDstData = calloc(DstSize + 1,
sizeof(
char));
958 CopyMemory(pDstData, &str[beg], DstSize);
959 const size_t rc = ConvertLineEndingToLF(pDstData, DstSize);
960 WINPR_ASSERT(rc <= UINT32_MAX);
967BOOL ClipboardInitSynthesizers(wClipboard* clipboard)
973 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_OEMTEXT,
974 clipboard_synthesize_cf_oemtext))
976 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_UNICODETEXT,
977 clipboard_synthesize_cf_unicodetext))
979 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_LOCALE,
980 clipboard_synthesize_cf_locale))
983 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
984 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, altFormatId,
985 clipboard_synthesize_utf8_string))
992 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_TEXT,
993 clipboard_synthesize_cf_text))
995 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_UNICODETEXT,
996 clipboard_synthesize_cf_unicodetext))
998 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_LOCALE,
999 clipboard_synthesize_cf_locale))
1001 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1002 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, altFormatId,
1003 clipboard_synthesize_utf8_string))
1010 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_TEXT,
1011 clipboard_synthesize_cf_text))
1013 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_OEMTEXT,
1014 clipboard_synthesize_cf_oemtext))
1016 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_LOCALE,
1017 clipboard_synthesize_cf_locale))
1019 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1020 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, altFormatId,
1021 clipboard_synthesize_utf8_string))
1028 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1032 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1033 clipboard_synthesize_cf_text))
1035 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1036 clipboard_synthesize_cf_oemtext))
1038 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1039 clipboard_synthesize_cf_unicodetext))
1041 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1042 clipboard_synthesize_cf_locale))
1050 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1054 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1055 clipboard_synthesize_cf_text))
1057 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1058 clipboard_synthesize_cf_oemtext))
1060 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1061 clipboard_synthesize_cf_unicodetext))
1063 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1064 clipboard_synthesize_cf_locale))
1069 const uint32_t htmlFormat = ClipboardRegisterFormat(clipboard, mime_ms_html);
1070 const uint32_t tiffFormat = ClipboardRegisterFormat(clipboard, mime_tiff);
1075 if (!ClipboardRegisterSynthesizer(clipboard, CF_TIFF, htmlFormat,
1076 clipboard_synthesize_image_html))
1078 if (!ClipboardRegisterSynthesizer(clipboard, tiffFormat, htmlFormat,
1079 clipboard_synthesize_image_html))
1086#if defined(WINPR_UTILS_IMAGE_DIBv5)
1087 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, CF_DIBV5,
1088 clipboard_synthesize_cf_dibv5))
1091 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1093 const char* mime = mime_bitmap[x];
1094 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1095 if (altFormatId == 0)
1097 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1098 clipboard_synthesize_image_bmp))
1101 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, htmlFormat,
1102 clipboard_synthesize_image_html))
1109#if defined(WINPR_UTILS_IMAGE_DIBv5)
1111 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, CF_DIB, clipboard_synthesize_cf_dib))
1114 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1116 const char* mime = mime_bitmap[x];
1117 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1118 if (altFormatId == 0)
1120 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1121 clipboard_synthesize_image_bmp))
1124 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, htmlFormat,
1125 clipboard_synthesize_image_html))
1133 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1135 const char* mime = mime_bitmap[x];
1136 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1137 if (altFormatId == 0)
1139 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1140 clipboard_synthesize_cf_dib))
1142#if defined(WINPR_UTILS_IMAGE_DIBv5)
1143 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1144 clipboard_synthesize_cf_dibv5))
1147 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1148 clipboard_synthesize_image_html))
1155#if defined(WINPR_UTILS_IMAGE_PNG)
1157 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_png);
1158 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1159 clipboard_synthesize_image_bmp_to_png))
1161 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1162 clipboard_synthesize_image_png_to_bmp))
1164 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1165 clipboard_synthesize_image_html))
1167#if defined(WINPR_UTILS_IMAGE_DIBv5)
1168 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1169 clipboard_synthesize_image_bmp_to_png))
1171 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1172 clipboard_synthesize_image_png_to_bmp))
1181#if defined(WINPR_UTILS_IMAGE_WEBP)
1183 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_webp);
1184 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1185 clipboard_synthesize_image_bmp_to_webp))
1187 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1188 clipboard_synthesize_image_webp_to_bmp))
1190 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1191 clipboard_synthesize_image_html))
1193#if defined(WINPR_UTILS_IMAGE_DIBv5)
1194 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1195 clipboard_synthesize_image_bmp_to_webp))
1197 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1198 clipboard_synthesize_image_webp_to_bmp))
1207#if defined(WINPR_UTILS_IMAGE_JPEG)
1209 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_jpeg);
1210 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1211 clipboard_synthesize_image_bmp_to_jpeg))
1213 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1214 clipboard_synthesize_image_jpeg_to_bmp))
1216 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1217 clipboard_synthesize_image_html))
1219#if defined(WINPR_UTILS_IMAGE_DIBv5)
1220 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1221 clipboard_synthesize_image_jpeg_to_bmp))
1223 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1224 clipboard_synthesize_image_bmp_to_jpeg))
1234 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1238 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_html);
1239 if (!ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1240 clipboard_synthesize_text_html))
1249 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_html);
1253 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1254 if (!ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1255 clipboard_synthesize_html_format))