winex11.drv: Implement synthesizing the CF_ENHMETAFILE clipboard format from CF_METAFILEPICT.

Alexander Scott-Johns alexander.scott.johns at googlemail.com
Thu Jan 27 20:42:45 CST 2011


-------------- next part --------------
From 7585fc1bf9695fe8a4d1649ff08b18266f2b7d81 Mon Sep 17 00:00:00 2001
From: Alexander Scott-Johns <alexander.scott.johns at googlemail.com>
Date: Tue, 25 Jan 2011 17:54:21 +0000
Subject: winex11.drv: Implement synthesizing EMF clipboard format from MF Picture clipboard format.

---
 dlls/winex11.drv/clipboard.c |   56 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index fcec86b..fed22e8 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -179,6 +179,7 @@ static BOOL X11DRV_CLIPBOARD_SynthesizeData(UINT wFormatID);
 static BOOL X11DRV_CLIPBOARD_RenderSynthesizedFormat(Display *display, LPWINE_CLIPDATA lpData);
 static BOOL X11DRV_CLIPBOARD_RenderSynthesizedDIB(Display *display);
 static BOOL X11DRV_CLIPBOARD_RenderSynthesizedBitmap(Display *display);
+static BOOL X11DRV_CLIPBOARD_RenderSynthesizedEnhMetaFile(Display *display);
 static void X11DRV_HandleSelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BOOL bIsMultiple );
 
 /* Clipboard formats
@@ -887,12 +888,15 @@ static BOOL X11DRV_CLIPBOARD_RenderSynthesizedFormat(Display *display, LPWINE_CL
                     break;
 
                 case CF_ENHMETAFILE:
+                    bret = X11DRV_CLIPBOARD_RenderSynthesizedEnhMetaFile( display );
+                    break;
+
                 case CF_METAFILEPICT:
-		    FIXME("Synthesizing wFormatID(0x%08x) not implemented\n", wFormatID);
+                    FIXME("Synthesizing CF_METAFILEPICT not implemented\n");
                     break;
 
                 default:
-		    FIXME("Called to synthesize unknown format\n");
+                    FIXME("Called to synthesize unknown format 0x%08x\n", wFormatID);
                     break;
             }
         }
@@ -1088,6 +1092,54 @@ static BOOL X11DRV_CLIPBOARD_RenderSynthesizedBitmap(Display *display)
 
 
 /**************************************************************************
+ *                      X11DRV_CLIPBOARD_RenderSynthesizedEnhMetaFile
+ */
+static BOOL X11DRV_CLIPBOARD_RenderSynthesizedEnhMetaFile(Display *display)
+{
+    BOOL bret = FALSE;
+    LPWINE_CLIPDATA lpSource = NULL;
+
+    TRACE("\n");
+
+    if ((lpSource = X11DRV_CLIPBOARD_LookupData(CF_ENHMETAFILE)) && lpSource->hData)
+    {
+        bret = TRUE;
+    }
+    /* If we have a MF pict and it's not synthesized or it has been rendered */
+    else if ((lpSource = X11DRV_CLIPBOARD_LookupData(CF_METAFILEPICT)) &&
+        (!(lpSource->wFlags & CF_FLAG_SYNTHESIZED) || lpSource->hData))
+    {
+        /* Render source if required */
+        if (lpSource->hData || X11DRV_CLIPBOARD_RenderFormat(display, lpSource))
+        {
+            METAFILEPICT *pmfp;
+            HENHMETAFILE hData = NULL;
+
+            pmfp = GlobalLock(lpSource->hData);
+            if (pmfp)
+            {
+                UINT size_mf_bits = GetMetaFileBitsEx(pmfp->hMF, 0, NULL);
+                void *mf_bits = HeapAlloc(GetProcessHeap(), 0, size_mf_bits);
+                GetMetaFileBitsEx(pmfp->hMF, size_mf_bits, mf_bits);
+                hData = SetWinMetaFileBits(size_mf_bits, mf_bits, NULL, pmfp);
+
+                HeapFree(GetProcessHeap(), 0, mf_bits);
+                GlobalUnlock(lpSource->hData);
+            }
+
+            if (hData)
+            {
+                X11DRV_CLIPBOARD_InsertClipboardData(CF_ENHMETAFILE, hData, 0, NULL, TRUE);
+                bret = TRUE;
+            }
+        }
+    }
+
+    return bret;
+}
+
+
+/**************************************************************************
  *		X11DRV_CLIPBOARD_ImportXAString
  *
  *  Import XA_STRING, converting the string to CF_TEXT.
-- 
1.7.0.4


More information about the wine-patches mailing list