Commit a9cc6f02 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

oleaut32: Implement OleLoadPictureFile.

parent 176fa9ad
......@@ -2297,15 +2297,6 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
return hr;
}
/***********************************************************************
* OleLoadPictureFile (OLEAUT32.422)
*/
HRESULT WINAPI OleLoadPictureFile(VARIANT file, LPDISPATCH *picture)
{
FIXME("(%s %p): stub\n", wine_dbgstr_variant(&file), picture);
return E_NOTIMPL;
}
static HRESULT create_stream(const WCHAR *filename, IStream **stream)
{
HANDLE hFile;
......@@ -2346,6 +2337,33 @@ static HRESULT create_stream(const WCHAR *filename, IStream **stream)
}
/***********************************************************************
* OleLoadPictureFile (OLEAUT32.422)
*/
HRESULT WINAPI OleLoadPictureFile(VARIANT filename, IDispatch **picture)
{
IStream *stream;
HRESULT hr;
TRACE("(%s,%p)\n", wine_dbgstr_variant(&filename), picture);
if (V_VT(&filename) != VT_BSTR)
return CTL_E_FILENOTFOUND;
hr = create_stream(V_BSTR(&filename), &stream);
if (hr != S_OK)
{
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
return CTL_E_FILENOTFOUND;
return CTL_E_PATHFILEACCESSERROR;
}
hr = OleLoadPicture(stream, 0, FALSE, &IID_IDispatch, (void **)picture);
IStream_Release(stream);
return hr;
}
/***********************************************************************
* OleSavePictureFile (OLEAUT32.423)
*/
HRESULT WINAPI OleSavePictureFile(IDispatch *picture, BSTR filename)
......
......@@ -948,6 +948,7 @@ static void test_OleLoadPicturePath(void)
HANDLE file;
DWORD size;
WCHAR *ptr;
VARIANT var;
const struct
{
......@@ -1014,6 +1015,14 @@ static void test_OleLoadPicturePath(void)
if (pic)
IPicture_Release(pic);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW + 8);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == S_OK, "OleLoadPictureFile error %#lx\n", hres);
IPicture_Release(pic);
VariantClear(&var);
/* Try a DOS path with tacked on "file:". */
hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
ok(hres == S_OK ||
......@@ -1022,6 +1031,13 @@ static void test_OleLoadPicturePath(void)
if (pic)
IPicture_Release(pic);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
VariantClear(&var);
DeleteFileA(temp_file);
/* Try with a nonexistent file. */
......@@ -1031,12 +1047,26 @@ static void test_OleLoadPicturePath(void)
broken(hres == E_FAIL), /*Win2k */
"Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW + 8);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_FILENOTFOUND, "wrong error %#lx\n", hres);
VariantClear(&var);
hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
ok(hres == INET_E_RESOURCE_NOT_FOUND || /* XP+ */
broken(hres == E_UNEXPECTED) || /* NT4 */
broken(hres == E_FAIL), /* Win2k */
"Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
VariantClear(&var);
file = CreateFileA(temp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
......@@ -1058,6 +1088,13 @@ static void test_OleLoadPicturePath(void)
if (pic)
IPicture_Release(pic);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
VariantClear(&var);
DeleteFileA(temp_file);
/* Try with a nonexistent file. */
......@@ -1066,6 +1103,22 @@ static void test_OleLoadPicturePath(void)
broken(hres == E_UNEXPECTED) || /* NT4 */
broken(hres == E_FAIL), /* Win2k */
"Expected OleLoadPicturePath to return INET_E_RESOURCE_NOT_FOUND, got 0x%08lx\n", hres);
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(temp_fileW);
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_PATHFILEACCESSERROR, "wrong error %#lx\n", hres);
VariantClear(&var);
VariantInit(&var);
V_VT(&var) = VT_INT;
V_INT(&var) = 762;
hres = OleLoadPictureFile(var, (IDispatch **)&pic);
ok(hres == CTL_E_FILENOTFOUND, "wrong error %#lx\n", hres);
if (0) /* crashes under Windows */
hres = OleLoadPictureFile(var, NULL);
}
static void test_himetric(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment