[ros-diffs] [jimtabor] 28172: Started CreateMetaFile, port from wine. Made changes to the structures. Added new support routines.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Sun Aug 5 11:21:00 CEST 2007


Author: jimtabor
Date: Sun Aug  5 13:21:00 2007
New Revision: 28172

URL: http://svn.reactos.org/svn/reactos?rev=28172&view=rev
Log:
Started CreateMetaFile, port from wine. Made changes to the structures. Added new support routines.

Modified:
    trunk/reactos/dll/win32/gdi32/include/gdi32p.h
    trunk/reactos/dll/win32/gdi32/misc/stubs.c
    trunk/reactos/dll/win32/gdi32/objects/metafile.c

Modified: trunk/reactos/dll/win32/gdi32/include/gdi32p.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/include/gdi32p.h?rev=28172&r1=28171&r2=28172&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/include/gdi32p.h (original)
+++ trunk/reactos/dll/win32/gdi32/include/gdi32p.h Sun Aug  5 13:21:00 2007
@@ -35,12 +35,12 @@
 
 /* TYPES *********************************************************************/
 
-// Based on wmfapi.h and Wine. This is the DC_ATTR for a MetaDC file.
+// Based on wmfapi.h and Wine.
 typedef struct tagMETAFILEDC {
   PVOID      pvMetaBuffer;
   HANDLE     hFile;
   DWORD      Size;
-  PMETAHEADER mf;
+  METAHEADER mh;
   UINT       handles_size, cur_handles;
   HGDIOBJ   *handles;
 
@@ -49,9 +49,17 @@
   HGDIOBJ    Brush;
   HGDIOBJ    Palette;
   HGDIOBJ    Font;
+  
+  WCHAR      Filename[MAX_PATH+2];
   // Add more later.
 } METAFILEDC,*PMETAFILEDC;
 
+// Metafile Entry handle
+typedef struct tagMF_ENTRY {
+  LIST_ENTRY   List;
+  HGDIOBJ      hmDC;             // Handle return from NtGdiCreateClientObj.
+  PMETAFILEDC pmfDC;
+} MF_ENTRY, *PMF_ENTRY;
 
 typedef struct tagENHMETAFILE {
   PVOID      pvMetaBuffer;

Modified: trunk/reactos/dll/win32/gdi32/misc/stubs.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs.c?rev=28172&r1=28171&r2=28172&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubs.c (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubs.c Sun Aug  5 13:21:00 2007
@@ -33,37 +33,7 @@
 	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
 	return FALSE;
 }
-
-
-/*
- * @unimplemented
- */
-HMETAFILE
-STDCALL
-CloseMetaFile(
-	HDC	a0
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return 0;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-DeleteMetaFile(
-	HMETAFILE	a0
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return FALSE;
-}
-
+  
 
 /*
  * @unimplemented

Modified: trunk/reactos/dll/win32/gdi32/objects/metafile.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/metafile.c?rev=28172&r1=28171&r2=28172&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/metafile.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/metafile.c Sun Aug  5 13:21:00 2007
@@ -1,4 +1,93 @@
 #include "precomp.h"
+
+/* DEFINES *******************************************************************/
+
+
+/* PRIVATE DATA **************************************************************/
+
+PMF_ENTRY hMF_List = NULL;
+DWORD hMFCount = 0;
+
+/* INTERNAL FUNCTIONS ********************************************************/
+
+BOOL
+MF_CreateMFDC ( HGDIOBJ hMDC, 
+                PMETAFILEDC pmfDC )
+{
+  PMF_ENTRY pMFME;
+  
+  pMFME = LocalAlloc(LMEM_ZEROINIT, sizeof(MF_ENTRY));
+  if (!pMFME)
+  {
+    return FALSE;
+  }
+  
+  if (hMF_List == NULL)
+  {
+    hMF_List = pMFME;
+    InitializeListHead(&hMF_List->List);
+  }
+  else
+    InsertTailList(&hMF_List->List, &pMFME->List);
+
+  pMFME->hmDC  = hMDC;
+  pMFME->pmfDC = pmfDC;
+    
+  hMFCount++;
+  return TRUE;
+}
+
+
+PMETAFILEDC
+MF_GetMFDC ( HGDIOBJ hMDC )
+{
+  PMF_ENTRY pMFME = hMF_List;
+
+  do
+  {
+    if ( pMFME->hmDC == hMDC ) return pMFME->pmfDC;
+    pMFME = (PMF_ENTRY) pMFME->List.Flink;
+  }
+  while ( pMFME != hMF_List );
+
+  return NULL;
+}
+
+
+BOOL
+MF_DeleteMFDC ( HGDIOBJ hMDC )
+{
+  PMF_ENTRY pMFME = hMF_List;
+
+  do
+  {
+    if ( pMFME->hmDC == hMDC)
+    {
+       RemoveEntryList(&pMFME->List);
+       LocalFree ( pMFME );
+       hMFCount--;
+       return TRUE;
+    }
+    pMFME = (PMF_ENTRY) pMFME->List.Flink;
+  }
+  while ( pMFME != hMF_List );
+
+  return FALSE;
+}
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @unimplemented
+ */
+HMETAFILE
+STDCALL
+CloseMetaFile(
+	HDC	a0
+	)
+{
+	return 0;
+}
 
 
 /*
@@ -34,8 +123,7 @@
     SetLastError (RtlNtStatusToDosError(Status));
   else
   {
-
-    rc = NULL;
+    rc = CopyMetaFileW( hmfSrc, lpszFileW );
     HEAP_free ( lpszFileW );
   }
 
@@ -52,7 +140,50 @@
 	LPCWSTR		lpszFile
 	)
 {
-  return NULL;
+  HANDLE hFile;
+  HDC hmDC;
+  PMETAFILEDC pmfDC = LocalAlloc(LMEM_ZEROINIT, sizeof(METAFILEDC));
+  if (!pmfDC) return NULL;
+  
+  pmfDC->mh.mtHeaderSize   = sizeof(METAHEADER) / sizeof(WORD);
+  pmfDC->mh.mtVersion      = 0x0300;
+  pmfDC->mh.mtSize         = pmfDC->mh.mtHeaderSize;
+
+  if (lpszFile)  /* disk based metafile */
+  {
+    pmfDC->mh.mtType = METAFILE_DISK;
+
+    if(!GetFullPathName(  lpszFile,
+                          MAX_PATH,
+         (LPTSTR) &pmfDC->Filename,
+               (LPTSTR*) &lpszFile))
+    {
+//       MFDRV_DeleteDC( dc->physDev );
+       return NULL;
+    }
+
+    if ((hFile = CreateFileW(pmfDC->Filename, GENERIC_WRITE, 0, NULL,
+				CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE)
+    {
+//       MFDRV_DeleteDC( dc->physDev );
+       return NULL;
+    }
+
+    if (!WriteFile( hFile, &pmfDC->mh, sizeof(pmfDC->mh), NULL, NULL ))
+    {
+//       MFDRV_DeleteDC( dc->physDev );
+       return NULL;
+    }
+      pmfDC->hFile = hFile; 
+  }
+  else  /* memory based metafile */
+    pmfDC->mh.mtType = METAFILE_MEMORY;
+
+  hmDC = NtGdiCreateClientObj ( GDI_OBJECT_TYPE_METADC );
+
+  MF_CreateMFDC ( hmDC, pmfDC );
+
+  return hmDC;
 }
 
 
@@ -74,11 +205,23 @@
     SetLastError (RtlNtStatusToDosError(Status));
   else
     {
-      rc = NULL;
-
+      rc = CreateMetaFileW( lpszFileW );
       HEAP_free ( lpszFileW );
     }
   return rc;
+}
+
+
+/*
+ * @unimplemented
+ */
+BOOL
+STDCALL
+DeleteMetaFile(
+	HMETAFILE	a0
+	)
+{
+	return FALSE;
 }
 
 
@@ -113,8 +256,7 @@
     SetLastError (RtlNtStatusToDosError(Status));
   else
     {
-      rc = NULL;
-
+      rc = GetMetaFileW( lpszMetaFileW );
       HEAP_free ( lpszMetaFileW );
     }
 




More information about the Ros-diffs mailing list