shell32: Don't crash on NULL cmdgroup in DefView OleCommandTarget.
[wine] / dlls / shdocvw / frame.c
1 /*
2  * Copyright 2005 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "wine/debug.h"
20 #include "shdocvw.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
23
24 #define INPLACEFRAME_THIS(iface) DEFINE_THIS(DocHost, OleInPlaceFrame, iface)
25
26 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface,
27                                                   REFIID riid, void **ppv)
28 {
29     DocHost *This = INPLACEFRAME_THIS(iface);
30
31     *ppv = NULL;
32
33     if(IsEqualGUID(&IID_IUnknown, riid)) {
34         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
35         *ppv = INPLACEFRAME(This);
36     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
37         TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
38         *ppv = INPLACEFRAME(This);
39     }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid)) {
40         TRACE("(%p)->(IID_IOleInPlaceUIWindow %p)\n", This, ppv);
41         *ppv = INPLACEFRAME(This);
42     }else if(IsEqualGUID(&IID_IOleInPlaceFrame, riid)) {
43         TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppv);
44         *ppv = INPLACEFRAME(This);
45     }
46
47     if(*ppv) {
48         IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
49         return S_OK;
50     }
51
52     WARN("Unsopported interface %s\n", debugstr_guid(riid));
53     return E_NOINTERFACE;
54 }
55
56 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
57 {
58     DocHost *This = INPLACEFRAME_THIS(iface);
59     return IOleClientSite_AddRef(CLIENTSITE(This));
60 }
61
62 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
63 {
64     DocHost *This = INPLACEFRAME_THIS(iface);
65     return IOleClientSite_Release(CLIENTSITE(This));
66 }
67
68 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
69 {
70     DocHost *This = INPLACEFRAME_THIS(iface);
71     FIXME("(%p)->(%p)\n", This, phwnd);
72     return E_NOTIMPL;
73 }
74
75 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface,
76                                                         BOOL fEnterMode)
77 {
78     DocHost *This = INPLACEFRAME_THIS(iface);
79     FIXME("(%p)->(%x)\n", This, fEnterMode);
80     return E_NOTIMPL;
81 }
82
83 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
84 {
85     DocHost *This = INPLACEFRAME_THIS(iface);
86     FIXME("(%p)->(%p)\n", This, lprectBorder);
87     return E_NOTIMPL;
88 }
89
90 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
91                                                       LPCBORDERWIDTHS pborderwidths)
92 {
93     DocHost *This = INPLACEFRAME_THIS(iface);
94     FIXME("(%p)->(%p)\n", This, pborderwidths);
95     return E_NOTIMPL;
96 }
97
98 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
99                                                   LPCBORDERWIDTHS pborderwidths)
100 {
101     DocHost *This = INPLACEFRAME_THIS(iface);
102     FIXME("(%p)->(%p)\n", This, pborderwidths);
103     return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
107         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
108 {
109     DocHost *This = INPLACEFRAME_THIS(iface);
110     FIXME("(%p)->(%p %s)\n", This, pActiveObject, debugstr_w(pszObjName));
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
115         LPOLEMENUGROUPWIDTHS lpMenuWidths)
116 {
117     DocHost *This = INPLACEFRAME_THIS(iface);
118     FIXME("(%p)->(%p %p)\n", This, hmenuShared, lpMenuWidths);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
123         HOLEMENU holemenu, HWND hwndActiveObject)
124 {
125     DocHost *This = INPLACEFRAME_THIS(iface);
126     FIXME("(%p)->(%p %p %p)\n", This, hmenuShared, holemenu, hwndActiveObject);
127     return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
131 {
132     DocHost *This = INPLACEFRAME_THIS(iface);
133     FIXME("(%p)->(%p)\n", This, hmenuShared);
134     return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface,
138                                                  LPCOLESTR pszStatusText)
139 {
140     DocHost *This = INPLACEFRAME_THIS(iface);
141     TRACE("(%p)->(%s)\n", This, debugstr_w(pszStatusText));
142     return This->container_vtbl->SetStatusText(This, pszStatusText);
143 }
144
145 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
146 {
147     DocHost *This = INPLACEFRAME_THIS(iface);
148     FIXME("(%p)->(%x)\n", This, fEnable);
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg,
153                                                         WORD wID)
154 {
155     DocHost *This = INPLACEFRAME_THIS(iface);
156     FIXME("(%p)->(%p %d)\n", This, lpmsg, wID);
157     return E_NOTIMPL;
158 }
159
160 #undef INPLACEFRAME_THIS
161
162 static const IOleInPlaceFrameVtbl OleInPlaceFrameVtbl = {
163     InPlaceFrame_QueryInterface,
164     InPlaceFrame_AddRef,
165     InPlaceFrame_Release,
166     InPlaceFrame_GetWindow,
167     InPlaceFrame_ContextSensitiveHelp,
168     InPlaceFrame_GetBorder,
169     InPlaceFrame_RequestBorderSpace,
170     InPlaceFrame_SetBorderSpace,
171     InPlaceFrame_SetActiveObject,
172     InPlaceFrame_InsertMenus,
173     InPlaceFrame_SetMenu,
174     InPlaceFrame_RemoveMenus,
175     InPlaceFrame_SetStatusText,
176     InPlaceFrame_EnableModeless,
177     InPlaceFrame_TranslateAccelerator
178 };
179
180 void DocHost_Frame_Init(DocHost *This)
181 {
182     This->lpOleInPlaceFrameVtbl = &OleInPlaceFrameVtbl;
183 }