crypt32: NULL ptr could leak into function (Coverity).
[wine] / dlls / mshtml / htmltextcont.c
1 /*
2  * Copyright 2006 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 "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 #define HTMLTEXTCONT_THIS(iface) DEFINE_THIS(HTMLTextContainer, HTMLTextContainer, iface)
38
39 static HRESULT WINAPI HTMLTextContainer_QueryInterface(IHTMLTextContainer *iface,
40                                                        REFIID riid, void **ppv)
41 {
42     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
43     return IHTMLElement_QueryInterface(&This->element.IHTMLElement_iface, riid, ppv);
44 }
45
46 static ULONG WINAPI HTMLTextContainer_AddRef(IHTMLTextContainer *iface)
47 {
48     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
49     return IHTMLElement_AddRef(&This->element.IHTMLElement_iface);
50 }
51
52 static ULONG WINAPI HTMLTextContainer_Release(IHTMLTextContainer *iface)
53 {
54     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
55     return IHTMLElement_Release(&This->element.IHTMLElement_iface);
56 }
57
58 static HRESULT WINAPI HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer *iface, UINT *pctinfo)
59 {
60     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
61     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
62 }
63
64 static HRESULT WINAPI HTMLTextContainer_GetTypeInfo(IHTMLTextContainer *iface, UINT iTInfo,
65                                               LCID lcid, ITypeInfo **ppTInfo)
66 {
67     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
68     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
69             ppTInfo);
70 }
71
72 static HRESULT WINAPI HTMLTextContainer_GetIDsOfNames(IHTMLTextContainer *iface, REFIID riid,
73                                                 LPOLESTR *rgszNames, UINT cNames,
74                                                 LCID lcid, DISPID *rgDispId)
75 {
76     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
77     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
78             cNames, lcid, rgDispId);
79 }
80
81 static HRESULT WINAPI HTMLTextContainer_Invoke(IHTMLTextContainer *iface, DISPID dispIdMember,
82                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
83                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
84 {
85     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
86     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
87             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
88 }
89
90 static HRESULT WINAPI HTMLTextContainer_createControlRange(IHTMLTextContainer *iface,
91                                                            IDispatch **range)
92 {
93     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
94     FIXME("(%p)->(%p)\n", This, range);
95     return E_NOTIMPL;
96 }
97
98 static HRESULT WINAPI HTMLTextContainer_get_scrollHeight(IHTMLTextContainer *iface, LONG *p)
99 {
100     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
101
102     TRACE("(%p)->(%p)\n", This, p);
103
104     return IHTMLElement2_get_scrollHeight(&This->element.IHTMLElement2_iface, p);
105 }
106
107 static HRESULT WINAPI HTMLTextContainer_get_scrollWidth(IHTMLTextContainer *iface, LONG *p)
108 {
109     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
110
111     TRACE("(%p)->(%p)\n", This, p);
112
113     return IHTMLElement2_get_scrollWidth(&This->element.IHTMLElement2_iface, p);
114 }
115
116 static HRESULT WINAPI HTMLTextContainer_put_scrollTop(IHTMLTextContainer *iface, LONG v)
117 {
118     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
119
120     TRACE("(%p)->(%d)\n", This, v);
121
122     return IHTMLElement2_put_scrollTop(&This->element.IHTMLElement2_iface, v);
123 }
124
125 static HRESULT WINAPI HTMLTextContainer_get_scrollTop(IHTMLTextContainer *iface, LONG *p)
126 {
127     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
128
129     TRACE("(%p)->(%p)\n", This, p);
130
131     return IHTMLElement2_get_scrollTop(&This->element.IHTMLElement2_iface, p);
132 }
133
134 static HRESULT WINAPI HTMLTextContainer_put_scrollLeft(IHTMLTextContainer *iface, LONG v)
135 {
136     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
137
138     TRACE("(%p)->(%d)\n", This, v);
139
140     return IHTMLElement2_put_scrollLeft(&This->element.IHTMLElement2_iface, v);
141 }
142
143 static HRESULT WINAPI HTMLTextContainer_get_scrollLeft(IHTMLTextContainer *iface, LONG *p)
144 {
145     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
146
147     TRACE("(%p)->(%p)\n", This, p);
148
149     return IHTMLElement2_get_scrollLeft(&This->element.IHTMLElement2_iface, p);
150 }
151
152 static HRESULT WINAPI HTMLTextContainer_put_onscroll(IHTMLTextContainer *iface, VARIANT v)
153 {
154     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
155     FIXME("(%p)->()\n", This);
156     return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI HTMLTextContainer_get_onscroll(IHTMLTextContainer *iface, VARIANT *p)
160 {
161     HTMLTextContainer *This = HTMLTEXTCONT_THIS(iface);
162     FIXME("(%p)->(%p)\n", This, p);
163     return E_NOTIMPL;
164 }
165
166 #undef HTMLTEXTCONT_THIS
167
168 static const IHTMLTextContainerVtbl HTMLTextContainerVtbl = {
169     HTMLTextContainer_QueryInterface,
170     HTMLTextContainer_AddRef,
171     HTMLTextContainer_Release,
172     HTMLTextContainer_GetTypeInfoCount,
173     HTMLTextContainer_GetTypeInfo,
174     HTMLTextContainer_GetIDsOfNames,
175     HTMLTextContainer_Invoke,
176     HTMLTextContainer_createControlRange,
177     HTMLTextContainer_get_scrollHeight,
178     HTMLTextContainer_get_scrollWidth,
179     HTMLTextContainer_put_scrollTop,
180     HTMLTextContainer_get_scrollTop,
181     HTMLTextContainer_put_scrollLeft,
182     HTMLTextContainer_get_scrollLeft,
183     HTMLTextContainer_put_onscroll,
184     HTMLTextContainer_get_onscroll
185 };
186
187 void HTMLTextContainer_Init(HTMLTextContainer *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
188         dispex_static_data_t *dispex_data)
189 {
190     This->lpHTMLTextContainerVtbl = &HTMLTextContainerVtbl;
191
192     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
193
194     ConnectionPoint_Init(&This->cp, &This->element.cp_container, &DIID_HTMLTextContainerEvents, NULL);
195 }