Added QueryStatus implementation.

This commit is contained in:
Jacek Caban 2005-08-02 09:50:19 +00:00 committed by Alexandre Julliard
parent fa043b06ba
commit 0a93f42b80
2 changed files with 173 additions and 3 deletions

View File

@ -464,6 +464,48 @@ static const IOleDocumentVtbl OleDocumentVtbl = {
#define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface) #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
static const OLECMDF status_table[OLECMDID_GETPRINTTEMPLATE+1] = {
0,
OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
OLECMDF_SUPPORTED, /* OLECMDID_NEW */
OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
OLECMDF_SUPPORTED, /* OLECMDID_CUT */
OLECMDF_SUPPORTED, /* OLECMDID_COPY */
OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
OLECMDF_SUPPORTED, /* OLECMDID_RENDO */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
0,
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
0,0,0,0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
0,0,0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
};
static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv) static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
{ {
HTMLDocument *This = CMDTARGET_THIS(iface); HTMLDocument *This = CMDTARGET_THIS(iface);
@ -486,8 +528,33 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText) ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
{ {
HTMLDocument *This = CMDTARGET_THIS(iface); HTMLDocument *This = CMDTARGET_THIS(iface);
FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); HRESULT hres = S_OK;
return E_NOTIMPL;
TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
if(!pguidCmdGroup) {
ULONG i;
for(i=0; i<cCmds; i++) {
if(prgCmds[i].cmdID<OLECMDID_OPEN || prgCmds[i].cmdID>OLECMDID_GETPRINTTEMPLATE) {
WARN("Unsupported cmdID = %ld\n", prgCmds[i].cmdID);
prgCmds[i].cmdf = 0;
hres = OLECMDERR_E_NOTSUPPORTED;
}else {
prgCmds[i].cmdf = status_table[prgCmds[i].cmdID];
TRACE("cmdID = %ld returning %lx\n", prgCmds[i].cmdID, prgCmds[i].cmdID);
hres = S_OK;
}
}
if(pguidCmdGroup)
FIXME("Set pCmdText\n");
}else {
FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
hres = OLECMDERR_E_UNKNOWNGROUP;
}
return hres;
} }
static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup, static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,

View File

@ -806,12 +806,76 @@ static void test_Persist()
} }
} }
static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
0,
OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
OLECMDF_SUPPORTED, /* OLECMDID_NEW */
OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
OLECMDF_SUPPORTED, /* OLECMDID_CUT */
OLECMDF_SUPPORTED, /* OLECMDID_COPY */
OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
OLECMDF_SUPPORTED, /* OLECMDID_RENDO */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
0,
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
0,0,0,0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
0,0,0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
0,0,
OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
0,0,0,
OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
};
static void test_OleCommandTarget(IOleCommandTarget *cmdtrg)
{
OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
int i;
HRESULT hres;
for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
cmds[i].cmdID = i+1;
cmds[i].cmdf = 0xf0f0;
}
hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %lx\n", i, cmds[i].cmdID);
ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%lx, expected %x\n",
i+1, cmds[i].cmdf, expect_cmds[i+1]);
}
}
static void test_HTMLDocument(void) static void test_HTMLDocument(void)
{ {
IOleObject *oleobj = NULL; IOleObject *oleobj = NULL;
IOleClientSite *clientsite = (LPVOID)0xdeadbeef; IOleClientSite *clientsite = (LPVOID)0xdeadbeef;
IOleInPlaceObjectWindowless *windowlessobj = NULL; IOleInPlaceObjectWindowless *windowlessobj = NULL;
IOleInPlaceActiveObject *activeobject = NULL; IOleInPlaceActiveObject *activeobject = NULL;
IOleCommandTarget *cmdtrg = NULL;
GUID guid; GUID guid;
RECT rect = {0,0,500,500}; RECT rect = {0,0,500,500};
HRESULT hres; HRESULT hres;
@ -844,7 +908,10 @@ static void test_HTMLDocument(void)
hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless, hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless,
(void**)&windowlessobj); (void**)&windowlessobj);
ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres); ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres);
hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
ok(hres == S_OK, "could not get IOleCommandTarget: %08lx\n", hres);
hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj); hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj);
ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres); ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
if(oleobj) { if(oleobj) {
@ -890,6 +957,31 @@ static void test_HTMLDocument(void)
CHECK_CALLED(ActivateMe); CHECK_CALLED(ActivateMe);
} }
if(cmdtrg) {
OLECMD cmd[2] = {
{OLECMDID_OPEN, 0xf0f0},
{OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
};
hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
ok(hres == OLECMDERR_E_NOTSUPPORTED,
"QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
"cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
"cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
ok(hres == OLECMDERR_E_UNKNOWNGROUP,
"QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
test_OleCommandTarget(cmdtrg);
}
hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject); hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres); ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
@ -912,6 +1004,9 @@ static void test_HTMLDocument(void)
CHECK_CALLED(OnUIDeactivate); CHECK_CALLED(OnUIDeactivate);
} }
if(cmdtrg)
test_OleCommandTarget(cmdtrg);
if(activeobject) { if(activeobject) {
HWND tmp_hwnd; HWND tmp_hwnd;
hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd); hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
@ -926,6 +1021,9 @@ static void test_HTMLDocument(void)
CHECK_CALLED(OnInPlaceDeactivate); CHECK_CALLED(OnInPlaceDeactivate);
} }
/* Calling test_OleCommandTarget here couses Segmentation Fault with native
* MSHTML. It doesn't with Wine. */
if(activeobject) { if(activeobject) {
HWND tmp_hwnd; HWND tmp_hwnd;
hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd); hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
@ -1015,6 +1113,9 @@ static void test_HTMLDocument(void)
ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd); ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
} }
if(cmdtrg)
test_OleCommandTarget(cmdtrg);
if(view) { if(view) {
SET_EXPECT(SetActiveObject); SET_EXPECT(SetActiveObject);
SET_EXPECT(HideUI); SET_EXPECT(HideUI);
@ -1067,6 +1168,8 @@ static void test_HTMLDocument(void)
ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres); ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
} }
if(cmdtrg)
IOleCommandTarget_Release(cmdtrg);
if(windowlessobj) if(windowlessobj)
IOleInPlaceObjectWindowless_Release(windowlessobj); IOleInPlaceObjectWindowless_Release(windowlessobj);
if(oleobj) if(oleobj)