user32/tests: Fix a spelling error in a scroll comment.
[wine.git] / dlls / mshtml / htmltablecell.c
bloba63c1562caae58bef2c7127853e5e3432c44b796
1 /*
2 * Copyright 2012 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 HTMLElement element;
38 IHTMLTableCell IHTMLTableCell_iface;
40 nsIDOMHTMLTableCellElement *nscell;
41 } HTMLTableCell;
43 static inline HTMLTableCell *impl_from_IHTMLTableCell(IHTMLTableCell *iface)
45 return CONTAINING_RECORD(iface, HTMLTableCell, IHTMLTableCell_iface);
48 static HRESULT WINAPI HTMLTableCell_QueryInterface(IHTMLTableCell *iface, REFIID riid, void **ppv)
50 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
52 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
55 static ULONG WINAPI HTMLTableCell_AddRef(IHTMLTableCell *iface)
57 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
59 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
62 static ULONG WINAPI HTMLTableCell_Release(IHTMLTableCell *iface)
64 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
66 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
69 static HRESULT WINAPI HTMLTableCell_GetTypeInfoCount(IHTMLTableCell *iface, UINT *pctinfo)
71 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
75 static HRESULT WINAPI HTMLTableCell_GetTypeInfo(IHTMLTableCell *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
79 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
80 ppTInfo);
83 static HRESULT WINAPI HTMLTableCell_GetIDsOfNames(IHTMLTableCell *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
86 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
87 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
88 cNames, lcid, rgDispId);
91 static HRESULT WINAPI HTMLTableCell_Invoke(IHTMLTableCell *iface, DISPID dispIdMember, REFIID riid,
92 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
93 UINT *puArgErr)
95 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
96 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
97 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 static HRESULT WINAPI HTMLTableCell_put_rowSpan(IHTMLTableCell *iface, LONG v)
102 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
103 FIXME("(%p)->(%d)\n", This, v);
104 return E_NOTIMPL;
107 static HRESULT WINAPI HTMLTableCell_get_rowSpan(IHTMLTableCell *iface, LONG *p)
109 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
110 FIXME("(%p)->(%p)\n", This, p);
111 return E_NOTIMPL;
114 static HRESULT WINAPI HTMLTableCell_put_colSpan(IHTMLTableCell *iface, LONG v)
116 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
117 FIXME("(%p)->(%d)\n", This, v);
118 return E_NOTIMPL;
121 static HRESULT WINAPI HTMLTableCell_get_colSpan(IHTMLTableCell *iface, LONG *p)
123 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
124 FIXME("(%p)->(%p)\n", This, p);
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLTableCell_put_align(IHTMLTableCell *iface, BSTR v)
130 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
131 nsAString str;
132 nsresult nsres;
134 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
136 nsAString_InitDepend(&str, v);
137 nsres = nsIDOMHTMLTableCellElement_SetAlign(This->nscell, &str);
138 nsAString_Finish(&str);
139 if (NS_FAILED(nsres)) {
140 ERR("Set Align failed: %08x\n", nsres);
141 return E_FAIL;
143 return S_OK;
146 static HRESULT WINAPI HTMLTableCell_get_align(IHTMLTableCell *iface, BSTR *p)
148 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
149 nsAString str;
150 nsresult nsres;
152 TRACE("(%p)->(%p)\n", This, p);
154 nsAString_Init(&str, NULL);
155 nsres = nsIDOMHTMLTableCellElement_GetAlign(This->nscell, &str);
157 return return_nsstr(nsres, &str, p);
160 static HRESULT WINAPI HTMLTableCell_put_vAlign(IHTMLTableCell *iface, BSTR v)
162 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
163 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
164 return E_NOTIMPL;
167 static HRESULT WINAPI HTMLTableCell_get_vAlign(IHTMLTableCell *iface, BSTR *p)
169 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
170 FIXME("(%p)->(%p)\n", This, p);
171 return E_NOTIMPL;
174 static HRESULT WINAPI HTMLTableCell_put_bgColor(IHTMLTableCell *iface, VARIANT v)
176 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
177 nsAString strColor;
178 nsresult nsres;
180 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
182 if(!variant_to_nscolor(&v, &strColor))
183 return S_OK;
185 nsres = nsIDOMHTMLTableCellElement_SetBgColor(This->nscell, &strColor);
186 nsAString_Finish(&strColor);
187 if(NS_FAILED(nsres)) {
188 ERR("SetBgColor(%s) failed: %08x\n", debugstr_variant(&v), nsres);
189 return E_FAIL;
192 return S_OK;
195 static HRESULT WINAPI HTMLTableCell_get_bgColor(IHTMLTableCell *iface, VARIANT *p)
197 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
198 nsAString strColor;
199 nsresult nsres;
200 HRESULT hres;
202 TRACE("(%p)->(%p)\n", This, p);
204 nsAString_Init(&strColor, NULL);
205 nsres = nsIDOMHTMLTableCellElement_GetBgColor(This->nscell, &strColor);
207 if(NS_SUCCEEDED(nsres)) {
208 const PRUnichar *color;
209 nsAString_GetData(&strColor, &color);
210 V_VT(p) = VT_BSTR;
211 hres = nscolor_to_str(color, &V_BSTR(p));
212 }else {
213 ERR("GetBgColor failed: %08x\n", nsres);
214 hres = E_FAIL;
216 nsAString_Finish(&strColor);
217 return hres;
220 static HRESULT WINAPI HTMLTableCell_put_noWrap(IHTMLTableCell *iface, VARIANT_BOOL v)
222 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
223 FIXME("(%p)->(%x)\n", This, v);
224 return E_NOTIMPL;
227 static HRESULT WINAPI HTMLTableCell_get_noWrap(IHTMLTableCell *iface, VARIANT_BOOL *p)
229 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
230 FIXME("(%p)->(%p)\n", This, p);
231 return E_NOTIMPL;
234 static HRESULT WINAPI HTMLTableCell_put_background(IHTMLTableCell *iface, BSTR v)
236 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
237 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
238 return E_NOTIMPL;
241 static HRESULT WINAPI HTMLTableCell_get_background(IHTMLTableCell *iface, BSTR *p)
243 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
244 FIXME("(%p)->(%p)\n", This, p);
245 return E_NOTIMPL;
248 static HRESULT WINAPI HTMLTableCell_put_borderColor(IHTMLTableCell *iface, VARIANT v)
250 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
251 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
252 return E_NOTIMPL;
255 static HRESULT WINAPI HTMLTableCell_get_borderColor(IHTMLTableCell *iface, VARIANT *p)
257 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
258 FIXME("(%p)->(%p)\n", This, p);
259 return E_NOTIMPL;
262 static HRESULT WINAPI HTMLTableCell_put_borderColorLight(IHTMLTableCell *iface, VARIANT v)
264 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
265 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
266 return E_NOTIMPL;
269 static HRESULT WINAPI HTMLTableCell_get_borderColorLight(IHTMLTableCell *iface, VARIANT *p)
271 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
272 FIXME("(%p)->(%p)\n", This, p);
273 return E_NOTIMPL;
276 static HRESULT WINAPI HTMLTableCell_put_borderColorDark(IHTMLTableCell *iface, VARIANT v)
278 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
279 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
280 return E_NOTIMPL;
283 static HRESULT WINAPI HTMLTableCell_get_borderColorDark(IHTMLTableCell *iface, VARIANT *p)
285 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
286 FIXME("(%p)->(%p)\n", This, p);
287 return E_NOTIMPL;
290 static HRESULT WINAPI HTMLTableCell_put_width(IHTMLTableCell *iface, VARIANT v)
292 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
293 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
294 return E_NOTIMPL;
297 static HRESULT WINAPI HTMLTableCell_get_width(IHTMLTableCell *iface, VARIANT *p)
299 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
300 FIXME("(%p)->(%p)\n", This, p);
301 return E_NOTIMPL;
304 static HRESULT WINAPI HTMLTableCell_put_height(IHTMLTableCell *iface, VARIANT v)
306 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
307 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
308 return E_NOTIMPL;
311 static HRESULT WINAPI HTMLTableCell_get_height(IHTMLTableCell *iface, VARIANT *p)
313 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
314 FIXME("(%p)->(%p)\n", This, p);
315 return E_NOTIMPL;
318 static HRESULT WINAPI HTMLTableCell_get_cellIndex(IHTMLTableCell *iface, LONG *p)
320 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
321 nsresult nsres;
323 TRACE("(%p)->(%p)\n", This, p);
324 nsres = nsIDOMHTMLTableCellElement_GetCellIndex(This->nscell, p);
325 if (NS_FAILED(nsres)) {
326 ERR("Get CellIndex failed: %08x\n", nsres);
327 return E_FAIL;
330 return S_OK;
333 static const IHTMLTableCellVtbl HTMLTableCellVtbl = {
334 HTMLTableCell_QueryInterface,
335 HTMLTableCell_AddRef,
336 HTMLTableCell_Release,
337 HTMLTableCell_GetTypeInfoCount,
338 HTMLTableCell_GetTypeInfo,
339 HTMLTableCell_GetIDsOfNames,
340 HTMLTableCell_Invoke,
341 HTMLTableCell_put_rowSpan,
342 HTMLTableCell_get_rowSpan,
343 HTMLTableCell_put_colSpan,
344 HTMLTableCell_get_colSpan,
345 HTMLTableCell_put_align,
346 HTMLTableCell_get_align,
347 HTMLTableCell_put_vAlign,
348 HTMLTableCell_get_vAlign,
349 HTMLTableCell_put_bgColor,
350 HTMLTableCell_get_bgColor,
351 HTMLTableCell_put_noWrap,
352 HTMLTableCell_get_noWrap,
353 HTMLTableCell_put_background,
354 HTMLTableCell_get_background,
355 HTMLTableCell_put_borderColor,
356 HTMLTableCell_get_borderColor,
357 HTMLTableCell_put_borderColorLight,
358 HTMLTableCell_get_borderColorLight,
359 HTMLTableCell_put_borderColorDark,
360 HTMLTableCell_get_borderColorDark,
361 HTMLTableCell_put_width,
362 HTMLTableCell_get_width,
363 HTMLTableCell_put_height,
364 HTMLTableCell_get_height,
365 HTMLTableCell_get_cellIndex
368 static inline HTMLTableCell *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
370 return CONTAINING_RECORD(iface, HTMLTableCell, element.node);
373 static HRESULT HTMLTableCell_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
375 HTMLTableCell *This = impl_from_HTMLDOMNode(iface);
377 if(IsEqualGUID(&IID_IUnknown, riid)) {
378 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
379 *ppv = &This->IHTMLTableCell_iface;
380 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
381 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
382 *ppv = &This->IHTMLTableCell_iface;
383 }else if(IsEqualGUID(&IID_IHTMLTableCell, riid)) {
384 TRACE("(%p)->(IID_IHTMLTableCell %p)\n", This, ppv);
385 *ppv = &This->IHTMLTableCell_iface;
386 }else {
387 return HTMLElement_QI(&This->element.node, riid, ppv);
390 IUnknown_AddRef((IUnknown*)*ppv);
391 return S_OK;
394 static void HTMLTableCell_destructor(HTMLDOMNode *iface)
396 HTMLTableCell *This = impl_from_HTMLDOMNode(iface);
398 HTMLElement_destructor(&This->element.node);
401 static void HTMLTableCell_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
403 HTMLTableCell *This = impl_from_HTMLDOMNode(iface);
405 if(This->nscell)
406 note_cc_edge((nsISupports*)This->nscell, "This->nstablecell", cb);
409 static void HTMLTableCell_unlink(HTMLDOMNode *iface)
411 HTMLTableCell *This = impl_from_HTMLDOMNode(iface);
413 if(This->nscell) {
414 nsIDOMHTMLTableCellElement *nscell = This->nscell;
416 This->nscell = NULL;
417 nsIDOMHTMLTableCellElement_Release(nscell);
421 static const NodeImplVtbl HTMLTableCellImplVtbl = {
422 HTMLTableCell_QI,
423 HTMLTableCell_destructor,
424 HTMLElement_cpc,
425 HTMLElement_clone,
426 HTMLElement_handle_event,
427 HTMLElement_get_attr_col,
428 NULL,
429 NULL,
430 NULL,
431 NULL,
432 NULL,
433 NULL,
434 NULL,
435 NULL,
436 NULL,
437 HTMLTableCell_traverse,
438 HTMLTableCell_unlink
441 static const tid_t HTMLTableCell_iface_tids[] = {
442 HTMLELEMENT_TIDS,
443 IHTMLTableCell_tid,
447 static dispex_static_data_t HTMLTableCell_dispex = {
448 NULL,
449 DispHTMLTableCell_tid,
450 NULL,
451 HTMLTableCell_iface_tids
454 HRESULT HTMLTableCell_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
456 HTMLTableCell *ret;
457 nsresult nsres;
459 ret = heap_alloc_zero(sizeof(*ret));
460 if(!ret)
461 return E_OUTOFMEMORY;
463 ret->IHTMLTableCell_iface.lpVtbl = &HTMLTableCellVtbl;
464 ret->element.node.vtbl = &HTMLTableCellImplVtbl;
466 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTableCell_dispex);
468 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableCellElement, (void**)&ret->nscell);
469 assert(nsres == NS_OK);
471 *elem = &ret->element;
472 return S_OK;