Changeset 83631 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Apr 8, 2020 9:40:37 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
r83630 r83631 354 354 int writeToPasteboard(PasteboardRef hPasteboard, uint64_t idOwnership, const void *pv, uint32_t cb, uint32_t fFormat) 355 355 { 356 int rc; 357 OSStatus orc; 356 int rc; 357 OSStatus orc; 358 CFDataRef hData; 358 359 Log(("writeToPasteboard: fFormat = %02X\n", fFormat)); 359 360 … … 364 365 * Handle the unicode text 365 366 */ 366 if (fFormat & VBOX_SHCL_FMT_UNICODETEXT) 367 /** @todo Figure out the format of kUTTypeHTML. Seems it is neiter UTF-8 or 368 * UTF-16. */ 369 if (fFormat & (VBOX_SHCL_FMT_UNICODETEXT /*| VBOX_SHCL_FMT_HTML*/)) 367 370 { 368 371 PCRTUTF16 const pwszSrc = (PCRTUTF16)pv; … … 397 400 */ 398 401 rc = VINF_SUCCESS; 399 CFDataRef hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pwszDst, cwcDst * sizeof(RTUTF16)); 400 if (hData) 401 { 402 orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership, 403 kUTTypeUTF16PlainText, hData, kPasteboardFlavorNoFlags); 404 if (orc != 0) 405 { 406 Log(("writeToPasteboard: PasteboardPutItemFlavor/kUTTypeUTF16PlainText failed: %d (%#x)\n", orc, orc)); 407 rc = VERR_GENERAL_FAILURE; 408 } 409 else 410 { 411 Log(("writeToPasteboard: CFDataCreate/UTF16 failed!\n")); 412 rc = VERR_NO_MEMORY; 413 } 414 CFRelease(hData); 402 //if (fFormat & (VBOX_SHCL_FMT_UNICODETEXT | VBOX_SHCL_FMT_HTML)) 403 { 404 hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pwszDst, cwcDst * sizeof(RTUTF16)); 405 if (hData) 406 { 407 orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership, 408 fFormat & VBOX_SHCL_FMT_UNICODETEXT ? kUTTypeUTF16PlainText : kUTTypeHTML, 409 hData, kPasteboardFlavorNoFlags); 410 if (orc != 0) 411 { 412 Log(("writeToPasteboard: PasteboardPutItemFlavor/%s failed: %d (%#x)\n", 413 fFormat & VBOX_SHCL_FMT_UNICODETEXT ? "kUTTypeUTF16PlainText" : "kUTTypeHTML", orc, orc)); 414 rc = VERR_GENERAL_FAILURE; 415 } 416 else 417 { 418 Log(("writeToPasteboard: CFDataCreate/UTF16 failed!\n")); 419 rc = VERR_NO_MEMORY; 420 } 421 CFRelease(hData); 422 } 415 423 } 416 424 … … 418 426 * Now for the UTF-8 version. 419 427 */ 420 char *pszDst; 421 int rc2 = RTUtf16ToUtf8(pwszDst, &pszDst); 422 if (RT_SUCCESS(rc2)) 423 { 424 hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pszDst, strlen(pszDst)); 425 if (hData) 426 { 427 orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership, 428 kUTTypeUTF8PlainText, hData, kPasteboardFlavorNoFlags); 429 if (orc != 0) 428 //if (fFormat & VBOX_SHCL_FMT_UNICODETEXT) 429 { 430 char *pszDst; 431 int rc2 = RTUtf16ToUtf8(pwszDst, &pszDst); 432 if (RT_SUCCESS(rc2)) 433 { 434 hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pszDst, strlen(pszDst)); 435 if (hData) 430 436 { 431 Log(("writeToPasteboard: PasteboardPutItemFlavor/kUTTypeUTF8PlainText failed: %d (%#x)\n", orc, orc)); 432 rc = VERR_GENERAL_FAILURE; 437 orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership, 438 fFormat & VBOX_SHCL_FMT_UNICODETEXT ? kUTTypeUTF8PlainText : kUTTypeHTML, 439 hData, kPasteboardFlavorNoFlags); 440 if (orc != 0) 441 { 442 Log(("writeToPasteboard: PasteboardPutItemFlavor/%s failed: %d (%#x)\n", 443 fFormat & VBOX_SHCL_FMT_UNICODETEXT ? "kUTTypeUTF8PlainText" : "kUTTypeHTML", orc, orc)); 444 rc = VERR_GENERAL_FAILURE; 445 } 446 CFRelease(hData); 433 447 } 434 CFRelease(hData); 448 else 449 { 450 Log(("writeToPasteboard: CFDataCreate/UTF8 failed!\n")); 451 rc = VERR_NO_MEMORY; 452 } 453 RTStrFree(pszDst); 435 454 } 436 455 else 437 { 438 Log(("writeToPasteboard: CFDataCreate/UTF8 failed!\n")); 439 rc = VERR_NO_MEMORY; 440 } 441 RTStrFree(pszDst); 442 } 443 else 444 rc = rc2; 456 rc = rc2; 457 } 445 458 } 446 459 else … … 461 474 if (RT_SUCCESS(rc)) 462 475 { 463 CFDataRefhData = CFDataCreate(kCFAllocatorDefault, (UInt8 const *)pvBmp, cbBmp);476 hData = CFDataCreate(kCFAllocatorDefault, (UInt8 const *)pvBmp, cbBmp); 464 477 if (hData) 465 478 {
Note:
See TracChangeset
for help on using the changeset viewer.