Ken Thomases : winemac: Extract new function from macdrv_GetClipboardData() parameterized by the target pasteboard.

Alexandre Julliard julliard at winehq.org
Thu Mar 14 14:55:05 CDT 2013


Module: wine
Branch: master
Commit: c8e6bad15338252b5d93d542feda93b747189871
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c8e6bad15338252b5d93d542feda93b747189871

Author: Ken Thomases <ken at codeweavers.com>
Date:   Wed Mar 13 16:53:16 2013 -0500

winemac: Extract new function from macdrv_GetClipboardData() parameterized by the target pasteboard.

---

 dlls/winemac.drv/clipboard.c |  126 ++++++++++++++++++++++-------------------
 1 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c
index 4a6f859..4197515 100644
--- a/dlls/winemac.drv/clipboard.c
+++ b/dlls/winemac.drv/clipboard.c
@@ -1257,6 +1257,73 @@ static BOOL release_ownership(void)
 
 
 /**************************************************************************
+ *              macdrv_get_pasteboard_data
+ */
+static HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format)
+{
+    CFArrayRef types;
+    CFIndex count;
+    CFIndex i;
+    CFStringRef type, best_type;
+    WINE_CLIPFORMAT* best_format = NULL;
+    HANDLE data = NULL;
+
+    TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(desired_format));
+
+    types = macdrv_copy_pasteboard_types(pasteboard);
+    if (!types)
+    {
+        WARN("Failed to copy pasteboard types\n");
+        return NULL;
+    }
+
+    count = CFArrayGetCount(types);
+    TRACE("got %ld types\n", count);
+
+    for (i = 0; (!best_format || best_format->synthesized) && i < count; i++)
+    {
+        WINE_CLIPFORMAT* format;
+
+        type = CFArrayGetValueAtIndex(types, i);
+
+        format = NULL;
+        while ((!best_format || best_format->synthesized) && (format = format_for_type(format, type)))
+        {
+            TRACE("for type %s got format %p/%s\n", debugstr_cf(type), format, debugstr_format(format ? format->format_id : 0));
+
+            if (format->format_id == desired_format)
+            {
+                /* The best format is the matching one which is not synthesized.  Failing that,
+                   the best format is the first matching synthesized format. */
+                if (!format->synthesized || !best_format)
+                {
+                    best_type = type;
+                    best_format = format;
+                }
+            }
+        }
+    }
+
+    if (best_format)
+    {
+        CFDataRef pasteboard_data = macdrv_copy_pasteboard_data(pasteboard, best_type);
+
+        TRACE("got pasteboard data for type %s: %s\n", debugstr_cf(best_type), debugstr_cf(pasteboard_data));
+
+        if (pasteboard_data)
+        {
+            data = best_format->import_func(pasteboard_data);
+            CFRelease(pasteboard_data);
+        }
+    }
+
+    CFRelease(types);
+    TRACE(" -> %p\n", data);
+    return data;
+}
+
+
+/**************************************************************************
  *              check_clipboard_ownership
  */
 static void check_clipboard_ownership(HWND *owner)
@@ -1480,66 +1547,9 @@ UINT CDECL macdrv_EnumClipboardFormats(UINT prev_format)
  */
 HANDLE CDECL macdrv_GetClipboardData(UINT desired_format)
 {
-    CFArrayRef types;
-    CFIndex count;
-    CFIndex i;
-    CFStringRef type, best_type;
-    WINE_CLIPFORMAT* best_format = NULL;
-    HANDLE data = NULL;
-
-    TRACE("desired_format %s\n", debugstr_format(desired_format));
     check_clipboard_ownership(NULL);
 
-    types = macdrv_copy_pasteboard_types(NULL);
-    if (!types)
-    {
-        WARN("Failed to copy pasteboard types\n");
-        return NULL;
-    }
-
-    count = CFArrayGetCount(types);
-    TRACE("got %ld types\n", count);
-
-    for (i = 0; (!best_format || best_format->synthesized) && i < count; i++)
-    {
-        WINE_CLIPFORMAT* format;
-
-        type = CFArrayGetValueAtIndex(types, i);
-
-        format = NULL;
-        while ((!best_format || best_format->synthesized) && (format = format_for_type(format, type)))
-        {
-            TRACE("for type %s got format %p/%s\n", debugstr_cf(type), format, debugstr_format(format ? format->format_id : 0));
-
-            if (format->format_id == desired_format)
-            {
-                /* The best format is the matching one which is not synthesized.  Failing that,
-                   the best format is the first matching synthesized format. */
-                if (!format->synthesized || !best_format)
-                {
-                    best_type = type;
-                    best_format = format;
-                }
-            }
-        }
-    }
-
-    if (best_format)
-    {
-        CFDataRef pasteboard_data = macdrv_copy_pasteboard_data(NULL, best_type);
-
-        TRACE("got pasteboard data for type %s: %s\n", debugstr_cf(best_type), debugstr_cf(pasteboard_data));
-
-        if (pasteboard_data)
-        {
-            data = best_format->import_func(pasteboard_data);
-            CFRelease(pasteboard_data);
-        }
-    }
-
-    CFRelease(types);
-    TRACE(" -> %p\n", data);
-    return data;
+    return macdrv_get_pasteboard_data(NULL, desired_format);
 }
 
 




More information about the wine-cvs mailing list