mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
oleaut32-OleLoadPictureFile: Updated patchset.
This commit is contained in:
parent
96fddf8187
commit
7edc147a61
@ -0,0 +1,68 @@
|
||||
From 1d3c7baaddc652049995ffc1fbb41e3950dcd8dc Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Sun, 27 Mar 2016 12:30:00 +0800
|
||||
Subject: oleaut32: Do not reimplement OleLoadPicture in OleLoadPicturePath.
|
||||
|
||||
punkCaller is ignored by StdPicture ClassFactory implementation anyway.
|
||||
---
|
||||
dlls/oleaut32/olepicture.c | 27 +--------------------------
|
||||
1 file changed, 1 insertion(+), 26 deletions(-)
|
||||
|
||||
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
|
||||
index 44157de..285afba 100644
|
||||
--- a/dlls/oleaut32/olepicture.c
|
||||
+++ b/dlls/oleaut32/olepicture.c
|
||||
@@ -2332,16 +2332,13 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
|
||||
LPVOID *ppvRet )
|
||||
{
|
||||
static const WCHAR file[] = { 'f','i','l','e',':',0 };
|
||||
- IPicture *ipicture;
|
||||
HANDLE hFile;
|
||||
DWORD dwFileSize;
|
||||
HGLOBAL hGlobal = NULL;
|
||||
DWORD dwBytesRead;
|
||||
IStream *stream;
|
||||
BOOL bRead;
|
||||
- IPersistStream *pStream;
|
||||
HRESULT hRes;
|
||||
- HRESULT init_res;
|
||||
WCHAR *file_candidate;
|
||||
WCHAR path_buf[MAX_PATH];
|
||||
|
||||
@@ -2418,32 +2415,10 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
|
||||
return hRes;
|
||||
}
|
||||
|
||||
- init_res = CoInitialize(NULL);
|
||||
-
|
||||
- hRes = CoCreateInstance(&CLSID_StdPicture, punkCaller, CLSCTX_INPROC_SERVER,
|
||||
- &IID_IPicture, (LPVOID*)&ipicture);
|
||||
- if (SUCCEEDED(hRes)) {
|
||||
- hRes = IPicture_QueryInterface(ipicture, &IID_IPersistStream, (LPVOID*)&pStream);
|
||||
-
|
||||
- if (SUCCEEDED(hRes)) {
|
||||
- hRes = IPersistStream_Load(pStream, stream);
|
||||
-
|
||||
- if (SUCCEEDED(hRes)) {
|
||||
- hRes = IPicture_QueryInterface(ipicture, riid, ppvRet);
|
||||
-
|
||||
- if (FAILED(hRes))
|
||||
- ERR("Failed to get interface %s from IPicture.\n", debugstr_guid(riid));
|
||||
- }
|
||||
- IPersistStream_Release(pStream);
|
||||
- }
|
||||
- IPicture_Release(ipicture);
|
||||
- }
|
||||
+ hRes = OleLoadPicture(stream, 0, FALSE, riid, ppvRet);
|
||||
|
||||
IStream_Release(stream);
|
||||
|
||||
- if (SUCCEEDED(init_res))
|
||||
- CoUninitialize();
|
||||
-
|
||||
return hRes;
|
||||
}
|
||||
|
||||
--
|
||||
2.7.1
|
||||
|
@ -0,0 +1,114 @@
|
||||
From 80a5db695f22b94335d3945354c1e28c519f81ff Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Sun, 27 Mar 2016 16:26:47 +0800
|
||||
Subject: oleaut32: Factor out stream creation from OleLoadPicturePath.
|
||||
|
||||
---
|
||||
dlls/oleaut32/olepicture.c | 75 +++++++++++++++++++++++++---------------------
|
||||
1 file changed, 41 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
|
||||
index 285afba..9badf31 100644
|
||||
--- a/dlls/oleaut32/olepicture.c
|
||||
+++ b/dlls/oleaut32/olepicture.c
|
||||
@@ -2315,6 +2315,45 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
|
||||
return hr;
|
||||
}
|
||||
|
||||
+static HRESULT create_stream(const WCHAR *filename, IStream **stream)
|
||||
+{
|
||||
+ HANDLE hFile;
|
||||
+ DWORD dwFileSize;
|
||||
+ HGLOBAL hGlobal = NULL;
|
||||
+ DWORD dwBytesRead;
|
||||
+ HRESULT hr = S_OK;
|
||||
+
|
||||
+ hFile = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
+ if (hFile == INVALID_HANDLE_VALUE)
|
||||
+ return HRESULT_FROM_WIN32(GetLastError());
|
||||
+
|
||||
+ dwFileSize = GetFileSize(hFile, NULL);
|
||||
+ if (dwFileSize != INVALID_FILE_SIZE)
|
||||
+ {
|
||||
+ hGlobal = GlobalAlloc(GMEM_FIXED, dwFileSize);
|
||||
+ if (!hGlobal)
|
||||
+ hr = E_OUTOFMEMORY;
|
||||
+ else
|
||||
+ {
|
||||
+ if (!ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL))
|
||||
+ {
|
||||
+ GlobalFree(hGlobal);
|
||||
+ hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ CloseHandle(hFile);
|
||||
+
|
||||
+ if (FAILED(hr)) return hr;
|
||||
+
|
||||
+ hr = CreateStreamOnHGlobal(hGlobal, TRUE, stream);
|
||||
+ if (FAILED(hr))
|
||||
+ GlobalFree(hGlobal);
|
||||
+
|
||||
+ return hr;
|
||||
+}
|
||||
+
|
||||
/***********************************************************************
|
||||
* OleSavePictureFile (OLEAUT32.423)
|
||||
*/
|
||||
@@ -2332,12 +2371,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
|
||||
LPVOID *ppvRet )
|
||||
{
|
||||
static const WCHAR file[] = { 'f','i','l','e',':',0 };
|
||||
- HANDLE hFile;
|
||||
- DWORD dwFileSize;
|
||||
- HGLOBAL hGlobal = NULL;
|
||||
- DWORD dwBytesRead;
|
||||
IStream *stream;
|
||||
- BOOL bRead;
|
||||
HRESULT hRes;
|
||||
WCHAR *file_candidate;
|
||||
WCHAR path_buf[MAX_PATH];
|
||||
@@ -2366,36 +2400,9 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
|
||||
|
||||
/* Handle candidate DOS paths separately. */
|
||||
if (file_candidate[1] == ':') {
|
||||
- hFile = CreateFileW(file_candidate, GENERIC_READ, 0, NULL, OPEN_EXISTING,
|
||||
- 0, NULL);
|
||||
- if (hFile == INVALID_HANDLE_VALUE)
|
||||
- return INET_E_RESOURCE_NOT_FOUND;
|
||||
-
|
||||
- dwFileSize = GetFileSize(hFile, NULL);
|
||||
- if (dwFileSize != INVALID_FILE_SIZE )
|
||||
- {
|
||||
- hGlobal = GlobalAlloc(GMEM_FIXED,dwFileSize);
|
||||
- if ( hGlobal)
|
||||
- {
|
||||
- bRead = ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL) && dwBytesRead == dwFileSize;
|
||||
- if (!bRead)
|
||||
- {
|
||||
- GlobalFree(hGlobal);
|
||||
- hGlobal = 0;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- CloseHandle(hFile);
|
||||
-
|
||||
- if (!hGlobal)
|
||||
+ hRes = create_stream(file_candidate, &stream);
|
||||
+ if (FAILED(hRes))
|
||||
return INET_E_RESOURCE_NOT_FOUND;
|
||||
-
|
||||
- hRes = CreateStreamOnHGlobal(hGlobal, TRUE, &stream);
|
||||
- if (FAILED(hRes))
|
||||
- {
|
||||
- GlobalFree(hGlobal);
|
||||
- return hRes;
|
||||
- }
|
||||
} else {
|
||||
IMoniker *pmnk;
|
||||
IBindCtx *pbc;
|
||||
--
|
||||
2.7.1
|
||||
|
@ -1,13 +1,13 @@
|
||||
From 348a0830b6b31fefd170e667f650db437914bee2 Mon Sep 17 00:00:00 2001
|
||||
From d6e0caff3ae762f25517309b93ac3b706f2e7958 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Thu, 24 Mar 2016 13:35:32 +0800
|
||||
Subject: oleaut32: Implement OleLoadPictureFile.
|
||||
Date: Sun, 27 Mar 2016 16:28:33 +0800
|
||||
Subject: oleaut32: Implement OleLoadPictureFile. (v2)
|
||||
|
||||
---
|
||||
dlls/oleaut32/oleaut32.spec | 2 +-
|
||||
dlls/oleaut32/olepicture.c | 19 ++++++++++++++
|
||||
dlls/oleaut32/olepicture.c | 27 ++++++++++++++++++++
|
||||
dlls/oleaut32/tests/olepicture.c | 53 ++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 73 insertions(+), 1 deletion(-)
|
||||
3 files changed, 81 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
|
||||
index f5ad0ef..97aec54 100644
|
||||
@ -23,10 +23,10 @@ index f5ad0ef..97aec54 100644
|
||||
424 stdcall OleLoadPicturePath(wstr ptr long long ptr ptr)
|
||||
425 stdcall VarUI4FromI8(int64 ptr)
|
||||
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
|
||||
index 44157de..e700656 100644
|
||||
index 9badf31..29a091f 100644
|
||||
--- a/dlls/oleaut32/olepicture.c
|
||||
+++ b/dlls/oleaut32/olepicture.c
|
||||
@@ -2316,6 +2316,25 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
|
||||
@@ -2355,6 +2355,33 @@ static HRESULT create_stream(const WCHAR *filename, IStream **stream)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@ -34,18 +34,26 @@ index 44157de..e700656 100644
|
||||
+ */
|
||||
+HRESULT WINAPI OleLoadPictureFile(VARIANT filename, IDispatch **picture)
|
||||
+{
|
||||
+ static const WCHAR file[] = { 'f','i','l','e',':',0 };
|
||||
+ IStream *stream;
|
||||
+ HRESULT hr;
|
||||
+
|
||||
+ TRACE("(%s,%p)\n", wine_dbgstr_variant(&filename), picture);
|
||||
+
|
||||
+ if (V_VT(&filename) != VT_BSTR)
|
||||
+ return CTL_E_FILENOTFOUND;
|
||||
+
|
||||
+ /* explicitly reject file: prefixes */
|
||||
+ if (!strncmpW(V_BSTR(&filename), file, 5))
|
||||
+ return CTL_E_PATHFILEACCESSERROR;
|
||||
+ 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 OleLoadPicturePath(V_BSTR(&filename), NULL, 0, 0, &IID_IDispatch, (void **)picture);
|
||||
+ return CTL_E_PATHFILEACCESSERROR;
|
||||
+ }
|
||||
+
|
||||
+ hr = OleLoadPicture(stream, 0, FALSE, &IID_IDispatch, (void **)picture);
|
||||
+ IStream_Release(stream);
|
||||
+ return hr;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
@ -53,7 +61,7 @@ index 44157de..e700656 100644
|
||||
*/
|
||||
HRESULT WINAPI OleSavePictureFile(IDispatch *picture, BSTR filename)
|
||||
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
|
||||
index 0903298..8ebf9ea 100644
|
||||
index 0903298..46cb185 100644
|
||||
--- a/dlls/oleaut32/tests/olepicture.c
|
||||
+++ b/dlls/oleaut32/tests/olepicture.c
|
||||
@@ -850,6 +850,7 @@ static void test_OleLoadPicturePath(void)
|
||||
@ -101,7 +109,7 @@ index 0903298..8ebf9ea 100644
|
||||
+ V_VT(&var) = VT_BSTR;
|
||||
+ V_BSTR(&var) = SysAllocString(temp_fileW + 8);
|
||||
+ hres = OleLoadPictureFile(var, (IDispatch **)&pic);
|
||||
+ todo_wine ok(hres == CTL_E_FILENOTFOUND, "wrong error %#x\n", hres);
|
||||
+ ok(hres == CTL_E_FILENOTFOUND, "wrong error %#x\n", hres);
|
||||
+ VariantClear(&var);
|
||||
+
|
||||
hres = OleLoadPicturePath(temp_fileW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
|
@ -5648,9 +5648,13 @@ fi
|
||||
# | * dlls/oleaut32/oleaut32.spec, dlls/oleaut32/olepicture.c, dlls/oleaut32/tests/olepicture.c
|
||||
# |
|
||||
if test "$enable_oleaut32_OleLoadPictureFile" -eq 1; then
|
||||
patch_apply oleaut32-OleLoadPictureFile/0001-oleaut32-Implement-OleLoadPictureFile.patch
|
||||
patch_apply oleaut32-OleLoadPictureFile/0001-oleaut32-Do-not-reimplement-OleLoadPicture-in-OleLoa.patch
|
||||
patch_apply oleaut32-OleLoadPictureFile/0002-oleaut32-Factor-out-stream-creation-from-OleLoadPict.patch
|
||||
patch_apply oleaut32-OleLoadPictureFile/0003-oleaut32-Implement-OleLoadPictureFile.patch
|
||||
(
|
||||
echo '+ { "Dmitry Timoshkov", "oleaut32: Implement OleLoadPictureFile.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "oleaut32: Do not reimplement OleLoadPicture in OleLoadPicturePath.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "oleaut32: Factor out stream creation from OleLoadPicturePath.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "oleaut32: Implement OleLoadPictureFile.", 2 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user