[vbox-dev] [PATCH] OSX cosmetics: Use official constants instead of type strings

François Revol revol at free.fr
Sat Mar 5 19:52:54 GMT 2011


This patch replaces hardcoded type strings with their official constants from UICoreTypes.h which are available since OSX 10.4 (which is the minimum supported it seems).
No functional change.

This patch is under MIT license.

François.

Index: src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
===================================================================
--- src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 36094)
+++ src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(working copy)
@@ -110,8 +110,8 @@
                 flavorType = static_cast <CFStringRef> (CFArrayGetValueAtIndex (flavorTypeArray,
                                                                                 flavorIndex));
                 /* Currently only unicode supported */
-                if (UTTypeConformsTo (flavorType, CFSTR ("public.utf8-plain-text")) ||
-                    UTTypeConformsTo (flavorType, CFSTR ("public.utf16-plain-text")))
+                if (UTTypeConformsTo (flavorType, kUTTypeUTF8PlainText) ||
+                    UTTypeConformsTo (flavorType, kUTTypeUTF16PlainText))
                 {
                     Log (("Unicode flavor detected.\n"));
                     *pfFormats |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
@@ -163,14 +163,14 @@
             CFDataRef outData;
             PRTUTF16 pwszTmp = NULL;
             /* Try utf-16 first */
-            if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, CFSTR ("public.utf16-plain-text"), &outData)))
+            if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, kUTTypeUTF16PlainText, &outData)))
             {
                 Log (("Clipboard content is utf-16\n"));
                 rc = RTUtf16DupEx (&pwszTmp, (PRTUTF16)CFDataGetBytePtr (outData), 0);
             }
             /* Second try is utf-8 */
             else
-                if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, CFSTR ("public.utf8-plain-text"), &outData)))
+                if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, kUTTypeUTF8PlainText, &outData)))
                 {
                     Log (("readFromPasteboard: clipboard content is utf-8\n"));
                     rc = RTStrToUtf16 ((const char*)CFDataGetBytePtr (outData), &pwszTmp);
@@ -282,7 +282,7 @@
         {
             /* Put the Utf-16 version to the pasteboard */
             PasteboardPutItemFlavor (pPasteboard, itemId,
-                                     CFSTR ("public.utf16-plain-text"),
+                                     kUTTypeUTF16PlainText,
                                      textData, 0);
         }
         /* Create a Utf-8 version */
@@ -296,7 +296,7 @@
             {
                 /* Put the Utf-8 version to the pasteboard */
                 PasteboardPutItemFlavor (pPasteboard, itemId,
-                                         CFSTR ("public.utf8-plain-text"),
+                                         kUTTypeUTF8PlainText,
                                          textData, 0);
             }
             RTStrFree (pszDestText);





More information about the vbox-dev mailing list