2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 /**********************************************************
42 * IOleCommandTarget implementation
45 #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
47 static HRESULT exec_open(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
49 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
53 static HRESULT exec_new(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
55 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
59 static HRESULT exec_save(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
61 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
65 static HRESULT exec_save_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
67 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
71 static HRESULT exec_save_copy_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
73 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
77 static HRESULT exec_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
79 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
83 static HRESULT exec_print_preview(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
85 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
89 static HRESULT exec_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
91 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
95 static HRESULT exec_spell(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
97 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
101 static HRESULT exec_properties(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
103 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
107 static HRESULT exec_cut(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
109 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
113 static HRESULT exec_copy(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
115 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
119 static HRESULT exec_paste(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
121 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
125 static HRESULT exec_paste_special(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
127 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
131 static HRESULT exec_undo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
133 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
137 static HRESULT exec_rendo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
139 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
143 static HRESULT exec_select_all(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
145 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
149 static HRESULT exec_clear_selection(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
151 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
155 static HRESULT exec_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
157 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
161 static HRESULT exec_get_zoom_range(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
163 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
167 static HRESULT exec_refresh(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
169 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
173 static HRESULT exec_stop(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
175 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
179 static HRESULT exec_stop_download(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
181 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
185 static HRESULT exec_delete(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
187 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
191 static HRESULT exec_enable_interaction(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
193 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
197 static HRESULT exec_on_unload(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
199 TRACE("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
201 /* Tests show that we have nothing more to do here */
204 V_VT(pvaOut) = VT_BOOL;
205 V_BOOL(pvaOut) = VARIANT_TRUE;
211 static HRESULT exec_show_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
213 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
217 static HRESULT exec_show_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
219 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
223 static HRESULT exec_close(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
225 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
229 static HRESULT exec_set_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
231 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
235 static HRESULT exec_get_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
237 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
241 static HRESULT exec_browsemode(HTMLDocument *This)
243 WARN("(%p)\n", This);
245 This->usermode = BROWSEMODE;
250 static HRESULT exec_baselinefont3(HTMLDocument *This)
252 FIXME("(%p)\n", This);
256 static const struct {
258 HRESULT (*func)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
259 } exec_table[OLECMDID_GETPRINTTEMPLATE+1] = {
261 { OLECMDF_SUPPORTED, exec_open }, /* OLECMDID_OPEN */
262 { OLECMDF_SUPPORTED, exec_new }, /* OLECMDID_NEW */
263 { OLECMDF_SUPPORTED, exec_save }, /* OLECMDID_SAVE */
264 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_save_as }, /* OLECMDID_SAVEAS */
265 { OLECMDF_SUPPORTED, exec_save_copy_as }, /* OLECMDID_SAVECOPYAS */
266 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print }, /* OLECMDID_PRINT */
267 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print_preview }, /* OLECMDID_PRINTPREVIEW */
268 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_page_setup }, /* OLECMDID_PAGESETUP */
269 { OLECMDF_SUPPORTED, exec_spell }, /* OLECMDID_SPELL */
270 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_properties }, /* OLECMDID_PROPERTIES */
271 { OLECMDF_SUPPORTED, exec_cut }, /* OLECMDID_CUT */
272 { OLECMDF_SUPPORTED, exec_copy }, /* OLECMDID_COPY */
273 { OLECMDF_SUPPORTED, exec_paste }, /* OLECMDID_PASTE */
274 { OLECMDF_SUPPORTED, exec_paste_special }, /* OLECMDID_PASTESPECIAL */
275 { OLECMDF_SUPPORTED, exec_undo }, /* OLECMDID_UNDO */
276 { OLECMDF_SUPPORTED, exec_rendo }, /* OLECMDID_REDO */
277 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_select_all }, /* OLECMDID_SELECTALL */
278 { OLECMDF_SUPPORTED, exec_clear_selection }, /* OLECMDID_CLEARSELECTION */
279 { OLECMDF_SUPPORTED, exec_zoom }, /* OLECMDID_ZOOM */
280 { OLECMDF_SUPPORTED, exec_get_zoom_range }, /* OLECMDID_GETZOOMRANGE */
282 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_refresh }, /* OLECMDID_REFRESH */
283 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_stop }, /* OLECMDID_STOP */
284 {0},{0},{0},{0},{0},{0},
285 { OLECMDF_SUPPORTED, exec_stop_download }, /* OLECMDID_STOPDOWNLOAD */
287 { OLECMDF_SUPPORTED, exec_delete }, /* OLECMDID_DELETE */
289 { OLECMDF_SUPPORTED, exec_enable_interaction }, /* OLECMDID_ENABLE_INTERACTION */
290 { OLECMDF_SUPPORTED, exec_on_unload }, /* OLECMDID_ONUNLOAD */
292 { OLECMDF_SUPPORTED, exec_show_page_setup }, /* OLECMDID_SHOWPAGESETUP */
293 { OLECMDF_SUPPORTED, exec_show_print }, /* OLECMDID_SHOWPRINT */
295 { OLECMDF_SUPPORTED, exec_close }, /* OLECMDID_CLOSE */
297 { OLECMDF_SUPPORTED, exec_set_print_template }, /* OLECMDID_SETPRINTTEMPLATE */
298 { OLECMDF_SUPPORTED, exec_get_print_template } /* OLECMDID_GETPRINTTEMPLATE */
301 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
303 HTMLDocument *This = CMDTARGET_THIS(iface);
304 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
307 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
309 HTMLDocument *This = CMDTARGET_THIS(iface);
310 return IHTMLDocument2_AddRef(HTMLDOC(This));
313 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
315 HTMLDocument *This = CMDTARGET_THIS(iface);
316 return IHTMLDocument_Release(HTMLDOC(This));
319 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
320 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
322 HTMLDocument *This = CMDTARGET_THIS(iface);
323 HRESULT hres = S_OK, hr;
325 TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
330 for(i=0; i<cCmds; i++) {
331 if(prgCmds[i].cmdID<OLECMDID_OPEN || prgCmds[i].cmdID>OLECMDID_GETPRINTTEMPLATE) {
332 WARN("Unsupported cmdID = %ld\n", prgCmds[i].cmdID);
334 hres = OLECMDERR_E_NOTSUPPORTED;
336 if(prgCmds[i].cmdID == OLECMDID_OPEN || prgCmds[i].cmdID == OLECMDID_NEW) {
337 IOleCommandTarget *cmdtrg = NULL;
340 prgCmds[i].cmdf = OLECMDF_SUPPORTED;
342 hr = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
345 olecmd.cmdID = prgCmds[i].cmdID;
348 hr = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &olecmd, NULL);
349 if(SUCCEEDED(hr) && olecmd.cmdf)
350 prgCmds[i].cmdf = olecmd.cmdf;
353 ERR("This->client == NULL, native would crash\n");
356 prgCmds[i].cmdf = exec_table[prgCmds[i].cmdID].cmdf;
357 TRACE("cmdID = %ld returning %lx\n", prgCmds[i].cmdID, prgCmds[i].cmdf);
364 FIXME("Set pCmdText\n");
366 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
367 hres = OLECMDERR_E_UNKNOWNGROUP;
373 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
374 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
376 HTMLDocument *This = CMDTARGET_THIS(iface);
379 if(nCmdID<OLECMDID_OPEN || nCmdID>OLECMDID_GETPRINTTEMPLATE || !exec_table[nCmdID].func) {
380 WARN("Unsupported cmdID = %ld\n", nCmdID);
381 return OLECMDERR_E_NOTSUPPORTED;
384 return exec_table[nCmdID].func(This, nCmdexecopt, pvaIn, pvaOut);
385 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
386 FIXME("unsupported nCmdID %ld of CGID_Explorer group\n", nCmdID);
387 TRACE("%p %p\n", pvaIn, pvaOut);
388 return OLECMDERR_E_NOTSUPPORTED;
389 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
390 FIXME("unsupported nCmdID %ld of CGID_ShellDocView group\n", nCmdID);
391 return OLECMDERR_E_NOTSUPPORTED;
392 }else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
395 return exec_browsemode(This);
396 case IDM_BASELINEFONT3:
397 return exec_baselinefont3(This);
399 FIXME("unsupported nCmdID %ld of CGID_MSHTML group\n", nCmdID);
400 return OLECMDERR_E_NOTSUPPORTED;
404 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
405 return OLECMDERR_E_UNKNOWNGROUP;
408 #undef CMDTARGET_THIS
410 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
411 OleCommandTarget_QueryInterface,
412 OleCommandTarget_AddRef,
413 OleCommandTarget_Release,
414 OleCommandTarget_QueryStatus,
415 OleCommandTarget_Exec
418 void HTMLDocument_OleCmd_Init(HTMLDocument *This)
420 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;