Added IOleCommandTarget::Exec implementation.

This commit is contained in:
Jacek Caban 2005-08-03 21:26:40 +00:00 committed by Alexandre Julliard
parent 49b7fdcfc0
commit 7d0de94185
2 changed files with 259 additions and 45 deletions

View File

@ -464,46 +464,235 @@ static const IOleDocumentVtbl OleDocumentVtbl = {
#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 exec_open(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_new(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_save(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_save_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_save_copy_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_print_preview(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_spell(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_properties(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_cut(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_copy(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_paste(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_paste_special(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_undo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_rendo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_select_all(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_clear_selection(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_get_zoom_range(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_refresh(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_stop(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_stop_download(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_delete(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_enable_interaction(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_on_unload(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_show_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_show_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_close(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_set_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static HRESULT exec_get_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL;
}
static const struct {
OLECMDF cmdf;
HRESULT (*func)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
} exec_table[OLECMDID_GETPRINTTEMPLATE+1] = {
{0},
{ OLECMDF_SUPPORTED, exec_open }, /* OLECMDID_OPEN */
{ OLECMDF_SUPPORTED, exec_new }, /* OLECMDID_NEW */
{ OLECMDF_SUPPORTED, exec_save }, /* OLECMDID_SAVE */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_save_as }, /* OLECMDID_SAVEAS */
{ OLECMDF_SUPPORTED, exec_save_copy_as }, /* OLECMDID_SAVECOPYAS */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print }, /* OLECMDID_PRINT */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print_preview }, /* OLECMDID_PRINTPREVIEW */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_page_setup }, /* OLECMDID_PAGESETUP */
{ OLECMDF_SUPPORTED, exec_spell }, /* OLECMDID_SPELL */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_properties }, /* OLECMDID_PROPERTIES */
{ OLECMDF_SUPPORTED, exec_cut }, /* OLECMDID_CUT */
{ OLECMDF_SUPPORTED, exec_copy }, /* OLECMDID_COPY */
{ OLECMDF_SUPPORTED, exec_paste }, /* OLECMDID_PASTE */
{ OLECMDF_SUPPORTED, exec_paste_special }, /* OLECMDID_PASTESPECIAL */
{ OLECMDF_SUPPORTED, exec_undo }, /* OLECMDID_UNDO */
{ OLECMDF_SUPPORTED, exec_rendo }, /* OLECMDID_REDO */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_select_all }, /* OLECMDID_SELECTALL */
{ OLECMDF_SUPPORTED, exec_clear_selection }, /* OLECMDID_CLEARSELECTION */
{ OLECMDF_SUPPORTED, exec_zoom }, /* OLECMDID_ZOOM */
{ OLECMDF_SUPPORTED, exec_get_zoom_range }, /* OLECMDID_GETZOOMRANGE */
{0},
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_refresh }, /* OLECMDID_REFRESH */
{ OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_stop }, /* OLECMDID_STOP */
{0},{0},{0},{0},{0},{0},
{ OLECMDF_SUPPORTED, exec_stop_download }, /* OLECMDID_STOPDOWNLOAD */
{0},{0},
{ OLECMDF_SUPPORTED, exec_delete }, /* OLECMDID_DELETE */
{0},{0},
{ OLECMDF_SUPPORTED, exec_enable_interaction }, /* OLECMDID_ENABLE_INTERACTION */
{ OLECMDF_SUPPORTED, exec_on_unload }, /* OLECMDID_ONUNLOAD */
{0},{0},{0},{0},{0},
{ OLECMDF_SUPPORTED, exec_show_page_setup }, /* OLECMDID_SHOWPAGESETUP */
{ OLECMDF_SUPPORTED, exec_show_print }, /* OLECMDID_SHOWPRINT */
{0},{0},
{ OLECMDF_SUPPORTED, exec_close }, /* OLECMDID_CLOSE */
{0},{0},{0},
{ OLECMDF_SUPPORTED, exec_set_print_template }, /* OLECMDID_SETPRINTTEMPLATE */
{ OLECMDF_SUPPORTED, exec_get_print_template } /* OLECMDID_GETPRINTTEMPLATE */
};
static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
@ -541,7 +730,7 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
prgCmds[i].cmdf = 0;
hres = OLECMDERR_E_NOTSUPPORTED;
}else {
prgCmds[i].cmdf = status_table[prgCmds[i].cmdID];
prgCmds[i].cmdf = exec_table[prgCmds[i].cmdID].cmdf;
TRACE("cmdID = %ld returning %lx\n", prgCmds[i].cmdID, prgCmds[i].cmdID);
hres = S_OK;
}
@ -561,9 +750,18 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
HTMLDocument *This = CMDTARGET_THIS(iface);
FIXME("(%p)->(%s %ld %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
pvaIn, pvaOut);
return E_NOTIMPL;
if(!pguidCmdGroup) {
if(nCmdID<OLECMDID_OPEN || nCmdID>OLECMDID_GETPRINTTEMPLATE || !exec_table[nCmdID].func) {
WARN("Unsupported cmdID = %ld\n", nCmdID);
return OLECMDERR_E_NOTSUPPORTED;
}
return exec_table[nCmdID].func(This, nCmdexecopt, pvaIn, pvaOut);
}
FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
return OLECMDERR_E_UNKNOWNGROUP;
}
static const IOleCommandTargetVtbl OleCommandTargetVtbl = {

View File

@ -823,7 +823,7 @@ static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
OLECMDF_SUPPORTED, /* OLECMDID_RENDO */
OLECMDF_SUPPORTED, /* OLECMDID_REDO */
OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
@ -958,6 +958,8 @@ static void test_HTMLDocument(void)
}
if(cmdtrg) {
int i;
OLECMD cmd[2] = {
{OLECMDID_OPEN, 0xf0f0},
{OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
@ -979,6 +981,20 @@ static void test_HTMLDocument(void)
ok(hres == OLECMDERR_E_UNKNOWNGROUP,
"QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
if(!expect_cmds[i]) {
hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
ok(hres == OLECMDERR_E_NOTSUPPORTED,
"Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
}
}
hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
ok(hres == OLECMDERR_E_NOTSUPPORTED,
"Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
test_OleCommandTarget(cmdtrg);
}