1 | /*
|
---|
2 | * OLE Picture object
|
---|
3 | *
|
---|
4 | * Implementation of OLE IPicture and related interfaces
|
---|
5 | *
|
---|
6 | * Copyright 2000 Huw D M Davies for CodeWeavers.
|
---|
7 | * Copyright 2001 Marcus Meissner
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * BUGS
|
---|
11 | *
|
---|
12 | * Support PICTYPE_BITMAP and PICTYPE_ICON, altough only bitmaps very well..
|
---|
13 | * Lots of methods are just stubs.
|
---|
14 | *
|
---|
15 | *
|
---|
16 | * NOTES (or things that msdn doesn't tell you)
|
---|
17 | *
|
---|
18 | * The width and height properties are returned in HIMETRIC units (0.01mm)
|
---|
19 | * IPicture::Render also uses these to select a region of the src picture.
|
---|
20 | * A bitmap's size is converted into these units by using the screen resolution
|
---|
21 | * thus an 8x8 bitmap on a 96dpi screen has a size of 212x212 (8/96 * 2540).
|
---|
22 | *
|
---|
23 | */
|
---|
24 | #ifdef __WIN32OS2__
|
---|
25 | #define HAVE_FLOAT_H
|
---|
26 | #define WINE_LARGE_INTEGER
|
---|
27 | #include "oleaut32.h"
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #include "config.h"
|
---|
31 |
|
---|
32 | #include <unistd.h>
|
---|
33 | #include <stdio.h>
|
---|
34 | #include <string.h>
|
---|
35 | #include "winerror.h"
|
---|
36 | #include "winbase.h"
|
---|
37 | #include "wingdi.h"
|
---|
38 | #include "winuser.h"
|
---|
39 | #include "ole2.h"
|
---|
40 | #include "olectl.h"
|
---|
41 | #include "oleauto.h"
|
---|
42 | #include "wine/obj_picture.h"
|
---|
43 | #include "wine/obj_connection.h"
|
---|
44 | #include "connpt.h"
|
---|
45 | #include "debugtools.h"
|
---|
46 |
|
---|
47 | #include "wine/wingdi16.h"
|
---|
48 | #include "cursoricon.h"
|
---|
49 |
|
---|
50 | #ifdef HAVE_LIBJPEG
|
---|
51 | /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
|
---|
52 | #define XMD_H
|
---|
53 | #ifdef HAVE_JPEGLIB_H
|
---|
54 | # include <jpeglib.h>
|
---|
55 | #endif
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifdef __WIN32OS2__
|
---|
59 | #undef FIXME
|
---|
60 | #undef TRACE
|
---|
61 | #ifdef DEBUG
|
---|
62 | #define TRACE WriteLog("%s", __FUNCTION__); WriteLog
|
---|
63 | #define FIXME WriteLog("FIXME %s", __FUNCTION__); WriteLog
|
---|
64 | #else
|
---|
65 | #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
|
---|
66 | #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
|
---|
67 | #endif
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | DEFAULT_DEBUG_CHANNEL(ole);
|
---|
71 |
|
---|
72 | /*************************************************************************
|
---|
73 | * Declaration of implementation class
|
---|
74 | */
|
---|
75 |
|
---|
76 | typedef struct OLEPictureImpl {
|
---|
77 |
|
---|
78 | /*
|
---|
79 | * IPicture handles IUnknown
|
---|
80 | */
|
---|
81 |
|
---|
82 | ICOM_VTABLE(IPicture) *lpvtbl1;
|
---|
83 | ICOM_VTABLE(IDispatch) *lpvtbl2;
|
---|
84 | ICOM_VTABLE(IPersistStream) *lpvtbl3;
|
---|
85 | ICOM_VTABLE(IConnectionPointContainer) *lpvtbl4;
|
---|
86 |
|
---|
87 | /* Object referenece count */
|
---|
88 | DWORD ref;
|
---|
89 |
|
---|
90 | /* We own the object and must destroy it ourselves */
|
---|
91 | BOOL fOwn;
|
---|
92 |
|
---|
93 | /* Picture description */
|
---|
94 | PICTDESC desc;
|
---|
95 |
|
---|
96 | /* These are the pixel size of a bitmap */
|
---|
97 | DWORD origWidth;
|
---|
98 | DWORD origHeight;
|
---|
99 |
|
---|
100 | /* And these are the size of the picture converted into HIMETRIC units */
|
---|
101 | OLE_XSIZE_HIMETRIC himetricWidth;
|
---|
102 | OLE_YSIZE_HIMETRIC himetricHeight;
|
---|
103 |
|
---|
104 | IConnectionPoint *pCP;
|
---|
105 |
|
---|
106 | BOOL keepOrigFormat;
|
---|
107 | HDC hDCCur;
|
---|
108 | } OLEPictureImpl;
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * Macros to retrieve pointer to IUnknown (IPicture) from the other VTables.
|
---|
112 | */
|
---|
113 | #define ICOM_THIS_From_IDispatch(impl, name) \
|
---|
114 | impl *This = (impl*)(((char*)name)-sizeof(void*));
|
---|
115 | #define ICOM_THIS_From_IPersistStream(impl, name) \
|
---|
116 | impl *This = (impl*)(((char*)name)-2*sizeof(void*));
|
---|
117 | #define ICOM_THIS_From_IConnectionPointContainer(impl, name) \
|
---|
118 | impl *This = (impl*)(((char*)name)-3*sizeof(void*));
|
---|
119 |
|
---|
120 | /*
|
---|
121 | * Predeclare VTables. They get initialized at the end.
|
---|
122 | */
|
---|
123 | static ICOM_VTABLE(IPicture) OLEPictureImpl_VTable;
|
---|
124 | static ICOM_VTABLE(IDispatch) OLEPictureImpl_IDispatch_VTable;
|
---|
125 | static ICOM_VTABLE(IPersistStream) OLEPictureImpl_IPersistStream_VTable;
|
---|
126 | static ICOM_VTABLE(IConnectionPointContainer) OLEPictureImpl_IConnectionPointContainer_VTable;
|
---|
127 |
|
---|
128 | /***********************************************************************
|
---|
129 | * Implementation of the OLEPictureImpl class.
|
---|
130 | */
|
---|
131 |
|
---|
132 | static void OLEPictureImpl_SetBitmap(OLEPictureImpl*This) {
|
---|
133 | BITMAP bm;
|
---|
134 | HDC hdcRef;
|
---|
135 |
|
---|
136 | TRACE("bitmap handle %08x\n", This->desc.u.bmp.hbitmap);
|
---|
137 | if(GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
|
---|
138 | ERR("GetObject fails\n");
|
---|
139 | return;
|
---|
140 | }
|
---|
141 | This->origWidth = bm.bmWidth;
|
---|
142 | This->origHeight = bm.bmHeight;
|
---|
143 | /* The width and height are stored in HIMETRIC units (0.01 mm),
|
---|
144 | so we take our pixel width divide by pixels per inch and
|
---|
145 | multiply by 25.4 * 100 */
|
---|
146 | /* Should we use GetBitmapDimension if available? */
|
---|
147 | hdcRef = CreateCompatibleDC(0);
|
---|
148 | This->himetricWidth =(bm.bmWidth *2540)/GetDeviceCaps(hdcRef, LOGPIXELSX);
|
---|
149 | This->himetricHeight=(bm.bmHeight*2540)/GetDeviceCaps(hdcRef, LOGPIXELSY);
|
---|
150 | DeleteDC(hdcRef);
|
---|
151 | }
|
---|
152 |
|
---|
153 | /************************************************************************
|
---|
154 | * OLEPictureImpl_Construct
|
---|
155 | *
|
---|
156 | * This method will construct a new instance of the OLEPictureImpl
|
---|
157 | * class.
|
---|
158 | *
|
---|
159 | * The caller of this method must release the object when it's
|
---|
160 | * done with it.
|
---|
161 | */
|
---|
162 | static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn)
|
---|
163 | {
|
---|
164 | OLEPictureImpl* newObject = 0;
|
---|
165 |
|
---|
166 | if (pictDesc)
|
---|
167 | TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * Allocate space for the object.
|
---|
171 | */
|
---|
172 | newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEPictureImpl));
|
---|
173 |
|
---|
174 | if (newObject==0)
|
---|
175 | return newObject;
|
---|
176 |
|
---|
177 | /*
|
---|
178 | * Initialize the virtual function table.
|
---|
179 | */
|
---|
180 | newObject->lpvtbl1 = &OLEPictureImpl_VTable;
|
---|
181 | newObject->lpvtbl2 = &OLEPictureImpl_IDispatch_VTable;
|
---|
182 | newObject->lpvtbl3 = &OLEPictureImpl_IPersistStream_VTable;
|
---|
183 | newObject->lpvtbl4 = &OLEPictureImpl_IConnectionPointContainer_VTable;
|
---|
184 |
|
---|
185 | CreateConnectionPoint((IUnknown*)newObject,&IID_IPropertyNotifySink,&newObject->pCP);
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * Start with one reference count. The caller of this function
|
---|
189 | * must release the interface pointer when it is done.
|
---|
190 | */
|
---|
191 | newObject->ref = 1;
|
---|
192 | newObject->hDCCur = 0;
|
---|
193 |
|
---|
194 | newObject->fOwn = fOwn;
|
---|
195 |
|
---|
196 | /* dunno about original value */
|
---|
197 | newObject->keepOrigFormat = TRUE;
|
---|
198 |
|
---|
199 | if (pictDesc) {
|
---|
200 | if(pictDesc->cbSizeofstruct != sizeof(PICTDESC)) {
|
---|
201 | FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
|
---|
202 | }
|
---|
203 | memcpy(&newObject->desc, pictDesc, sizeof(PICTDESC));
|
---|
204 |
|
---|
205 |
|
---|
206 | switch(pictDesc->picType) {
|
---|
207 | case PICTYPE_BITMAP:
|
---|
208 | OLEPictureImpl_SetBitmap(newObject);
|
---|
209 | break;
|
---|
210 |
|
---|
211 | case PICTYPE_METAFILE:
|
---|
212 | TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
|
---|
213 | newObject->himetricWidth = pictDesc->u.wmf.xExt;
|
---|
214 | newObject->himetricHeight = pictDesc->u.wmf.yExt;
|
---|
215 | break;
|
---|
216 |
|
---|
217 | case PICTYPE_ICON:
|
---|
218 | case PICTYPE_ENHMETAFILE:
|
---|
219 | default:
|
---|
220 | FIXME("Unsupported type %d\n", pictDesc->picType);
|
---|
221 | newObject->himetricWidth = newObject->himetricHeight = 0;
|
---|
222 | break;
|
---|
223 | }
|
---|
224 | } else {
|
---|
225 | newObject->desc.picType = PICTYPE_UNINITIALIZED;
|
---|
226 | }
|
---|
227 |
|
---|
228 | TRACE("returning %p\n", newObject);
|
---|
229 | return newObject;
|
---|
230 | }
|
---|
231 |
|
---|
232 | /************************************************************************
|
---|
233 | * OLEPictureImpl_Destroy
|
---|
234 | *
|
---|
235 | * This method is called by the Release method when the reference
|
---|
236 | * count goes down to 0. It will free all resources used by
|
---|
237 | * this object. */
|
---|
238 | static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj)
|
---|
239 | {
|
---|
240 | TRACE("(%p)\n", Obj);
|
---|
241 |
|
---|
242 | if(Obj->fOwn) { /* We need to destroy the picture */
|
---|
243 | switch(Obj->desc.picType) {
|
---|
244 | case PICTYPE_BITMAP:
|
---|
245 | DeleteObject(Obj->desc.u.bmp.hbitmap);
|
---|
246 | break;
|
---|
247 | case PICTYPE_METAFILE:
|
---|
248 | DeleteMetaFile(Obj->desc.u.wmf.hmeta);
|
---|
249 | break;
|
---|
250 | case PICTYPE_ICON:
|
---|
251 | DestroyIcon(Obj->desc.u.icon.hicon);
|
---|
252 | break;
|
---|
253 | case PICTYPE_ENHMETAFILE:
|
---|
254 | DeleteEnhMetaFile(Obj->desc.u.emf.hemf);
|
---|
255 | break;
|
---|
256 | default:
|
---|
257 | FIXME("Unsupported type %d - unable to delete\n", Obj->desc.picType);
|
---|
258 | break;
|
---|
259 | }
|
---|
260 | }
|
---|
261 | HeapFree(GetProcessHeap(), 0, Obj);
|
---|
262 | }
|
---|
263 |
|
---|
264 | static ULONG WINAPI OLEPictureImpl_AddRef(IPicture* iface);
|
---|
265 |
|
---|
266 | /************************************************************************
|
---|
267 | * OLEPictureImpl_QueryInterface (IUnknown)
|
---|
268 | *
|
---|
269 | * See Windows documentation for more details on IUnknown methods.
|
---|
270 | */
|
---|
271 | static HRESULT WINAPI OLEPictureImpl_QueryInterface(
|
---|
272 | IPicture* iface,
|
---|
273 | REFIID riid,
|
---|
274 | void** ppvObject)
|
---|
275 | {
|
---|
276 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
277 | TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
|
---|
278 |
|
---|
279 | /*
|
---|
280 | * Perform a sanity check on the parameters.
|
---|
281 | */
|
---|
282 | if ( (This==0) || (ppvObject==0) )
|
---|
283 | return E_INVALIDARG;
|
---|
284 |
|
---|
285 | /*
|
---|
286 | * Initialize the return parameter.
|
---|
287 | */
|
---|
288 | *ppvObject = 0;
|
---|
289 |
|
---|
290 | /*
|
---|
291 | * Compare the riid with the interface IDs implemented by this object.
|
---|
292 | */
|
---|
293 | if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
|
---|
294 | {
|
---|
295 | *ppvObject = (IPicture*)This;
|
---|
296 | }
|
---|
297 | else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0)
|
---|
298 | {
|
---|
299 | *ppvObject = (IPicture*)This;
|
---|
300 | }
|
---|
301 | else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
|
---|
302 | {
|
---|
303 | *ppvObject = (IDispatch*)&(This->lpvtbl2);
|
---|
304 | }
|
---|
305 | else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0)
|
---|
306 | {
|
---|
307 | *ppvObject = (IDispatch*)&(This->lpvtbl2);
|
---|
308 | }
|
---|
309 | else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
|
---|
310 | {
|
---|
311 | *ppvObject = (IPersistStream*)&(This->lpvtbl3);
|
---|
312 | }
|
---|
313 | else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0)
|
---|
314 | {
|
---|
315 | *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4);
|
---|
316 | }
|
---|
317 | /*
|
---|
318 | * Check that we obtained an interface.
|
---|
319 | */
|
---|
320 | if ((*ppvObject)==0)
|
---|
321 | {
|
---|
322 | FIXME("() : asking for un supported interface %s\n",debugstr_guid(riid));
|
---|
323 | return E_NOINTERFACE;
|
---|
324 | }
|
---|
325 |
|
---|
326 | /*
|
---|
327 | * Query Interface always increases the reference count by one when it is
|
---|
328 | * successful
|
---|
329 | */
|
---|
330 | OLEPictureImpl_AddRef((IPicture*)This);
|
---|
331 |
|
---|
332 | return S_OK;;
|
---|
333 | }
|
---|
334 | /***********************************************************************
|
---|
335 | * OLEPicture_SendNotify (internal)
|
---|
336 | *
|
---|
337 | * Sends notification messages of changed properties to any interested
|
---|
338 | * connections.
|
---|
339 | */
|
---|
340 | static void OLEPicture_SendNotify(OLEPictureImpl* this, DISPID dispID)
|
---|
341 | {
|
---|
342 | IEnumConnections *pEnum;
|
---|
343 | CONNECTDATA CD;
|
---|
344 |
|
---|
345 | if (IConnectionPoint_EnumConnections(this->pCP, &pEnum))
|
---|
346 | return;
|
---|
347 | while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
|
---|
348 | IPropertyNotifySink *sink;
|
---|
349 |
|
---|
350 | IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
|
---|
351 | IPropertyNotifySink_OnChanged(sink, dispID);
|
---|
352 | IPropertyNotifySink_Release(sink);
|
---|
353 | IUnknown_Release(CD.pUnk);
|
---|
354 | }
|
---|
355 | IEnumConnections_Release(pEnum);
|
---|
356 | return;
|
---|
357 | }
|
---|
358 |
|
---|
359 | /************************************************************************
|
---|
360 | * OLEPictureImpl_AddRef (IUnknown)
|
---|
361 | *
|
---|
362 | * See Windows documentation for more details on IUnknown methods.
|
---|
363 | */
|
---|
364 | static ULONG WINAPI OLEPictureImpl_AddRef(
|
---|
365 | IPicture* iface)
|
---|
366 | {
|
---|
367 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
368 | TRACE("(%p)->(ref=%ld)\n", This, This->ref);
|
---|
369 | This->ref++;
|
---|
370 |
|
---|
371 | return This->ref;
|
---|
372 | }
|
---|
373 |
|
---|
374 | /************************************************************************
|
---|
375 | * OLEPictureImpl_Release (IUnknown)
|
---|
376 | *
|
---|
377 | * See Windows documentation for more details on IUnknown methods.
|
---|
378 | */
|
---|
379 | static ULONG WINAPI OLEPictureImpl_Release(
|
---|
380 | IPicture* iface)
|
---|
381 | {
|
---|
382 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
383 | TRACE("(%p)->(ref=%ld)\n", This, This->ref);
|
---|
384 |
|
---|
385 | /*
|
---|
386 | * Decrease the reference count on this object.
|
---|
387 | */
|
---|
388 | This->ref--;
|
---|
389 |
|
---|
390 | /*
|
---|
391 | * If the reference count goes down to 0, perform suicide.
|
---|
392 | */
|
---|
393 | if (This->ref==0)
|
---|
394 | {
|
---|
395 | OLEPictureImpl_Destroy(This);
|
---|
396 |
|
---|
397 | return 0;
|
---|
398 | }
|
---|
399 |
|
---|
400 | return This->ref;
|
---|
401 | }
|
---|
402 |
|
---|
403 |
|
---|
404 | /************************************************************************
|
---|
405 | * OLEPictureImpl_get_Handle
|
---|
406 | */
|
---|
407 | static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface,
|
---|
408 | OLE_HANDLE *phandle)
|
---|
409 | {
|
---|
410 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
411 | TRACE("(%p)->(%p)\n", This, phandle);
|
---|
412 | switch(This->desc.picType) {
|
---|
413 | case PICTYPE_BITMAP:
|
---|
414 | *phandle = This->desc.u.bmp.hbitmap;
|
---|
415 | break;
|
---|
416 | case PICTYPE_METAFILE:
|
---|
417 | *phandle = This->desc.u.wmf.hmeta;
|
---|
418 | break;
|
---|
419 | case PICTYPE_ICON:
|
---|
420 | *phandle = This->desc.u.icon.hicon;
|
---|
421 | break;
|
---|
422 | case PICTYPE_ENHMETAFILE:
|
---|
423 | *phandle = This->desc.u.emf.hemf;
|
---|
424 | break;
|
---|
425 | default:
|
---|
426 | FIXME("Unimplemented type %d\n", This->desc.picType);
|
---|
427 | return E_NOTIMPL;
|
---|
428 | }
|
---|
429 | TRACE("returning handle %08x\n", *phandle);
|
---|
430 | return S_OK;
|
---|
431 | }
|
---|
432 |
|
---|
433 | /************************************************************************
|
---|
434 | * OLEPictureImpl_get_hPal
|
---|
435 | */
|
---|
436 | static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface,
|
---|
437 | OLE_HANDLE *phandle)
|
---|
438 | {
|
---|
439 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
440 | FIXME("(%p)->(%p): stub\n", This, phandle);
|
---|
441 | return E_NOTIMPL;
|
---|
442 | }
|
---|
443 |
|
---|
444 | /************************************************************************
|
---|
445 | * OLEPictureImpl_get_Type
|
---|
446 | */
|
---|
447 | static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface,
|
---|
448 | short *ptype)
|
---|
449 | {
|
---|
450 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
451 | TRACE("(%p)->(%p): type is %d\n", This, ptype, This->desc.picType);
|
---|
452 | *ptype = This->desc.picType;
|
---|
453 | return S_OK;
|
---|
454 | }
|
---|
455 |
|
---|
456 | /************************************************************************
|
---|
457 | * OLEPictureImpl_get_Width
|
---|
458 | */
|
---|
459 | static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface,
|
---|
460 | OLE_XSIZE_HIMETRIC *pwidth)
|
---|
461 | {
|
---|
462 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
463 | TRACE("(%p)->(%p): width is %ld\n", This, pwidth, This->himetricWidth);
|
---|
464 | *pwidth = This->himetricWidth;
|
---|
465 | return S_OK;
|
---|
466 | }
|
---|
467 |
|
---|
468 | /************************************************************************
|
---|
469 | * OLEPictureImpl_get_Height
|
---|
470 | */
|
---|
471 | static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface,
|
---|
472 | OLE_YSIZE_HIMETRIC *pheight)
|
---|
473 | {
|
---|
474 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
475 | TRACE("(%p)->(%p): height is %ld\n", This, pheight, This->himetricHeight);
|
---|
476 | *pheight = This->himetricHeight;
|
---|
477 | return S_OK;
|
---|
478 | }
|
---|
479 |
|
---|
480 | /************************************************************************
|
---|
481 | * OLEPictureImpl_Render
|
---|
482 | */
|
---|
483 | static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc,
|
---|
484 | long x, long y, long cx, long cy,
|
---|
485 | OLE_XPOS_HIMETRIC xSrc,
|
---|
486 | OLE_YPOS_HIMETRIC ySrc,
|
---|
487 | OLE_XSIZE_HIMETRIC cxSrc,
|
---|
488 | OLE_YSIZE_HIMETRIC cySrc,
|
---|
489 | LPCRECT prcWBounds)
|
---|
490 | {
|
---|
491 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
492 | TRACE("(%p)->(%08x, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",
|
---|
493 | This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
|
---|
494 | if(prcWBounds)
|
---|
495 | TRACE("prcWBounds (%d,%d) - (%d,%d)\n", prcWBounds->left, prcWBounds->top,
|
---|
496 | prcWBounds->right, prcWBounds->bottom);
|
---|
497 |
|
---|
498 | /*
|
---|
499 | * While the documentation suggests this to be here (or after rendering?)
|
---|
500 | * it does cause an endless recursion in my sample app. -MM 20010804
|
---|
501 | OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
|
---|
502 | */
|
---|
503 |
|
---|
504 | switch(This->desc.picType) {
|
---|
505 | case PICTYPE_BITMAP:
|
---|
506 | {
|
---|
507 | HBITMAP hbmpOld;
|
---|
508 | HDC hdcBmp;
|
---|
509 |
|
---|
510 | /* Set a mapping mode that maps bitmap pixels into HIMETRIC units.
|
---|
511 | NB y-axis gets flipped */
|
---|
512 |
|
---|
513 | hdcBmp = CreateCompatibleDC(0);
|
---|
514 | SetMapMode(hdcBmp, MM_ANISOTROPIC);
|
---|
515 | SetWindowOrgEx(hdcBmp, 0, 0, NULL);
|
---|
516 | SetWindowExtEx(hdcBmp, This->himetricWidth, This->himetricHeight, NULL);
|
---|
517 | SetViewportOrgEx(hdcBmp, 0, This->origHeight, NULL);
|
---|
518 | SetViewportExtEx(hdcBmp, This->origWidth, -This->origHeight, NULL);
|
---|
519 |
|
---|
520 | hbmpOld = SelectObject(hdcBmp, This->desc.u.bmp.hbitmap);
|
---|
521 |
|
---|
522 | StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
|
---|
523 |
|
---|
524 | SelectObject(hdcBmp, hbmpOld);
|
---|
525 | DeleteDC(hdcBmp);
|
---|
526 | }
|
---|
527 | break;
|
---|
528 | case PICTYPE_ICON:
|
---|
529 | FIXME("Not quite correct implementation of rendering icons...\n");
|
---|
530 | DrawIcon(hdc,x,y,This->desc.u.icon.hicon);
|
---|
531 | break;
|
---|
532 |
|
---|
533 | case PICTYPE_METAFILE:
|
---|
534 | case PICTYPE_ENHMETAFILE:
|
---|
535 | default:
|
---|
536 | FIXME("type %d not implemented\n", This->desc.picType);
|
---|
537 | return E_NOTIMPL;
|
---|
538 | }
|
---|
539 | return S_OK;
|
---|
540 | }
|
---|
541 |
|
---|
542 | /************************************************************************
|
---|
543 | * OLEPictureImpl_set_hPal
|
---|
544 | */
|
---|
545 | static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface,
|
---|
546 | OLE_HANDLE hpal)
|
---|
547 | {
|
---|
548 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
549 | FIXME("(%p)->(%08x): stub\n", This, hpal);
|
---|
550 | OLEPicture_SendNotify(This,DISPID_PICT_HPAL);
|
---|
551 | return E_NOTIMPL;
|
---|
552 | }
|
---|
553 |
|
---|
554 | /************************************************************************
|
---|
555 | * OLEPictureImpl_get_CurDC
|
---|
556 | */
|
---|
557 | static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface,
|
---|
558 | HDC *phdc)
|
---|
559 | {
|
---|
560 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
561 | TRACE("(%p), returning %x\n", This, This->hDCCur);
|
---|
562 | if (phdc) *phdc = This->hDCCur;
|
---|
563 | return S_OK;
|
---|
564 | }
|
---|
565 |
|
---|
566 | /************************************************************************
|
---|
567 | * OLEPictureImpl_SelectPicture
|
---|
568 | */
|
---|
569 | static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface,
|
---|
570 | HDC hdcIn,
|
---|
571 | HDC *phdcOut,
|
---|
572 | OLE_HANDLE *phbmpOut)
|
---|
573 | {
|
---|
574 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
575 | TRACE("(%p)->(%08x, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
|
---|
576 | if (This->desc.picType == PICTYPE_BITMAP) {
|
---|
577 | SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
|
---|
578 |
|
---|
579 | if (phdcOut)
|
---|
580 | *phdcOut = This->hDCCur;
|
---|
581 | This->hDCCur = hdcIn;
|
---|
582 | if (phbmpOut)
|
---|
583 | *phbmpOut = This->desc.u.bmp.hbitmap;
|
---|
584 | return S_OK;
|
---|
585 | } else {
|
---|
586 | FIXME("Don't know how to select picture type %d\n",This->desc.picType);
|
---|
587 | return E_FAIL;
|
---|
588 | }
|
---|
589 | }
|
---|
590 |
|
---|
591 | /************************************************************************
|
---|
592 | * OLEPictureImpl_get_KeepOriginalFormat
|
---|
593 | */
|
---|
594 | static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface,
|
---|
595 | BOOL *pfKeep)
|
---|
596 | {
|
---|
597 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
598 | TRACE("(%p)->(%p)\n", This, pfKeep);
|
---|
599 | if (!pfKeep)
|
---|
600 | return E_POINTER;
|
---|
601 | *pfKeep = This->keepOrigFormat;
|
---|
602 | return S_OK;
|
---|
603 | }
|
---|
604 |
|
---|
605 | /************************************************************************
|
---|
606 | * OLEPictureImpl_put_KeepOriginalFormat
|
---|
607 | */
|
---|
608 | static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface,
|
---|
609 | BOOL keep)
|
---|
610 | {
|
---|
611 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
612 | TRACE("(%p)->(%d)\n", This, keep);
|
---|
613 | This->keepOrigFormat = keep;
|
---|
614 | /* FIXME: what DISPID notification here? */
|
---|
615 | return S_OK;
|
---|
616 | }
|
---|
617 |
|
---|
618 | /************************************************************************
|
---|
619 | * OLEPictureImpl_PictureChanged
|
---|
620 | */
|
---|
621 | static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
|
---|
622 | {
|
---|
623 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
624 | TRACE("(%p)->()\n", This);
|
---|
625 | OLEPicture_SendNotify(This,DISPID_PICT_HANDLE);
|
---|
626 | return S_OK;
|
---|
627 | }
|
---|
628 |
|
---|
629 | /************************************************************************
|
---|
630 | * OLEPictureImpl_SaveAsFile
|
---|
631 | */
|
---|
632 | static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
|
---|
633 | IStream *pstream,
|
---|
634 | BOOL SaveMemCopy,
|
---|
635 | LONG *pcbSize)
|
---|
636 | {
|
---|
637 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
638 | FIXME("(%p)->(%p, %d, %p): stub\n", This, pstream, SaveMemCopy, pcbSize);
|
---|
639 | return E_NOTIMPL;
|
---|
640 | }
|
---|
641 |
|
---|
642 | /************************************************************************
|
---|
643 | * OLEPictureImpl_get_Attributes
|
---|
644 | */
|
---|
645 | static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface,
|
---|
646 | DWORD *pdwAttr)
|
---|
647 | {
|
---|
648 | ICOM_THIS(OLEPictureImpl, iface);
|
---|
649 | TRACE("(%p)->(%p).\n", This, pdwAttr);
|
---|
650 | *pdwAttr = 0;
|
---|
651 | switch (This->desc.picType) {
|
---|
652 | case PICTYPE_BITMAP: break; /* not 'truely' scalable, see MSDN. */
|
---|
653 | case PICTYPE_ICON: *pdwAttr = PICTURE_TRANSPARENT;break;
|
---|
654 | case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
|
---|
655 | default:FIXME("Unknown pictype %d\n",This->desc.picType);break;
|
---|
656 | }
|
---|
657 | return S_OK;
|
---|
658 | }
|
---|
659 |
|
---|
660 |
|
---|
661 | /************************************************************************
|
---|
662 | * IConnectionPointContainer
|
---|
663 | */
|
---|
664 |
|
---|
665 | static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface(
|
---|
666 | IConnectionPointContainer* iface,
|
---|
667 | REFIID riid,
|
---|
668 | VOID** ppvoid
|
---|
669 | ) {
|
---|
670 | ICOM_THIS_From_IConnectionPointContainer(IPicture,iface);
|
---|
671 |
|
---|
672 | return IPicture_QueryInterface(This,riid,ppvoid);
|
---|
673 | }
|
---|
674 |
|
---|
675 | static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef(
|
---|
676 | IConnectionPointContainer* iface)
|
---|
677 | {
|
---|
678 | ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
|
---|
679 |
|
---|
680 | return IPicture_AddRef(This);
|
---|
681 | }
|
---|
682 |
|
---|
683 | static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release(
|
---|
684 | IConnectionPointContainer* iface)
|
---|
685 | {
|
---|
686 | ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
|
---|
687 |
|
---|
688 | return IPicture_Release(This);
|
---|
689 | }
|
---|
690 |
|
---|
691 | static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints(
|
---|
692 | IConnectionPointContainer* iface,
|
---|
693 | IEnumConnectionPoints** ppEnum
|
---|
694 | ) {
|
---|
695 | ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
|
---|
696 |
|
---|
697 | FIXME("(%p,%p), stub!\n",This,ppEnum);
|
---|
698 | return E_NOTIMPL;
|
---|
699 | }
|
---|
700 |
|
---|
701 | static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint(
|
---|
702 | IConnectionPointContainer* iface,
|
---|
703 | REFIID riid,
|
---|
704 | IConnectionPoint **ppCP
|
---|
705 | ) {
|
---|
706 | ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface);
|
---|
707 | TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
|
---|
708 | if (!ppCP)
|
---|
709 | return E_POINTER;
|
---|
710 | *ppCP = NULL;
|
---|
711 | if (IsEqualGUID(riid,&IID_IPropertyNotifySink))
|
---|
712 | return IConnectionPoint_QueryInterface(This->pCP,&IID_IConnectionPoint,(LPVOID)ppCP);
|
---|
713 | FIXME("tried to find connection point on %s?\n",debugstr_guid(riid));
|
---|
714 | return 0x80040200;
|
---|
715 | }
|
---|
716 | /************************************************************************
|
---|
717 | * IPersistStream
|
---|
718 | */
|
---|
719 | /************************************************************************
|
---|
720 | * OLEPictureImpl_IPersistStream_QueryInterface (IUnknown)
|
---|
721 | *
|
---|
722 | * See Windows documentation for more details on IUnknown methods.
|
---|
723 | */
|
---|
724 | static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface(
|
---|
725 | IPersistStream* iface,
|
---|
726 | REFIID riid,
|
---|
727 | VOID** ppvoid)
|
---|
728 | {
|
---|
729 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
730 |
|
---|
731 | return IPicture_QueryInterface(This, riid, ppvoid);
|
---|
732 | }
|
---|
733 |
|
---|
734 | /************************************************************************
|
---|
735 | * OLEPictureImpl_IPersistStream_AddRef (IUnknown)
|
---|
736 | *
|
---|
737 | * See Windows documentation for more details on IUnknown methods.
|
---|
738 | */
|
---|
739 | static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef(
|
---|
740 | IPersistStream* iface)
|
---|
741 | {
|
---|
742 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
743 |
|
---|
744 | return IPicture_AddRef(This);
|
---|
745 | }
|
---|
746 |
|
---|
747 | /************************************************************************
|
---|
748 | * OLEPictureImpl_IPersistStream_Release (IUnknown)
|
---|
749 | *
|
---|
750 | * See Windows documentation for more details on IUnknown methods.
|
---|
751 | */
|
---|
752 | static ULONG WINAPI OLEPictureImpl_IPersistStream_Release(
|
---|
753 | IPersistStream* iface)
|
---|
754 | {
|
---|
755 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
756 |
|
---|
757 | return IPicture_Release(This);
|
---|
758 | }
|
---|
759 |
|
---|
760 | /************************************************************************
|
---|
761 | * OLEPictureImpl_IPersistStream_GetClassID
|
---|
762 | */
|
---|
763 | static HRESULT WINAPI OLEPictureImpl_GetClassID(
|
---|
764 | IPersistStream* iface,CLSID* pClassID)
|
---|
765 | {
|
---|
766 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
767 | FIXME("(%p),stub!\n",This);
|
---|
768 | return E_NOTIMPL;
|
---|
769 | }
|
---|
770 |
|
---|
771 | /************************************************************************
|
---|
772 | * OLEPictureImpl_IPersistStream_IsDirty
|
---|
773 | */
|
---|
774 | static HRESULT WINAPI OLEPictureImpl_IsDirty(
|
---|
775 | IPersistStream* iface)
|
---|
776 | {
|
---|
777 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
778 | FIXME("(%p),stub!\n",This);
|
---|
779 | return E_NOTIMPL;
|
---|
780 | }
|
---|
781 |
|
---|
782 | #ifdef HAVE_LIBJPEG
|
---|
783 | /* for the jpeg decompressor source manager. */
|
---|
784 | static void _jpeg_init_source(j_decompress_ptr cinfo) { }
|
---|
785 |
|
---|
786 | static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
|
---|
787 | ERR("(), should not get here.\n");
|
---|
788 | return FALSE;
|
---|
789 | }
|
---|
790 |
|
---|
791 | static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) {
|
---|
792 | ERR("(%ld), should not get here.\n",num_bytes);
|
---|
793 | }
|
---|
794 |
|
---|
795 | static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
|
---|
796 | ERR("(desired=%d), should not get here.\n",desired);
|
---|
797 | return FALSE;
|
---|
798 | }
|
---|
799 | static void _jpeg_term_source(j_decompress_ptr cinfo) { }
|
---|
800 | #endif /* HAVE_LIBJPEG */
|
---|
801 |
|
---|
802 | /************************************************************************
|
---|
803 | * OLEPictureImpl_IPersistStream_Load (IUnknown)
|
---|
804 | *
|
---|
805 | * Loads the binary data from the IStream. Starts at current position.
|
---|
806 | * There appears to be an 2 DWORD header:
|
---|
807 | * DWORD magic;
|
---|
808 | * DWORD len;
|
---|
809 | *
|
---|
810 | * Currently implemented: BITMAP, ICON, JPEG.
|
---|
811 | */
|
---|
812 | static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) {
|
---|
813 | HRESULT hr = E_FAIL;
|
---|
814 | ULONG xread;
|
---|
815 | BYTE *xbuf;
|
---|
816 | DWORD header[2];
|
---|
817 | WORD magic;
|
---|
818 | ICOM_THIS_From_IPersistStream(OLEPictureImpl, iface);
|
---|
819 |
|
---|
820 | TRACE("(%p,%p)\n",This,pStm);
|
---|
821 |
|
---|
822 | hr=IStream_Read(pStm,header,8,&xread);
|
---|
823 | if (hr || xread!=8) {
|
---|
824 | FIXME("Failure while reading picture header (hr is %lx, nread is %ld).\n",hr,xread);
|
---|
825 | return hr;
|
---|
826 | }
|
---|
827 | xread = 0;
|
---|
828 | xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
|
---|
829 | while (xread < header[1]) {
|
---|
830 | ULONG nread;
|
---|
831 | hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
|
---|
832 | xread+=nread;
|
---|
833 | if (hr || !nread)
|
---|
834 | break;
|
---|
835 | }
|
---|
836 | if (xread != header[1])
|
---|
837 | FIXME("Could only read %ld of %ld bytes?\n",xread,header[1]);
|
---|
838 |
|
---|
839 | magic = xbuf[0] + (xbuf[1]<<8);
|
---|
840 | switch (magic) {
|
---|
841 | case 0xd8ff: { /* JPEG */
|
---|
842 | #ifdef HAVE_LIBJPEG
|
---|
843 | struct jpeg_decompress_struct jd;
|
---|
844 | struct jpeg_error_mgr jerr;
|
---|
845 | int ret;
|
---|
846 | JDIMENSION x;
|
---|
847 | JSAMPROW samprow;
|
---|
848 | BITMAPINFOHEADER bmi;
|
---|
849 | LPBYTE bits;
|
---|
850 | HDC hdcref;
|
---|
851 | struct jpeg_source_mgr xjsm;
|
---|
852 |
|
---|
853 | /* This is basically so we can use in-memory data for jpeg decompression.
|
---|
854 | * We need to have all the functions.
|
---|
855 | */
|
---|
856 | xjsm.next_input_byte = xbuf;
|
---|
857 | xjsm.bytes_in_buffer = xread;
|
---|
858 | xjsm.init_source = _jpeg_init_source;
|
---|
859 | xjsm.fill_input_buffer = _jpeg_fill_input_buffer;
|
---|
860 | xjsm.skip_input_data = _jpeg_skip_input_data;
|
---|
861 | xjsm.resync_to_restart = _jpeg_resync_to_restart;
|
---|
862 | xjsm.term_source = _jpeg_term_source;
|
---|
863 |
|
---|
864 | jd.err = jpeg_std_error(&jerr);
|
---|
865 | jpeg_create_decompress(&jd);
|
---|
866 | jd.src = &xjsm;
|
---|
867 | ret=jpeg_read_header(&jd,TRUE);
|
---|
868 | jpeg_start_decompress(&jd);
|
---|
869 | if (ret != JPEG_HEADER_OK) {
|
---|
870 | ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
|
---|
871 | HeapFree(GetProcessHeap(),0,xbuf);
|
---|
872 | return E_FAIL;
|
---|
873 | }
|
---|
874 | bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*jd.output_width*jd.output_components);
|
---|
875 | samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components);
|
---|
876 | while ( jd.output_scanline<jd.output_height ) {
|
---|
877 | x = jpeg_read_scanlines(&jd,&samprow,1);
|
---|
878 | if (x != 1) {
|
---|
879 | FIXME("failed to read current scanline?\n");
|
---|
880 | break;
|
---|
881 | }
|
---|
882 | memcpy( bits+jd.output_scanline*jd.output_width*jd.output_components,
|
---|
883 | samprow,
|
---|
884 | jd.output_width*jd.output_components
|
---|
885 | );
|
---|
886 | }
|
---|
887 | bmi.biSize = sizeof(bmi);
|
---|
888 | bmi.biWidth = jd.output_width;
|
---|
889 | bmi.biHeight = -jd.output_height;
|
---|
890 | bmi.biPlanes = 1;
|
---|
891 | bmi.biBitCount = jd.output_components<<3;
|
---|
892 | bmi.biCompression = BI_RGB;
|
---|
893 | bmi.biSizeImage = jd.output_height*jd.output_width*jd.output_components;
|
---|
894 | bmi.biXPelsPerMeter = 0;
|
---|
895 | bmi.biYPelsPerMeter = 0;
|
---|
896 | bmi.biClrUsed = 0;
|
---|
897 | bmi.biClrImportant = 0;
|
---|
898 |
|
---|
899 | HeapFree(GetProcessHeap(),0,samprow);
|
---|
900 | jpeg_finish_decompress(&jd);
|
---|
901 | jpeg_destroy_decompress(&jd);
|
---|
902 | hdcref = GetDC(0);
|
---|
903 | This->desc.u.bmp.hbitmap=CreateDIBitmap(
|
---|
904 | hdcref,
|
---|
905 | &bmi,
|
---|
906 | CBM_INIT,
|
---|
907 | bits,
|
---|
908 | (BITMAPINFO*)&bmi,
|
---|
909 | DIB_RGB_COLORS
|
---|
910 | );
|
---|
911 | DeleteDC(hdcref);
|
---|
912 | This->desc.picType = PICTYPE_BITMAP;
|
---|
913 | OLEPictureImpl_SetBitmap(This);
|
---|
914 | hr = S_OK;
|
---|
915 | HeapFree(GetProcessHeap(),0,bits);
|
---|
916 | #else
|
---|
917 | ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n");
|
---|
918 | hr = E_FAIL;
|
---|
919 | #endif
|
---|
920 | break;
|
---|
921 | }
|
---|
922 | case 0x4d42: { /* Bitmap */
|
---|
923 | BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf;
|
---|
924 | BITMAPINFO *bi = (BITMAPINFO*)(bfh+1);
|
---|
925 | HDC hdcref;
|
---|
926 |
|
---|
927 | /* Does not matter whether this is a coreheader or not, we only use
|
---|
928 | * components which are in both
|
---|
929 | */
|
---|
930 | hdcref = GetDC(0);
|
---|
931 | This->desc.u.bmp.hbitmap = CreateDIBitmap(
|
---|
932 | hdcref,
|
---|
933 | &(bi->bmiHeader),
|
---|
934 | CBM_INIT,
|
---|
935 | xbuf+bfh->bfOffBits,
|
---|
936 | bi,
|
---|
937 | (bi->bmiHeader.biBitCount<=8)?DIB_PAL_COLORS:DIB_RGB_COLORS
|
---|
938 | );
|
---|
939 | DeleteDC(hdcref);
|
---|
940 | This->desc.picType = PICTYPE_BITMAP;
|
---|
941 | OLEPictureImpl_SetBitmap(This);
|
---|
942 | hr = S_OK;
|
---|
943 | break;
|
---|
944 | }
|
---|
945 | case 0x0000: { /* ICON , first word is dwReserved */
|
---|
946 | HICON hicon;
|
---|
947 | CURSORICONFILEDIR *cifd = (CURSORICONFILEDIR*)xbuf;
|
---|
948 | int i;
|
---|
949 |
|
---|
950 | /*
|
---|
951 | FIXME("icon.idReserved=%d\n",cifd->idReserved);
|
---|
952 | FIXME("icon.idType=%d\n",cifd->idType);
|
---|
953 | FIXME("icon.idCount=%d\n",cifd->idCount);
|
---|
954 |
|
---|
955 | for (i=0;i<cifd->idCount;i++) {
|
---|
956 | FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
|
---|
957 | FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
|
---|
958 | FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
|
---|
959 | FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
|
---|
960 | FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
|
---|
961 | FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
|
---|
962 | FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
|
---|
963 | FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
|
---|
964 | }
|
---|
965 | */
|
---|
966 | i=0;
|
---|
967 | /* If we have more than one icon, try to find the best.
|
---|
968 | * this currently means '32 pixel wide'.
|
---|
969 | */
|
---|
970 | if (cifd->idCount!=1) {
|
---|
971 | for (i=0;i<cifd->idCount;i++) {
|
---|
972 | if (cifd->idEntries[i].bWidth == 32)
|
---|
973 | break;
|
---|
974 | }
|
---|
975 | if (i==cifd->idCount) i=0;
|
---|
976 | }
|
---|
977 |
|
---|
978 | hicon = CreateIconFromResourceEx(
|
---|
979 | xbuf+cifd->idEntries[i].dwDIBOffset,
|
---|
980 | cifd->idEntries[i].dwDIBSize,
|
---|
981 | TRUE, /* is icon */
|
---|
982 | 0x00030000,
|
---|
983 | cifd->idEntries[i].bWidth,
|
---|
984 | cifd->idEntries[i].bHeight,
|
---|
985 | 0
|
---|
986 | );
|
---|
987 | if (!hicon) {
|
---|
988 | FIXME("CreateIcon failed.\n");
|
---|
989 | hr = E_FAIL;
|
---|
990 | } else {
|
---|
991 | This->desc.picType = PICTYPE_ICON;
|
---|
992 | This->desc.u.icon.hicon = hicon;
|
---|
993 | hr = S_OK;
|
---|
994 | }
|
---|
995 | break;
|
---|
996 | }
|
---|
997 | default:
|
---|
998 | FIXME("Unknown magic %04x\n",magic);
|
---|
999 | hr=E_FAIL;
|
---|
1000 | break;
|
---|
1001 | }
|
---|
1002 | HeapFree(GetProcessHeap(),0,xbuf);
|
---|
1003 |
|
---|
1004 | /* FIXME: this notify is not really documented */
|
---|
1005 | if (hr==S_OK)
|
---|
1006 | OLEPicture_SendNotify(This,DISPID_PICT_TYPE);
|
---|
1007 | return hr;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | static HRESULT WINAPI OLEPictureImpl_Save(
|
---|
1011 | IPersistStream* iface,IStream*pStm,BOOL fClearDirty)
|
---|
1012 | {
|
---|
1013 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
1014 | FIXME("(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
|
---|
1015 | return E_NOTIMPL;
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | static HRESULT WINAPI OLEPictureImpl_GetSizeMax(
|
---|
1019 | IPersistStream* iface,ULARGE_INTEGER*pcbSize)
|
---|
1020 | {
|
---|
1021 | ICOM_THIS_From_IPersistStream(IPicture, iface);
|
---|
1022 | FIXME("(%p,%p),stub!\n",This,pcbSize);
|
---|
1023 | return E_NOTIMPL;
|
---|
1024 | }
|
---|
1025 |
|
---|
1026 | /************************************************************************
|
---|
1027 | * IDispatch
|
---|
1028 | */
|
---|
1029 | /************************************************************************
|
---|
1030 | * OLEPictureImpl_IDispatch_QueryInterface (IUnknown)
|
---|
1031 | *
|
---|
1032 | * See Windows documentation for more details on IUnknown methods.
|
---|
1033 | */
|
---|
1034 | static HRESULT WINAPI OLEPictureImpl_IDispatch_QueryInterface(
|
---|
1035 | IDispatch* iface,
|
---|
1036 | REFIID riid,
|
---|
1037 | VOID** ppvoid)
|
---|
1038 | {
|
---|
1039 | ICOM_THIS_From_IDispatch(IPicture, iface);
|
---|
1040 |
|
---|
1041 | return IPicture_QueryInterface(This, riid, ppvoid);
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | /************************************************************************
|
---|
1045 | * OLEPictureImpl_IDispatch_AddRef (IUnknown)
|
---|
1046 | *
|
---|
1047 | * See Windows documentation for more details on IUnknown methods.
|
---|
1048 | */
|
---|
1049 | static ULONG WINAPI OLEPictureImpl_IDispatch_AddRef(
|
---|
1050 | IDispatch* iface)
|
---|
1051 | {
|
---|
1052 | ICOM_THIS_From_IDispatch(IPicture, iface);
|
---|
1053 |
|
---|
1054 | return IPicture_AddRef(This);
|
---|
1055 | }
|
---|
1056 |
|
---|
1057 | /************************************************************************
|
---|
1058 | * OLEPictureImpl_IDispatch_Release (IUnknown)
|
---|
1059 | *
|
---|
1060 | * See Windows documentation for more details on IUnknown methods.
|
---|
1061 | */
|
---|
1062 | static ULONG WINAPI OLEPictureImpl_IDispatch_Release(
|
---|
1063 | IDispatch* iface)
|
---|
1064 | {
|
---|
1065 | ICOM_THIS_From_IDispatch(IPicture, iface);
|
---|
1066 |
|
---|
1067 | return IPicture_Release(This);
|
---|
1068 | }
|
---|
1069 |
|
---|
1070 | /************************************************************************
|
---|
1071 | * OLEPictureImpl_GetTypeInfoCount (IDispatch)
|
---|
1072 | *
|
---|
1073 | * See Windows documentation for more details on IDispatch methods.
|
---|
1074 | */
|
---|
1075 | static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(
|
---|
1076 | IDispatch* iface,
|
---|
1077 | unsigned int* pctinfo)
|
---|
1078 | {
|
---|
1079 | FIXME("():Stub\n");
|
---|
1080 |
|
---|
1081 | return E_NOTIMPL;
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | /************************************************************************
|
---|
1085 | * OLEPictureImpl_GetTypeInfo (IDispatch)
|
---|
1086 | *
|
---|
1087 | * See Windows documentation for more details on IDispatch methods.
|
---|
1088 | */
|
---|
1089 | static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(
|
---|
1090 | IDispatch* iface,
|
---|
1091 | UINT iTInfo,
|
---|
1092 | LCID lcid,
|
---|
1093 | ITypeInfo** ppTInfo)
|
---|
1094 | {
|
---|
1095 | FIXME("():Stub\n");
|
---|
1096 |
|
---|
1097 | return E_NOTIMPL;
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | /************************************************************************
|
---|
1101 | * OLEPictureImpl_GetIDsOfNames (IDispatch)
|
---|
1102 | *
|
---|
1103 | * See Windows documentation for more details on IDispatch methods.
|
---|
1104 | */
|
---|
1105 | static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(
|
---|
1106 | IDispatch* iface,
|
---|
1107 | REFIID riid,
|
---|
1108 | LPOLESTR* rgszNames,
|
---|
1109 | UINT cNames,
|
---|
1110 | LCID lcid,
|
---|
1111 | DISPID* rgDispId)
|
---|
1112 | {
|
---|
1113 | FIXME("():Stub\n");
|
---|
1114 |
|
---|
1115 | return E_NOTIMPL;
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | /************************************************************************
|
---|
1119 | * OLEPictureImpl_Invoke (IDispatch)
|
---|
1120 | *
|
---|
1121 | * See Windows documentation for more details on IDispatch methods.
|
---|
1122 | */
|
---|
1123 | static HRESULT WINAPI OLEPictureImpl_Invoke(
|
---|
1124 | IDispatch* iface,
|
---|
1125 | DISPID dispIdMember,
|
---|
1126 | REFIID riid,
|
---|
1127 | LCID lcid,
|
---|
1128 | WORD wFlags,
|
---|
1129 | DISPPARAMS* pDispParams,
|
---|
1130 | VARIANT* pVarResult,
|
---|
1131 | EXCEPINFO* pExepInfo,
|
---|
1132 | UINT* puArgErr)
|
---|
1133 | {
|
---|
1134 | FIXME("(dispid: %ld):Stub\n",dispIdMember);
|
---|
1135 |
|
---|
1136 | VariantInit(pVarResult);
|
---|
1137 | V_VT(pVarResult) = VT_BOOL;
|
---|
1138 | V_UNION(pVarResult,boolVal) = FALSE;
|
---|
1139 | return S_OK;
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 |
|
---|
1143 | static ICOM_VTABLE(IPicture) OLEPictureImpl_VTable =
|
---|
1144 | {
|
---|
1145 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1146 | OLEPictureImpl_QueryInterface,
|
---|
1147 | OLEPictureImpl_AddRef,
|
---|
1148 | OLEPictureImpl_Release,
|
---|
1149 | OLEPictureImpl_get_Handle,
|
---|
1150 | OLEPictureImpl_get_hPal,
|
---|
1151 | OLEPictureImpl_get_Type,
|
---|
1152 | OLEPictureImpl_get_Width,
|
---|
1153 | OLEPictureImpl_get_Height,
|
---|
1154 | OLEPictureImpl_Render,
|
---|
1155 | OLEPictureImpl_set_hPal,
|
---|
1156 | OLEPictureImpl_get_CurDC,
|
---|
1157 | OLEPictureImpl_SelectPicture,
|
---|
1158 | OLEPictureImpl_get_KeepOriginalFormat,
|
---|
1159 | OLEPictureImpl_put_KeepOriginalFormat,
|
---|
1160 | OLEPictureImpl_PictureChanged,
|
---|
1161 | OLEPictureImpl_SaveAsFile,
|
---|
1162 | OLEPictureImpl_get_Attributes
|
---|
1163 | };
|
---|
1164 |
|
---|
1165 | static ICOM_VTABLE(IDispatch) OLEPictureImpl_IDispatch_VTable =
|
---|
1166 | {
|
---|
1167 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1168 | OLEPictureImpl_IDispatch_QueryInterface,
|
---|
1169 | OLEPictureImpl_IDispatch_AddRef,
|
---|
1170 | OLEPictureImpl_IDispatch_Release,
|
---|
1171 | OLEPictureImpl_GetTypeInfoCount,
|
---|
1172 | OLEPictureImpl_GetTypeInfo,
|
---|
1173 | OLEPictureImpl_GetIDsOfNames,
|
---|
1174 | OLEPictureImpl_Invoke
|
---|
1175 | };
|
---|
1176 |
|
---|
1177 | static ICOM_VTABLE(IPersistStream) OLEPictureImpl_IPersistStream_VTable =
|
---|
1178 | {
|
---|
1179 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1180 | OLEPictureImpl_IPersistStream_QueryInterface,
|
---|
1181 | OLEPictureImpl_IPersistStream_AddRef,
|
---|
1182 | OLEPictureImpl_IPersistStream_Release,
|
---|
1183 | OLEPictureImpl_GetClassID,
|
---|
1184 | OLEPictureImpl_IsDirty,
|
---|
1185 | OLEPictureImpl_Load,
|
---|
1186 | OLEPictureImpl_Save,
|
---|
1187 | OLEPictureImpl_GetSizeMax
|
---|
1188 | };
|
---|
1189 |
|
---|
1190 | static ICOM_VTABLE(IConnectionPointContainer) OLEPictureImpl_IConnectionPointContainer_VTable =
|
---|
1191 | {
|
---|
1192 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
1193 | OLEPictureImpl_IConnectionPointContainer_QueryInterface,
|
---|
1194 | OLEPictureImpl_IConnectionPointContainer_AddRef,
|
---|
1195 | OLEPictureImpl_IConnectionPointContainer_Release,
|
---|
1196 | OLEPictureImpl_EnumConnectionPoints,
|
---|
1197 | OLEPictureImpl_FindConnectionPoint
|
---|
1198 | };
|
---|
1199 |
|
---|
1200 | /***********************************************************************
|
---|
1201 | * OleCreatePictureIndirect (OLEAUT32.419)
|
---|
1202 | */
|
---|
1203 | HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid,
|
---|
1204 | BOOL fOwn, LPVOID *ppvObj )
|
---|
1205 | {
|
---|
1206 | OLEPictureImpl* newPict = NULL;
|
---|
1207 | HRESULT hr = S_OK;
|
---|
1208 |
|
---|
1209 | TRACE("(%p,%p,%d,%p)\n", lpPictDesc, riid, fOwn, ppvObj);
|
---|
1210 |
|
---|
1211 | /*
|
---|
1212 | * Sanity check
|
---|
1213 | */
|
---|
1214 | if (ppvObj==0)
|
---|
1215 | return E_POINTER;
|
---|
1216 |
|
---|
1217 | *ppvObj = NULL;
|
---|
1218 |
|
---|
1219 | /*
|
---|
1220 | * Try to construct a new instance of the class.
|
---|
1221 | */
|
---|
1222 | newPict = OLEPictureImpl_Construct(lpPictDesc, fOwn);
|
---|
1223 |
|
---|
1224 | if (newPict == NULL)
|
---|
1225 | return E_OUTOFMEMORY;
|
---|
1226 |
|
---|
1227 | /*
|
---|
1228 | * Make sure it supports the interface required by the caller.
|
---|
1229 | */
|
---|
1230 | hr = IPicture_QueryInterface((IPicture*)newPict, riid, ppvObj);
|
---|
1231 |
|
---|
1232 | /*
|
---|
1233 | * Release the reference obtained in the constructor. If
|
---|
1234 | * the QueryInterface was unsuccessful, it will free the class.
|
---|
1235 | */
|
---|
1236 | IPicture_Release((IPicture*)newPict);
|
---|
1237 |
|
---|
1238 | return hr;
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 |
|
---|
1242 | /***********************************************************************
|
---|
1243 | * OleLoadPicture (OLEAUT32.418)
|
---|
1244 | */
|
---|
1245 | HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
|
---|
1246 | REFIID riid, LPVOID *ppvObj )
|
---|
1247 | {
|
---|
1248 | LPPERSISTSTREAM ps;
|
---|
1249 | IPicture *newpic;
|
---|
1250 | HRESULT hr;
|
---|
1251 |
|
---|
1252 | TRACE("(%p,%ld,%d,%s,%p), partially implemented.\n",
|
---|
1253 | lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
|
---|
1254 |
|
---|
1255 | hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
|
---|
1256 | if (hr)
|
---|
1257 | return hr;
|
---|
1258 | hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
|
---|
1259 | if (hr) {
|
---|
1260 | FIXME("Could not get IPersistStream iface from Ole Picture?\n");
|
---|
1261 | IPicture_Release(newpic);
|
---|
1262 | *ppvObj = NULL;
|
---|
1263 | return hr;
|
---|
1264 | }
|
---|
1265 | IPersistStream_Load(ps,lpstream);
|
---|
1266 | IPersistStream_Release(ps);
|
---|
1267 | hr = IPicture_QueryInterface(newpic,riid,ppvObj);
|
---|
1268 | if (hr)
|
---|
1269 | FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
|
---|
1270 | IPicture_Release(newpic);
|
---|
1271 | return hr;
|
---|
1272 | }
|
---|
1273 |
|
---|
1274 | /***********************************************************************
|
---|
1275 | * OleLoadPictureEx (OLEAUT32.425)
|
---|
1276 | */
|
---|
1277 | HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
|
---|
1278 | REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
|
---|
1279 | {
|
---|
1280 | FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
|
---|
1281 | lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
|
---|
1282 | return S_OK;
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | #ifdef __WIN32OS2__
|
---|
1286 |
|
---|
1287 | // ----------------------------------------------------------------------
|
---|
1288 | // OleLoadPictureFile
|
---|
1289 | // ----------------------------------------------------------------------
|
---|
1290 | HRESULT WIN32API OleLoadPictureFile(VARIANT varFileName, LPDISPATCH* lplpdispPicture)
|
---|
1291 | {
|
---|
1292 | dprintf(("OLEAUT32: OleLoadPictureFile - stub"));
|
---|
1293 | return S_OK;
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | // ----------------------------------------------------------------------
|
---|
1297 | // OleSavePictureFile
|
---|
1298 | // ----------------------------------------------------------------------
|
---|
1299 | HRESULT WIN32API OleSavePictureFile(LPDISPATCH lpdispPicture,
|
---|
1300 | BSTR bstrFileName)
|
---|
1301 | {
|
---|
1302 | dprintf(("OLEAUT32: OleSavePictureFile - stub"));
|
---|
1303 | return S_OK;
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 | // ----------------------------------------------------------------------
|
---|
1307 | // OleLoadPicturePath
|
---|
1308 | // ----------------------------------------------------------------------
|
---|
1309 | HRESULT WIN32API OleLoadPicturePath
|
---|
1310 | (LPOLESTR szURLorPath,
|
---|
1311 | LPUNKNOWN punkCaller,
|
---|
1312 | DWORD dwReserved,
|
---|
1313 | OLE_COLOR clrReserved,
|
---|
1314 | REFIID riid,
|
---|
1315 | LPVOID * ppvRet )
|
---|
1316 | {
|
---|
1317 | dprintf(("OLEAUT32: OleLoadPicturePath - stub"));
|
---|
1318 | return S_OK;
|
---|
1319 | }
|
---|
1320 | #endif
|
---|