PATCH: OleLoadPictureEx

Marcus Meissner marcus at jet.franken.de
Mon Nov 11 03:14:11 CST 2002


Hi,

resubmit of OleLoadPictureEx.

Ciao, Marcus

Changelog:
	Implemented OleLoadPictureEx.

Index: olepicture.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/olepicture.c,v
retrieving revision 1.19
diff -u -u -p -r1.19 olepicture.c
--- olepicture.c	25 Oct 2002 03:12:50 -0000	1.19
+++ olepicture.c	11 Nov 2002 09:11:06 -0000
@@ -106,6 +106,10 @@ typedef struct OLEPictureImpl {
 
     BOOL keepOrigFormat;
     HDC	hDCCur;
+
+  /* data */
+    void* data;
+    int datalen;
 } OLEPictureImpl;
 
 /*
@@ -170,7 +174,7 @@ static OLEPictureImpl* OLEPictureImpl_Co
   /*
    * Allocate space for the object.
    */
-  newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEPictureImpl));
+  newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
 
   if (newObject==0)
     return newObject;
@@ -259,6 +263,7 @@ static void OLEPictureImpl_Destroy(OLEPi
       break;
     }
   }
+  if (Obj->data) HeapFree(GetProcessHeap(), 0, Obj->data);
   HeapFree(GetProcessHeap(), 0, Obj);
 }
 
@@ -636,8 +641,8 @@ static HRESULT WINAPI OLEPictureImpl_Sav
 						LONG *pcbSize)
 {
   ICOM_THIS(OLEPictureImpl, iface);
-  FIXME("(%p)->(%p, %d, %p): stub\n", This, pstream, SaveMemCopy, pcbSize);
-  return E_NOTIMPL;
+  FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This, pstream, SaveMemCopy, pcbSize);
+  return IStream_Write(pstream,This->data,This->datalen,(ULONG*)pcbSize);
 }
 
 /************************************************************************
@@ -826,7 +831,8 @@ static HRESULT WINAPI OLEPictureImpl_Loa
       return hr;
   }
   xread = 0;
-  xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
+  xbuf = This->data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
+  This->datalen = header[1];
   while (xread < header[1]) {
     ULONG nread;
     hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
@@ -1000,7 +1006,6 @@ static HRESULT WINAPI OLEPictureImpl_Loa
     hr=E_FAIL;
     break;
   }
-  HeapFree(GetProcessHeap(),0,xbuf);
 
   /* FIXME: this notify is not really documented */
   if (hr==S_OK)
@@ -1276,9 +1281,30 @@ HRESULT WINAPI OleLoadPicture( LPSTREAM 
  * OleLoadPictureEx (OLEAUT32.401)
  */
 HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
-		            REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
+		            REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
 {
-  FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
-	lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
-  return S_OK;
+  LPPERSISTSTREAM ps;
+  IPicture	*newpic;
+  HRESULT hr;
+
+  FIXME("(%p,%ld,%d,%s,x=%ld,y=%ld,f=%lx,%p), partially implemented.\n",
+	lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj);
+
+  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
+  if (hr)
+    return hr;
+  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
+  if (hr) {
+      FIXME("Could not get IPersistStream iface from Ole Picture?\n");
+      IPicture_Release(newpic);
+      *ppvObj = NULL;
+      return hr;
+  }
+  IPersistStream_Load(ps,lpstream);
+  IPersistStream_Release(ps);
+  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
+  if (hr)
+      FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
+  IPicture_Release(newpic);
+  return hr;
 }



More information about the wine-patches mailing list