atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[wine] / dlls / mshtml / htmlgeneric.c
1 /*
2  * Copyright 2008 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
20 #include <stdarg.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.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     IHTMLGenericElement IHTMLGenericElement_iface;
39 } HTMLGenericElement;
40
41 static inline HTMLGenericElement *impl_from_IHTMLGenericElement(IHTMLGenericElement *iface)
42 {
43     return CONTAINING_RECORD(iface, HTMLGenericElement, IHTMLGenericElement_iface);
44 }
45
46 static HRESULT WINAPI HTMLGenericElement_QueryInterface(IHTMLGenericElement *iface, REFIID riid, void **ppv)
47 {
48     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
49
50     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
51 }
52
53 static ULONG WINAPI HTMLGenericElement_AddRef(IHTMLGenericElement *iface)
54 {
55     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
56
57     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
58 }
59
60 static ULONG WINAPI HTMLGenericElement_Release(IHTMLGenericElement *iface)
61 {
62     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
63
64     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
65 }
66
67 static HRESULT WINAPI HTMLGenericElement_GetTypeInfoCount(IHTMLGenericElement *iface, UINT *pctinfo)
68 {
69     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
70     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
71 }
72
73 static HRESULT WINAPI HTMLGenericElement_GetTypeInfo(IHTMLGenericElement *iface, UINT iTInfo,
74                                               LCID lcid, ITypeInfo **ppTInfo)
75 {
76     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
77     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
78             ppTInfo);
79 }
80
81 static HRESULT WINAPI HTMLGenericElement_GetIDsOfNames(IHTMLGenericElement *iface, REFIID riid,
82         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
83 {
84     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
85     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
86             cNames, lcid, rgDispId);
87 }
88
89 static HRESULT WINAPI HTMLGenericElement_Invoke(IHTMLGenericElement *iface, DISPID dispIdMember,
90         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 {
93     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
94     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
95             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
96 }
97
98 static HRESULT WINAPI HTMLGenericElement_get_recordset(IHTMLGenericElement *iface, IDispatch **p)
99 {
100     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
101     FIXME("(%p)->(%p)\n", This, p);
102     return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI HTMLGenericElement_namedRecordset(IHTMLGenericElement *iface,
106         BSTR dataMember, VARIANT *hierarchy, IDispatch **ppRecordset)
107 {
108     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
109     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
110     return E_NOTIMPL;
111 }
112
113 static const IHTMLGenericElementVtbl HTMLGenericElementVtbl = {
114     HTMLGenericElement_QueryInterface,
115     HTMLGenericElement_AddRef,
116     HTMLGenericElement_Release,
117     HTMLGenericElement_GetTypeInfoCount,
118     HTMLGenericElement_GetTypeInfo,
119     HTMLGenericElement_GetIDsOfNames,
120     HTMLGenericElement_Invoke,
121     HTMLGenericElement_get_recordset,
122     HTMLGenericElement_namedRecordset
123 };
124
125 static inline HTMLGenericElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
126 {
127     return CONTAINING_RECORD(iface, HTMLGenericElement, element.node);
128 }
129
130 static HRESULT HTMLGenericElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
131 {
132     HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
133
134     *ppv = NULL;
135
136     if(IsEqualGUID(&IID_IHTMLGenericElement, riid)) {
137         TRACE("(%p)->(IID_IHTMLGenericElement %p)\n", This, ppv);
138         *ppv = &This->IHTMLGenericElement_iface;
139     }else {
140         return HTMLElement_QI(&This->element.node, riid, ppv);
141     }
142
143     IUnknown_AddRef((IUnknown*)*ppv);
144     return S_OK;
145 }
146
147 static void HTMLGenericElement_destructor(HTMLDOMNode *iface)
148 {
149     HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
150
151     HTMLElement_destructor(&This->element.node);
152 }
153
154 static const NodeImplVtbl HTMLGenericElementImplVtbl = {
155     HTMLGenericElement_QI,
156     HTMLGenericElement_destructor,
157     HTMLElement_clone,
158     HTMLElement_handle_event,
159     HTMLElement_get_attr_col
160 };
161
162 static const tid_t HTMLGenericElement_iface_tids[] = {
163     HTMLELEMENT_TIDS,
164     IHTMLGenericElement_tid,
165     0
166 };
167
168 static dispex_static_data_t HTMLGenericElement_dispex = {
169     NULL,
170     DispHTMLGenericElement_tid,
171     NULL,
172     HTMLGenericElement_iface_tids
173 };
174
175 HRESULT HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
176 {
177     HTMLGenericElement *ret;
178
179     ret = heap_alloc_zero(sizeof(HTMLGenericElement));
180     if(!ret)
181         return E_OUTOFMEMORY;
182
183     ret->IHTMLGenericElement_iface.lpVtbl = &HTMLGenericElementVtbl;
184     ret->element.node.vtbl = &HTMLGenericElementImplVtbl;
185
186     HTMLElement_Init(&ret->element, doc, nselem, &HTMLGenericElement_dispex);
187
188     *elem = &ret->element;
189     return S_OK;
190 }