- Added OnAmbientPropertyChange implementation.

- Call IDispatch::Invoke when native does (with test).
This commit is contained in:
Jacek Caban 2005-08-22 09:25:20 +00:00 committed by Alexandre Julliard
parent da3393d4d7
commit d5b898c14c
3 changed files with 306 additions and 4 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = mshtml.dll
IMPORTLIB = libmshtml.$(IMPLIBEXT)
IMPORTS = urlmon ole32 user32 gdi32 advapi32 kernel32 ntdll
IMPORTS = urlmon ole32 oleaut32 user32 gdi32 advapi32 kernel32 ntdll
EXTRALIBS = $(LIBUNICODE) -lstrmiids -luuid
EXTRADEFS = -DCOM_NO_WINDOWS_H

View File

@ -28,6 +28,8 @@
#include "winuser.h"
#include "ole2.h"
#include "shlguid.h"
#include "mshtmdid.h"
#include "idispids.h"
#include "wine/debug.h"
@ -153,6 +155,12 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite
This->client = pClientSite;
This->hostui = pDocHostUIHandler;
IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERMODE);
IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_SILENT);
IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERAGENT);
IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_PALETTE);
return S_OK;
}
@ -855,11 +863,125 @@ static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *pMsg)
return E_NOTIMPL;
}
static HRESULT get_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
{
IDispatch *disp = NULL;
DISPPARAMS dispparams = {NULL, 0};
UINT err;
HRESULT hres;
hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
if(FAILED(hres)) {
TRACE("Could not get IDispatch\n");
return hres;
}
VariantInit(res);
hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispparams, res, NULL, &err);
IDispatch_Release(disp);
return hres;
}
static HRESULT on_change_dlcontrol(HTMLDocument *This)
{
VARIANT res;
HRESULT hres;
hres = get_property(This->client, DISPID_AMBIENT_DLCONTROL, &res);
if(SUCCEEDED(hres))
FIXME("unsupported dlcontrol %08lx\n", V_I4(&res));
return S_OK;
}
static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
{
HTMLDocument *This = CONTROL_THIS(iface);
FIXME("(%p)->(%ld)\n", This, dispID);
return E_NOTIMPL;
VARIANT res;
HRESULT hres;
if(!This->client) {
TRACE("This->client = NULL\n");
return S_OK;
}
switch(dispID) {
case DISPID_AMBIENT_USERMODE:
TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This);
hres = get_property(This->client, DISPID_AMBIENT_USERMODE, &res);
if(FAILED(hres))
return S_OK;
if(V_VT(&res) == VT_BOOL) {
if(!V_BOOL(&res)) {
FIXME("edit mode is not supported\n");
hres = E_FAIL;
}
}else {
FIXME("V_VT(res)=%d\n", V_VT(&res));
}
return S_OK;
case DISPID_AMBIENT_DLCONTROL:
TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This);
return on_change_dlcontrol(This);
case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This);
on_change_dlcontrol(This);
hres = get_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &res);
if(FAILED(hres))
return S_OK;
if(V_VT(&res) == VT_BOOL) {
if(V_BOOL(&res)) {
FIXME("offline connection is not supported\n");
hres = E_FAIL;
}
}else {
FIXME("V_VT(res)=%d\n", V_VT(&res));
}
return S_OK;
case DISPID_AMBIENT_SILENT:
TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This);
on_change_dlcontrol(This);
hres = get_property(This->client, DISPID_AMBIENT_SILENT, &res);
if(FAILED(hres))
return S_OK;
if(V_VT(&res) == VT_BOOL) {
if(V_BOOL(&res)) {
FIXME("silent mode is not supported\n");
hres = E_FAIL;
}
}else {
FIXME("V_VT(res)=%d\n", V_VT(&res));
}
return S_OK;
case DISPID_AMBIENT_USERAGENT:
TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This);
hres = get_property(This->client, DISPID_AMBIENT_USERAGENT, &res);
if(FAILED(hres))
return S_OK;
FIXME("not supported AMBIENT_USERAGENT\n");
hres = E_FAIL;
return S_OK;
case DISPID_AMBIENT_PALETTE:
TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This);
hres = get_property(This->client, DISPID_AMBIENT_PALETTE, &res);
if(FAILED(hres))
return S_OK;
FIXME("not supported AMBIENT_PALETTE\n");
hres = E_FAIL;
return S_OK;
}
FIXME("(%p) unsupported dispID=%ld\n", This, dispID);
return E_FAIL;
}
static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)

View File

@ -27,6 +27,8 @@
#include "mshtml.h"
#include "docobj.h"
#include "mshtmhst.h"
#include "mshtmdid.h"
#include "idispids.h"
#include "shlguid.h"
#include "initguid.h"
@ -43,6 +45,10 @@ DEFINE_SHLGUID(CGID_Undocumented, 0x000214D4L, 0, 0);
expect_ ## func = FALSE; \
called_ ## func = TRUE
#define CHECK_EXPECT2(func) \
ok(expect_ ##func, "unexpected call\n"); \
called_ ## func = TRUE
#define CHECK_CALLED(func) \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE
@ -72,6 +78,12 @@ DEFINE_EXPECT(QueryStatus_OPEN);
DEFINE_EXPECT(QueryStatus_NEW);
DEFINE_EXPECT(Exec_SETPROGRESSMAX);
DEFINE_EXPECT(Exec_SETPROGRESSPOS);
DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
static BOOL expect_LockContainer_fLock;
static BOOL expect_SetActiveObject_active;
@ -879,6 +891,93 @@ static IOleCommandTargetVtbl OleCommandTargetVtbl = {
static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
{
return QueryInterface(riid, ppv);
}
static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
{
return 2;
}
static ULONG WINAPI Dispatch_Release(IDispatch *iface)
{
return 1;
}
static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
ITypeInfo **ppTInfo)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
ok(pDispParams != NULL, "pDispParams == NULL\n");
ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
ok(puArgErr != NULL, "puArgErr == NULL\n");
ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
switch(dispIdMember) {
case DISPID_AMBIENT_USERMODE:
CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
V_VT(pVarResult) = VT_BOOL;
V_BOOL(pVarResult) = VARIANT_TRUE;
return S_OK;
case DISPID_AMBIENT_DLCONTROL:
CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
return E_FAIL;
case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
return E_FAIL;
case DISPID_AMBIENT_SILENT:
CHECK_EXPECT(Invoke_AMBIENT_SILENT);
V_VT(pVarResult) = VT_BOOL;
V_BOOL(pVarResult) = VARIANT_FALSE;
return S_OK;
case DISPID_AMBIENT_USERAGENT:
CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
return E_FAIL;
case DISPID_AMBIENT_PALETTE:
CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
return E_FAIL;
};
ok(0, "unexpected dispid %ld\n", dispIdMember);
return E_FAIL;
}
static IDispatchVtbl DispatchVtbl = {
Dispatch_QueryInterface,
Dispatch_AddRef,
Dispatch_Release,
Dispatch_GetTypeInfoCount,
Dispatch_GetTypeInfo,
Dispatch_GetIDsOfNames,
Dispatch_Invoke
};
static IDispatch Dispatch = { &DispatchVtbl };
static HRESULT QueryInterface(REFIID riid, void **ppv)
{
*ppv = NULL;
@ -897,9 +996,10 @@ static HRESULT QueryInterface(REFIID riid, void **ppv)
*ppv = &InPlaceFrame;
else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
*ppv = &OleCommandTarget;
else if(IsEqualGUID(&IID_IDispatch, riid))
*ppv = &Dispatch;
/* TODO:
* IDispatch
* IServiceProvider
* {D48A6EC6-6A4A-11CF-94A7-444553540000}
* {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
@ -1151,6 +1251,12 @@ static void test_ClientSite(IOleObject *oleobj, DWORD flags)
SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
SET_EXPECT(Exec_SETPROGRESSMAX);
SET_EXPECT(Exec_SETPROGRESSPOS);
SET_EXPECT(Invoke_AMBIENT_USERMODE);
SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
SET_EXPECT(Invoke_AMBIENT_SILENT);
SET_EXPECT(Invoke_AMBIENT_USERAGENT);
SET_EXPECT(Invoke_AMBIENT_PALETTE);
hres = IOleObject_SetClientSite(oleobj, &ClientSite);
ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
CHECK_CALLED(GetHostInfo);
@ -1162,12 +1268,83 @@ static void test_ClientSite(IOleObject *oleobj, DWORD flags)
CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
CHECK_CALLED(Exec_SETPROGRESSMAX);
CHECK_CALLED(Exec_SETPROGRESSPOS);
CHECK_CALLED(Invoke_AMBIENT_USERMODE);
CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
CHECK_CALLED(Invoke_AMBIENT_SILENT);
CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
CHECK_CALLED(Invoke_AMBIENT_PALETTE);
hres = IOleObject_GetClientSite(oleobj, &clientsite);
ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
}
static void test_OnAmbientPropertyChange(IUnknown *unk)
{
IOleControl *control = NULL;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
if(FAILED(hres))
return;
SET_EXPECT(Invoke_AMBIENT_USERMODE);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_USERMODE);
SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
SET_EXPECT(Invoke_AMBIENT_SILENT);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
CHECK_CALLED(Invoke_AMBIENT_SILENT);
SET_EXPECT(Invoke_AMBIENT_USERAGENT);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
SET_EXPECT(Invoke_AMBIENT_PALETTE);
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
CHECK_CALLED(Invoke_AMBIENT_PALETTE);
IOleControl_Release(control);
}
static void test_OnAmbientPropertyChange2(IUnknown *unk)
{
IOleControl *control = NULL;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
if(FAILED(hres))
return;
hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
ok(hres == S_OK, "OnAmbientPropertyChange failed: %08lx\n", hres);
IOleControl_Release(control);
}
static void test_Close(IUnknown *unk, BOOL set_client)
{
IOleObject *oleobj = NULL;
@ -1336,6 +1513,7 @@ static void test_HTMLDocument(void)
test_Persist(unk);
test_OnAmbientPropertyChange2(unk);
hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
if(FAILED(hres)) {
IUnknown_Release(unk);
@ -1344,6 +1522,7 @@ static void test_HTMLDocument(void)
test_OleCommandTarget_fail(unk);
test_OleCommandTarget(unk);
test_OnAmbientPropertyChange(unk);
test_Window(unk, TRUE);
test_UIDeactivate();
test_OleCommandTarget(unk);
@ -1376,6 +1555,7 @@ static void test_HTMLDocument(void)
test_CloseView();
test_CloseView();
test_Close(unk, TRUE);
test_OnAmbientPropertyChange2(unk);
if(view)
IOleDocumentView_Release(view);