Index: /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 83630)
+++ /trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 83631)
@@ -354,6 +354,7 @@
 int writeToPasteboard(PasteboardRef hPasteboard, uint64_t idOwnership, const void *pv, uint32_t cb, uint32_t fFormat)
 {
-    int rc;
-    OSStatus orc;
+    int       rc;
+    OSStatus  orc;
+    CFDataRef hData;
     Log(("writeToPasteboard: fFormat = %02X\n", fFormat));
 
@@ -364,5 +365,7 @@
      * Handle the unicode text
      */
-    if (fFormat & VBOX_SHCL_FMT_UNICODETEXT)
+    /** @todo Figure out the format of kUTTypeHTML.  Seems it is neiter UTF-8 or
+     *        UTF-16. */
+    if (fFormat & (VBOX_SHCL_FMT_UNICODETEXT /*| VBOX_SHCL_FMT_HTML*/))
     {
         PCRTUTF16 const pwszSrc = (PCRTUTF16)pv;
@@ -397,20 +400,25 @@
              */
             rc = VINF_SUCCESS;
-            CFDataRef hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pwszDst, cwcDst * sizeof(RTUTF16));
-            if (hData)
-            {
-                orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership,
-                                              kUTTypeUTF16PlainText, hData, kPasteboardFlavorNoFlags);
-                if (orc != 0)
-                {
-                    Log(("writeToPasteboard: PasteboardPutItemFlavor/kUTTypeUTF16PlainText failed: %d (%#x)\n", orc, orc));
-                    rc = VERR_GENERAL_FAILURE;
-                }
-                else
-                {
-                    Log(("writeToPasteboard: CFDataCreate/UTF16 failed!\n"));
-                    rc = VERR_NO_MEMORY;
-                }
-                CFRelease(hData);
+            //if (fFormat & (VBOX_SHCL_FMT_UNICODETEXT | VBOX_SHCL_FMT_HTML))
+            {
+                hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pwszDst, cwcDst * sizeof(RTUTF16));
+                if (hData)
+                {
+                    orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership,
+                                                  fFormat & VBOX_SHCL_FMT_UNICODETEXT ? kUTTypeUTF16PlainText : kUTTypeHTML,
+                                                  hData, kPasteboardFlavorNoFlags);
+                    if (orc != 0)
+                    {
+                        Log(("writeToPasteboard: PasteboardPutItemFlavor/%s failed: %d (%#x)\n",
+                             fFormat & VBOX_SHCL_FMT_UNICODETEXT ? "kUTTypeUTF16PlainText" : "kUTTypeHTML", orc, orc));
+                        rc = VERR_GENERAL_FAILURE;
+                    }
+                    else
+                    {
+                        Log(("writeToPasteboard: CFDataCreate/UTF16 failed!\n"));
+                        rc = VERR_NO_MEMORY;
+                    }
+                    CFRelease(hData);
+                }
             }
 
@@ -418,29 +426,34 @@
              * Now for the UTF-8 version.
              */
-            char *pszDst;
-            int rc2 = RTUtf16ToUtf8(pwszDst, &pszDst);
-            if (RT_SUCCESS(rc2))
-            {
-                hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pszDst, strlen(pszDst));
-                if (hData)
-                {
-                    orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership,
-                                                  kUTTypeUTF8PlainText, hData, kPasteboardFlavorNoFlags);
-                    if (orc != 0)
+            //if (fFormat & VBOX_SHCL_FMT_UNICODETEXT)
+            {
+                char *pszDst;
+                int rc2 = RTUtf16ToUtf8(pwszDst, &pszDst);
+                if (RT_SUCCESS(rc2))
+                {
+                    hData = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)pszDst, strlen(pszDst));
+                    if (hData)
                     {
-                        Log(("writeToPasteboard: PasteboardPutItemFlavor/kUTTypeUTF8PlainText failed: %d (%#x)\n", orc, orc));
-                        rc = VERR_GENERAL_FAILURE;
+                        orc = PasteboardPutItemFlavor(hPasteboard, (PasteboardItemID)idOwnership,
+                                                      fFormat & VBOX_SHCL_FMT_UNICODETEXT ? kUTTypeUTF8PlainText : kUTTypeHTML,
+                                                      hData, kPasteboardFlavorNoFlags);
+                        if (orc != 0)
+                        {
+                            Log(("writeToPasteboard: PasteboardPutItemFlavor/%s failed: %d (%#x)\n",
+                                 fFormat & VBOX_SHCL_FMT_UNICODETEXT ? "kUTTypeUTF8PlainText" : "kUTTypeHTML", orc, orc));
+                            rc = VERR_GENERAL_FAILURE;
+                        }
+                        CFRelease(hData);
                     }
-                    CFRelease(hData);
+                    else
+                    {
+                        Log(("writeToPasteboard: CFDataCreate/UTF8 failed!\n"));
+                        rc = VERR_NO_MEMORY;
+                    }
+                    RTStrFree(pszDst);
                 }
                 else
-                {
-                    Log(("writeToPasteboard: CFDataCreate/UTF8 failed!\n"));
-                    rc = VERR_NO_MEMORY;
-                }
-                RTStrFree(pszDst);
-            }
-            else
-                rc = rc2;
+                    rc = rc2;
+            }
         }
         else
@@ -461,5 +474,5 @@
         if (RT_SUCCESS(rc))
         {
-            CFDataRef hData = CFDataCreate(kCFAllocatorDefault, (UInt8 const *)pvBmp, cbBmp);
+            hData = CFDataCreate(kCFAllocatorDefault, (UInt8 const *)pvBmp, cbBmp);
             if (hData)
             {
