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+/";
46WINPR_ATTR_NODISCARD
static inline char* b64_encode(
const BYTE* WINPR_RESTRICT data,
size_t length,
50 const BYTE* WINPR_RESTRICT alphabet = enc_base64url;
53 size_t outLen = (length + 3) * 4 / 3;
57 const size_t alen = outLen + extra + 1ull;
58 BYTE* p = malloc(alen);
77 blocks = length - (length % 3);
78 for (
size_t i = 0; i < blocks; i += 3, q += 3)
80 c = (q[0] << 16) + (q[1] << 8) + q[2];
82 *p++ = alphabet[(c & 0x00FC0000) >> 18];
83 *p++ = alphabet[(c & 0x0003F000) >> 12];
84 *p++ = alphabet[(c & 0x00000FC0) >> 6];
85 *p++ = alphabet[c & 0x0000003F];
95 *p++ = alphabet[(c & 0x00FC0000) >> 18];
96 *p++ = alphabet[(c & 0x0003F000) >> 12];
99 c = (q[0] << 16) + (q[1] << 8);
100 *p++ = alphabet[(c & 0x00FC0000) >> 18];
101 *p++ = alphabet[(c & 0x0003F000) >> 12];
102 *p++ = alphabet[(c & 0x00000FC0) >> 6];
109 *plen = WINPR_ASSERTING_INT_CAST(
size_t, p - ret);
125static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId,
const void* data,
129 char* pDstData =
nullptr;
131 if (formatId == CF_UNICODETEXT)
133 char* str = ConvertWCharNToUtf8Alloc(data, *pSize /
sizeof(WCHAR), &size);
135 if (!str || (size > UINT32_MAX))
141 pDstData = ConvertLineEndingToCRLF(str, &size);
143 *pSize = (UINT32)size;
146 else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
147 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
150 pDstData = ConvertLineEndingToCRLF(data, &size);
152 if (!pDstData || (size >= UINT32_MAX))
159 *pSize = (UINT32)size + 1;
172static void* clipboard_synthesize_cf_oemtext(wClipboard* clipboard, UINT32 formatId,
173 const void* data, UINT32* pSize)
175 return clipboard_synthesize_cf_text(clipboard, formatId, data, pSize);
184static void* clipboard_synthesize_cf_locale(WINPR_ATTR_UNUSED wClipboard* clipboard,
185 WINPR_ATTR_UNUSED UINT32 formatId,
186 WINPR_ATTR_UNUSED
const void* data,
187 WINPR_ATTR_UNUSED UINT32* pSize)
189 UINT32* pDstData =
nullptr;
190 pDstData = (UINT32*)malloc(
sizeof(UINT32));
196 return (
void*)pDstData;
205static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 formatId,
206 const void* data, UINT32* pSize)
209 char* crlfStr =
nullptr;
210 WCHAR* pDstData =
nullptr;
212 if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
213 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
216 if (!pSize || (*pSize > INT32_MAX))
220 crlfStr = ConvertLineEndingToCRLF((
const char*)data, &size);
225 pDstData = ConvertUtf8NToWCharAlloc(crlfStr, size, &len);
228 if ((len < 1) || ((len + 1) > UINT32_MAX /
sizeof(WCHAR)))
234 const size_t slen = (len + 1) *
sizeof(WCHAR);
235 *pSize = (UINT32)slen;
238 return (
void*)pDstData;
247static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 formatId,
248 const void* data, UINT32* pSize)
250 if (formatId == CF_UNICODETEXT)
253 char* pDstData = ConvertWCharNToUtf8Alloc(data, *pSize /
sizeof(WCHAR), &size);
258 const size_t rc = ConvertLineEndingToLF(pDstData, size);
259 WINPR_ASSERT(rc <= UINT32_MAX);
263 else if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
264 (formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
266 const size_t size = *pSize;
267 char* pDstData = calloc(size + 1,
sizeof(
char));
272 CopyMemory(pDstData, data, size);
273 const size_t rc = ConvertLineEndingToLF(pDstData, size);
274 WINPR_ASSERT(rc <= UINT32_MAX);
282static BOOL is_format_bitmap(wClipboard* clipboard, UINT32 formatId)
284 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
286 const char* mime = mime_bitmap[x];
287 const UINT32 altFormatId = ClipboardGetFormatId(clipboard, mime);
288 if (altFormatId == formatId)
301static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
const void* data,
306 BYTE* pDstData =
nullptr;
309#if defined(WINPR_UTILS_IMAGE_DIBv5)
310 if (formatId == CF_DIBV5)
312 WLog_WARN(TAG,
"[DIB] Unsupported destination format %s",
313 ClipboardGetFormatName(clipboard, formatId));
317 if (is_format_bitmap(clipboard, formatId))
320 wStream sbuffer = WINPR_C_ARRAY_INIT;
321 wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
322 if (!readBitmapFileHeader(s, &pFileHeader))
326 pDstData = (BYTE*)malloc(DstSize);
332 CopyMemory(pDstData, data, DstSize);
338 WLog_WARN(TAG,
"[DIB] Unsupported destination format %s",
339 ClipboardGetFormatName(clipboard, formatId));
350#if defined(WINPR_UTILS_IMAGE_DIBv5)
351static void* clipboard_synthesize_cf_dibv5(wClipboard* clipboard, UINT32 formatId,
352 WINPR_ATTR_UNUSED
const void* data,
353 WINPR_ATTR_UNUSED UINT32* pSize)
355 if (formatId == CF_DIB)
357 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
358 ClipboardGetFormatName(clipboard, formatId));
360 else if (is_format_bitmap(clipboard, formatId))
362 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
363 ClipboardGetFormatName(clipboard, formatId));
367 BOOL handled = FALSE;
368#if defined(WINPR_UTILS_IMAGE_PNG)
370 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_png);
371 if (formatId == altFormatId)
376#if defined(WINPR_UTILS_IMAGE_JPEG)
378 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_jpeg);
379 if (formatId == altFormatId)
386 WLog_WARN(TAG,
"[DIBv5] Unsupported destination format %s",
387 ClipboardGetFormatName(clipboard, formatId));
396 size_t offset,
const void* data,
size_t size,
399 WINPR_ASSERT(pInfoHeader);
403 if ((pInfoHeader->biBitCount < 1) || (pInfoHeader->biBitCount > 32))
409 if ((pInfoHeader->biSize > size) || (offset > (size - pInfoHeader->biSize)))
413 if (bitmapOffset > DstSize)
416 wStream* s = Stream_New(
nullptr, DstSize);
421 fileHeader.bfType[0] =
'B';
422 fileHeader.bfType[1] =
'M';
423 fileHeader.bfSize = (UINT32)DstSize;
424 fileHeader.bfOffBits = (UINT32)bitmapOffset;
425 if (!writeBitmapFileHeader(s, &fileHeader))
428 if (!Stream_EnsureRemainingCapacity(s, size))
430 Stream_Write(s, data, size);
433 const size_t len = Stream_GetPosition(s);
438 *pSize = (UINT32)DstSize;
441 BYTE* dst = Stream_Buffer(s);
442 Stream_Free(s, FALSE);
447 Stream_Free(s, TRUE);
457static void* clipboard_synthesize_image_bmp(WINPR_ATTR_UNUSED wClipboard* clipboard,
458 UINT32 formatId,
const void* data, UINT32* pSize)
460 UINT32 SrcSize = *pSize;
462 if (formatId == CF_DIB)
467 wStream sbuffer = WINPR_C_ARRAY_INIT;
470 wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
471 if (!readBitmapInfoHeader(s, &header, &offset))
474 return clipboard_prepend_bmp_header(&header, offset, data, SrcSize, pSize);
476#if defined(WINPR_UTILS_IMAGE_DIBv5)
477 else if (formatId == CF_DIBV5)
479 WLog_WARN(TAG,
"[BMP] Unsupported destination format %s",
480 ClipboardGetFormatName(clipboard, formatId));
485 WLog_WARN(TAG,
"[BMP] Unsupported destination format %s",
486 ClipboardGetFormatName(clipboard, formatId));
492#if defined(WINPR_UTILS_IMAGE_PNG) || defined(WINPR_UTILS_IMAGE_WEBP) || \
493 defined(WINPR_UTILS_IMAGE_JPEG)
494static void* clipboard_synthesize_image_bmp_to_format(wClipboard* clipboard, UINT32 formatId,
495 UINT32 bmpFormat,
const void* data,
498 WINPR_ASSERT(clipboard);
503 void* result =
nullptr;
505 wImage* img = winpr_image_new();
506 void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, pSize);
507 const UINT32 SrcSize = *pSize;
513 if (winpr_image_read_buffer(img, bmp, SrcSize) <= 0)
516 result = winpr_image_write_buffer(img, bmpFormat, &dsize);
519 if (dsize <= UINT32_MAX)
520 *pSize = (UINT32)dsize;
530 winpr_image_free(img, TRUE);
535#if defined(WINPR_UTILS_IMAGE_PNG)
536static void* clipboard_synthesize_image_bmp_to_png(wClipboard* clipboard, UINT32 formatId,
537 const void* data, UINT32* pSize)
539 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_PNG, data,
544#if defined(WINPR_UTILS_IMAGE_PNG) || defined(WINPR_UTILS_IMAGE_WEBP) || \
545 defined(WINPR_UTILS_IMAGE_JPEG)
546static void* clipboard_synthesize_image_format_to_bmp(WINPR_ATTR_UNUSED wClipboard* clipboard,
547 WINPR_ATTR_UNUSED UINT32 srcFormatId,
548 const void* data, UINT32* pSize)
550 WINPR_ASSERT(clipboard);
555 const UINT32 SrcSize = *pSize;
557 wImage* image = winpr_image_new();
561 const int res = winpr_image_read_buffer(image, data, SrcSize);
565 dst = winpr_image_write_buffer(image, WINPR_IMAGE_BITMAP, &size);
572 *pSize = (UINT32)size;
575 winpr_image_free(image, TRUE);
584#if defined(WINPR_UTILS_IMAGE_PNG)
585static void* clipboard_synthesize_image_png_to_bmp(wClipboard* clipboard, UINT32 formatId,
586 const void* data, UINT32* pSize)
588 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
592#if defined(WINPR_UTILS_IMAGE_WEBP)
593static void* clipboard_synthesize_image_bmp_to_webp(wClipboard* clipboard, UINT32 formatId,
594 const void* data, UINT32* pSize)
596 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_WEBP, data,
600static void* clipboard_synthesize_image_webp_to_bmp(wClipboard* clipboard, UINT32 formatId,
601 const void* data, UINT32* pSize)
603 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
607#if defined(WINPR_UTILS_IMAGE_JPEG)
608static void* clipboard_synthesize_image_bmp_to_jpeg(wClipboard* clipboard, UINT32 formatId,
609 const void* data, UINT32* pSize)
611 return clipboard_synthesize_image_bmp_to_format(clipboard, formatId, WINPR_IMAGE_JPEG, data,
615static void* clipboard_synthesize_image_jpeg_to_bmp(wClipboard* clipboard, UINT32 formatId,
616 const void* data, UINT32* pSize)
618 return clipboard_synthesize_image_format_to_bmp(clipboard, formatId, data, pSize);
628static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 formatId,
629 const void* pData, UINT32* pSize)
638 char* pDstData =
nullptr;
640 pSrcData.cpv =
nullptr;
642 WINPR_ASSERT(clipboard);
645 if (formatId == ClipboardGetFormatId(clipboard, mime_html))
647 const size_t SrcSize = (size_t)*pSize;
648 const size_t DstSize = SrcSize + 200;
649 char* body =
nullptr;
650 char num[20] = WINPR_C_ARRAY_INIT;
653 pSrcData.pv = calloc(1, SrcSize + 1);
656 memcpy(pSrcData.pv, pData, SrcSize);
660 if (SrcSize > INT_MAX)
664 if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF))
666 if (!ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)))
671 if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))
673 char* utfString = ConvertWCharNToUtf8Alloc(&pSrcData.pv[1],
674 (SrcSize /
sizeof(WCHAR)) - 1,
nullptr);
676 pSrcData.cpc = utfString;
682 pDstData = (
char*)calloc(1, DstSize);
687 (void)sprintf_s(pDstData, DstSize,
689 "StartHTML:0000000000\r\n"
690 "EndHTML:0000000000\r\n"
691 "StartFragment:0000000000\r\n"
692 "EndFragment:0000000000\r\n");
693 body = strstr(pSrcData.cpc,
"<body");
696 body = strstr(pSrcData.cpc,
"<BODY");
699 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
700 CopyMemory(&pDstData[23], num, 10);
704 if (!winpr_str_append(
"<HTML><BODY>", pDstData, DstSize,
nullptr))
708 if (!winpr_str_append(
"<!--StartFragment-->", pDstData, DstSize,
nullptr))
712 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
713 CopyMemory(&pDstData[69], num, 10);
715 if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize,
nullptr))
719 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, SrcSize + 200));
720 CopyMemory(&pDstData[93], num, 10);
722 if (!winpr_str_append(
"<!--EndFragment-->", pDstData, DstSize,
nullptr))
727 if (!winpr_str_append(
"</BODY></HTML>", pDstData, DstSize,
nullptr))
732 (void)sprintf_s(num,
sizeof(num),
"%010" PRIuz
"", strnlen(pDstData, DstSize));
733 CopyMemory(&pDstData[43], num, 10);
734 *pSize = (UINT32)strnlen(pDstData, DstSize) + 1;
741static char* html_pre_write(
wStream* s,
const char* what)
743 const size_t len = strlen(what);
744 Stream_Write(s, what, len);
745 char* startHTML = Stream_PointerAs(s,
char);
746 for (
size_t x = 0; x < 10; x++)
747 Stream_Write_INT8(s,
'0');
748 Stream_Write(s,
"\r\n", 2);
752static void html_fill_number(
char* pos,
size_t val)
754 char str[11] = WINPR_C_ARRAY_INIT;
755 (void)_snprintf(str,
sizeof(str),
"%010" PRIuz, val);
756 memcpy(pos, str, 10);
759static void* clipboard_wrap_html(
const char* mime,
const char* idata,
size_t ilength,
768 char* b64 = b64_encode((
const BYTE*)idata, ilength, &b64len);
772 const size_t mimelen = strlen(mime);
773 wStream* s = Stream_New(
nullptr, b64len + 225 + mimelen);
780 char* startHTML = html_pre_write(s,
"Version:0.9\r\nStartHTML:");
781 char* endHTML = html_pre_write(s,
"EndHTML:");
782 char* startFragment = html_pre_write(s,
"StartFragment:");
783 char* endFragment = html_pre_write(s,
"EndFragment:");
785 html_fill_number(startHTML, Stream_GetPosition(s));
786 const char html[] =
"<html><!--StartFragment-->";
787 Stream_Write(s, html, strnlen(html,
sizeof(html)));
789 html_fill_number(startFragment, Stream_GetPosition(s));
791 const char body[] =
"<body><img alt=\"FreeRDP clipboard image\" src=\"data:";
792 Stream_Write(s, body, strnlen(body,
sizeof(body)));
794 Stream_Write(s, mime, mimelen);
796 const char base64[] =
";base64,";
797 Stream_Write(s, base64, strnlen(base64,
sizeof(base64)));
798 Stream_Write(s, b64, b64len);
800 const char end[] =
"\"/></body>";
801 Stream_Write(s, end, strnlen(end,
sizeof(end)));
803 html_fill_number(endFragment, Stream_GetPosition(s));
805 const char fragend[] =
"<!--EndFragment--></html>";
806 Stream_Write(s, fragend, strnlen(fragend,
sizeof(fragend)));
807 html_fill_number(endHTML, Stream_GetPosition(s));
809 void* res = Stream_Buffer(s);
810 const size_t pos = Stream_GetPosition(s);
811 *plen = WINPR_ASSERTING_INT_CAST(uint32_t, pos);
812 Stream_Free(s, FALSE);
817static void* clipboard_wrap_format_to_html(uint32_t bmpFormat,
const char* idata,
size_t ilength,
821 wImage* img = winpr_image_new();
825 if (winpr_image_read_buffer(img, (
const BYTE*)idata, ilength) <= 0)
830 void* bmp = winpr_image_write_buffer(img, bmpFormat, &bmpsize);
834 res = clipboard_wrap_html(winpr_image_format_mime(bmpFormat), bmp, bmpsize, plen);
838 winpr_image_free(img, TRUE);
842static void* clipboard_wrap_bmp_to_html(
const char* idata,
size_t ilength, uint32_t* plen)
844 const uint32_t formats[] = { WINPR_IMAGE_WEBP, WINPR_IMAGE_PNG, WINPR_IMAGE_JPEG };
846 for (
size_t x = 0; x < ARRAYSIZE(formats); x++)
848 const uint32_t format = formats[x];
849 if (winpr_image_format_is_supported(format))
851 return clipboard_wrap_format_to_html(format, idata, ilength, plen);
854 const uint32_t bmpFormat = WINPR_IMAGE_BITMAP;
855 return clipboard_wrap_html(winpr_image_format_mime(bmpFormat), idata, ilength, plen);
858static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipboard,
859 UINT32 formatId,
const void* data, UINT32* pSize)
863 const size_t datalen = *pSize;
868 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
872 uint32_t bmplen = *pSize;
873 void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, &bmplen);
876 WLog_WARN(TAG,
"failed to convert formatId 0x%08" PRIx32
" [%s]", formatId,
877 ClipboardGetFormatName(clipboard, formatId));
882 void* res = clipboard_wrap_bmp_to_html(bmp, bmplen, pSize);
888 const uint32_t idWebp = ClipboardRegisterFormat(clipboard, mime_webp);
889 const uint32_t idPng = ClipboardRegisterFormat(clipboard, mime_png);
890 const uint32_t idJpeg = ClipboardRegisterFormat(clipboard, mime_jpeg);
891 const uint32_t idTiff = ClipboardRegisterFormat(clipboard, mime_tiff);
892 if (formatId == idWebp)
894 return clipboard_wrap_html(mime_webp, data, datalen, pSize);
896 else if (formatId == idPng)
898 return clipboard_wrap_html(mime_png, data, datalen, pSize);
900 else if (formatId == idJpeg)
902 return clipboard_wrap_html(mime_jpeg, data, datalen, pSize);
904 else if (formatId == idTiff)
906 return clipboard_wrap_html(mime_tiff, data, datalen, pSize);
910 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
912 const char* mime = mime_bitmap[x];
913 const uint32_t
id = ClipboardRegisterFormat(clipboard, mime);
916 return clipboard_wrap_bmp_to_html(data, datalen, pSize);
920 WLog_WARN(TAG,
"Unsupported image format id 0x%08" PRIx32
" [%s]", formatId,
921 ClipboardGetFormatName(clipboard, formatId));
934static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 formatId,
935 const void* data, UINT32* pSize)
937 char* pDstData =
nullptr;
939 if (formatId == ClipboardGetFormatId(clipboard, mime_ms_html))
941 const char* str = (
const char*)data;
942 const size_t SrcSize = *pSize;
943 const char* begStr = strstr(str,
"StartHTML:");
944 const char* endStr = strstr(str,
"EndHTML:");
946 if (!begStr || !endStr)
950 const long beg = strtol(&begStr[10],
nullptr, 10);
955 const long end = strtol(&endStr[8],
nullptr, 10);
957 if ((beg < 0) || (end < 0) || ((
size_t)beg > SrcSize) || ((
size_t)end > SrcSize) ||
958 (beg >= end) || (errno != 0))
961 const size_t DstSize = (size_t)(end - beg);
962 pDstData = calloc(DstSize + 1,
sizeof(
char));
967 CopyMemory(pDstData, &str[beg], DstSize);
968 const size_t rc = ConvertLineEndingToLF(pDstData, DstSize);
969 WINPR_ASSERT(rc <= UINT32_MAX);
976BOOL ClipboardInitSynthesizers(wClipboard* clipboard)
982 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_OEMTEXT,
983 clipboard_synthesize_cf_oemtext))
985 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_UNICODETEXT,
986 clipboard_synthesize_cf_unicodetext))
988 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, CF_LOCALE,
989 clipboard_synthesize_cf_locale))
992 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
993 if (!ClipboardRegisterSynthesizer(clipboard, CF_TEXT, altFormatId,
994 clipboard_synthesize_utf8_string))
1001 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_TEXT,
1002 clipboard_synthesize_cf_text))
1004 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_UNICODETEXT,
1005 clipboard_synthesize_cf_unicodetext))
1007 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, CF_LOCALE,
1008 clipboard_synthesize_cf_locale))
1010 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1011 if (!ClipboardRegisterSynthesizer(clipboard, CF_OEMTEXT, altFormatId,
1012 clipboard_synthesize_utf8_string))
1019 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_TEXT,
1020 clipboard_synthesize_cf_text))
1022 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_OEMTEXT,
1023 clipboard_synthesize_cf_oemtext))
1025 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, CF_LOCALE,
1026 clipboard_synthesize_cf_locale))
1028 UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1029 if (!ClipboardRegisterSynthesizer(clipboard, CF_UNICODETEXT, altFormatId,
1030 clipboard_synthesize_utf8_string))
1037 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1041 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1042 clipboard_synthesize_cf_text))
1044 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1045 clipboard_synthesize_cf_oemtext))
1047 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1048 clipboard_synthesize_cf_unicodetext))
1050 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1051 clipboard_synthesize_cf_locale))
1059 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_text_plain);
1063 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_TEXT,
1064 clipboard_synthesize_cf_text))
1066 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_OEMTEXT,
1067 clipboard_synthesize_cf_oemtext))
1069 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_UNICODETEXT,
1070 clipboard_synthesize_cf_unicodetext))
1072 if (!ClipboardRegisterSynthesizer(clipboard, formatId, CF_LOCALE,
1073 clipboard_synthesize_cf_locale))
1078 const uint32_t htmlFormat = ClipboardRegisterFormat(clipboard, mime_ms_html);
1079 const uint32_t tiffFormat = ClipboardRegisterFormat(clipboard, mime_tiff);
1084 if (!ClipboardRegisterSynthesizer(clipboard, CF_TIFF, htmlFormat,
1085 clipboard_synthesize_image_html))
1087 if (!ClipboardRegisterSynthesizer(clipboard, tiffFormat, htmlFormat,
1088 clipboard_synthesize_image_html))
1095#if defined(WINPR_UTILS_IMAGE_DIBv5)
1096 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, CF_DIBV5,
1097 clipboard_synthesize_cf_dibv5))
1100 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1102 const char* mime = mime_bitmap[x];
1103 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1104 if (altFormatId == 0)
1106 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1107 clipboard_synthesize_image_bmp))
1110 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, htmlFormat,
1111 clipboard_synthesize_image_html))
1118#if defined(WINPR_UTILS_IMAGE_DIBv5)
1120 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, CF_DIB, clipboard_synthesize_cf_dib))
1123 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1125 const char* mime = mime_bitmap[x];
1126 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1127 if (altFormatId == 0)
1129 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1130 clipboard_synthesize_image_bmp))
1133 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, htmlFormat,
1134 clipboard_synthesize_image_html))
1142 for (
size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++)
1144 const char* mime = mime_bitmap[x];
1145 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime);
1146 if (altFormatId == 0)
1148 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1149 clipboard_synthesize_cf_dib))
1151#if defined(WINPR_UTILS_IMAGE_DIBv5)
1152 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1153 clipboard_synthesize_cf_dibv5))
1156 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1157 clipboard_synthesize_image_html))
1164#if defined(WINPR_UTILS_IMAGE_PNG)
1166 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_png);
1167 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1168 clipboard_synthesize_image_bmp_to_png))
1170 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1171 clipboard_synthesize_image_png_to_bmp))
1173 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1174 clipboard_synthesize_image_html))
1176#if defined(WINPR_UTILS_IMAGE_DIBv5)
1177 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1178 clipboard_synthesize_image_bmp_to_png))
1180 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1181 clipboard_synthesize_image_png_to_bmp))
1190#if defined(WINPR_UTILS_IMAGE_WEBP)
1192 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_webp);
1193 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1194 clipboard_synthesize_image_bmp_to_webp))
1196 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1197 clipboard_synthesize_image_webp_to_bmp))
1199 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1200 clipboard_synthesize_image_html))
1202#if defined(WINPR_UTILS_IMAGE_DIBv5)
1203 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1204 clipboard_synthesize_image_bmp_to_webp))
1206 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1207 clipboard_synthesize_image_webp_to_bmp))
1216#if defined(WINPR_UTILS_IMAGE_JPEG)
1218 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_jpeg);
1219 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIB, altFormatId,
1220 clipboard_synthesize_image_bmp_to_jpeg))
1222 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIB,
1223 clipboard_synthesize_image_jpeg_to_bmp))
1225 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, htmlFormat,
1226 clipboard_synthesize_image_html))
1228#if defined(WINPR_UTILS_IMAGE_DIBv5)
1229 if (!ClipboardRegisterSynthesizer(clipboard, altFormatId, CF_DIBV5,
1230 clipboard_synthesize_image_jpeg_to_bmp))
1232 if (!ClipboardRegisterSynthesizer(clipboard, CF_DIBV5, altFormatId,
1233 clipboard_synthesize_image_bmp_to_jpeg))
1243 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1247 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_html);
1248 if (!ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1249 clipboard_synthesize_text_html))
1258 UINT32 formatId = ClipboardRegisterFormat(clipboard, mime_html);
1262 const UINT32 altFormatId = ClipboardRegisterFormat(clipboard, mime_ms_html);
1263 if (!ClipboardRegisterSynthesizer(clipboard, formatId, altFormatId,
1264 clipboard_synthesize_html_format))