crypt32: NULL ptr could leak into function (Coverity).
[wine] / dlls / mshtml / htmlstyle3.c
1 /*
2  * Copyright 2009 Alistair Leslie-Hughes
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 "ole2.h"
27
28 #include "mshtml_private.h"
29 #include "htmlstyle.h"
30
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35
36 #define HTMLSTYLE3_THIS(iface) DEFINE_THIS(HTMLStyle, HTMLStyle3, iface)
37
38 static HRESULT WINAPI HTMLStyle3_QueryInterface(IHTMLStyle3 *iface, REFIID riid, void **ppv)
39 {
40     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
41
42     return IHTMLStyle_QueryInterface(HTMLSTYLE(This), riid, ppv);
43 }
44
45 static ULONG WINAPI HTMLStyle3_AddRef(IHTMLStyle3 *iface)
46 {
47     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
48
49     return IHTMLStyle_AddRef(HTMLSTYLE(This));
50 }
51
52 static ULONG WINAPI HTMLStyle3_Release(IHTMLStyle3 *iface)
53 {
54     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
55
56     return IHTMLStyle_Release(HTMLSTYLE(This));
57 }
58
59 static HRESULT WINAPI HTMLStyle3_GetTypeInfoCount(IHTMLStyle3 *iface, UINT *pctinfo)
60 {
61     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
62     return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
63 }
64
65 static HRESULT WINAPI HTMLStyle3_GetTypeInfo(IHTMLStyle3 *iface, UINT iTInfo,
66                                               LCID lcid, ITypeInfo **ppTInfo)
67 {
68     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
69     return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
70 }
71
72 static HRESULT WINAPI HTMLStyle3_GetIDsOfNames(IHTMLStyle3 *iface, REFIID riid,
73                                                 LPOLESTR *rgszNames, UINT cNames,
74                                                 LCID lcid, DISPID *rgDispId)
75 {
76     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
77     return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
78             lcid, rgDispId);
79 }
80
81 static HRESULT WINAPI HTMLStyle3_Invoke(IHTMLStyle3 *iface, DISPID dispIdMember,
82                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
83                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
84 {
85     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
86     return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
87             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
88 }
89
90 static HRESULT WINAPI HTMLStyle3_put_layoutFlow(IHTMLStyle3 *iface, BSTR v)
91 {
92     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
93     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
94     return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI HTMLStyle3_get_layoutFlow(IHTMLStyle3 *iface, BSTR *p)
98 {
99     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
100     FIXME("(%p)->(%p)\n", This, p);
101     return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI HTMLStyle3_put_zoom(IHTMLStyle3 *iface, VARIANT v)
105 {
106     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
107
108     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
109
110     /* zoom property is IE CSS extension that is mostly used as a hack to workaround IE bugs.
111      * The value is set to 1 then. We can safely ignore setting zoom to 1. */
112     if(V_VT(&v) == VT_I4 && V_I4(&v) == 1)
113         return S_OK;
114
115     FIXME("stub for %s\n", debugstr_variant(&v));
116     return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI HTMLStyle3_get_zoom(IHTMLStyle3 *iface, VARIANT *p)
120 {
121     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
122     FIXME("(%p)->(%p)\n", This, p);
123     return E_NOTIMPL;
124 }
125
126 static HRESULT WINAPI HTMLStyle3_put_wordWrap(IHTMLStyle3 *iface, BSTR v)
127 {
128     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
129
130     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
131
132     return set_nsstyle_attr(This->nsstyle, STYLEID_WORD_WRAP, v, 0);
133 }
134
135 static HRESULT WINAPI HTMLStyle3_get_wordWrap(IHTMLStyle3 *iface, BSTR *p)
136 {
137     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
138
139     TRACE("(%p)->(%p)\n", This, p);
140
141     return get_nsstyle_attr(This->nsstyle, STYLEID_WORD_WRAP, p);
142 }
143
144 static HRESULT WINAPI HTMLStyle3_put_textUnderlinePosition(IHTMLStyle3 *iface, BSTR v)
145 {
146     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
147     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
148     return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI HTMLStyle3_get_textUnderlinePosition(IHTMLStyle3 *iface, BSTR *p)
152 {
153     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
154     FIXME("(%p)->(%p)\n", This, p);
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI HTMLStyle3_put_scrollbarBaseColor(IHTMLStyle3 *iface, VARIANT v)
159 {
160     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
161     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
162     return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI HTMLStyle3_get_scrollbarBaseColor(IHTMLStyle3 *iface, VARIANT *p)
166 {
167     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
168     FIXME("(%p)->(%p)\n", This, p);
169     return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI HTMLStyle3_put_scrollbarFaceColor(IHTMLStyle3 *iface, VARIANT v)
173 {
174     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
175     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
176     return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI HTMLStyle3_get_scrollbarFaceColor(IHTMLStyle3 *iface, VARIANT *p)
180 {
181     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
182     FIXME("(%p)->(%p)\n", This, p);
183     return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI HTMLStyle3_put_scrollbar3dLightColor(IHTMLStyle3 *iface, VARIANT v)
187 {
188     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
189     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI HTMLStyle3_get_scrollbar3dLightColor(IHTMLStyle3 *iface, VARIANT *p)
194 {
195     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
196     FIXME("(%p)->(%p)\n", This, p);
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI HTMLStyle3_put_scrollbarShadowColor(IHTMLStyle3 *iface, VARIANT v)
201 {
202     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
203     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
204     return E_NOTIMPL;
205 }
206
207 static HRESULT WINAPI HTMLStyle3_get_scrollbarShadowColor(IHTMLStyle3 *iface, VARIANT *p)
208 {
209     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
210     FIXME("(%p)->(%p)\n", This, p);
211     return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI HTMLStyle3_put_scrollbarHighlightColor(IHTMLStyle3 *iface, VARIANT v)
215 {
216     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
217     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
218     return E_NOTIMPL;
219 }
220
221 static HRESULT WINAPI HTMLStyle3_get_scrollbarHighlightColor(IHTMLStyle3 *iface, VARIANT *p)
222 {
223     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
224     FIXME("(%p)->(%p)\n", This, p);
225     return E_NOTIMPL;
226 }
227
228 static HRESULT WINAPI HTMLStyle3_put_scrollbarDarkShadowColor(IHTMLStyle3 *iface, VARIANT v)
229 {
230     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
231     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
232     return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI HTMLStyle3_get_scrollbarDarkShadowColor(IHTMLStyle3 *iface, VARIANT *p)
236 {
237     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
238     FIXME("(%p)->(%p)\n", This, p);
239     return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI HTMLStyle3_put_scrollbarArrowColor(IHTMLStyle3 *iface, VARIANT v)
243 {
244     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
245     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
246     return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI HTMLStyle3_get_scrollbarArrowColor(IHTMLStyle3 *iface, VARIANT *p)
250 {
251     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
252     FIXME("(%p)->(%p)\n", This, p);
253     return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI HTMLStyle3_put_scrollbarTrackColor(IHTMLStyle3 *iface, VARIANT v)
257 {
258     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
259     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
260     return E_NOTIMPL;
261 }
262
263 static HRESULT WINAPI HTMLStyle3_get_scrollbarTrackColor(IHTMLStyle3 *iface, VARIANT *p)
264 {
265     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
266     FIXME("(%p)->(%p)\n", This, p);
267     return E_NOTIMPL;
268 }
269
270 static HRESULT WINAPI HTMLStyle3_put_writingMode(IHTMLStyle3 *iface, BSTR v)
271 {
272     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
273     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
274     return E_NOTIMPL;
275 }
276
277 static HRESULT WINAPI HTMLStyle3_get_writingMode(IHTMLStyle3 *iface, BSTR *p)
278 {
279     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
280     FIXME("(%p)->(%p)\n", This, p);
281     return E_NOTIMPL;
282 }
283
284 static HRESULT WINAPI HTMLStyle3_put_textAlignLast(IHTMLStyle3 *iface, BSTR v)
285 {
286     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
287     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
288     return E_NOTIMPL;
289 }
290
291 static HRESULT WINAPI HTMLStyle3_get_textAlignLast(IHTMLStyle3 *iface, BSTR *p)
292 {
293     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
294     FIXME("(%p)->(%p)\n", This, p);
295     return E_NOTIMPL;
296 }
297
298 static HRESULT WINAPI HTMLStyle3_put_textKashidaSpace(IHTMLStyle3 *iface, VARIANT v)
299 {
300     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
301     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
302     return E_NOTIMPL;
303 }
304
305 static HRESULT WINAPI HTMLStyle3_get_textKashidaSpace(IHTMLStyle3 *iface, VARIANT *p)
306 {
307     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
308     FIXME("(%p)->(%p)\n", This, p);
309     return E_NOTIMPL;
310 }
311
312 static const IHTMLStyle3Vtbl HTMLStyle3Vtbl = {
313     HTMLStyle3_QueryInterface,
314     HTMLStyle3_AddRef,
315     HTMLStyle3_Release,
316     HTMLStyle3_GetTypeInfoCount,
317     HTMLStyle3_GetTypeInfo,
318     HTMLStyle3_GetIDsOfNames,
319     HTMLStyle3_Invoke,
320     HTMLStyle3_put_layoutFlow,
321     HTMLStyle3_get_layoutFlow,
322     HTMLStyle3_put_zoom,
323     HTMLStyle3_get_zoom,
324     HTMLStyle3_put_wordWrap,
325     HTMLStyle3_get_wordWrap,
326     HTMLStyle3_put_textUnderlinePosition,
327     HTMLStyle3_get_textUnderlinePosition,
328     HTMLStyle3_put_scrollbarBaseColor,
329     HTMLStyle3_get_scrollbarBaseColor,
330     HTMLStyle3_put_scrollbarFaceColor,
331     HTMLStyle3_get_scrollbarFaceColor,
332     HTMLStyle3_put_scrollbar3dLightColor,
333     HTMLStyle3_get_scrollbar3dLightColor,
334     HTMLStyle3_put_scrollbarShadowColor,
335     HTMLStyle3_get_scrollbarShadowColor,
336     HTMLStyle3_put_scrollbarHighlightColor,
337     HTMLStyle3_get_scrollbarHighlightColor,
338     HTMLStyle3_put_scrollbarDarkShadowColor,
339     HTMLStyle3_get_scrollbarDarkShadowColor,
340     HTMLStyle3_put_scrollbarArrowColor,
341     HTMLStyle3_get_scrollbarArrowColor,
342     HTMLStyle3_put_scrollbarTrackColor,
343     HTMLStyle3_get_scrollbarTrackColor,
344     HTMLStyle3_put_writingMode,
345     HTMLStyle3_get_writingMode,
346     HTMLStyle3_put_textAlignLast,
347     HTMLStyle3_get_textAlignLast,
348     HTMLStyle3_put_textKashidaSpace,
349     HTMLStyle3_get_textKashidaSpace
350 };
351
352 /*
353  * IHTMLStyle4 Interface
354  */
355 #define HTMLSTYLE4_THIS(iface) DEFINE_THIS(HTMLStyle, HTMLStyle4, iface)
356
357 static HRESULT WINAPI HTMLStyle4_QueryInterface(IHTMLStyle4 *iface, REFIID riid, void **ppv)
358 {
359     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
360
361     return IHTMLStyle_QueryInterface(HTMLSTYLE(This), riid, ppv);
362 }
363
364 static ULONG WINAPI HTMLStyle4_AddRef(IHTMLStyle4 *iface)
365 {
366     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
367
368     return IHTMLStyle_AddRef(HTMLSTYLE(This));
369 }
370
371 static ULONG WINAPI HTMLStyle4_Release(IHTMLStyle4 *iface)
372 {
373     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
374
375     return IHTMLStyle_Release(HTMLSTYLE(This));
376 }
377
378 static HRESULT WINAPI HTMLStyle4_GetTypeInfoCount(IHTMLStyle4 *iface, UINT *pctinfo)
379 {
380     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
381     return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
382 }
383
384 static HRESULT WINAPI HTMLStyle4_GetTypeInfo(IHTMLStyle4 *iface, UINT iTInfo,
385                                               LCID lcid, ITypeInfo **ppTInfo)
386 {
387     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
388     return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
389 }
390
391 static HRESULT WINAPI HTMLStyle4_GetIDsOfNames(IHTMLStyle4 *iface, REFIID riid,
392                                                 LPOLESTR *rgszNames, UINT cNames,
393                                                 LCID lcid, DISPID *rgDispId)
394 {
395     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
396     return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
397             lcid, rgDispId);
398 }
399
400 static HRESULT WINAPI HTMLStyle4_Invoke(IHTMLStyle4 *iface, DISPID dispIdMember,
401                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
402                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
403 {
404     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
405     return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
406             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
407 }
408
409 static HRESULT WINAPI HTMLStyle4_put_textOverflow(IHTMLStyle4 *iface, BSTR v)
410 {
411     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
412     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
413     return E_NOTIMPL;
414 }
415
416 static HRESULT WINAPI HTMLStyle4_get_textOverflow(IHTMLStyle4 *iface, BSTR *p)
417 {
418     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
419     FIXME("(%p)->(%p)\n", This, p);
420     return E_NOTIMPL;
421 }
422
423 static HRESULT WINAPI HTMLStyle4_put_minHeight(IHTMLStyle4 *iface, VARIANT v)
424 {
425     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
426
427     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
428
429     return set_nsstyle_attr_var(This->nsstyle, STYLEID_MIN_HEIGHT, &v, 0);
430 }
431
432 static HRESULT WINAPI HTMLStyle4_get_minHeight(IHTMLStyle4 *iface, VARIANT *p)
433 {
434     HTMLStyle *This = HTMLSTYLE4_THIS(iface);
435
436     TRACE("(%p)->(%p)\n", This, p);
437
438     return get_nsstyle_attr_var(This->nsstyle, STYLEID_MIN_HEIGHT, p, 0);
439 }
440
441 static const IHTMLStyle4Vtbl HTMLStyle4Vtbl = {
442     HTMLStyle4_QueryInterface,
443     HTMLStyle4_AddRef,
444     HTMLStyle4_Release,
445     HTMLStyle4_GetTypeInfoCount,
446     HTMLStyle4_GetTypeInfo,
447     HTMLStyle4_GetIDsOfNames,
448     HTMLStyle4_Invoke,
449     HTMLStyle4_put_textOverflow,
450     HTMLStyle4_get_textOverflow,
451     HTMLStyle4_put_minHeight,
452     HTMLStyle4_get_minHeight
453 };
454
455 void HTMLStyle3_Init(HTMLStyle *This)
456 {
457     This->lpHTMLStyle3Vtbl = &HTMLStyle3Vtbl;
458     This->lpHTMLStyle4Vtbl = &HTMLStyle4Vtbl;
459 }