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