Indentation in CopyMetaFileW is a bit inconsistent (there are some tabs which I left since I didn't touch those lines). Should I redo my patch to get rid of them (adds some noise to the patch), keep them in a separate patch (limited to this very function) or leave it as is? Also, should I change MF_CreateMetaHeaderDisk to accept a LPCWSTR, even though it then needs to convert it back to Ascii, or is the proposed way sufficient? Changelog: Removed a W->A cross-call (CopyMetaFileW->CopyMetaFileA). Vincent
Index: objects/metafile.c =================================================================== RCS file: /home/wine/wine/objects/metafile.c,v retrieving revision 1.59 diff -u -r1.59 metafile.c --- objects/metafile.c 8 Dec 2003 21:58:55 -0000 1.59 +++ objects/metafile.c 13 Jan 2004 03:22:31 -0000 @@ -52,6 +52,8 @@ #include "wine/wingdi16.h" #include "bitmap.h" #include "wownt32.h" +#include "winreg.h" +#include "winternl.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(metafile); @@ -418,7 +420,7 @@ /****************************************************************** - * CopyMetaFileA (GDI32.@) + * CopyMetaFileW (GDI32.@) * * Copies the metafile corresponding to hSrcMetaFile to either * a disk file, if a filename is given, or to a new memory based @@ -432,15 +434,15 @@ * * Copying to disk returns NULL even if successful. */ -HMETAFILE WINAPI CopyMetaFileA( +HMETAFILE WINAPI CopyMetaFileW( HMETAFILE hSrcMetaFile, /* [in] handle of metafile to copy */ - LPCSTR lpFilename /* [in] filename if copying to a file */ + LPCWSTR lpFilename /* [in] filename if copying to a file */ ) { METAHEADER *mh = MF_GetMetaHeader( hSrcMetaFile ); METAHEADER *mh2 = NULL; HANDLE hFile; - TRACE("(%p,%s)\n", hSrcMetaFile, lpFilename); + TRACE("(%p,%s)\n", hSrcMetaFile, debugstr_w(lpFilename)); if(!mh) return 0; @@ -452,14 +454,20 @@ } if(lpFilename) { /* disk based metafile */ - if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL, + DWORD len; + LPSTR lpFilenameA; + if((hFile = CreateFileW(lpFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { HeapFree( GetProcessHeap(), 0, mh2 ); return 0; } WriteFile(hFile, mh2, mh2->mtSize * 2, NULL, NULL); CloseHandle(hFile); - mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename); + len = WideCharToMultiByte(CP_ACP, 0, lpFilename, -1, NULL, 0, NULL, NULL); + lpFilenameA = HeapAlloc(GetProcessHeap(), 0, len); + WideCharToMultiByte(CP_ACP, 0, lpFilename, -1, lpFilenameA, len, NULL, NULL); + mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilenameA); + HeapFree(GetProcessHeap(), 0, lpFilenameA); } return MF_Create_HMETAFILE( mh2 ); @@ -467,21 +475,21 @@ /****************************************************************** - * CopyMetaFileW (GDI32.@) + * CopyMetaFileA (GDI32.@) */ -HMETAFILE WINAPI CopyMetaFileW( HMETAFILE hSrcMetaFile, - LPCWSTR lpFilename ) +HMETAFILE WINAPI CopyMetaFileA( HMETAFILE hSrcMetaFile, + LPCSTR lpFilename ) { + UNICODE_STRING lpFilenameW; HMETAFILE ret = 0; - DWORD len = WideCharToMultiByte( CP_ACP, 0, lpFilename, -1, NULL, 0, NULL, NULL ); - LPSTR p = HeapAlloc( GetProcessHeap(), 0, len ); - if (p) - { - WideCharToMultiByte( CP_ACP, 0, lpFilename, -1, p, len, NULL, NULL ); - ret = CopyMetaFileA( hSrcMetaFile, p ); - HeapFree( GetProcessHeap(), 0, p ); + if (lpFilename) RtlCreateUnicodeStringFromAsciiz(&lpFilenameW, lpFilename); + else lpFilenameW.Buffer = NULL; + + if (lpFilenameW.Buffer) { + ret = CopyMetaFileW( hSrcMetaFile, lpFilenameW.Buffer ); } + RtlFreeUnicodeString(&lpFilenameW); return ret; }