Module: wine Branch: master Commit: ec52a1f55700989f014851eef0a25641f8bc983a URL: http://source.winehq.org/git/wine.git/?a=commit;h=ec52a1f55700989f014851eef0...
Author: Qian Hong qhong@codeweavers.com Date: Fri Jan 16 16:09:36 2015 +0800
atl: Improved content type handling of AtlAxCreateControlEx.
---
dlls/atl/Makefile.in | 2 +- dlls/atl/atl_ax.c | 69 +++++++++++++++++++++++++++++++++++++++---------- dlls/atl100/Makefile.in | 2 +- dlls/atl100/tests/atl.c | 8 +++--- dlls/atl110/Makefile.in | 2 +- dlls/atl80/Makefile.in | 2 +- dlls/atl90/Makefile.in | 2 +- 7 files changed, 65 insertions(+), 22 deletions(-)
diff --git a/dlls/atl/Makefile.in b/dlls/atl/Makefile.in index 34ae9b8..826a5bf 100644 --- a/dlls/atl/Makefile.in +++ b/dlls/atl/Makefile.in @@ -1,6 +1,6 @@ MODULE = atl.dll IMPORTLIB = atl -IMPORTS = uuid oleaut32 ole32 user32 gdi32 advapi32 +IMPORTS = uuid oleaut32 ole32 user32 gdi32 advapi32 shlwapi EXTRADEFS = -D_ATL_VER=_ATL_VER_30
C_SRCS = \ diff --git a/dlls/atl/atl_ax.c b/dlls/atl/atl_ax.c index d16cdfd..15b0550 100644 --- a/dlls/atl/atl_ax.c +++ b/dlls/atl/atl_ax.c @@ -35,6 +35,7 @@ #include "atlbase.h" #include "atliface.h" #include "atlwin.h" +#include "shlwapi.h"
#include "wine/unicode.h"
@@ -991,6 +992,48 @@ HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd, NULL, NULL, NULL ); }
+enum content +{ + IsEmpty = 0, + IsGUID = 1, + IsHTML = 2, + IsURL = 3, + IsUnknown = 4 +}; + +static enum content get_content_type(LPCOLESTR name, CLSID *control_id) +{ + WCHAR new_urlW[MAX_PATH]; + DWORD size = MAX_PATH; + WCHAR mshtml_prefixW[] = {'m','s','h','t','m','l',':','\0'}; + + if (!name || !name[0]) + { + WARN("name %s\n", wine_dbgstr_w(name)); + return IsEmpty; + } + + if (CLSIDFromString(name, control_id) == S_OK || + CLSIDFromProgID(name, control_id) == S_OK) + return IsGUID; + + if (PathIsURLW (name) || + UrlApplySchemeW(name, new_urlW, &size, URL_APPLY_GUESSSCHEME|URL_APPLY_GUESSFILE) == S_OK) + { + *control_id = CLSID_WebBrowser; + return IsURL; + } + + if (!strncmpiW(name, mshtml_prefixW, 7)) + { + FIXME("mshtml prefix not implemented\n"); + *control_id = CLSID_WebBrowser; + return IsHTML; + } + + return IsUnknown; +} + /*********************************************************************** * AtlAxCreateControlEx [atl100.@] * @@ -1005,24 +1048,24 @@ HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd, CLSID controlId; HRESULT hRes; IOleObject *pControl; - IUnknown *pUnkControl; + IUnknown *pUnkControl = NULL; IPersistStreamInit *pPSInit; - IUnknown *pContainer; - enum {IsGUID=0,IsHTML=1,IsURL=2} content; + IUnknown *pContainer = NULL; + enum content content;
TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream, ppUnkContainer, ppUnkControl, iidSink, punkSink);
- hRes = CLSIDFromString( lpszName, &controlId ); - if ( FAILED(hRes) ) - hRes = CLSIDFromProgID( lpszName, &controlId ); - if ( SUCCEEDED( hRes ) ) - content = IsGUID; - else { - /* FIXME - check for MSHTML: prefix! */ - content = IsURL; - controlId = CLSID_WebBrowser; - } + if (ppUnkContainer) *ppUnkContainer = NULL; + if (ppUnkControl) *ppUnkControl = NULL; + + content = get_content_type(lpszName, &controlId); + + if (content == IsEmpty) + return S_OK; + + if (content == IsUnknown) + return CO_E_CLASSSTRING;
hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject, (void**) &pControl ); diff --git a/dlls/atl100/Makefile.in b/dlls/atl100/Makefile.in index 916bd8e..719afe0 100644 --- a/dlls/atl100/Makefile.in +++ b/dlls/atl100/Makefile.in @@ -1,6 +1,6 @@ MODULE = atl100.dll IMPORTLIB = atl100 -IMPORTS = uuid ole32 oleaut32 user32 gdi32 advapi32 +IMPORTS = uuid ole32 oleaut32 user32 gdi32 advapi32 shlwapi EXTRADEFS = -D_ATL_VER=_ATL_VER_100 PARENTSRC = ../atl
diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c index 8cf0a32..699af0a 100644 --- a/dlls/atl100/tests/atl.c +++ b/dlls/atl100/tests/atl.c @@ -643,8 +643,8 @@ static void test_ax_win(void) ok(hwnd != NULL, "CreateWindow failed!\n"); control = (IUnknown *)0xdeadbeef; res = AtlAxGetControl(hwnd, &control); - todo_wine ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); - todo_wine ok(!control, "returned %p\n", control); + ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); + ok(!control, "returned %p\n", control); if (control) IUnknown_Release(control); DestroyWindow(hwnd);
@@ -652,8 +652,8 @@ static void test_ax_win(void) ok(hwnd != NULL, "CreateWindow failed!\n"); control = (IUnknown *)0xdeadbeef; res = AtlAxGetControl(hwnd, &control); - todo_wine ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); - todo_wine ok(!control, "returned %p\n", control); + ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res); + ok(!control, "returned %p\n", control); if (control) IUnknown_Release(control); DestroyWindow(hwnd);
diff --git a/dlls/atl110/Makefile.in b/dlls/atl110/Makefile.in index ced0f18..49ba933 100644 --- a/dlls/atl110/Makefile.in +++ b/dlls/atl110/Makefile.in @@ -1,5 +1,5 @@ MODULE = atl110.dll -IMPORTS = oleaut32 ole32 user32 gdi32 advapi32 uuid +IMPORTS = oleaut32 ole32 user32 gdi32 advapi32 uuid shlwapi EXTRADEFS = -D_ATL_VER=_ATL_VER_110 PARENTSRC = ../atl
diff --git a/dlls/atl80/Makefile.in b/dlls/atl80/Makefile.in index 4b7bbd7..b3a5a9c 100644 --- a/dlls/atl80/Makefile.in +++ b/dlls/atl80/Makefile.in @@ -1,6 +1,6 @@ MODULE = atl80.dll IMPORTLIB = atl80 -IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid +IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid shlwapi EXTRADEFS = -D_ATL_VER=_ATL_VER_80 PARENTSRC = ../atl
diff --git a/dlls/atl90/Makefile.in b/dlls/atl90/Makefile.in index 5fed63b..d3aebe6 100644 --- a/dlls/atl90/Makefile.in +++ b/dlls/atl90/Makefile.in @@ -1,5 +1,5 @@ MODULE = atl90.dll -IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid +IMPORTS = oleaut32 user32 ole32 gdi32 advapi32 uuid shlwapi EXTRADEFS = -D_ATL_VER=_ATL_VER_90 PARENTSRC = ../atl