blob: cb27f6875a2d306e1d2ae22c74d2e227e3ee8811 [file] [log] [blame]
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001/*
Huw D M Davies585c8461999-05-02 09:23:51 +00002 * Enhanced metafile functions
3 * Copyright 1998 Douglas Ridgway
4 * 1999 Huw D M Davies
Peter Hunnisettc821a751999-12-04 03:56:53 +00005 *
6 *
7 * The enhanced format consists of the following elements:
8 *
9 * A header
10 * A table of handles to GDI objects
Peter Hunnisettc821a751999-12-04 03:56:53 +000011 * An array of metafile records
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +000012 * A private palette
Peter Hunnisettc821a751999-12-04 03:56:53 +000013 *
14 *
15 * The standard format consists of a header and an array of metafile records.
16 *
Huw D M Davies585c8461999-05-02 09:23:51 +000017 */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000018
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000019#include <string.h>
Marcus Meissnerae0a73d1999-01-20 14:11:07 +000020#include <assert.h>
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000021#include "winbase.h"
Marcus Meissner6b9dd2e1999-03-18 17:39:57 +000022#include "wingdi.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000023#include "wine/winestring.h"
Charles Suprin41043011998-11-07 12:56:31 +000024#include "winerror.h"
Huw D M Davies585c8461999-05-02 09:23:51 +000025#include "enhmetafile.h"
Alexandre Julliard15657091999-05-23 10:25:25 +000026#include "debugtools.h"
Huw D M Davies585c8461999-05-02 09:23:51 +000027#include "heap.h"
Peter Hunnisettc821a751999-12-04 03:56:53 +000028#include "metafile.h"
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000029
Huw D M Davies585c8461999-05-02 09:23:51 +000030DEFAULT_DEBUG_CHANNEL(enhmetafile)
31
32/****************************************************************************
33 * EMF_Create_HENHMETAFILE
34 */
35HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, HFILE hFile, HANDLE
36 hMapping )
37{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000038 HENHMETAFILE hmf = 0;
39 ENHMETAFILEOBJ *metaObj = GDI_AllocObject( sizeof(ENHMETAFILEOBJ),
40 ENHMETAFILE_MAGIC, &hmf );
41 if (metaObj)
42 {
Huw D M Davies585c8461999-05-02 09:23:51 +000043 metaObj->emh = emh;
44 metaObj->hFile = hFile;
45 metaObj->hMapping = hMapping;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000046 GDI_ReleaseObj( hmf );
47 }
Huw D M Davies585c8461999-05-02 09:23:51 +000048 return hmf;
49}
50
51/****************************************************************************
52 * EMF_Delete_HENHMETAFILE
53 */
54static BOOL EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf )
55{
56 ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_GetObjPtr( hmf,
57 ENHMETAFILE_MAGIC );
58 if(!metaObj) return FALSE;
59 if(metaObj->hMapping) {
60 UnmapViewOfFile( metaObj->emh );
61 CloseHandle( metaObj->hMapping );
62 CloseHandle( metaObj->hFile );
63 } else
Alexandre Julliard90476d62000-02-16 22:47:24 +000064 HeapFree( GetProcessHeap(), 0, metaObj->emh );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000065 return GDI_FreeObject( hmf, metaObj );
Huw D M Davies585c8461999-05-02 09:23:51 +000066}
67
68/******************************************************************
69 * EMF_GetEnhMetaHeader
70 *
71 * Returns ptr to ENHMETAHEADER associated with HENHMETAFILE
72 * Should be followed by call to EMF_ReleaseEnhMetaHeader
73 */
74static ENHMETAHEADER *EMF_GetEnhMetaHeader( HENHMETAFILE hmf )
75{
76 ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_GetObjPtr( hmf,
77 ENHMETAFILE_MAGIC );
Alexandre Julliard15657091999-05-23 10:25:25 +000078 TRACE("hmf %04x -> enhmetaObj %p\n", hmf, metaObj);
Huw D M Davies0ae4e091999-06-12 06:49:52 +000079 return metaObj ? metaObj->emh : NULL;
Huw D M Davies585c8461999-05-02 09:23:51 +000080}
81
82/******************************************************************
83 * EMF_ReleaseEnhMetaHeader
84 *
85 * Releases ENHMETAHEADER associated with HENHMETAFILE
86 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000087static void EMF_ReleaseEnhMetaHeader( HENHMETAFILE hmf )
Huw D M Davies585c8461999-05-02 09:23:51 +000088{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000089 GDI_ReleaseObj( hmf );
Huw D M Davies585c8461999-05-02 09:23:51 +000090}
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000091
Alexandre Julliarda69b88b1998-03-15 20:29:56 +000092/*****************************************************************************
Huw D M Davies585c8461999-05-02 09:23:51 +000093 * EMF_GetEnhMetaFile
94 *
95 */
96static HENHMETAFILE EMF_GetEnhMetaFile( HFILE hFile )
97{
98 ENHMETAHEADER *emh;
99 HANDLE hMapping;
100
101 hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
102 emh = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
103
104 if (emh->iType != EMR_HEADER || emh->dSignature != ENHMETA_SIGNATURE) {
Alexandre Julliard15657091999-05-23 10:25:25 +0000105 WARN("Invalid emf header type 0x%08lx sig 0x%08lx.\n",
Huw D M Davies585c8461999-05-02 09:23:51 +0000106 emh->iType, emh->dSignature);
107 UnmapViewOfFile( emh );
108 CloseHandle( hMapping );
109 return 0;
110 }
111 return EMF_Create_HENHMETAFILE( emh, hFile, hMapping );
112}
113
114
115/*****************************************************************************
116 * GetEnhMetaFileA (GDI32.174)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000117 *
118 *
119 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000120HENHMETAFILE WINAPI GetEnhMetaFileA(
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000121 LPCSTR lpszMetaFile /* filename of enhanced metafile */
122 )
123{
Huw D M Davies585c8461999-05-02 09:23:51 +0000124 HENHMETAFILE hmf;
125 HFILE hFile;
126
Huw D M Davies0ae4e091999-06-12 06:49:52 +0000127 hFile = CreateFileA(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
128 OPEN_EXISTING, 0, 0);
Huw D M Davies585c8461999-05-02 09:23:51 +0000129 if (hFile == INVALID_HANDLE_VALUE) {
Alexandre Julliard15657091999-05-23 10:25:25 +0000130 WARN("could not open %s\n", lpszMetaFile);
Huw D M Davies585c8461999-05-02 09:23:51 +0000131 return 0;
132 }
133 hmf = EMF_GetEnhMetaFile( hFile );
134 if(!hmf)
135 CloseHandle( hFile );
136 return hmf;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000137}
138
139/*****************************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000140 * GetEnhMetaFileW (GDI32.180)
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000141 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000142HENHMETAFILE WINAPI GetEnhMetaFileW(
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000143 LPCWSTR lpszMetaFile) /* filename of enhanced metafile */
144{
Huw D M Davies585c8461999-05-02 09:23:51 +0000145 HENHMETAFILE hmf;
146 HFILE hFile;
147
Huw D M Davies0ae4e091999-06-12 06:49:52 +0000148 hFile = CreateFileW(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
149 OPEN_EXISTING, 0, 0);
Huw D M Davies585c8461999-05-02 09:23:51 +0000150 if (hFile == INVALID_HANDLE_VALUE) {
Alexandre Julliard15657091999-05-23 10:25:25 +0000151 WARN("could not open %s\n", debugstr_w(lpszMetaFile));
Huw D M Davies585c8461999-05-02 09:23:51 +0000152 return 0;
153 }
154 hmf = EMF_GetEnhMetaFile( hFile );
155 if(!hmf)
156 CloseHandle( hFile );
157 return hmf;
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000158}
159
160/*****************************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000161 * GetEnhMetaFileHeader (GDI32.178)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000162 *
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000163 * If buf is NULL, returns the size of buffer required.
164 * Otherwise, copy up to bufsize bytes of enhanced metafile header into
165 * buf.
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000166 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000167UINT WINAPI GetEnhMetaFileHeader(
168 HENHMETAFILE hmf, /* enhanced metafile */
169 UINT bufsize, /* size of buffer */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000170 LPENHMETAHEADER buf /* buffer */
171 )
172{
Huw D M Davies585c8461999-05-02 09:23:51 +0000173 LPENHMETAHEADER emh;
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000174 UINT size;
Huw D M Davies585c8461999-05-02 09:23:51 +0000175
Huw D M Davies585c8461999-05-02 09:23:51 +0000176 emh = EMF_GetEnhMetaHeader(hmf);
Huw D M Davies0ae4e091999-06-12 06:49:52 +0000177 if(!emh) return FALSE;
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000178 size = emh->nSize;
179 if (!buf) {
180 EMF_ReleaseEnhMetaHeader(hmf);
181 return size;
182 }
183 size = min(size, bufsize);
184 memmove(buf, emh, size);
Huw D M Davies585c8461999-05-02 09:23:51 +0000185 EMF_ReleaseEnhMetaHeader(hmf);
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000186 return size;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000187}
188
189
190/*****************************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000191 * GetEnhMetaFileDescriptionA (GDI32.176)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000192 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000193UINT WINAPI GetEnhMetaFileDescriptionA(
194 HENHMETAFILE hmf, /* enhanced metafile */
195 UINT size, /* size of buf */
Alexandre Julliard54c27111998-03-29 19:44:57 +0000196 LPSTR buf /* buffer to receive description */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000197 )
198{
Huw D M Davies585c8461999-05-02 09:23:51 +0000199 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf);
Hidenori Takeshimae2905ea2000-03-26 14:43:22 +0000200 INT first, first_A;
Huw D M Davies585c8461999-05-02 09:23:51 +0000201
Huw D M Davies0ae4e091999-06-12 06:49:52 +0000202 if(!emh) return FALSE;
Huw D M Davies585c8461999-05-02 09:23:51 +0000203 if(emh->nDescription == 0 || emh->offDescription == 0) {
204 EMF_ReleaseEnhMetaHeader(hmf);
205 return 0;
206 }
207 if (!buf || !size ) {
208 EMF_ReleaseEnhMetaHeader(hmf);
209 return emh->nDescription;
210 }
211
Patrik Stridvall896889f1999-05-08 12:50:36 +0000212 first = lstrlenW( (WCHAR *) ((char *) emh + emh->offDescription));
Huw D M Davies585c8461999-05-02 09:23:51 +0000213
Patrik Stridvall896889f1999-05-08 12:50:36 +0000214 lstrcpynWtoA(buf, (WCHAR *) ((char *) emh + emh->offDescription), size);
Alexandre Julliardcb10fda2000-08-06 02:41:16 +0000215 first_A = strlen( buf );
Hidenori Takeshimae2905ea2000-03-26 14:43:22 +0000216 buf += first_A + 1;
Patrik Stridvall896889f1999-05-08 12:50:36 +0000217 lstrcpynWtoA(buf, (WCHAR *) ((char *) emh + emh->offDescription+2*(first+1)),
Hidenori Takeshimae2905ea2000-03-26 14:43:22 +0000218 size - first_A - 1); /* i18n ready */
Alexandre Julliardcb10fda2000-08-06 02:41:16 +0000219 first_A += strlen(buf) + 1;
Huw D M Davies585c8461999-05-02 09:23:51 +0000220
221 EMF_ReleaseEnhMetaHeader(hmf);
Hidenori Takeshimae2905ea2000-03-26 14:43:22 +0000222 return min(size, first_A);
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000223}
224
225/*****************************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000226 * GetEnhMetaFileDescriptionW (GDI32.177)
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000227 *
228 * Copies the description string of an enhanced metafile into a buffer
229 * _buf_.
230 *
231 * If _buf_ is NULL, returns size of _buf_ required. Otherwise, returns
232 * number of characters copied.
233 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000234UINT WINAPI GetEnhMetaFileDescriptionW(
235 HENHMETAFILE hmf, /* enhanced metafile */
236 UINT size, /* size of buf */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000237 LPWSTR buf /* buffer to receive description */
238 )
239{
Huw D M Davies585c8461999-05-02 09:23:51 +0000240 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf);
Huw D M Davies0ae4e091999-06-12 06:49:52 +0000241
242 if(!emh) return FALSE;
Huw D M Davies585c8461999-05-02 09:23:51 +0000243 if(emh->nDescription == 0 || emh->offDescription == 0) {
244 EMF_ReleaseEnhMetaHeader(hmf);
245 return 0;
246 }
247 if (!buf || !size ) {
248 EMF_ReleaseEnhMetaHeader(hmf);
249 return emh->nDescription;
250 }
251
Patrik Stridvall896889f1999-05-08 12:50:36 +0000252 memmove(buf, (char *) emh + emh->offDescription,
Francois Gouget6d77d3a2000-03-25 21:44:35 +0000253 min(size,emh->nDescription));
Huw D M Davies585c8461999-05-02 09:23:51 +0000254 EMF_ReleaseEnhMetaHeader(hmf);
Francois Gouget6d77d3a2000-03-25 21:44:35 +0000255 return min(size, emh->nDescription);
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000256}
257
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000258/****************************************************************************
259 * SetEnhMetaFileBits (GDI32.315)
260 *
261 * Creates an enhanced metafile by copying _bufsize_ bytes from _buf_.
262 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000263HENHMETAFILE WINAPI SetEnhMetaFileBits(UINT bufsize, const BYTE *buf)
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000264{
Alexandre Julliard90476d62000-02-16 22:47:24 +0000265 ENHMETAHEADER *emh = HeapAlloc( GetProcessHeap(), 0, bufsize );
Huw D M Davies585c8461999-05-02 09:23:51 +0000266 memmove(emh, buf, bufsize);
267 return EMF_Create_HENHMETAFILE( emh, 0, 0 );
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000268}
269
270/*****************************************************************************
271 * GetEnhMetaFileBits (GDI32.175)
272 *
273 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000274UINT WINAPI GetEnhMetaFileBits(
275 HENHMETAFILE hmf,
276 UINT bufsize,
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000277 LPBYTE buf
Peter Hunnisettc821a751999-12-04 03:56:53 +0000278)
279{
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000280 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader( hmf );
281 UINT size;
Peter Hunnisettc821a751999-12-04 03:56:53 +0000282
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000283 if(!emh) return 0;
Peter Hunnisettc821a751999-12-04 03:56:53 +0000284
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000285 size = emh->nBytes;
286 if( buf == NULL ) {
287 EMF_ReleaseEnhMetaHeader( hmf );
288 return size;
289 }
Peter Hunnisettc821a751999-12-04 03:56:53 +0000290
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000291 size = min( size, bufsize );
292 memmove(buf, emh, size);
Peter Hunnisettc821a751999-12-04 03:56:53 +0000293
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +0000294 EMF_ReleaseEnhMetaHeader( hmf );
295 return size;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000296}
297
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000298/*****************************************************************************
299 * PlayEnhMetaFileRecord (GDI32.264)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000300 *
301 * Render a single enhanced metafile record in the device context hdc.
302 *
303 * RETURNS
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000304 * TRUE (non zero) on success, FALSE on error.
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000305 * BUGS
Alexandre Julliard54c27111998-03-29 19:44:57 +0000306 * Many unimplemented records.
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000307 * No error handling on record play failures (ie checking return codes)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000308 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000309BOOL WINAPI PlayEnhMetaFileRecord(
310 HDC hdc, /* device context in which to render EMF record */
311 LPHANDLETABLE handletable, /* array of handles to be used in rendering record */
Alexandre Julliard54c27111998-03-29 19:44:57 +0000312 const ENHMETARECORD *mr, /* EMF record to render */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000313 UINT handles /* size of handle array */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000314 )
315{
316 int type;
Alexandre Julliard15657091999-05-23 10:25:25 +0000317 TRACE(
Alexandre Julliard54c27111998-03-29 19:44:57 +0000318 "hdc = %08x, handletable = %p, record = %p, numHandles = %d\n",
319 hdc, handletable, mr, handles);
320 if (!mr) return FALSE;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000321
Alexandre Julliard54c27111998-03-29 19:44:57 +0000322 type = mr->iType;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000323
Alexandre Julliard15657091999-05-23 10:25:25 +0000324 TRACE(" type=%d\n", type);
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000325 switch(type)
326 {
327 case EMR_HEADER:
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000328 break;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000329 case EMR_EOF:
Alexandre Julliard54c27111998-03-29 19:44:57 +0000330 break;
Alexandre Julliard54c27111998-03-29 19:44:57 +0000331 case EMR_GDICOMMENT:
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000332 {
333 PEMRGDICOMMENT lpGdiComment = (PEMRGDICOMMENT)mr;
334 /* In an enhanced metafile, there can be both public and private GDI comments */
335 GdiComment( hdc, lpGdiComment->cbData, lpGdiComment->Data );
336 break;
337 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000338 case EMR_SETMAPMODE:
339 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000340 PEMRSETMAPMODE pSetMapMode = (PEMRSETMAPMODE) mr;
341 SetMapMode(hdc, pSetMapMode->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000342 break;
343 }
344 case EMR_SETBKMODE:
345 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000346 PEMRSETBKMODE pSetBkMode = (PEMRSETBKMODE) mr;
347 SetBkMode(hdc, pSetBkMode->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000348 break;
349 }
350 case EMR_SETBKCOLOR:
351 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000352 PEMRSETBKCOLOR pSetBkColor = (PEMRSETBKCOLOR) mr;
353 SetBkColor(hdc, pSetBkColor->crColor);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000354 break;
355 }
356 case EMR_SETPOLYFILLMODE:
357 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000358 PEMRSETPOLYFILLMODE pSetPolyFillMode = (PEMRSETPOLYFILLMODE) mr;
359 SetPolyFillMode(hdc, pSetPolyFillMode->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000360 break;
361 }
362 case EMR_SETROP2:
363 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000364 PEMRSETROP2 pSetROP2 = (PEMRSETROP2) mr;
365 SetROP2(hdc, pSetROP2->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000366 break;
367 }
368 case EMR_SETSTRETCHBLTMODE:
369 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000370 PEMRSETSTRETCHBLTMODE pSetStretchBltMode = (PEMRSETSTRETCHBLTMODE) mr;
371 SetStretchBltMode(hdc, pSetStretchBltMode->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000372 break;
373 }
374 case EMR_SETTEXTALIGN:
375 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000376 PEMRSETTEXTALIGN pSetTextAlign = (PEMRSETTEXTALIGN) mr;
377 SetTextAlign(hdc, pSetTextAlign->iMode);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000378 break;
379 }
380 case EMR_SETTEXTCOLOR:
381 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000382 PEMRSETTEXTCOLOR pSetTextColor = (PEMRSETTEXTCOLOR) mr;
383 SetTextColor(hdc, pSetTextColor->crColor);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000384 break;
385 }
386 case EMR_SAVEDC:
387 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000388 SaveDC(hdc);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000389 break;
390 }
391 case EMR_RESTOREDC:
392 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000393 PEMRRESTOREDC pRestoreDC = (PEMRRESTOREDC) mr;
394 RestoreDC(hdc, pRestoreDC->iRelative);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000395 break;
396 }
397 case EMR_INTERSECTCLIPRECT:
398 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000399 PEMRINTERSECTCLIPRECT pClipRect = (PEMRINTERSECTCLIPRECT) mr;
400 IntersectClipRect(hdc, pClipRect->rclClip.left, pClipRect->rclClip.top,
401 pClipRect->rclClip.right, pClipRect->rclClip.bottom);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000402 break;
403 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000404 case EMR_SELECTOBJECT:
405 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000406 PEMRSELECTOBJECT pSelectObject = (PEMRSELECTOBJECT) mr;
407 if( pSelectObject->ihObject & 0x80000000 ) {
408 /* High order bit is set - it's a stock object
409 * Strip the high bit to get the index.
410 * See MSDN article Q142319
411 */
412 SelectObject( hdc, GetStockObject( pSelectObject->ihObject &
413 0x7fffffff ) );
414 } else {
415 /* High order bit wasn't set - not a stock object
416 */
417 SelectObject( hdc,
418 (handletable->objectHandle)[pSelectObject->ihObject] );
419 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000420 break;
421 }
422 case EMR_DELETEOBJECT:
423 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000424 PEMRDELETEOBJECT pDeleteObject = (PEMRDELETEOBJECT) mr;
425 DeleteObject( (handletable->objectHandle)[pDeleteObject->ihObject]);
426 (handletable->objectHandle)[pDeleteObject->ihObject] = 0;
Alexandre Julliard54c27111998-03-29 19:44:57 +0000427 break;
428 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000429 case EMR_SETWINDOWORGEX:
430 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000431 PEMRSETWINDOWORGEX pSetWindowOrgEx = (PEMRSETWINDOWORGEX) mr;
432 SetWindowOrgEx(hdc, pSetWindowOrgEx->ptlOrigin.x,
433 pSetWindowOrgEx->ptlOrigin.y, NULL);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000434 break;
435 }
436 case EMR_SETWINDOWEXTEX:
437 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000438 PEMRSETWINDOWEXTEX pSetWindowExtEx = (PEMRSETWINDOWEXTEX) mr;
439 SetWindowExtEx(hdc, pSetWindowExtEx->szlExtent.cx,
440 pSetWindowExtEx->szlExtent.cy, NULL);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000441 break;
442 }
443 case EMR_SETVIEWPORTORGEX:
444 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000445 PEMRSETVIEWPORTORGEX pSetViewportOrgEx = (PEMRSETVIEWPORTORGEX) mr;
446 SetViewportOrgEx(hdc, pSetViewportOrgEx->ptlOrigin.x,
447 pSetViewportOrgEx->ptlOrigin.y, NULL);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000448 break;
449 }
450 case EMR_SETVIEWPORTEXTEX:
451 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000452 PEMRSETVIEWPORTEXTEX pSetViewportExtEx = (PEMRSETVIEWPORTEXTEX) mr;
453 SetViewportExtEx(hdc, pSetViewportExtEx->szlExtent.cx,
454 pSetViewportExtEx->szlExtent.cy, NULL);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000455 break;
456 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000457 case EMR_CREATEPEN:
458 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000459 PEMRCREATEPEN pCreatePen = (PEMRCREATEPEN) mr;
460 (handletable->objectHandle)[pCreatePen->ihPen] =
461 CreatePenIndirect(&pCreatePen->lopn);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000462 break;
463 }
464 case EMR_EXTCREATEPEN:
465 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000466 PEMREXTCREATEPEN pPen = (PEMREXTCREATEPEN) mr;
467 LOGBRUSH lb;
468 lb.lbStyle = pPen->elp.elpBrushStyle;
469 lb.lbColor = pPen->elp.elpColor;
470 lb.lbHatch = pPen->elp.elpHatch;
471
472 if(pPen->offBmi || pPen->offBits)
473 FIXME("EMR_EXTCREATEPEN: Need to copy brush bitmap\n");
474
475 (handletable->objectHandle)[pPen->ihPen] =
476 ExtCreatePen(pPen->elp.elpPenStyle, pPen->elp.elpWidth, &lb,
477 pPen->elp.elpNumEntries, pPen->elp.elpStyleEntry);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000478 break;
479 }
480 case EMR_CREATEBRUSHINDIRECT:
481 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000482 PEMRCREATEBRUSHINDIRECT pBrush = (PEMRCREATEBRUSHINDIRECT) mr;
483 (handletable->objectHandle)[pBrush->ihBrush] =
484 CreateBrushIndirect(&pBrush->lb);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000485 break;
486 }
487 case EMR_EXTCREATEFONTINDIRECTW:
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000488 {
489 PEMREXTCREATEFONTINDIRECTW pFont = (PEMREXTCREATEFONTINDIRECTW) mr;
490 (handletable->objectHandle)[pFont->ihFont] =
491 CreateFontIndirectW(&pFont->elfw.elfLogFont);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000492 break;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000493 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000494 case EMR_MOVETOEX:
495 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000496 PEMRMOVETOEX pMoveToEx = (PEMRMOVETOEX) mr;
497 MoveToEx(hdc, pMoveToEx->ptl.x, pMoveToEx->ptl.y, NULL);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000498 break;
499 }
500 case EMR_LINETO:
501 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000502 PEMRLINETO pLineTo = (PEMRLINETO) mr;
503 LineTo(hdc, pLineTo->ptl.x, pLineTo->ptl.y);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000504 break;
505 }
506 case EMR_RECTANGLE:
507 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000508 PEMRRECTANGLE pRect = (PEMRRECTANGLE) mr;
509 Rectangle(hdc, pRect->rclBox.left, pRect->rclBox.top,
510 pRect->rclBox.right, pRect->rclBox.bottom);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000511 break;
512 }
513 case EMR_ELLIPSE:
514 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000515 PEMRELLIPSE pEllipse = (PEMRELLIPSE) mr;
516 Ellipse(hdc, pEllipse->rclBox.left, pEllipse->rclBox.top,
517 pEllipse->rclBox.right, pEllipse->rclBox.bottom);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000518 break;
519 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000520 case EMR_POLYGON16:
521 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000522 PEMRPOLYGON16 pPoly = (PEMRPOLYGON16) mr;
523 /* Shouldn't use Polygon16 since pPoly->cpts is DWORD */
524 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
525 pPoly->cpts * sizeof(POINT) );
526 DWORD i;
527 for(i = 0; i < pPoly->cpts; i++)
528 CONV_POINT16TO32(pPoly->apts + i, pts + i);
529 Polygon(hdc, pts, pPoly->cpts);
530 HeapFree( GetProcessHeap(), 0, pts );
Alexandre Julliard54c27111998-03-29 19:44:57 +0000531 break;
532 }
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000533 case EMR_POLYLINE16:
534 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000535 PEMRPOLYLINE16 pPoly = (PEMRPOLYLINE16) mr;
536 /* Shouldn't use Polyline16 since pPoly->cpts is DWORD */
537 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
538 pPoly->cpts * sizeof(POINT) );
539 DWORD i;
540 for(i = 0; i < pPoly->cpts; i++)
541 CONV_POINT16TO32(pPoly->apts + i, pts + i);
542 Polyline(hdc, pts, pPoly->cpts);
543 HeapFree( GetProcessHeap(), 0, pts );
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000544 break;
545 }
Huw D M Daviesc7acd782000-08-20 03:40:04 +0000546 case EMR_POLYLINETO16:
547 {
548 PEMRPOLYLINETO16 pPoly = (PEMRPOLYLINETO16) mr;
549 /* Shouldn't use PolylineTo16 since pPoly->cpts is DWORD */
550 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
551 pPoly->cpts * sizeof(POINT) );
552 DWORD i;
553 for(i = 0; i < pPoly->cpts; i++)
554 CONV_POINT16TO32(pPoly->apts + i, pts + i);
555 PolylineTo(hdc, pts, pPoly->cpts);
556 HeapFree( GetProcessHeap(), 0, pts );
557 break;
558 }
559 case EMR_POLYBEZIER16:
560 {
561 PEMRPOLYBEZIER16 pPoly = (PEMRPOLYBEZIER16) mr;
562 /* Shouldn't use PolyBezier16 since pPoly->cpts is DWORD */
563 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
564 pPoly->cpts * sizeof(POINT) );
565 DWORD i;
566 for(i = 0; i < pPoly->cpts; i++)
567 CONV_POINT16TO32(pPoly->apts + i, pts + i);
568 PolyBezier(hdc, pts, pPoly->cpts);
569 HeapFree( GetProcessHeap(), 0, pts );
570 break;
571 }
572 case EMR_POLYBEZIERTO16:
573 {
574 PEMRPOLYBEZIERTO16 pPoly = (PEMRPOLYBEZIERTO16) mr;
575 /* Shouldn't use PolyBezierTo16 since pPoly->cpts is DWORD */
576 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
577 pPoly->cpts * sizeof(POINT) );
578 DWORD i;
579 for(i = 0; i < pPoly->cpts; i++)
580 CONV_POINT16TO32(pPoly->apts + i, pts + i);
581 PolyBezierTo(hdc, pts, pPoly->cpts);
582 HeapFree( GetProcessHeap(), 0, pts );
583 break;
584 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000585 case EMR_POLYPOLYGON16:
586 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000587 PEMRPOLYPOLYGON16 pPolyPoly = (PEMRPOLYPOLYGON16) mr;
588 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
589 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000590
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000591 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
592 pPolyPoly->cpts * sizeof(POINT) );
593 DWORD i;
594 for(i = 0; i < pPolyPoly->cpts; i++)
595 CONV_POINT16TO32((POINTS*) (pPolyPoly->aPolyCounts +
596 pPolyPoly->nPolys) + i, pts + i);
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000597
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000598 PolyPolygon(hdc, pts, (INT*)pPolyPoly->aPolyCounts, pPolyPoly->nPolys);
599 HeapFree( GetProcessHeap(), 0, pts );
Alexandre Julliard54c27111998-03-29 19:44:57 +0000600 break;
601 }
Huw D M Daviesc7acd782000-08-20 03:40:04 +0000602 case EMR_POLYPOLYLINE16:
603 {
604 PEMRPOLYPOLYLINE16 pPolyPoly = (PEMRPOLYPOLYLINE16) mr;
605 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
606 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
607
608 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
609 pPolyPoly->cpts * sizeof(POINT) );
610 DWORD i;
611 for(i = 0; i < pPolyPoly->cpts; i++)
612 CONV_POINT16TO32((POINTS*) (pPolyPoly->aPolyCounts +
613 pPolyPoly->nPolys) + i, pts + i);
614
615 PolyPolyline(hdc, pts, pPolyPoly->aPolyCounts, pPolyPoly->nPolys);
616 HeapFree( GetProcessHeap(), 0, pts );
617 break;
618 }
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000619
Jason McMullane113b091999-02-09 14:08:57 +0000620 case EMR_STRETCHDIBITS:
621 {
622 LONG xDest = mr->dParm[4];
623 LONG yDest = mr->dParm[5];
624 LONG xSrc = mr->dParm[6];
625 LONG ySrc = mr->dParm[7];
626 LONG cxSrc = mr->dParm[8];
627 LONG cySrc = mr->dParm[9];
628 DWORD offBmiSrc = mr->dParm[10];
629 DWORD offBitsSrc = mr->dParm[12];
630 DWORD iUsageSrc = mr->dParm[14];
631 DWORD dwRop = mr->dParm[15];
632 LONG cxDest = mr->dParm[16];
633 LONG cyDest = mr->dParm[17];
634
Alexandre Julliarda3960291999-02-26 11:11:13 +0000635 StretchDIBits(hdc,xDest,yDest,cxDest,cyDest,
Jason McMullane113b091999-02-09 14:08:57 +0000636 xSrc,ySrc,cxSrc,cySrc,
637 ((char *)mr)+offBitsSrc,
638 (const BITMAPINFO *)(((char *)mr)+offBmiSrc),
639 iUsageSrc,dwRop);
640 break;
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000641 }
Alexandre Julliard54c27111998-03-29 19:44:57 +0000642 case EMR_EXTTEXTOUTW:
643 {
644 /* 0-3: ??? */
645 DWORD flags = mr->dParm[4];
646 /* 5, 6: ??? */
647 DWORD x = mr->dParm[7], y = mr->dParm[8];
648 DWORD count = mr->dParm[9];
649 /* 10-16: ??? */
650 LPWSTR str = (LPWSTR)& mr->dParm[17];
651 /* trailing info: dx array? */
Alexandre Julliard15657091999-05-23 10:25:25 +0000652 FIXME("Many ExtTextOut args not handled\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +0000653 ExtTextOutW(hdc, x, y, flags, /* lpRect */ NULL,
Alexandre Julliard54c27111998-03-29 19:44:57 +0000654 str, count, /* lpDx */ NULL);
655 break;
656 }
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000657
658 case EMR_CREATEPALETTE:
659 {
660 PEMRCREATEPALETTE lpCreatePal = (PEMRCREATEPALETTE)mr;
Alexandre Julliard54c27111998-03-29 19:44:57 +0000661
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000662 (handletable->objectHandle)[ lpCreatePal->ihPal ] =
663 CreatePalette( &lpCreatePal->lgpl );
664
665 break;
666 }
667
668 case EMR_SELECTPALETTE:
669 {
670 PEMRSELECTPALETTE lpSelectPal = (PEMRSELECTPALETTE)mr;
671
672 /* FIXME: Should this be forcing background mode? */
673 (handletable->objectHandle)[ lpSelectPal->ihPal ] =
674 SelectPalette( hdc, lpSelectPal->ihPal, FALSE );
675 break;
676 }
677
678 case EMR_REALIZEPALETTE:
679 {
680 RealizePalette( hdc );
681 break;
682 }
683
684#if 0
685 case EMR_EXTSELECTCLIPRGN:
686 {
687 PEMREXTSELECTCLIPRGN lpRgn = (PEMREXTSELECTCLIPRGN)mr;
688
689 /* Need to make a region out of the RGNDATA we have */
690 ExtSelectClipRgn( hdc, ..., (INT)(lpRgn->iMode) );
691
692 }
693#endif
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000694
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000695 case EMR_SETMETARGN:
696 {
697 SetMetaRgn( hdc );
698 break;
699 }
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000700
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000701 case EMR_SETWORLDTRANSFORM:
702 {
703 PEMRSETWORLDTRANSFORM lpXfrm = (PEMRSETWORLDTRANSFORM)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000704
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000705 SetWorldTransform( hdc, &lpXfrm->xform );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000706
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000707 break;
708 }
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000709
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000710 case EMR_POLYBEZIER:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000711 {
712 PEMRPOLYBEZIER lpPolyBez = (PEMRPOLYBEZIER)mr;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000713 PolyBezier(hdc, (const LPPOINT)lpPolyBez->aptl, (UINT)lpPolyBez->cptl);
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000714 break;
715 }
716
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000717 case EMR_POLYGON:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000718 {
719 PEMRPOLYGON lpPoly = (PEMRPOLYGON)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000720 Polygon( hdc, (const LPPOINT)lpPoly->aptl, (UINT)lpPoly->cptl );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000721 break;
722 }
723
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000724 case EMR_POLYLINE:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000725 {
726 PEMRPOLYLINE lpPolyLine = (PEMRPOLYLINE)mr;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000727 Polyline(hdc, (const LPPOINT)lpPolyLine->aptl, (UINT)lpPolyLine->cptl);
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000728 break;
729 }
730
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000731 case EMR_POLYBEZIERTO:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000732 {
733 PEMRPOLYBEZIERTO lpPolyBezierTo = (PEMRPOLYBEZIERTO)mr;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000734 PolyBezierTo( hdc, (const LPPOINT)lpPolyBezierTo->aptl,
735 (UINT)lpPolyBezierTo->cptl );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000736 break;
737 }
738
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000739 case EMR_POLYLINETO:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000740 {
741 PEMRPOLYLINETO lpPolyLineTo = (PEMRPOLYLINETO)mr;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000742 PolylineTo( hdc, (const LPPOINT)lpPolyLineTo->aptl,
743 (UINT)lpPolyLineTo->cptl );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000744 break;
745 }
746
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000747 case EMR_POLYPOLYLINE:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000748 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000749 PEMRPOLYPOLYLINE pPolyPolyline = (PEMRPOLYPOLYLINE) mr;
750 /* NB Points at pPolyPolyline->aPolyCounts + pPolyPolyline->nPolys */
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000751
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000752 PolyPolyline(hdc, (LPPOINT)(pPolyPolyline->aPolyCounts +
753 pPolyPolyline->nPolys),
754 pPolyPolyline->aPolyCounts,
755 pPolyPolyline->nPolys );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000756
757 break;
758 }
759
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000760 case EMR_POLYPOLYGON:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000761 {
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000762 PEMRPOLYPOLYGON pPolyPolygon = (PEMRPOLYPOLYGON) mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000763
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000764 /* NB Points at pPolyPolygon->aPolyCounts + pPolyPolygon->nPolys */
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000765
Huw D M Daviesc9315fe2000-04-18 11:52:58 +0000766 PolyPolygon(hdc, (LPPOINT)(pPolyPolygon->aPolyCounts +
767 pPolyPolygon->nPolys),
768 (INT*)pPolyPolygon->aPolyCounts, pPolyPolygon->nPolys );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000769 break;
770 }
771
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000772 case EMR_SETBRUSHORGEX:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000773 {
774 PEMRSETBRUSHORGEX lpSetBrushOrgEx = (PEMRSETBRUSHORGEX)mr;
775
776 SetBrushOrgEx( hdc,
777 (INT)lpSetBrushOrgEx->ptlOrigin.x,
778 (INT)lpSetBrushOrgEx->ptlOrigin.y,
779 NULL );
780
781 break;
782 }
783
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000784 case EMR_SETPIXELV:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000785 {
786 PEMRSETPIXELV lpSetPixelV = (PEMRSETPIXELV)mr;
787
788 SetPixelV( hdc,
789 (INT)lpSetPixelV->ptlPixel.x,
790 (INT)lpSetPixelV->ptlPixel.y,
791 lpSetPixelV->crColor );
792
793 break;
794 }
795
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000796 case EMR_SETMAPPERFLAGS:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000797 {
798 PEMRSETMAPPERFLAGS lpSetMapperFlags = (PEMRSETMAPPERFLAGS)mr;
799
800 SetMapperFlags( hdc, lpSetMapperFlags->dwFlags );
801
802 break;
803 }
804
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000805 case EMR_SETCOLORADJUSTMENT:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000806 {
807 PEMRSETCOLORADJUSTMENT lpSetColorAdjust = (PEMRSETCOLORADJUSTMENT)mr;
808
809 SetColorAdjustment( hdc, &lpSetColorAdjust->ColorAdjustment );
810
811 break;
812 }
813
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000814 case EMR_OFFSETCLIPRGN:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000815 {
816 PEMROFFSETCLIPRGN lpOffsetClipRgn = (PEMROFFSETCLIPRGN)mr;
817
818 OffsetClipRgn( hdc,
819 (INT)lpOffsetClipRgn->ptlOffset.x,
820 (INT)lpOffsetClipRgn->ptlOffset.y );
821
822 break;
823 }
824
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000825 case EMR_EXCLUDECLIPRECT:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000826 {
827 PEMREXCLUDECLIPRECT lpExcludeClipRect = (PEMREXCLUDECLIPRECT)mr;
828
829 ExcludeClipRect( hdc,
830 lpExcludeClipRect->rclClip.left,
831 lpExcludeClipRect->rclClip.top,
832 lpExcludeClipRect->rclClip.right,
833 lpExcludeClipRect->rclClip.bottom );
834
835 break;
836 }
837
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000838 case EMR_SCALEVIEWPORTEXTEX:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000839 {
840 PEMRSCALEVIEWPORTEXTEX lpScaleViewportExtEx = (PEMRSCALEVIEWPORTEXTEX)mr;
841
842 ScaleViewportExtEx( hdc,
843 lpScaleViewportExtEx->xNum,
844 lpScaleViewportExtEx->xDenom,
845 lpScaleViewportExtEx->yNum,
846 lpScaleViewportExtEx->yDenom,
847 NULL );
848
849 break;
850 }
851
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000852 case EMR_SCALEWINDOWEXTEX:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000853 {
854 PEMRSCALEWINDOWEXTEX lpScaleWindowExtEx = (PEMRSCALEWINDOWEXTEX)mr;
855
856 ScaleWindowExtEx( hdc,
857 lpScaleWindowExtEx->xNum,
858 lpScaleWindowExtEx->xDenom,
859 lpScaleWindowExtEx->yNum,
860 lpScaleWindowExtEx->yDenom,
861 NULL );
862
863 break;
864 }
865
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000866 case EMR_MODIFYWORLDTRANSFORM:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000867 {
868 PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans = (PEMRMODIFYWORLDTRANSFORM)mr;
869
870 ModifyWorldTransform( hdc, &lpModifyWorldTrans->xform,
871 lpModifyWorldTrans->iMode );
872
873 break;
874 }
875
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000876 case EMR_ANGLEARC:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000877 {
878 PEMRANGLEARC lpAngleArc = (PEMRANGLEARC)mr;
879
880 AngleArc( hdc,
881 (INT)lpAngleArc->ptlCenter.x, (INT)lpAngleArc->ptlCenter.y,
882 lpAngleArc->nRadius, lpAngleArc->eStartAngle,
883 lpAngleArc->eSweepAngle );
884
885 break;
886 }
887
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000888 case EMR_ROUNDRECT:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000889 {
890 PEMRROUNDRECT lpRoundRect = (PEMRROUNDRECT)mr;
891
892 RoundRect( hdc,
893 lpRoundRect->rclBox.left,
894 lpRoundRect->rclBox.top,
895 lpRoundRect->rclBox.right,
896 lpRoundRect->rclBox.bottom,
897 lpRoundRect->szlCorner.cx,
898 lpRoundRect->szlCorner.cy );
899
900 break;
901 }
902
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000903 case EMR_ARC:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000904 {
905 PEMRARC lpArc = (PEMRARC)mr;
906
907 Arc( hdc,
908 (INT)lpArc->rclBox.left,
909 (INT)lpArc->rclBox.top,
910 (INT)lpArc->rclBox.right,
911 (INT)lpArc->rclBox.bottom,
912 (INT)lpArc->ptlStart.x,
913 (INT)lpArc->ptlStart.y,
914 (INT)lpArc->ptlEnd.x,
915 (INT)lpArc->ptlEnd.y );
916
917 break;
918 }
919
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000920 case EMR_CHORD:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000921 {
922 PEMRCHORD lpChord = (PEMRCHORD)mr;
923
924 Chord( hdc,
925 (INT)lpChord->rclBox.left,
926 (INT)lpChord->rclBox.top,
927 (INT)lpChord->rclBox.right,
928 (INT)lpChord->rclBox.bottom,
929 (INT)lpChord->ptlStart.x,
930 (INT)lpChord->ptlStart.y,
931 (INT)lpChord->ptlEnd.x,
932 (INT)lpChord->ptlEnd.y );
933
934 break;
935 }
936
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000937 case EMR_PIE:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000938 {
939 PEMRPIE lpPie = (PEMRPIE)mr;
940
941 Pie( hdc,
942 (INT)lpPie->rclBox.left,
943 (INT)lpPie->rclBox.top,
944 (INT)lpPie->rclBox.right,
945 (INT)lpPie->rclBox.bottom,
946 (INT)lpPie->ptlStart.x,
947 (INT)lpPie->ptlStart.y,
948 (INT)lpPie->ptlEnd.x,
949 (INT)lpPie->ptlEnd.y );
950
951 break;
952 }
953
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000954 case EMR_ARCTO:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000955 {
956 PEMRARC lpArcTo = (PEMRARC)mr;
957
958 ArcTo( hdc,
959 (INT)lpArcTo->rclBox.left,
960 (INT)lpArcTo->rclBox.top,
961 (INT)lpArcTo->rclBox.right,
962 (INT)lpArcTo->rclBox.bottom,
963 (INT)lpArcTo->ptlStart.x,
964 (INT)lpArcTo->ptlStart.y,
965 (INT)lpArcTo->ptlEnd.x,
966 (INT)lpArcTo->ptlEnd.y );
967
968 break;
969 }
970
971 case EMR_EXTFLOODFILL:
972 {
973 PEMREXTFLOODFILL lpExtFloodFill = (PEMREXTFLOODFILL)mr;
974
975 ExtFloodFill( hdc,
976 (INT)lpExtFloodFill->ptlStart.x,
977 (INT)lpExtFloodFill->ptlStart.y,
978 lpExtFloodFill->crColor,
979 (UINT)lpExtFloodFill->iMode );
980
981 break;
982 }
983
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000984 case EMR_POLYDRAW:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000985 {
986 PEMRPOLYDRAW lpPolyDraw = (PEMRPOLYDRAW)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000987 PolyDraw( hdc,
988 (const LPPOINT)lpPolyDraw->aptl,
989 lpPolyDraw->abTypes,
990 (INT)lpPolyDraw->cptl );
991
992 break;
993 }
994
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +0000995 case EMR_SETARCDIRECTION:
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000996 {
997 PEMRSETARCDIRECTION lpSetArcDirection = (PEMRSETARCDIRECTION)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000998 SetArcDirection( hdc, (INT)lpSetArcDirection->iArcDirection );
Peter Hunnisett27548ee1999-12-25 22:58:59 +0000999 break;
1000 }
1001
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001002 case EMR_SETMITERLIMIT:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001003 {
1004 PEMRSETMITERLIMIT lpSetMiterLimit = (PEMRSETMITERLIMIT)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001005 SetMiterLimit( hdc, lpSetMiterLimit->eMiterLimit, NULL );
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001006 break;
1007 }
1008
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001009 case EMR_BEGINPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001010 {
1011 BeginPath( hdc );
1012 break;
1013 }
1014
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001015 case EMR_ENDPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001016 {
1017 EndPath( hdc );
1018 break;
1019 }
1020
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001021 case EMR_CLOSEFIGURE:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001022 {
1023 CloseFigure( hdc );
1024 break;
1025 }
1026
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001027 case EMR_FILLPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001028 {
1029 /*PEMRFILLPATH lpFillPath = (PEMRFILLPATH)mr;*/
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001030 FillPath( hdc );
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001031 break;
1032 }
1033
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001034 case EMR_STROKEANDFILLPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001035 {
1036 /*PEMRSTROKEANDFILLPATH lpStrokeAndFillPath = (PEMRSTROKEANDFILLPATH)mr;*/
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001037 StrokeAndFillPath( hdc );
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001038 break;
1039 }
1040
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001041 case EMR_STROKEPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001042 {
1043 /*PEMRSTROKEPATH lpStrokePath = (PEMRSTROKEPATH)mr;*/
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001044 StrokePath( hdc );
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001045 break;
1046 }
1047
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001048 case EMR_FLATTENPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001049 {
1050 FlattenPath( hdc );
1051 break;
1052 }
1053
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001054 case EMR_WIDENPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001055 {
1056 WidenPath( hdc );
1057 break;
1058 }
1059
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001060 case EMR_SELECTCLIPPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001061 {
1062 PEMRSELECTCLIPPATH lpSelectClipPath = (PEMRSELECTCLIPPATH)mr;
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001063 SelectClipPath( hdc, (INT)lpSelectClipPath->iMode );
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001064 break;
1065 }
1066
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001067 case EMR_ABORTPATH:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001068 {
1069 AbortPath( hdc );
1070 break;
1071 }
1072
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001073 case EMR_CREATECOLORSPACE:
1074 {
1075 PEMRCREATECOLORSPACE lpCreateColorSpace = (PEMRCREATECOLORSPACE)mr;
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001076 (handletable->objectHandle)[lpCreateColorSpace->ihCS] =
1077 CreateColorSpaceA( &lpCreateColorSpace->lcs );
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001078 break;
1079 }
1080
1081 case EMR_SETCOLORSPACE:
1082 {
1083 PEMRSETCOLORSPACE lpSetColorSpace = (PEMRSETCOLORSPACE)mr;
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001084 SetColorSpace( hdc,
1085 (handletable->objectHandle)[lpSetColorSpace->ihCS] );
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001086 break;
1087 }
1088
1089 case EMR_DELETECOLORSPACE:
1090 {
1091 PEMRDELETECOLORSPACE lpDeleteColorSpace = (PEMRDELETECOLORSPACE)mr;
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001092 DeleteColorSpace( (handletable->objectHandle)[lpDeleteColorSpace->ihCS] );
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001093 break;
1094 }
1095
1096 case EMR_SETICMMODE:
1097 {
1098 PERMSETICMMODE lpSetICMMode = (PERMSETICMMODE)mr;
Huw D M Daviesc9315fe2000-04-18 11:52:58 +00001099 SetICMMode( hdc, (INT)lpSetICMMode->iMode );
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001100 break;
1101 }
1102
1103 case EMR_PIXELFORMAT:
1104 {
1105 INT iPixelFormat;
1106 PEMRPIXELFORMAT lpPixelFormat = (PEMRPIXELFORMAT)mr;
1107
1108 iPixelFormat = ChoosePixelFormat( hdc, &lpPixelFormat->pfd );
1109 SetPixelFormat( hdc, iPixelFormat, &lpPixelFormat->pfd );
1110
1111 break;
1112 }
1113
1114 case EMR_SETPALETTEENTRIES:
1115 {
1116 PEMRSETPALETTEENTRIES lpSetPaletteEntries = (PEMRSETPALETTEENTRIES)mr;
1117
1118 SetPaletteEntries( (handletable->objectHandle)[lpSetPaletteEntries->ihPal],
1119 (UINT)lpSetPaletteEntries->iStart,
1120 (UINT)lpSetPaletteEntries->cEntries,
1121 lpSetPaletteEntries->aPalEntries );
1122
1123 break;
1124 }
1125
1126 case EMR_RESIZEPALETTE:
1127 {
1128 PEMRRESIZEPALETTE lpResizePalette = (PEMRRESIZEPALETTE)mr;
1129
1130 ResizePalette( (handletable->objectHandle)[lpResizePalette->ihPal],
1131 (UINT)lpResizePalette->cEntries );
1132
1133 break;
1134 }
1135
1136 case EMR_CREATEDIBPATTERNBRUSHPT:
1137 {
1138 PEMRCREATEDIBPATTERNBRUSHPT lpCreate = (PEMRCREATEDIBPATTERNBRUSHPT)mr;
1139
1140 /* This is a BITMAPINFO struct followed directly by bitmap bits */
1141 LPVOID lpPackedStruct = HeapAlloc( GetProcessHeap(),
1142 0,
1143 lpCreate->cbBmi + lpCreate->cbBits );
1144 /* Now pack this structure */
1145 memcpy( lpPackedStruct,
1146 ((BYTE*)lpCreate) + lpCreate->offBmi,
1147 lpCreate->cbBmi );
1148 memcpy( ((BYTE*)lpPackedStruct) + lpCreate->cbBmi,
1149 ((BYTE*)lpCreate) + lpCreate->offBits,
1150 lpCreate->cbBits );
1151
1152 (handletable->objectHandle)[lpCreate->ihBrush] =
1153 CreateDIBPatternBrushPt( lpPackedStruct,
1154 (UINT)lpCreate->iUsage );
1155
1156 break;
1157 }
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001158
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001159 case EMR_BITBLT:
1160 case EMR_STRETCHBLT:
1161 case EMR_MASKBLT:
1162 case EMR_PLGBLT:
1163 case EMR_SETDIBITSTODEVICE:
1164 case EMR_EXTTEXTOUTA:
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001165 case EMR_POLYDRAW16:
1166 case EMR_CREATEMONOBRUSH:
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001167 case EMR_POLYTEXTOUTA:
1168 case EMR_POLYTEXTOUTW:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001169 case EMR_FILLRGN:
1170 case EMR_FRAMERGN:
1171 case EMR_INVERTRGN:
1172 case EMR_PAINTRGN:
Peter Hunnisettf2b84922000-01-15 22:17:49 +00001173 case EMR_GLSRECORD:
1174 case EMR_GLSBOUNDEDRECORD:
Alexandre Julliard54c27111998-03-29 19:44:57 +00001175 default:
Peter Hunnisett27548ee1999-12-25 22:58:59 +00001176 /* From docs: If PlayEnhMetaFileRecord doesn't recognize a
1177 record then ignore and return TRUE. */
Alexandre Julliard15657091999-05-23 10:25:25 +00001178 FIXME("type %d is unimplemented\n", type);
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001179 break;
1180 }
Alexandre Julliard54c27111998-03-29 19:44:57 +00001181 return TRUE;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001182}
1183
1184
1185/*****************************************************************************
1186 *
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001187 * EnumEnhMetaFile (GDI32.79)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001188 *
1189 * Walk an enhanced metafile, calling a user-specified function _EnhMetaFunc_
1190 * for each
1191 * record. Returns when either every record has been used or
1192 * when _EnhMetaFunc_ returns FALSE.
1193 *
1194 *
1195 * RETURNS
1196 * TRUE if every record is used, FALSE if any invocation of _EnhMetaFunc_
1197 * returns FALSE.
1198 *
1199 * BUGS
Alexandre Julliard54c27111998-03-29 19:44:57 +00001200 * Ignores rect.
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001201 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001202BOOL WINAPI EnumEnhMetaFile(
1203 HDC hdc, /* device context to pass to _EnhMetaFunc_ */
1204 HENHMETAFILE hmf, /* EMF to walk */
1205 ENHMFENUMPROC callback, /* callback function */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001206 LPVOID data, /* optional data for callback function */
Huw D M Davies280aeb92000-03-30 20:22:41 +00001207 const RECT *lpRect /* bounding rectangle for rendered metafile */
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001208 )
1209{
Huw D M Davies585c8461999-05-02 09:23:51 +00001210 BOOL ret = TRUE;
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001211 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf);
Huw D M Davies280aeb92000-03-30 20:22:41 +00001212 INT count, i;
Huw D M Davies0ae4e091999-06-12 06:49:52 +00001213 HANDLETABLE *ht;
Huw D M Davies585c8461999-05-02 09:23:51 +00001214 INT savedMode = 0;
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001215 FLOAT xSrcPixSize, ySrcPixSize, xscale, yscale;
1216 XFORM savedXform, xform;
Huw D M Davies0ae4e091999-06-12 06:49:52 +00001217
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001218 if(!emh) {
1219 SetLastError(ERROR_INVALID_HANDLE);
1220 return FALSE;
1221 }
1222 if(!lpRect) {
1223 SetLastError(ERROR_INVALID_PARAMETER);
1224 return FALSE;
1225 }
1226 count = emh->nHandles;
Huw D M Davies280aeb92000-03-30 20:22:41 +00001227 ht = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
1228 sizeof(HANDLETABLE) * count );
1229 ht->objectHandle[0] = hmf;
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001230
1231 xSrcPixSize = (FLOAT) emh->szlMillimeters.cx / emh->szlDevice.cx;
1232 ySrcPixSize = (FLOAT) emh->szlMillimeters.cy / emh->szlDevice.cy;
1233 xscale = (FLOAT)(lpRect->right - lpRect->left) * 100.0 /
1234 (emh->rclFrame.right - emh->rclFrame.left) * xSrcPixSize;
1235 yscale = (FLOAT)(lpRect->bottom - lpRect->top) * 100.0 /
1236 (emh->rclFrame.bottom - emh->rclFrame.top) * ySrcPixSize;
1237
1238 xform.eM11 = xscale;
1239 xform.eM12 = 0;
1240 xform.eM21 = 0;
1241 xform.eM22 = yscale;
1242 if(emh->rclFrame.left || emh->rclFrame.top)
1243 FIXME("Can't cope with nonzero rclFrame origin yet\n");
1244 /* eDx = lpRect->left - (lpRect width) / (rclFrame width) * rclFrame.left ? */
1245 xform.eDx = lpRect->left;
1246 xform.eDy = lpRect->top;
1247 savedMode = SetGraphicsMode(hdc, GM_ADVANCED);
1248 GetWorldTransform(hdc, &savedXform);
1249 if (!ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY)) {
1250 ERR("World transform failed!\n");
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001251 }
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001252
Huw D M Davies280aeb92000-03-30 20:22:41 +00001253 while (ret) {
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001254 ret = (*callback)(hdc, ht, (LPENHMETARECORD) emh, count, data);
1255 if (emh->iType == EMR_EOF) break;
1256 emh = (LPENHMETAHEADER) ((char *) emh + emh->nSize);
Huw D M Davies585c8461999-05-02 09:23:51 +00001257 }
Huw D M Davies280aeb92000-03-30 20:22:41 +00001258 for(i = 1; i < count; i++) /* Don't delete element 0 (hmf) */
1259 if( (ht->objectHandle)[i] )
1260 DeleteObject( (ht->objectHandle)[i] );
Huw D M Davies585c8461999-05-02 09:23:51 +00001261 HeapFree( GetProcessHeap(), 0, ht );
1262 EMF_ReleaseEnhMetaHeader(hmf);
Huw D M Davies2cf4ebc2000-04-13 15:57:34 +00001263 SetWorldTransform(hdc, &savedXform);
Huw D M Davies585c8461999-05-02 09:23:51 +00001264 if (savedMode) SetGraphicsMode(hdc, savedMode);
Huw D M Davies585c8461999-05-02 09:23:51 +00001265 return ret;
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001266}
1267
Huw D M Davies280aeb92000-03-30 20:22:41 +00001268static INT CALLBACK EMF_PlayEnhMetaFileCallback(HDC hdc, HANDLETABLE *ht,
1269 ENHMETARECORD *emr,
1270 INT handles, LPVOID data)
1271{
1272 return PlayEnhMetaFileRecord(hdc, ht, emr, handles);
1273}
1274
1275/**************************************************************************
1276 * PlayEnhMetaFile (GDI32.263)
1277 *
1278 * Renders an enhanced metafile into a specified rectangle *lpRect
1279 * in device context hdc.
1280 *
1281 */
1282BOOL WINAPI PlayEnhMetaFile(
1283 HDC hdc, /* DC to render into */
1284 HENHMETAFILE hmf, /* metafile to render */
1285 const RECT *lpRect /* rectangle to place metafile inside */
1286 )
1287{
1288 return EnumEnhMetaFile(hdc, hmf, EMF_PlayEnhMetaFileCallback, NULL,
1289 lpRect);
1290}
1291
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001292/*****************************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001293 * DeleteEnhMetaFile (GDI32.68)
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001294 *
1295 * Deletes an enhanced metafile and frees the associated storage.
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001296 */
Huw D M Davies585c8461999-05-02 09:23:51 +00001297BOOL WINAPI DeleteEnhMetaFile(HENHMETAFILE hmf)
1298{
1299 return EMF_Delete_HENHMETAFILE( hmf );
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001300}
1301
1302/*****************************************************************************
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001303 * CopyEnhMetaFileA (GDI32.21) Duplicate an enhanced metafile
1304 *
1305 *
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001306 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001307HENHMETAFILE WINAPI CopyEnhMetaFileA(
Huw D M Davies585c8461999-05-02 09:23:51 +00001308 HENHMETAFILE hmfSrc,
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001309 LPCSTR file)
1310{
Huw D M Davies585c8461999-05-02 09:23:51 +00001311 ENHMETAHEADER *emrSrc = EMF_GetEnhMetaHeader( hmfSrc ), *emrDst;
1312 HENHMETAFILE hmfDst;
1313
Huw D M Davies0ae4e091999-06-12 06:49:52 +00001314 if(!emrSrc) return FALSE;
Huw D M Davies585c8461999-05-02 09:23:51 +00001315 if (!file) {
Alexandre Julliard90476d62000-02-16 22:47:24 +00001316 emrDst = HeapAlloc( GetProcessHeap(), 0, emrSrc->nBytes );
Huw D M Davies585c8461999-05-02 09:23:51 +00001317 memcpy( emrDst, emrSrc, emrSrc->nBytes );
1318 hmfDst = EMF_Create_HENHMETAFILE( emrDst, 0, 0 );
1319 } else {
1320 HFILE hFile;
1321 hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, NULL,
1322 CREATE_ALWAYS, 0, -1);
1323 WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0);
1324 hmfDst = EMF_GetEnhMetaFile( hFile );
1325 }
1326 EMF_ReleaseEnhMetaHeader( hmfSrc );
1327 return hmfDst;
Alexandre Julliard54c27111998-03-29 19:44:57 +00001328}
1329
Huw D M Davies585c8461999-05-02 09:23:51 +00001330
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001331/* Struct to be used to be passed in the LPVOID parameter for cbEnhPaletteCopy */
1332typedef struct tagEMF_PaletteCopy
1333{
1334 UINT cEntries;
1335 LPPALETTEENTRY lpPe;
1336} EMF_PaletteCopy;
1337
1338/***************************************************************
1339 * Find the EMR_EOF record and then use it to find the
1340 * palette entries for this enhanced metafile.
1341 * The lpData is actually a pointer to a EMF_PaletteCopy struct
1342 * which contains the max number of elements to copy and where
1343 * to copy them to.
1344 *
1345 * NOTE: To be used by GetEnhMetaFilePaletteEntries only!
1346 */
1347INT CALLBACK cbEnhPaletteCopy( HDC a,
1348 LPHANDLETABLE b,
1349 LPENHMETARECORD lpEMR,
1350 INT c,
1351 LPVOID lpData )
1352{
1353
1354 if ( lpEMR->iType == EMR_EOF )
1355 {
1356 PEMREOF lpEof = (PEMREOF)lpEMR;
1357 EMF_PaletteCopy* info = (EMF_PaletteCopy*)lpData;
Francois Gouget6d77d3a2000-03-25 21:44:35 +00001358 DWORD dwNumPalToCopy = min( lpEof->nPalEntries, info->cEntries );
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001359
1360 TRACE( "copying 0x%08lx palettes\n", dwNumPalToCopy );
1361
1362 memcpy( (LPVOID)info->lpPe,
1363 (LPVOID)(((LPSTR)lpEof) + lpEof->offPalEntries),
1364 sizeof( *(info->lpPe) ) * dwNumPalToCopy );
1365
1366 /* Update the passed data as a return code */
1367 info->lpPe = NULL; /* Palettes were copied! */
1368 info->cEntries = (UINT)dwNumPalToCopy;
1369
1370 return FALSE; /* That's all we need */
1371 }
1372
1373 return TRUE;
1374}
1375
Charles Suprin41043011998-11-07 12:56:31 +00001376/*****************************************************************************
1377 * GetEnhMetaFilePaletteEntries (GDI32.179)
1378 *
1379 * Copy the palette and report size
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001380 *
1381 * BUGS: Error codes (SetLastError) are not set on failures
Charles Suprin41043011998-11-07 12:56:31 +00001382 */
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001383UINT WINAPI GetEnhMetaFilePaletteEntries( HENHMETAFILE hEmf,
1384 UINT cEntries,
1385 LPPALETTEENTRY lpPe )
Charles Suprin41043011998-11-07 12:56:31 +00001386{
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001387 ENHMETAHEADER* enhHeader = EMF_GetEnhMetaHeader( hEmf );
1388 UINT uReturnValue = GDI_ERROR;
1389 EMF_PaletteCopy infoForCallBack;
1390
1391 TRACE( "(%04x,%d,%p)\n", hEmf, cEntries, lpPe );
1392
1393 /* First check if there are any palettes associated with
1394 this metafile. */
1395 if ( enhHeader->nPalEntries == 0 )
1396 {
1397 /* No palette associated with this enhanced metafile */
1398 uReturnValue = 0;
1399 goto done;
1400 }
1401
1402 /* Is the user requesting the number of palettes? */
1403 if ( lpPe == NULL )
1404 {
1405 uReturnValue = (UINT)enhHeader->nPalEntries;
1406 goto done;
1407 }
1408
1409 /* Copy cEntries worth of PALETTEENTRY structs into the buffer */
1410 infoForCallBack.cEntries = cEntries;
1411 infoForCallBack.lpPe = lpPe;
1412
1413 if ( !EnumEnhMetaFile( 0, hEmf, cbEnhPaletteCopy,
1414 &infoForCallBack, NULL ) )
1415 {
1416 goto done;
1417 }
1418
1419 /* Verify that the callback executed correctly */
1420 if ( infoForCallBack.lpPe != NULL )
1421 {
1422 /* Callback proc had error! */
1423 ERR( "cbEnhPaletteCopy didn't execute correctly\n" );
1424 goto done;
1425 }
1426
1427 uReturnValue = infoForCallBack.cEntries;
1428
1429done:
1430
1431 EMF_ReleaseEnhMetaHeader( hEmf );
1432
1433 return uReturnValue;
Charles Suprin41043011998-11-07 12:56:31 +00001434}
1435
Charles Suprin41043011998-11-07 12:56:31 +00001436/******************************************************************
1437 * SetWinMetaFileBits (GDI32.343)
1438 *
1439 * Translate from old style to new style.
Peter Hunnisettc821a751999-12-04 03:56:53 +00001440 *
1441 * BUGS: - This doesn't take the DC and scaling into account
1442 * - Most record conversions aren't implemented
1443 * - Handle slot assignement is primative and most likely doesn't work
Charles Suprin41043011998-11-07 12:56:31 +00001444 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001445HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
Charles Suprin41043011998-11-07 12:56:31 +00001446 CONST BYTE *lpbBuffer,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001447 HDC hdcRef,
1448 CONST METAFILEPICT *lpmfp
Charles Suprin41043011998-11-07 12:56:31 +00001449 )
1450{
Peter Hunnisettc821a751999-12-04 03:56:53 +00001451 HENHMETAFILE hMf;
1452 LPVOID lpNewEnhMetaFileBuffer = NULL;
1453 UINT uNewEnhMetaFileBufferSize = 0;
1454 BOOL bFoundEOF = FALSE;
Charles Suprin41043011998-11-07 12:56:31 +00001455
Peter Hunnisettc821a751999-12-04 03:56:53 +00001456 FIXME( "(%d,%p,%04x,%p):stub\n", cbBuffer, lpbBuffer, hdcRef, lpmfp );
1457
1458 /* 1. Get the header - skip over this and get straight to the records */
1459
1460 uNewEnhMetaFileBufferSize = sizeof( ENHMETAHEADER );
Alexandre Julliard90476d62000-02-16 22:47:24 +00001461 lpNewEnhMetaFileBuffer = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
Peter Hunnisettc821a751999-12-04 03:56:53 +00001462 uNewEnhMetaFileBufferSize );
1463
1464 if( lpNewEnhMetaFileBuffer == NULL )
1465 {
1466 goto error;
1467 }
1468
1469 /* Fill in the header record */
1470 {
1471 LPENHMETAHEADER lpNewEnhMetaFileHeader = (LPENHMETAHEADER)lpNewEnhMetaFileBuffer;
1472
1473 lpNewEnhMetaFileHeader->iType = EMR_HEADER;
1474 lpNewEnhMetaFileHeader->nSize = sizeof( ENHMETAHEADER );
1475
1476 /* FIXME: Not right. Must be able to get this from the DC */
1477 lpNewEnhMetaFileHeader->rclBounds.left = 0;
1478 lpNewEnhMetaFileHeader->rclBounds.right = 0;
1479 lpNewEnhMetaFileHeader->rclBounds.top = 0;
1480 lpNewEnhMetaFileHeader->rclBounds.bottom = 0;
1481
1482 /* FIXME: Not right. Must be able to get this from the DC */
1483 lpNewEnhMetaFileHeader->rclFrame.left = 0;
1484 lpNewEnhMetaFileHeader->rclFrame.right = 0;
1485 lpNewEnhMetaFileHeader->rclFrame.top = 0;
1486 lpNewEnhMetaFileHeader->rclFrame.bottom = 0;
1487
1488 lpNewEnhMetaFileHeader->nHandles = 0; /* No handles yet */
1489
1490 /* FIXME: Add in the rest of the fields to the header */
1491 /* dSignature
1492 nVersion
1493 nRecords
1494 sReserved
1495 nDescription
1496 offDescription
1497 nPalEntries
1498 szlDevice
1499 szlMillimeters
1500 cbPixelFormat
1501 offPixelFormat,
1502 bOpenGL */
1503 }
1504
1505 (char*)lpbBuffer += ((METAHEADER*)lpbBuffer)->mtHeaderSize * 2; /* Point past the header - FIXME: metafile quirk? */
1506
1507 /* 2. Enum over individual records and convert them to the new type of records */
1508 while( !bFoundEOF )
1509 {
1510
1511 LPMETARECORD lpMetaRecord = (LPMETARECORD)lpbBuffer;
1512
1513#define EMF_ReAllocAndAdjustPointers( a , b ) \
1514 { \
1515 LPVOID lpTmp; \
Alexandre Julliard90476d62000-02-16 22:47:24 +00001516 lpTmp = HeapReAlloc( GetProcessHeap(), 0, \
Peter Hunnisettc821a751999-12-04 03:56:53 +00001517 lpNewEnhMetaFileBuffer, \
1518 uNewEnhMetaFileBufferSize + (b) ); \
1519 if( lpTmp == NULL ) { ERR( "No memory!\n" ); goto error; } \
1520 lpNewEnhMetaFileBuffer = lpTmp; \
1521 lpRecord = (a)( (char*)lpNewEnhMetaFileBuffer + uNewEnhMetaFileBufferSize ); \
1522 uNewEnhMetaFileBufferSize += (b); \
1523 }
1524
1525 switch( lpMetaRecord->rdFunction )
1526 {
1527 case META_EOF:
1528 {
1529 PEMREOF lpRecord;
1530 size_t uRecord = sizeof(*lpRecord);
1531
1532 EMF_ReAllocAndAdjustPointers(PEMREOF,uRecord);
1533
1534 /* Fill the new record - FIXME: This is not right */
1535 lpRecord->emr.iType = EMR_EOF;
1536 lpRecord->emr.nSize = sizeof( *lpRecord );
1537 lpRecord->nPalEntries = 0; /* FIXME */
1538 lpRecord->offPalEntries = 0; /* FIXME */
1539 lpRecord->nSizeLast = 0; /* FIXME */
1540
1541 /* No more records after this one */
1542 bFoundEOF = TRUE;
1543
1544 FIXME( "META_EOF conversion not correct\n" );
1545 break;
1546 }
1547
1548 case META_SETMAPMODE:
1549 {
1550 PEMRSETMAPMODE lpRecord;
1551 size_t uRecord = sizeof(*lpRecord);
1552
1553 EMF_ReAllocAndAdjustPointers(PEMRSETMAPMODE,uRecord);
1554
1555 lpRecord->emr.iType = EMR_SETMAPMODE;
1556 lpRecord->emr.nSize = sizeof( *lpRecord );
1557
1558 lpRecord->iMode = lpMetaRecord->rdParm[0];
1559
1560 break;
1561 }
1562
1563 case META_DELETEOBJECT: /* Select and Delete structures are the same */
1564 case META_SELECTOBJECT:
1565 {
1566 PEMRDELETEOBJECT lpRecord;
1567 size_t uRecord = sizeof(*lpRecord);
1568
1569 EMF_ReAllocAndAdjustPointers(PEMRDELETEOBJECT,uRecord);
1570
1571 if( lpMetaRecord->rdFunction == META_DELETEOBJECT )
1572 {
1573 lpRecord->emr.iType = EMR_DELETEOBJECT;
1574 }
1575 else
1576 {
1577 lpRecord->emr.iType = EMR_SELECTOBJECT;
1578 }
1579 lpRecord->emr.nSize = sizeof( *lpRecord );
1580
1581 lpRecord->ihObject = lpMetaRecord->rdParm[0]; /* FIXME: Handle */
1582
1583 break;
1584 }
1585
1586 case META_POLYGON: /* This is just plain busted. I don't know what I'm doing */
1587 {
1588 PEMRPOLYGON16 lpRecord; /* FIXME: Should it be a poly or poly16? */
1589 size_t uRecord = sizeof(*lpRecord);
1590
1591 EMF_ReAllocAndAdjustPointers(PEMRPOLYGON16,uRecord);
1592
1593 /* FIXME: This is mostly all wrong */
Peter Hunnisett0cdc4d91999-12-11 23:18:10 +00001594 lpRecord->emr.iType = EMR_POLYGON16;
Peter Hunnisettc821a751999-12-04 03:56:53 +00001595 lpRecord->emr.nSize = sizeof( *lpRecord );
1596
1597 lpRecord->rclBounds.left = 0;
1598 lpRecord->rclBounds.right = 0;
1599 lpRecord->rclBounds.top = 0;
1600 lpRecord->rclBounds.bottom = 0;
1601
1602 lpRecord->cpts = 0;
1603 lpRecord->apts[0].x = 0;
1604 lpRecord->apts[0].y = 0;
1605
1606 FIXME( "META_POLYGON conversion not correct\n" );
1607
1608 break;
1609 }
1610
1611 case META_SETPOLYFILLMODE:
1612 {
1613 PEMRSETPOLYFILLMODE lpRecord;
1614 size_t uRecord = sizeof(*lpRecord);
1615
1616 EMF_ReAllocAndAdjustPointers(PEMRSETPOLYFILLMODE,uRecord);
1617
1618 lpRecord->emr.iType = EMR_SETPOLYFILLMODE;
1619 lpRecord->emr.nSize = sizeof( *lpRecord );
1620
1621 lpRecord->iMode = lpMetaRecord->rdParm[0];
1622
1623 break;
1624 }
1625
1626 case META_SETWINDOWORG:
1627 {
1628 PEMRSETWINDOWORGEX lpRecord; /* Seems to be the closest thing */
1629 size_t uRecord = sizeof(*lpRecord);
1630
1631 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWORGEX,uRecord);
1632
1633 lpRecord->emr.iType = EMR_SETWINDOWORGEX;
1634 lpRecord->emr.nSize = sizeof( *lpRecord );
1635
1636 lpRecord->ptlOrigin.x = lpMetaRecord->rdParm[1];
1637 lpRecord->ptlOrigin.y = lpMetaRecord->rdParm[0];
1638
1639 break;
1640 }
1641
1642 case META_SETWINDOWEXT: /* Structure is the same for SETWINDOWEXT & SETVIEWPORTEXT */
1643 case META_SETVIEWPORTEXT:
1644 {
1645 PEMRSETWINDOWEXTEX lpRecord;
1646 size_t uRecord = sizeof(*lpRecord);
1647
1648 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWEXTEX,uRecord);
1649
1650 if ( lpMetaRecord->rdFunction == META_SETWINDOWEXT )
1651 {
1652 lpRecord->emr.iType = EMR_SETWINDOWORGEX;
1653 }
1654 else
1655 {
1656 lpRecord->emr.iType = EMR_SETVIEWPORTEXTEX;
1657 }
1658 lpRecord->emr.nSize = sizeof( *lpRecord );
1659
1660 lpRecord->szlExtent.cx = lpMetaRecord->rdParm[1];
1661 lpRecord->szlExtent.cy = lpMetaRecord->rdParm[0];
1662
1663 break;
1664 }
1665
1666 case META_CREATEBRUSHINDIRECT:
1667 {
1668 PEMRCREATEBRUSHINDIRECT lpRecord;
1669 size_t uRecord = sizeof(*lpRecord);
1670
1671 EMF_ReAllocAndAdjustPointers(PEMRCREATEBRUSHINDIRECT,uRecord);
1672
1673 lpRecord->emr.iType = EMR_CREATEBRUSHINDIRECT;
1674 lpRecord->emr.nSize = sizeof( *lpRecord );
1675
1676 lpRecord->ihBrush = ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nHandles;
1677 lpRecord->lb.lbStyle = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbStyle;
1678 lpRecord->lb.lbColor = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbColor;
1679 lpRecord->lb.lbHatch = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbHatch;
1680
1681 ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nHandles += 1; /* New handle */
1682
1683 break;
1684 }
1685
1686
1687 /* These are all unimplemented and as such are intended to fall through to the default case */
1688 case META_SETBKCOLOR:
1689 case META_SETBKMODE:
1690 case META_SETROP2:
1691 case META_SETRELABS:
1692 case META_SETSTRETCHBLTMODE:
1693 case META_SETTEXTCOLOR:
1694 case META_SETVIEWPORTORG:
1695 case META_OFFSETWINDOWORG:
1696 case META_SCALEWINDOWEXT:
1697 case META_OFFSETVIEWPORTORG:
1698 case META_SCALEVIEWPORTEXT:
1699 case META_LINETO:
1700 case META_MOVETO:
1701 case META_EXCLUDECLIPRECT:
1702 case META_INTERSECTCLIPRECT:
1703 case META_ARC:
1704 case META_ELLIPSE:
1705 case META_FLOODFILL:
1706 case META_PIE:
1707 case META_RECTANGLE:
1708 case META_ROUNDRECT:
1709 case META_PATBLT:
1710 case META_SAVEDC:
1711 case META_SETPIXEL:
1712 case META_OFFSETCLIPRGN:
1713 case META_TEXTOUT:
1714 case META_POLYPOLYGON:
1715 case META_POLYLINE:
1716 case META_RESTOREDC:
1717 case META_CHORD:
1718 case META_CREATEPATTERNBRUSH:
1719 case META_CREATEPENINDIRECT:
1720 case META_CREATEFONTINDIRECT:
1721 case META_CREATEPALETTE:
1722 case META_SETTEXTALIGN:
1723 case META_SELECTPALETTE:
1724 case META_SETMAPPERFLAGS:
1725 case META_REALIZEPALETTE:
1726 case META_ESCAPE:
1727 case META_EXTTEXTOUT:
1728 case META_STRETCHDIB:
1729 case META_DIBSTRETCHBLT:
1730 case META_STRETCHBLT:
1731 case META_BITBLT:
1732 case META_CREATEREGION:
1733 case META_FILLREGION:
1734 case META_FRAMEREGION:
1735 case META_INVERTREGION:
1736 case META_PAINTREGION:
1737 case META_SELECTCLIPREGION:
1738 case META_DIBCREATEPATTERNBRUSH:
1739 case META_DIBBITBLT:
1740 case META_SETTEXTCHAREXTRA:
1741 case META_SETTEXTJUSTIFICATION:
1742 case META_EXTFLOODFILL:
1743 case META_SETDIBTODEV:
1744 case META_DRAWTEXT:
1745 case META_ANIMATEPALETTE:
1746 case META_SETPALENTRIES:
1747 case META_RESIZEPALETTE:
1748 case META_RESETDC:
1749 case META_STARTDOC:
1750 case META_STARTPAGE:
1751 case META_ENDPAGE:
1752 case META_ABORTDOC:
1753 case META_ENDDOC:
1754 case META_CREATEBRUSH:
1755 case META_CREATEBITMAPINDIRECT:
1756 case META_CREATEBITMAP:
1757 /* Fall through to unimplemented */
1758 default:
1759 {
1760 /* Not implemented yet */
1761 FIXME( "Conversion of record type 0x%x not implemented.\n", lpMetaRecord->rdFunction );
1762 break;
1763 }
1764 }
1765
1766 /* Move to the next record */
1767 (char*)lpbBuffer += ((LPMETARECORD)lpbBuffer)->rdSize * 2; /* FIXME: Seem to be doing this in metafile.c */
1768
1769#undef ReAllocAndAdjustPointers
1770 }
1771
1772 /* We know the last of the header information now */
1773 ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nBytes = uNewEnhMetaFileBufferSize;
1774
1775 /* Create the enhanced metafile */
1776 hMf = SetEnhMetaFileBits( uNewEnhMetaFileBufferSize, (const BYTE*)lpNewEnhMetaFileBuffer );
1777
1778 if( !hMf )
1779 ERR( "Problem creating metafile. Did the conversion fail somewhere?\n" );
1780
1781 return hMf;
1782
1783error:
1784 /* Free the data associated with our copy since it's been copied */
Alexandre Julliard90476d62000-02-16 22:47:24 +00001785 HeapFree( GetProcessHeap(), 0, lpNewEnhMetaFileBuffer );
Peter Hunnisettc821a751999-12-04 03:56:53 +00001786
1787 return 0;
1788}
Charles Suprin41043011998-11-07 12:56:31 +00001789
1790
Alexandre Julliarda69b88b1998-03-15 20:29:56 +00001791