mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
173 lines
5.8 KiB
Diff
173 lines
5.8 KiB
Diff
From eb7f29d66825c454043b3f68594e5b50412300ed Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
Date: Sun, 27 Mar 2016 16:28:33 +0800
|
|
Subject: [PATCH] oleaut32: Implement OleLoadPictureFile. (v2)
|
|
|
|
---
|
|
dlls/oleaut32/olepicture.c | 36 ++++++++++++++++------
|
|
dlls/oleaut32/tests/olepicture.c | 53 ++++++++++++++++++++++++++++++++
|
|
2 files changed, 80 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
|
|
index 4a478217997..b5c9e8db271 100644
|
|
--- a/dlls/oleaut32/olepicture.c
|
|
+++ b/dlls/oleaut32/olepicture.c
|
|
@@ -2387,15 +2387,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;
|
|
@@ -2435,6 +2426,33 @@ static HRESULT create_stream(const WCHAR *filename, IStream **stream)
|
|
return hr;
|
|
}
|
|
|
|
+/***********************************************************************
|
|
+ * 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)
|
|
*/
|
|
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
|
|
index 747134e2458..78c2ed5294e 100644
|
|
--- a/dlls/oleaut32/tests/olepicture.c
|
|
+++ b/dlls/oleaut32/tests/olepicture.c
|
|
@@ -958,6 +958,7 @@ static void test_OleLoadPicturePath(void)
|
|
HANDLE file;
|
|
DWORD size;
|
|
WCHAR *ptr;
|
|
+ VARIANT var;
|
|
|
|
const struct
|
|
{
|
|
@@ -1024,6 +1025,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 %#x\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 ||
|
|
@@ -1032,6 +1041,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 %#x\n", hres);
|
|
+ VariantClear(&var);
|
|
+
|
|
DeleteFileA(temp_file);
|
|
|
|
/* Try with a nonexistent file. */
|
|
@@ -1041,12 +1057,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 %#x\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 %#x\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);
|
|
@@ -1068,6 +1098,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 %#x\n", hres);
|
|
+ VariantClear(&var);
|
|
+
|
|
DeleteFileA(temp_file);
|
|
|
|
/* Try with a nonexistent file. */
|
|
@@ -1076,6 +1113,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)
|
|
--
|
|
2.35.1
|
|
|