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 = NULL;
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 = NULL;
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 = NULL;
208 WCHAR* pDstData = NULL;
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 = NULL;
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))
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(NULL, 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)
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);
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(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 = NULL;
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;
641 char num[20] = { 0 };
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))
656 ByteSwapUnicode(pSrcData.pv, (SrcSize / 2));
659 if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))
662 ConvertWCharNToUtf8Alloc(&pSrcData.pv[1], SrcSize /
sizeof(WCHAR), NULL);
664 pSrcData.cpc = utfString;
670 pDstData = (
char*)calloc(1, DstSize);
675 (void)sprintf_s(pDstData, DstSize,
677 "StartHTML:0000000000\r\n"
678 "EndHTML:0000000000\r\n"
679 "StartFragment:0000000000\r\n"
680 "EndFragment:0000000000\r\n");
681 body = strstr(pSrcData.cpc,
"<body");
684 body = strstr(pSrcData.cpc,
"<BODY");
687 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
688 CopyMemory(&pDstData[23], num, 10);
692 if (!winpr_str_append(
"<HTML><BODY>", pDstData, DstSize, NULL))
696 if (!winpr_str_append(
"<!--StartFragment-->", pDstData, DstSize, NULL))
700 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
701 CopyMemory(&pDstData[69], num, 10);
703 if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize, NULL))
707 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
708 CopyMemory(&pDstData[93], num, 10);
710 if (!winpr_str_append(
"<!--EndFragment-->", pDstData, DstSize, NULL))
715 if (!winpr_str_append(
"</BODY></HTML>", pDstData, DstSize, NULL))
720 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
721 CopyMemory(&pDstData[43], num, 10);
722 *pSize = (UINT32)strnlen(pDstData, DstSize) + 1;
729static char* html_pre_write(
wStream* s,
const char* what)
731 const size_t len = strlen(what);
732 Stream_Write(s, what, len);
733 char* startHTML = Stream_PointerAs(s,
char);
734 for (
size_t x = 0; x < 10; x++)
735 Stream_Write_INT8(s,
'0');
736 Stream_Write(s,
"\r\n", 2);
740static void html_fill_number(
char* pos,
size_t val)
742 char str[11] = { 0 };
743 (void)_snprintf(str,
sizeof(str),
"%010" PRIuz, val);
744 memcpy(pos, str, 10);
747static void* clipboard_wrap_html(
const char* mime,
const char* idata,
size_t ilength,
756 char* b64 = b64_encode((
const BYTE*)idata, ilength, &b64len);
760 const size_t mimelen = strlen(mime);
761 wStream* s = Stream_New(NULL, b64len + 225 + mimelen);
768 char* startHTML = html_pre_write(s,
"Version:0.9\r\nStartHTML:");
769 char* endHTML = html_pre_write(s,
"EndHTML:");
770 char* startFragment = html_pre_write(s,
"StartFragment:");
771 char* endFragment = html_pre_write(s,
"EndFragment:");
773 html_fill_number(startHTML, Stream_GetPosition(s));
774 const char html[] =
"<html><!--StartFragment-->";
775 Stream_Write(s, html, strnlen(html,
sizeof(html)));
777 html_fill_number(startFragment, Stream_GetPosition(s));
779 const char body[] =
"<body><img alt=\"FreeRDP clipboard image\" src=\"data:";
780 Stream_Write(s, body, strnlen(body,
sizeof(body)));
782 Stream_Write(s, mime, mimelen);
784 const char base64[] =
";base64,";
785 Stream_Write(s, base64, strnlen(base64,
sizeof(base64)));
786 Stream_Write(s, b64, b64len);
788 const char end[] =
"\"/></body>";
789 Stream_Write(s, end, strnlen(end,
sizeof(end)));
791 html_fill_number(endFragment, Stream_GetPosition(s));
793 const char fragend[] =
"<!--EndFragment--></html>";
794 Stream_Write(s, fragend, strnlen(fragend,
sizeof(fragend)));
795 html_fill_number(endHTML, Stream_GetPosition(s));
797 void* res = Stream_Buffer(s);
798 const size_t pos = Stream_GetPosition(s);
799 *plen = WINPR_ASSERTING_INT_CAST(uint32_t, pos);
800 Stream_Free(s, FALSE);
805static void* clipboard_wrap_format_to_html(uint32_t bmpFormat,
const char* idata,
size_t ilength,
809 wImage* img = winpr_image_new();
813 if (winpr_image_read_buffer(img, (
const BYTE*)idata, ilength) <= 0)
818 void* bmp = winpr_image_write_buffer(img, bmpFormat, &bmpsize);
822 res = clipboard_wrap_html(winpr_image_format_mime(bmpFormat), bmp, bmpsize, plen);
826 winpr_image_free(img, TRUE);
830static void* clipboard_wrap_bmp_to_html(
const char* idata,
size_t ilength, uint32_t* plen)
832 const uint32_t formats[] = { WINPR_IMAGE_WEBP, WINPR_IMAGE_PNG, WINPR_IMAGE_JPEG };
834 for (
size_t x = 0; x < ARRAYSIZE(formats); x++)
836 const uint32_t format = formats[x];
837 if (winpr_image_format_is_supported(format))
839 return clipboard_wrap_format_to_html(format, idata, ilength, plen);
842 const uint32_t bmpFormat = WINPR_IMAGE_BITMAP;
843 return clipboard_wrap_html(winpr_image_format_mime(bmpFormat), idata, ilength, plen);
846static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipboard,
847 UINT32 formatId,
const void* data, UINT32* pSize)
851 const size_t datalen = *pSize;
856 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
860 uint32_t bmplen = *pSize;
861 void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, &bmplen);
864 WLog_WARN(TAG,
"failed to convert formatId 0x%08" PRIx32
" [%s]", formatId,
865 ClipboardGetFormatName(clipboard, formatId));
870 void* res = clipboard_wrap_bmp_to_html(bmp, bmplen, pSize);
876 const uint32_t idWebp = ClipboardRegisterFormat(clipboard, mime_webp);
877 const uint32_t idPng = ClipboardRegisterFormat(clipboard, mime_png);
878 const uint32_t idJpeg = ClipboardRegisterFormat(clipboard, mime_jpeg);
879 const uint32_t idTiff = ClipboardRegisterFormat(clipboard, mime_tiff);
880 if (formatId == idWebp)
882 return clipboard_wrap_html(mime_webp, data, datalen, pSize);
884 else if (formatId == idPng)
886 return clipboard_wrap_html(mime_png, data, datalen, pSize);
888 else if (formatId == idJpeg)
890 return clipboard_wrap_html(mime_jpeg, data, datalen, pSize);
892 else if (formatId == idTiff)
894 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
898 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
900 const char* mime = mime_bitmap[x];
901 const uint32_t
id = ClipboardRegisterFormat(clipboard, mime);
904 return clipboard_wrap_bmp_to_html(data, datalen, pSize);
908 WLog_WARN(TAG,
"Unsupported image format id 0x%08" PRIx32
" [%s]", formatId,
909 ClipboardGetFormatName(clipboard, formatId));
922static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 formatId,
923 const void* data, UINT32* pSize)
925 char* pDstData = NULL;
927 if (formatId == ClipboardGetFormatId(clipboard, mime_ms_html))
929 const char* str = (
const char*)data;
930 const size_t SrcSize = *pSize;
931 const char* begStr = strstr(str,
"StartHTML:");
932 const char* endStr = strstr(str,
"EndHTML:");
934 if (!begStr || !endStr)
938 const long beg = strtol(&begStr[10], NULL, 10);
943 const long end = strtol(&endStr[8], NULL, 10);
945 if ((beg < 0) || (end < 0) || ((
size_t)beg > SrcSize) || ((
size_t)end > SrcSize) ||
946 (beg >= end) || (errno != 0))
949 const size_t DstSize = (size_t)(end - beg);
950 pDstData = calloc(DstSize + 1,
sizeof(
char));
955 CopyMemory(pDstData, &str[beg], DstSize);
956 const size_t rc = ConvertLineEndingToLF(pDstData, DstSize);
957 WINPR_ASSERT(rc <= UINT32_MAX);
964BOOL ClipboardInitSynthesizers(wClipboard* clipboard)
970 ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_OEMTEXT,
971 clipboard_synthesize_cf_oemtext);
972 ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_UNICODETEXT,
973 clipboard_synthesize_cf_unicodetext);
974 ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_LOCALE, clipboard_synthesize_cf_locale);
976 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
977 ClipboardRegisterSynthesizer(clipboard, CF_TEXT, altFormatId,
978 clipboard_synthesize_utf8_string);
984 ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_TEXT, clipboard_synthesize_cf_text);
985 ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_UNICODETEXT,
986 clipboard_synthesize_cf_unicodetext);
987 ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_LOCALE,
988 clipboard_synthesize_cf_locale);
989 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
990 ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, altFormatId,
991 clipboard_synthesize_utf8_string);
997 ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_TEXT,
998 clipboard_synthesize_cf_text);
999 ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_OEMTEXT,
1000 clipboard_synthesize_cf_oemtext);
1001 ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_LOCALE,
1002 clipboard_synthesize_cf_locale);
1003 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1004 ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, altFormatId,
1005 clipboard_synthesize_utf8_string);
1011 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1015 ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1016 clipboard_synthesize_cf_text);
1017 ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1018 clipboard_synthesize_cf_oemtext);
1019 ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1020 clipboard_synthesize_cf_unicodetext);
1021 ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1022 clipboard_synthesize_cf_locale);
1029 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1033 ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1034 clipboard_synthesize_cf_text);
1035 ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1036 clipboard_synthesize_cf_oemtext);
1037 ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1038 clipboard_synthesize_cf_unicodetext);
1039 ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1040 clipboard_synthesize_cf_locale);
1044 const uint32_t htmlFormat = ClipboardRegisterFormat(clipboard, mime_ms_html);
1045 const uint32_t tiffFormat = ClipboardRegisterFormat(clipboard, mime_tiff);
1050 ClipboardRegisterSynthesizer(clipboard, CF_TIFF, htmlFormat, clipboard_synthesize_image_html);
1051 ClipboardRegisterSynthesizer(clipboard, tiffFormat, htmlFormat,
1052 clipboard_synthesize_image_html);
1058#if defined(WINPR_UTILS_IMAGE_DIBv5)
1059 ClipboardRegisterSynthesizer(clipboard, CF_DIB, CF_DIBV5, clipboard_synthesize_cf_dibv5);
1061 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1063 const char* mime = mime_bitmap[x];
1064 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1065 if (altFormatId == 0)
1067 ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1068 clipboard_synthesize_image_bmp);
1070 ClipboardRegisterSynthesizer(clipboard, CF_DIB, htmlFormat,
1071 clipboard_synthesize_image_html);
1077#if defined(WINPR_UTILS_IMAGE_DIBv5)
1079 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, CF_DIB, clipboard_synthesize_cf_dib);
1081 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1083 const char* mime = mime_bitmap[x];
1084 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1085 if (altFormatId == 0)
1087 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1088 clipboard_synthesize_image_bmp);
1090 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, htmlFormat,
1091 clipboard_synthesize_image_html);
1098 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1100 const char* mime = mime_bitmap[x];
1101 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1102 if (altFormatId == 0)
1104 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB, clipboard_synthesize_cf_dib);
1105#if defined(WINPR_UTILS_IMAGE_DIBv5)
1106 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1107 clipboard_synthesize_cf_dibv5);
1109 ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1110 clipboard_synthesize_image_html);
1116#if defined(WINPR_UTILS_IMAGE_PNG)
1118 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_png);
1119 ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1120 clipboard_synthesize_image_bmp_to_png);
1121 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1122 clipboard_synthesize_image_png_to_bmp);
1123 ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1124 clipboard_synthesize_image_html);
1125#if defined(WINPR_UTILS_IMAGE_DIBv5)
1126 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1127 clipboard_synthesize_image_bmp_to_png);
1128 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1129 clipboard_synthesize_image_png_to_bmp);
1137#if defined(WINPR_UTILS_IMAGE_WEBP)
1139 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_webp);
1140 ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1141 clipboard_synthesize_image_bmp_to_webp);
1142 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1143 clipboard_synthesize_image_webp_to_bmp);
1144 ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1145 clipboard_synthesize_image_html);
1146#if defined(WINPR_UTILS_IMAGE_DIBv5)
1147 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1148 clipboard_synthesize_image_bmp_to_webp);
1149 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1150 clipboard_synthesize_image_webp_to_bmp);
1158#if defined(WINPR_UTILS_IMAGE_JPEG)
1160 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_jpeg);
1161 ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1162 clipboard_synthesize_image_bmp_to_jpeg);
1163 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1164 clipboard_synthesize_image_jpeg_to_bmp);
1165 ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1166 clipboard_synthesize_image_html);
1167#if defined(WINPR_UTILS_IMAGE_DIBv5)
1168 ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1169 clipboard_synthesize_image_jpeg_to_bmp);
1170 ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1171 clipboard_synthesize_image_bmp_to_jpeg);
1180 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1184 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_html);
1185 ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1186 clipboard_synthesize_text_html);
1194 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_html);
1198 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1199 ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1200 clipboard_synthesize_html_format);