CopyEnhMetaFileW

Huw D M Davies h.davies1 at physics.ox.ac.uk
Mon Dec 1 11:13:06 CST 2003


        Huw Davies <huw at codeweavers.com>
        Implement CopyEnhMetaFileW
-- 
Huw Davies
huw at codeweavers.com
Index: objects/enhmetafile.c
===================================================================
RCS file: /home/wine/wine/objects/enhmetafile.c,v
retrieving revision 1.72
diff -u -r1.72 enhmetafile.c
--- objects/enhmetafile.c	11 Nov 2003 00:43:03 -0000	1.72
+++ objects/enhmetafile.c	1 Dec 2003 17:11:43 -0000
@@ -2248,6 +2248,43 @@
     return hmfDst;
 }
 
+/*****************************************************************************
+ *  CopyEnhMetaFileW (GDI32.@)  Duplicate an enhanced metafile
+ *
+ *
+ */
+HENHMETAFILE WINAPI CopyEnhMetaFileW(
+    HENHMETAFILE hmfSrc,
+    LPCWSTR file)
+{
+    ENHMETAHEADER *emrSrc = EMF_GetEnhMetaHeader( hmfSrc ), *emrDst;
+    HENHMETAFILE hmfDst;
+
+    if(!emrSrc) return FALSE;
+    if (!file) {
+        emrDst = HeapAlloc( GetProcessHeap(), 0, emrSrc->nBytes );
+	memcpy( emrDst, emrSrc, emrSrc->nBytes );
+	hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE );
+    } else {
+        HANDLE hFile;
+        hFile = CreateFileW( file, GENERIC_WRITE | GENERIC_READ, 0,
+			     NULL, CREATE_ALWAYS, 0, 0);
+	WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0);
+	CloseHandle( hFile );
+	/* Reopen file for reading only, so that apps can share
+	   read access to the file while hmf is still valid */
+        hFile = CreateFileW( file, GENERIC_READ, FILE_SHARE_READ,
+			     NULL, OPEN_EXISTING, 0, 0);
+	if(hFile == INVALID_HANDLE_VALUE) {
+	    ERR("Can't reopen emf for reading\n");
+	    return 0;
+	}
+	hmfDst = EMF_GetEnhMetaFile( hFile );
+        CloseHandle( hFile );
+    }
+    return hmfDst;
+}
+
 
 /* Struct to be used to be passed in the LPVOID parameter for cbEnhPaletteCopy */
 typedef struct tagEMF_PaletteCopy
Index: dlls/gdi/gdi32.spec
===================================================================
RCS file: /home/wine/wine/dlls/gdi/gdi32.spec,v
retrieving revision 1.32
diff -u -r1.32 gdi32.spec
--- dlls/gdi/gdi32.spec	5 Nov 2003 23:25:37 -0000	1.32
+++ dlls/gdi/gdi32.spec	1 Dec 2003 17:11:43 -0000
@@ -31,7 +31,7 @@
 @ stdcall CombineRgn(long long long long)
 @ stdcall CombineTransform(ptr ptr ptr)
 @ stdcall CopyEnhMetaFileA(long str)
-@ stub CopyEnhMetaFileW
+@ stdcall CopyEnhMetaFileW(long wstr)
 @ stdcall CopyMetaFileA(long str)
 @ stdcall CopyMetaFileW(long wstr)
 @ stdcall CreateBitmap(long long long long ptr)



More information about the wine-patches mailing list