From 901bdbf2d14746d04fe659c5f2a7a067bf1c365e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maxime=20Belleng=C3=A9?= Date: Fri, 4 Mar 2005 12:30:26 +0000 Subject: [PATCH] Implements OleLoadPicturePath. --- dlls/oleaut32/Makefile.in | 2 +- dlls/oleaut32/olepicture.c | 107 ++++++++++++++++++++++++++++++++++--- 2 files changed, 100 insertions(+), 9 deletions(-) diff --git a/dlls/oleaut32/Makefile.in b/dlls/oleaut32/Makefile.in index 428c9e8535..fcd548cc13 100644 --- a/dlls/oleaut32/Makefile.in +++ b/dlls/oleaut32/Makefile.in @@ -5,7 +5,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = oleaut32.dll IMPORTS = ole32 rpcrt4 user32 gdi32 advapi32 kernel32 ntdll -DELAYIMPORTS = comctl32 +DELAYIMPORTS = comctl32 urlmon EXTRALIBS = $(LIBUNICODE) -luuid C_SRCS = \ diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index 729a239fd4..a8cc77a123 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -71,7 +71,9 @@ #include "olectl.h" #include "oleauto.h" #include "connpt.h" +#include "urlmon.h" #include "wine/debug.h" +#include "wine/unicode.h" #include "wine/wingdi16.h" #include "cursoricon.h" @@ -1998,11 +2000,104 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller, DWORD dwReserved, OLE_COLOR clrReserved, REFIID riid, LPVOID *ppvRet ) { - FIXME("(%s,%p,%ld,%08lx,%s,%p): stub\n", + static const WCHAR file[] = { 'f','i','l','e',':','/','/',0 }; + IPicture *ipicture; + HANDLE hFile; + DWORD dwFileSize; + HGLOBAL hGlobal = NULL; + DWORD dwBytesRead = 0; + IStream *stream; + BOOL bRead; + IPersistStream *pStream; + HRESULT hRes; + + TRACE("(%s,%p,%ld,%08lx,%s,%p): stub\n", debugstr_w(szURLorPath), punkCaller, dwReserved, clrReserved, debugstr_guid(riid), ppvRet); - return E_NOTIMPL; + if (!ppvRet) return E_POINTER; + + if (strncmpW(szURLorPath, file, 7) == 0) { + szURLorPath += 7; + + hFile = CreateFileW(szURLorPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, + 0, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return E_UNEXPECTED; + + dwFileSize = GetFileSize(hFile, NULL); + if (dwFileSize != INVALID_FILE_SIZE ) + { + hGlobal = GlobalAlloc(GMEM_FIXED,dwFileSize); + if ( hGlobal) + { + bRead = ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL); + if (!bRead) + { + GlobalFree(hGlobal); + hGlobal = 0; + } + } + } + CloseHandle(hFile); + + if (!hGlobal) + return E_UNEXPECTED; + + hRes = CreateStreamOnHGlobal(hGlobal, TRUE, &stream); + if (FAILED(hRes)) + { + GlobalFree(hGlobal); + return hRes; + } + } else { + IMoniker *pmnk; + IBindCtx *pbc; + + hRes = CreateBindCtx(0, &pbc); + if (SUCCEEDED(hRes)) + { + hRes = CreateURLMoniker(NULL, szURLorPath, &pmnk); + if (SUCCEEDED(hRes)) + { + hRes = IMoniker_BindToStorage(pmnk, pbc, NULL, &IID_IStream, (LPVOID*)&stream); + IMoniker_Release(pmnk); + } + IBindCtx_Release(pbc); + } + if (FAILED(hRes)) + return hRes; + } + + hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER, + &IID_IPicture, (LPVOID*)&ipicture); + if (hRes != S_OK) { + IStream_Release(stream); + return hRes; + } + + hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream); + if (hRes) { + IStream_Release(stream); + IPicture_Release(ipicture); + return hRes; + } + + hRes = IPersistStream_Load(pStream, stream); + IPersistStream_Release(pStream); + IStream_Release(stream); + + if (hRes) { + IPicture_Release(ipicture); + return hRes; + } + + hRes = IPicture_QueryInterface(ipicture,riid,ppvRet); + if (hRes) + FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); + + IPicture_Release(ipicture); + return hRes; } /******************************************************************************* @@ -2038,12 +2133,8 @@ static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) { static HRESULT WINAPI SPCF_CreateInstance( LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj ) { - PICTDESC pd; - - FIXME("(%p,%p,%s,%p), creating stdpic with PICTYPE_NONE.\n",iface,pOuter,debugstr_guid(riid),ppobj); - pd.cbSizeofstruct = sizeof(pd); - pd.picType = PICTYPE_NONE; - return OleCreatePictureIndirect(&pd,riid,TRUE,ppobj); + /* Creates an uninitialized picture */ + return OleCreatePictureIndirect(NULL,riid,TRUE,ppobj); } -- 2.32.0.93.g670b81a890