Commit 6c706e02 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Move the IOleCommandTarget interface out of basedoc.

parent 07bf1d73
......@@ -1266,7 +1266,7 @@ HRESULT setup_edit_mode(HTMLDocumentObj *doc)
if(doc->hostui)
IDocHostUIHandler_ShowUI(doc->hostui, DOCHOSTUITYPE_AUTHOR,
&doc->basedoc.IOleInPlaceActiveObject_iface, &doc->basedoc.IOleCommandTarget_iface,
&doc->basedoc.IOleInPlaceActiveObject_iface, &doc->IOleCommandTarget_iface,
doc->frame, doc->ip_window);
if(doc->ip_window)
......
......@@ -1562,7 +1562,7 @@ static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID
return OLECMDERR_E_NOTSUPPORTED;
V_VT(&ret) = VT_EMPTY;
hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
hres = IOleCommandTarget_Exec(&This->doc_node->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
if(FAILED(hres))
return hres;
......@@ -5625,8 +5625,6 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
*ppv = &This->IOleInPlaceObjectWindowless_iface;
else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid))
*ppv = &This->IOleInPlaceObjectWindowless_iface;
else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
*ppv = &This->IOleCommandTarget_iface;
else if(IsEqualGUID(&IID_IOleControl, riid))
*ppv = &This->IOleControl_iface;
else if(IsEqualGUID(&DIID_DispHTMLDocument, riid))
......@@ -5709,7 +5707,6 @@ static void init_doc(HTMLDocument *doc, IUnknown *outer, IDispatchEx *dispex)
doc->outer_unk = outer;
doc->dispex = dispex;
HTMLDocument_OleCmd_Init(doc);
HTMLDocument_OleObj_Init(doc);
}
......@@ -5743,6 +5740,8 @@ static HRESULT HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
*ppv = &This->IPersistHistory_iface;
else if(IsEqualGUID(&IID_IHlinkTarget, riid))
*ppv = &This->IHlinkTarget_iface;
else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
*ppv = &This->IOleCommandTarget_iface;
else if(IsEqualGUID(&IID_IServiceProvider, riid))
*ppv = &This->IServiceProvider_iface;
else if(IsEqualGUID(&IID_IConnectionPointContainer, riid))
......@@ -6136,6 +6135,7 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo
ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)&doc->basedoc.IHTMLDocument2_iface, HTMLDocumentNode_cpc);
HTMLDocumentNode_Persist_Init(doc);
HTMLDocumentNode_Service_Init(doc);
HTMLDocumentNode_OleCmd_Init(doc);
HTMLDocumentNode_SecMgr_Init(doc);
list_init(&doc->selection_list);
......@@ -6268,6 +6268,8 @@ static HRESULT WINAPI HTMLDocumentObj_QueryInterface(IUnknown *iface, REFIID rii
*ppv = &This->IPersistHistory_iface;
}else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
*ppv = &This->IHlinkTarget_iface;
}else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
*ppv = &This->IOleCommandTarget_iface;
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
*ppv = &This->IServiceProvider_iface;
}else if(IsEqualGUID(&IID_ITargetContainer, riid)) {
......@@ -6498,6 +6500,7 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii
ConnectionPointContainer_Init(&doc->cp_container, &doc->IUnknown_inner, HTMLDocumentObj_cpc);
HTMLDocumentObj_Persist_Init(doc);
HTMLDocumentObj_Service_Init(doc);
HTMLDocumentObj_OleCmd_Init(doc);
TargetContainer_Init(doc);
doc->is_mhtml = is_mhtml;
......
......@@ -652,7 +652,6 @@ struct HTMLDocument {
IOleDocument IOleDocument_iface;
IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
IOleCommandTarget IOleCommandTarget_iface;
IOleControl IOleControl_iface;
IDispatchEx IDispatchEx_iface;
ISupportErrorInfo ISupportErrorInfo_iface;
......@@ -702,6 +701,7 @@ struct HTMLDocumentObj {
IPersistStreamInit IPersistStreamInit_iface;
IPersistHistory IPersistHistory_iface;
IHlinkTarget IHlinkTarget_iface;
IOleCommandTarget IOleCommandTarget_iface;
IServiceProvider IServiceProvider_iface;
ITargetContainer ITargetContainer_iface;
......@@ -902,6 +902,7 @@ struct HTMLDocumentNode {
IPersistStreamInit IPersistStreamInit_iface;
IPersistHistory IPersistHistory_iface;
IHlinkTarget IHlinkTarget_iface;
IOleCommandTarget IOleCommandTarget_iface;
IServiceProvider IServiceProvider_iface;
IInternetHostSecurityManager IInternetHostSecurityManager_iface;
......@@ -969,16 +970,17 @@ void detach_dom_implementation(IHTMLDOMImplementation*) DECLSPEC_HIDDEN;
HRESULT create_html_storage(HTMLInnerWindow*,BOOL,IHTMLStorage**) DECLSPEC_HIDDEN;
void detach_html_storage(IHTMLStorage*) DECLSPEC_HIDDEN;
void HTMLDocument_OleCmd_Init(HTMLDocument*) DECLSPEC_HIDDEN;
void HTMLDocument_OleObj_Init(HTMLDocument*) DECLSPEC_HIDDEN;
void HTMLDocument_View_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void HTMLDocumentObj_Persist_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void HTMLDocumentObj_Service_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void HTMLDocumentObj_OleCmd_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void TargetContainer_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void HTMLDocumentNode_Persist_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void HTMLDocumentNode_Service_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void HTMLDocumentNode_OleCmd_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**) DECLSPEC_HIDDEN;
......
......@@ -89,9 +89,14 @@ static nsIClipboardCommands *get_clipboard_commands(HTMLDocumentNode *doc)
* IOleCommandTarget implementation
*/
static inline HTMLDocument *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
static inline HTMLDocumentNode *HTMLDocumentNode_from_IOleCommandTarget(IOleCommandTarget *iface)
{
return CONTAINING_RECORD(iface, HTMLDocument, IOleCommandTarget_iface);
return CONTAINING_RECORD(iface, HTMLDocumentNode, IOleCommandTarget_iface);
}
static inline HTMLDocumentObj *HTMLDocumentObj_from_IOleCommandTarget(IOleCommandTarget *iface)
{
return CONTAINING_RECORD(iface, HTMLDocumentObj, IOleCommandTarget_iface);
}
static HRESULT exec_open(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
......@@ -793,22 +798,22 @@ static const cmdtable_t base_cmds[] = {
{0,NULL,NULL}
};
static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
static HRESULT WINAPI DocNodeOleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
{
HTMLDocument *This = impl_from_IOleCommandTarget(iface);
return htmldoc_query_interface(This, riid, ppv);
HTMLDocumentNode *This = HTMLDocumentNode_from_IOleCommandTarget(iface);
return htmldoc_query_interface(&This->basedoc, riid, ppv);
}
static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
static ULONG WINAPI DocNodeOleCommandTarget_AddRef(IOleCommandTarget *iface)
{
HTMLDocument *This = impl_from_IOleCommandTarget(iface);
return htmldoc_addref(This);
HTMLDocumentNode *This = HTMLDocumentNode_from_IOleCommandTarget(iface);
return htmldoc_addref(&This->basedoc);
}
static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
static ULONG WINAPI DocNodeOleCommandTarget_Release(IOleCommandTarget *iface)
{
HTMLDocument *This = impl_from_IOleCommandTarget(iface);
return htmldoc_release(This);
HTMLDocumentNode *This = HTMLDocumentNode_from_IOleCommandTarget(iface);
return htmldoc_release(&This->basedoc);
}
static HRESULT query_from_table(HTMLDocumentNode *doc, const cmdtable_t *cmdtable, OLECMD *cmd)
......@@ -826,17 +831,17 @@ static HRESULT query_from_table(HTMLDocumentNode *doc, const cmdtable_t *cmdtabl
return iter->query(doc, cmd);
}
static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
static HRESULT WINAPI DocNodeOleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
{
HTMLDocument *This = impl_from_IOleCommandTarget(iface);
HTMLDocumentNode *This = HTMLDocumentNode_from_IOleCommandTarget(iface);
HRESULT hres;
TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
if(pCmdText)
FIXME("Unsupported pCmdText\n");
if(!This->doc_node->browser)
if(!This->browser)
return E_UNEXPECTED;
if(!cCmds)
return S_OK;
......@@ -854,8 +859,8 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
OLECMD olecmd;
prgCmds[i].cmdf = OLECMDF_SUPPORTED;
if(This->doc_obj->client) {
hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget,
if(This->basedoc.doc_obj->client) {
hres = IOleClientSite_QueryInterface(This->basedoc.doc_obj->client, &IID_IOleCommandTarget,
(void**)&cmdtrg);
if(SUCCEEDED(hres)) {
olecmd.cmdID = prgCmds[i].cmdID;
......@@ -882,9 +887,9 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
ULONG i;
for(i=0; i<cCmds; i++) {
hres = query_from_table(This->doc_node, base_cmds, prgCmds+i);
hres = query_from_table(This, base_cmds, prgCmds+i);
if(hres == OLECMDERR_E_NOTSUPPORTED)
hres = query_from_table(This->doc_node, editmode_cmds, prgCmds+i);
hres = query_from_table(This, editmode_cmds, prgCmds+i);
if(hres == OLECMDERR_E_NOTSUPPORTED)
FIXME("CGID_MSHTML: unsupported cmdID %ld\n", prgCmds[i].cmdID);
}
......@@ -910,14 +915,14 @@ static HRESULT exec_from_table(HTMLDocumentNode *doc, const cmdtable_t *cmdtable
return iter->exec(doc, cmdexecopt, in, out);
}
static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
static HRESULT WINAPI DocNodeOleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
HTMLDocument *This = impl_from_IOleCommandTarget(iface);
HTMLDocumentNode *This = HTMLDocumentNode_from_IOleCommandTarget(iface);
TRACE("(%p)->(%s %ld %ld %s %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, wine_dbgstr_variant(pvaIn), pvaOut);
if(!This->doc_node->browser)
if(!This->browser)
return E_UNEXPECTED;
if(!pguidCmdGroup) {
......@@ -926,7 +931,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
return OLECMDERR_E_NOTSUPPORTED;
}
return exec_table[nCmdID].func(This->doc_node, nCmdexecopt, pvaIn, pvaOut);
return exec_table[nCmdID].func(This, nCmdexecopt, pvaIn, pvaOut);
}else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
FIXME("unsupported nCmdID %ld of CGID_Explorer group\n", nCmdID);
TRACE("%p %p\n", pvaIn, pvaOut);
......@@ -935,9 +940,9 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
FIXME("unsupported nCmdID %ld of CGID_ShellDocView group\n", nCmdID);
return OLECMDERR_E_NOTSUPPORTED;
}else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
HRESULT hres = exec_from_table(This->doc_node, base_cmds, nCmdID, nCmdexecopt, pvaIn, pvaOut);
HRESULT hres = exec_from_table(This, base_cmds, nCmdID, nCmdexecopt, pvaIn, pvaOut);
if(hres == OLECMDERR_E_NOTSUPPORTED)
hres = exec_from_table(This->doc_node, editmode_cmds, nCmdID,
hres = exec_from_table(This, editmode_cmds, nCmdID,
nCmdexecopt, pvaIn, pvaOut);
if(hres == OLECMDERR_E_NOTSUPPORTED)
FIXME("unsupported nCmdID %ld of CGID_MSHTML group\n", nCmdID);
......@@ -949,12 +954,60 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
return OLECMDERR_E_UNKNOWNGROUP;
}
static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
OleCommandTarget_QueryInterface,
OleCommandTarget_AddRef,
OleCommandTarget_Release,
OleCommandTarget_QueryStatus,
OleCommandTarget_Exec
static const IOleCommandTargetVtbl DocNodeOleCommandTargetVtbl = {
DocNodeOleCommandTarget_QueryInterface,
DocNodeOleCommandTarget_AddRef,
DocNodeOleCommandTarget_Release,
DocNodeOleCommandTarget_QueryStatus,
DocNodeOleCommandTarget_Exec
};
static HRESULT WINAPI DocObjOleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
{
HTMLDocumentObj *This = HTMLDocumentObj_from_IOleCommandTarget(iface);
return htmldoc_query_interface(&This->basedoc, riid, ppv);
}
static ULONG WINAPI DocObjOleCommandTarget_AddRef(IOleCommandTarget *iface)
{
HTMLDocumentObj *This = HTMLDocumentObj_from_IOleCommandTarget(iface);
return htmldoc_addref(&This->basedoc);
}
static ULONG WINAPI DocObjOleCommandTarget_Release(IOleCommandTarget *iface)
{
HTMLDocumentObj *This = HTMLDocumentObj_from_IOleCommandTarget(iface);
return htmldoc_release(&This->basedoc);
}
static HRESULT WINAPI DocObjOleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
{
HTMLDocumentObj *This = HTMLDocumentObj_from_IOleCommandTarget(iface);
if(!This->basedoc.doc_node)
return E_UNEXPECTED;
return IOleCommandTarget_QueryStatus(&This->basedoc.doc_node->IOleCommandTarget_iface,
pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
static HRESULT WINAPI DocObjOleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
HTMLDocumentObj *This = HTMLDocumentObj_from_IOleCommandTarget(iface);
if(!This->basedoc.doc_node)
return E_UNEXPECTED;
return IOleCommandTarget_Exec(&This->basedoc.doc_node->IOleCommandTarget_iface,
pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
static const IOleCommandTargetVtbl DocObjOleCommandTargetVtbl = {
DocObjOleCommandTarget_QueryInterface,
DocObjOleCommandTarget_AddRef,
DocObjOleCommandTarget_Release,
DocObjOleCommandTarget_QueryStatus,
DocObjOleCommandTarget_Exec
};
void show_context_menu(HTMLDocumentObj *This, DWORD dwID, POINT *ppt, IDispatch *elem)
......@@ -963,7 +1016,7 @@ void show_context_menu(HTMLDocumentObj *This, DWORD dwID, POINT *ppt, IDispatch
DWORD cmdid;
if(This->hostui && S_OK == IDocHostUIHandler_ShowContextMenu(This->hostui,
dwID, ppt, (IUnknown*)&This->basedoc.IOleCommandTarget_iface, elem))
dwID, ppt, (IUnknown*)&This->IOleCommandTarget_iface, elem))
return;
menu_res = LoadMenuW(get_shdoclc(), MAKEINTRESOURCEW(IDR_BROWSE_CONTEXT_MENU));
......@@ -974,11 +1027,16 @@ void show_context_menu(HTMLDocumentObj *This, DWORD dwID, POINT *ppt, IDispatch
DestroyMenu(menu_res);
if(cmdid)
IOleCommandTarget_Exec(&This->basedoc.IOleCommandTarget_iface, &CGID_MSHTML, cmdid, 0,
IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid, 0,
NULL, NULL);
}
void HTMLDocument_OleCmd_Init(HTMLDocument *This)
void HTMLDocumentNode_OleCmd_Init(HTMLDocumentNode *This)
{
This->IOleCommandTarget_iface.lpVtbl = &DocNodeOleCommandTargetVtbl;
}
void HTMLDocumentObj_OleCmd_Init(HTMLDocumentObj *This)
{
This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
This->IOleCommandTarget_iface.lpVtbl = &DocObjOleCommandTargetVtbl;
}
......@@ -625,7 +625,7 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f
if(This->hostui) {
hres = IDocHostUIHandler_ShowUI(This->hostui,
This->nscontainer->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
&This->basedoc.IOleInPlaceActiveObject_iface, &This->basedoc.IOleCommandTarget_iface,
&This->basedoc.IOleInPlaceActiveObject_iface, &This->IOleCommandTarget_iface,
This->frame, This->ip_window);
if(FAILED(hres))
IDocHostUIHandler_HideUI(This->hostui);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment