mshtml: HTMLWindow_item code clean up.
[wine] / dlls / mshtml / htmlembed.c
1 /*
2  * Copyright 2010 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 <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 typedef struct {
36     HTMLElement element;
37
38     IHTMLEmbedElement IHTMLEmbedElement_iface;
39 } HTMLEmbedElement;
40
41 static inline HTMLEmbedElement *impl_from_IHTMLEmbedElement(IHTMLEmbedElement *iface)
42 {
43     return CONTAINING_RECORD(iface, HTMLEmbedElement, IHTMLEmbedElement_iface);
44 }
45
46 static HRESULT WINAPI HTMLEmbedElement_QueryInterface(IHTMLEmbedElement *iface,
47         REFIID riid, void **ppv)
48 {
49     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
50
51     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
52 }
53
54 static ULONG WINAPI HTMLEmbedElement_AddRef(IHTMLEmbedElement *iface)
55 {
56     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
57
58     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
59 }
60
61 static ULONG WINAPI HTMLEmbedElement_Release(IHTMLEmbedElement *iface)
62 {
63     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
64
65     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
66 }
67
68 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfoCount(IHTMLEmbedElement *iface, UINT *pctinfo)
69 {
70     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
71     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
72 }
73
74 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfo(IHTMLEmbedElement *iface, UINT iTInfo,
75         LCID lcid, ITypeInfo **ppTInfo)
76 {
77     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
78     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
79             ppTInfo);
80 }
81
82 static HRESULT WINAPI HTMLEmbedElement_GetIDsOfNames(IHTMLEmbedElement *iface, REFIID riid,
83         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
84 {
85     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
86     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
87             cNames, lcid, rgDispId);
88 }
89
90 static HRESULT WINAPI HTMLEmbedElement_Invoke(IHTMLEmbedElement *iface, DISPID dispIdMember,
91         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
92         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 {
94     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
95     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
96             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
97 }
98
99 static HRESULT WINAPI HTMLEmbedElement_put_hidden(IHTMLEmbedElement *iface, BSTR v)
100 {
101     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
102     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
103     return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI HTMLEmbedElement_get_hidden(IHTMLEmbedElement *iface, BSTR *p)
107 {
108     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
109     FIXME("(%p)->(%p)\n", This, p);
110     return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI HTMLEmbedElement_get_palete(IHTMLEmbedElement *iface, BSTR *p)
114 {
115     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
116     FIXME("(%p)->(%p)\n", This, p);
117     return E_NOTIMPL;
118 }
119
120 static HRESULT WINAPI HTMLEmbedElement_get_pluginspage(IHTMLEmbedElement *iface, BSTR *p)
121 {
122     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
123     FIXME("(%p)->(%p)\n", This, p);
124     return E_NOTIMPL;
125 }
126
127 static HRESULT WINAPI HTMLEmbedElement_put_src(IHTMLEmbedElement *iface, BSTR v)
128 {
129     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
130     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
131     return E_NOTIMPL;
132 }
133
134 static HRESULT WINAPI HTMLEmbedElement_get_src(IHTMLEmbedElement *iface, BSTR *p)
135 {
136     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
137     FIXME("(%p)->(%p)\n", This, p);
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI HTMLEmbedElement_put_units(IHTMLEmbedElement *iface, BSTR v)
142 {
143     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
144     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLEmbedElement_get_units(IHTMLEmbedElement *iface, BSTR *p)
149 {
150     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
151     FIXME("(%p)->(%p)\n", This, p);
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI HTMLEmbedElement_put_name(IHTMLEmbedElement *iface, BSTR v)
156 {
157     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
158     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HTMLEmbedElement_get_name(IHTMLEmbedElement *iface, BSTR *p)
163 {
164     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
165     FIXME("(%p)->(%p)\n", This, p);
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI HTMLEmbedElement_put_width(IHTMLEmbedElement *iface, VARIANT v)
170 {
171     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
172     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI HTMLEmbedElement_get_width(IHTMLEmbedElement *iface, VARIANT *p)
177 {
178     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
179     FIXME("(%p)->(%p)\n", This, p);
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI HTMLEmbedElement_put_height(IHTMLEmbedElement *iface, VARIANT v)
184 {
185     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
186     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLEmbedElement_get_height(IHTMLEmbedElement *iface, VARIANT *p)
191 {
192     HTMLEmbedElement *This = impl_from_IHTMLEmbedElement(iface);
193     FIXME("(%p)->(%p)\n", This, p);
194     return E_NOTIMPL;
195 }
196
197 static const IHTMLEmbedElementVtbl HTMLEmbedElementVtbl = {
198     HTMLEmbedElement_QueryInterface,
199     HTMLEmbedElement_AddRef,
200     HTMLEmbedElement_Release,
201     HTMLEmbedElement_GetTypeInfoCount,
202     HTMLEmbedElement_GetTypeInfo,
203     HTMLEmbedElement_GetIDsOfNames,
204     HTMLEmbedElement_Invoke,
205     HTMLEmbedElement_put_hidden,
206     HTMLEmbedElement_get_hidden,
207     HTMLEmbedElement_get_palete,
208     HTMLEmbedElement_get_pluginspage,
209     HTMLEmbedElement_put_src,
210     HTMLEmbedElement_get_src,
211     HTMLEmbedElement_put_units,
212     HTMLEmbedElement_get_units,
213     HTMLEmbedElement_put_name,
214     HTMLEmbedElement_get_name,
215     HTMLEmbedElement_put_width,
216     HTMLEmbedElement_get_width,
217     HTMLEmbedElement_put_height,
218     HTMLEmbedElement_get_height
219 };
220
221 static inline HTMLEmbedElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
222 {
223     return CONTAINING_RECORD(iface, HTMLEmbedElement, element.node);
224 }
225
226 static HRESULT HTMLEmbedElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
227 {
228     HTMLEmbedElement *This = impl_from_HTMLDOMNode(iface);
229
230     if(IsEqualGUID(&IID_IUnknown, riid)) {
231         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
232         *ppv = &This->IHTMLEmbedElement_iface;
233     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
234         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
235         *ppv = &This->IHTMLEmbedElement_iface;
236     }else if(IsEqualGUID(&IID_IHTMLEmbedElement, riid)) {
237         TRACE("(%p)->(IID_IHTMLEmbedElement %p)\n", This, ppv);
238         *ppv = &This->IHTMLEmbedElement_iface;
239     }else {
240         return HTMLElement_QI(&This->element.node, riid, ppv);
241     }
242
243     IUnknown_AddRef((IUnknown*)*ppv);
244     return S_OK;
245 }
246
247 static void HTMLEmbedElement_destructor(HTMLDOMNode *iface)
248 {
249     HTMLEmbedElement *This = impl_from_HTMLDOMNode(iface);
250
251     HTMLElement_destructor(&This->element.node);
252 }
253
254 static const NodeImplVtbl HTMLEmbedElementImplVtbl = {
255     HTMLEmbedElement_QI,
256     HTMLEmbedElement_destructor,
257     HTMLElement_clone,
258     HTMLElement_get_attr_col
259 };
260
261 static const tid_t HTMLEmbedElement_iface_tids[] = {
262     HTMLELEMENT_TIDS,
263     IHTMLEmbedElement_tid,
264     0
265 };
266 static dispex_static_data_t HTMLEmbedElement_dispex = {
267     NULL,
268     DispHTMLEmbed_tid,
269     NULL,
270     HTMLEmbedElement_iface_tids
271 };
272
273 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
274 {
275     HTMLEmbedElement *ret;
276
277     ret = heap_alloc_zero(sizeof(*ret));
278     if(!ret)
279         return E_OUTOFMEMORY;
280
281     ret->IHTMLEmbedElement_iface.lpVtbl = &HTMLEmbedElementVtbl;
282     ret->element.node.vtbl = &HTMLEmbedElementImplVtbl;
283
284     HTMLElement_Init(&ret->element, doc, nselem, &HTMLEmbedElement_dispex);
285     *elem = &ret->element;
286     return S_OK;
287 }