d3d8: TRACE fixes.
[wine.git] / dlls / mshtml / htmltable.c
blob7e894c02424410d4903321e54ea540b0d7b58b6f
1 /*
2 * Copyright 2007 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 struct HTMLTable {
36 HTMLElement element;
38 IHTMLTable IHTMLTable_iface;
39 IHTMLTable2 IHTMLTable2_iface;
40 IHTMLTable3 IHTMLTable3_iface;
42 nsIDOMHTMLTableElement *nstable;
45 static inline HTMLTable *impl_from_IHTMLTable(IHTMLTable *iface)
47 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable_iface);
50 static inline HTMLTable *impl_from_IHTMLTable2(IHTMLTable2 *iface)
52 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable2_iface);
55 static inline HTMLTable *impl_from_IHTMLTable3(IHTMLTable3 *iface)
57 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable3_iface);
60 static HRESULT var2str(const VARIANT *p, nsAString *nsstr)
62 BSTR str;
63 BOOL ret;
64 HRESULT hres;
66 switch(V_VT(p)) {
67 case VT_BSTR:
68 return nsAString_Init(nsstr, V_BSTR(p))?
69 S_OK : E_OUTOFMEMORY;
70 case VT_R8:
71 hres = VarBstrFromR8(V_R8(p), 0, 0, &str);
72 break;
73 case VT_R4:
74 hres = VarBstrFromR4(V_R4(p), 0, 0, &str);
75 break;
76 case VT_I4:
77 hres = VarBstrFromI4(V_I4(p), 0, 0, &str);
78 break;
79 default:
80 FIXME("unsupported arg %s\n", debugstr_variant(p));
81 return E_NOTIMPL;
83 if (FAILED(hres))
84 return hres;
86 ret = nsAString_Init(nsstr, str);
87 SysFreeString(str);
88 return ret ? S_OK : E_OUTOFMEMORY;
91 static HRESULT nsstr_to_truncated_bstr(const nsAString *nsstr, BSTR *ret_ptr)
93 const PRUnichar *str, *ptr, *end = NULL;
94 BSTR ret;
96 nsAString_GetData(nsstr, &str);
98 for(ptr = str; isdigitW(*ptr); ptr++);
99 if(*ptr == '.') {
100 for(end = ptr++; isdigitW(*ptr); ptr++);
101 if(*ptr)
102 end = NULL;
105 ret = end ? SysAllocStringLen(str, end-str) : SysAllocString(str);
107 *ret_ptr = ret;
108 return ret ? S_OK : E_OUTOFMEMORY;
111 static HRESULT WINAPI HTMLTable_QueryInterface(IHTMLTable *iface,
112 REFIID riid, void **ppv)
114 HTMLTable *This = impl_from_IHTMLTable(iface);
116 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
119 static ULONG WINAPI HTMLTable_AddRef(IHTMLTable *iface)
121 HTMLTable *This = impl_from_IHTMLTable(iface);
123 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
126 static ULONG WINAPI HTMLTable_Release(IHTMLTable *iface)
128 HTMLTable *This = impl_from_IHTMLTable(iface);
130 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
133 static HRESULT WINAPI HTMLTable_GetTypeInfoCount(IHTMLTable *iface, UINT *pctinfo)
135 HTMLTable *This = impl_from_IHTMLTable(iface);
136 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
139 static HRESULT WINAPI HTMLTable_GetTypeInfo(IHTMLTable *iface, UINT iTInfo,
140 LCID lcid, ITypeInfo **ppTInfo)
142 HTMLTable *This = impl_from_IHTMLTable(iface);
143 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
144 ppTInfo);
147 static HRESULT WINAPI HTMLTable_GetIDsOfNames(IHTMLTable *iface, REFIID riid,
148 LPOLESTR *rgszNames, UINT cNames,
149 LCID lcid, DISPID *rgDispId)
151 HTMLTable *This = impl_from_IHTMLTable(iface);
152 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
153 cNames, lcid, rgDispId);
156 static HRESULT WINAPI HTMLTable_Invoke(IHTMLTable *iface, DISPID dispIdMember,
157 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
158 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
160 HTMLTable *This = impl_from_IHTMLTable(iface);
161 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
162 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
165 static HRESULT WINAPI HTMLTable_put_cols(IHTMLTable *iface, LONG v)
167 HTMLTable *This = impl_from_IHTMLTable(iface);
168 FIXME("(%p)->(%d)\n", This, v);
169 return E_NOTIMPL;
172 static HRESULT WINAPI HTMLTable_get_cols(IHTMLTable *iface, LONG *p)
174 HTMLTable *This = impl_from_IHTMLTable(iface);
175 FIXME("(%p)->(%p)\n", This, p);
176 return E_NOTIMPL;
179 static HRESULT WINAPI HTMLTable_put_border(IHTMLTable *iface, VARIANT v)
181 HTMLTable *This = impl_from_IHTMLTable(iface);
182 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
183 return E_NOTIMPL;
186 static HRESULT WINAPI HTMLTable_get_border(IHTMLTable *iface, VARIANT *p)
188 HTMLTable *This = impl_from_IHTMLTable(iface);
189 FIXME("(%p)->(%p)\n", This, p);
190 return E_NOTIMPL;
193 static HRESULT WINAPI HTMLTable_put_frame(IHTMLTable *iface, BSTR v)
195 HTMLTable *This = impl_from_IHTMLTable(iface);
196 nsAString str;
197 nsresult nsres;
199 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
201 nsAString_InitDepend(&str, v);
202 nsres = nsIDOMHTMLTableElement_SetFrame(This->nstable, &str);
203 nsAString_Finish(&str);
205 if (NS_FAILED(nsres)) {
206 ERR("SetFrame(%s) failed: %08x\n", debugstr_w(v), nsres);
207 return E_FAIL;
209 return S_OK;
212 static HRESULT WINAPI HTMLTable_get_frame(IHTMLTable *iface, BSTR *p)
214 HTMLTable *This = impl_from_IHTMLTable(iface);
215 nsAString str;
216 nsresult nsres;
218 TRACE("(%p)->(%p)\n", This, p);
220 nsAString_Init(&str, NULL);
221 nsres = nsIDOMHTMLTableElement_GetFrame(This->nstable, &str);
223 return return_nsstr(nsres, &str, p);
226 static HRESULT WINAPI HTMLTable_put_rules(IHTMLTable *iface, BSTR v)
228 HTMLTable *This = impl_from_IHTMLTable(iface);
229 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
230 return E_NOTIMPL;
233 static HRESULT WINAPI HTMLTable_get_rules(IHTMLTable *iface, BSTR *p)
235 HTMLTable *This = impl_from_IHTMLTable(iface);
236 FIXME("(%p)->(%p)\n", This, p);
237 return E_NOTIMPL;
240 static HRESULT WINAPI HTMLTable_put_cellSpacing(IHTMLTable *iface, VARIANT v)
242 HTMLTable *This = impl_from_IHTMLTable(iface);
243 nsAString nsstr;
244 WCHAR buf[64];
245 nsresult nsres;
247 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
249 switch(V_VT(&v)) {
250 case VT_BSTR:
251 nsAString_InitDepend(&nsstr, V_BSTR(&v));
252 break;
253 case VT_I4: {
254 static const WCHAR formatW[] = {'%','d',0};
255 sprintfW(buf, formatW, V_I4(&v));
256 nsAString_InitDepend(&nsstr, buf);
257 break;
259 default:
260 FIXME("unsupported arg %s\n", debugstr_variant(&v));
261 return E_NOTIMPL;
264 nsres = nsIDOMHTMLTableElement_SetCellSpacing(This->nstable, &nsstr);
265 nsAString_Finish(&nsstr);
266 if(NS_FAILED(nsres)) {
267 ERR("SetCellSpacing failed: %08x\n", nsres);
268 return E_FAIL;
271 return S_OK;
274 static HRESULT WINAPI HTMLTable_get_cellSpacing(IHTMLTable *iface, VARIANT *p)
276 HTMLTable *This = impl_from_IHTMLTable(iface);
277 nsAString nsstr;
278 nsresult nsres;
280 TRACE("(%p)->(%p)\n", This, p);
282 nsAString_Init(&nsstr, NULL);
283 nsres = nsIDOMHTMLTableElement_GetCellSpacing(This->nstable, &nsstr);
284 V_VT(p) = VT_BSTR;
285 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
288 static HRESULT WINAPI HTMLTable_put_cellPadding(IHTMLTable *iface, VARIANT v)
290 HTMLTable *This = impl_from_IHTMLTable(iface);
291 nsAString val;
292 HRESULT hres;
293 nsresult nsres;
295 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
297 hres = var2str(&v, &val);
298 if(FAILED(hres))
299 return hres;
301 nsres = nsIDOMHTMLTableElement_SetCellPadding(This->nstable, &val);
302 nsAString_Finish(&val);
303 if(NS_FAILED(nsres)) {
304 ERR("Set Width(%s) failed, err = %08x\n", debugstr_variant(&v), nsres);
305 return E_FAIL;
308 return S_OK;
311 static HRESULT WINAPI HTMLTable_get_cellPadding(IHTMLTable *iface, VARIANT *p)
313 HTMLTable *This = impl_from_IHTMLTable(iface);
314 nsAString val;
315 nsresult nsres;
317 TRACE("(%p)->(%p)\n", This, p);
319 nsAString_Init(&val, NULL);
320 nsres = nsIDOMHTMLTableElement_GetCellPadding(This->nstable, &val);
321 return return_nsstr_variant(nsres, &val, p);
324 static HRESULT WINAPI HTMLTable_put_background(IHTMLTable *iface, BSTR v)
326 HTMLTable *This = impl_from_IHTMLTable(iface);
327 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
328 return E_NOTIMPL;
331 static HRESULT WINAPI HTMLTable_get_background(IHTMLTable *iface, BSTR *p)
333 HTMLTable *This = impl_from_IHTMLTable(iface);
334 FIXME("(%p)->(%p)\n", This, p);
335 return E_NOTIMPL;
338 static HRESULT WINAPI HTMLTable_put_bgColor(IHTMLTable *iface, VARIANT v)
340 HTMLTable *This = impl_from_IHTMLTable(iface);
341 nsAString val;
342 nsresult nsres;
344 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
346 if(!variant_to_nscolor(&v, &val))
347 return S_OK;
349 nsres = nsIDOMHTMLTableElement_SetBgColor(This->nstable, &val);
350 nsAString_Finish(&val);
351 if (NS_FAILED(nsres)){
352 ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v));
353 return E_FAIL;
356 return S_OK;
359 static HRESULT WINAPI HTMLTable_get_bgColor(IHTMLTable *iface, VARIANT *p)
361 HTMLTable *This = impl_from_IHTMLTable(iface);
362 nsAString strColor;
363 nsresult nsres;
364 HRESULT hres;
365 const PRUnichar *color;
367 TRACE("(%p)->(%p)\n", This, p);
369 nsAString_Init(&strColor, NULL);
370 nsres = nsIDOMHTMLTableElement_GetBgColor(This->nstable, &strColor);
372 if(NS_SUCCEEDED(nsres)) {
373 nsAString_GetData(&strColor, &color);
374 V_VT(p) = VT_BSTR;
375 hres = nscolor_to_str(color, &V_BSTR(p));
376 }else {
377 ERR("SetBgColor failed: %08x\n", nsres);
378 hres = E_FAIL;
381 nsAString_Finish(&strColor);
382 return hres;
385 static HRESULT WINAPI HTMLTable_put_borderColor(IHTMLTable *iface, VARIANT v)
387 HTMLTable *This = impl_from_IHTMLTable(iface);
388 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
389 return E_NOTIMPL;
392 static HRESULT WINAPI HTMLTable_get_borderColor(IHTMLTable *iface, VARIANT *p)
394 HTMLTable *This = impl_from_IHTMLTable(iface);
395 FIXME("(%p)->(%p)\n", This, p);
396 return E_NOTIMPL;
399 static HRESULT WINAPI HTMLTable_put_borderColorLight(IHTMLTable *iface, VARIANT v)
401 HTMLTable *This = impl_from_IHTMLTable(iface);
402 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLTable_get_borderColorLight(IHTMLTable *iface, VARIANT *p)
408 HTMLTable *This = impl_from_IHTMLTable(iface);
409 FIXME("(%p)->(%p)\n", This, p);
410 return E_NOTIMPL;
413 static HRESULT WINAPI HTMLTable_put_borderColorDark(IHTMLTable *iface, VARIANT v)
415 HTMLTable *This = impl_from_IHTMLTable(iface);
416 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
417 return E_NOTIMPL;
420 static HRESULT WINAPI HTMLTable_get_borderColorDark(IHTMLTable *iface, VARIANT *p)
422 HTMLTable *This = impl_from_IHTMLTable(iface);
423 FIXME("(%p)->(%p)\n", This, p);
424 return E_NOTIMPL;
427 static HRESULT WINAPI HTMLTable_put_align(IHTMLTable *iface, BSTR v)
429 HTMLTable *This = impl_from_IHTMLTable(iface);
430 nsAString val;
431 nsresult nsres;
433 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
435 nsAString_InitDepend(&val, v);
437 nsres = nsIDOMHTMLTableElement_SetAlign(This->nstable, &val);
438 nsAString_Finish(&val);
439 if (NS_FAILED(nsres)){
440 ERR("Set Align(%s) failed!\n", debugstr_w(v));
441 return E_FAIL;
443 return S_OK;
446 static HRESULT WINAPI HTMLTable_get_align(IHTMLTable *iface, BSTR *p)
448 HTMLTable *This = impl_from_IHTMLTable(iface);
449 nsAString val;
450 nsresult nsres;
452 TRACE("(%p)->(%p)\n", This, p);
454 nsAString_Init(&val, NULL);
455 nsres = nsIDOMHTMLTableElement_GetAlign(This->nstable, &val);
457 return return_nsstr(nsres, &val, p);
460 static HRESULT WINAPI HTMLTable_refresh(IHTMLTable *iface)
462 HTMLTable *This = impl_from_IHTMLTable(iface);
463 FIXME("(%p)\n", This);
464 return E_NOTIMPL;
467 static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollection **p)
469 HTMLTable *This = impl_from_IHTMLTable(iface);
470 nsIDOMHTMLCollection *nscol;
471 nsresult nsres;
473 TRACE("(%p)->(%p)\n", This, p);
475 nsres = nsIDOMHTMLTableElement_GetRows(This->nstable, &nscol);
476 if(NS_FAILED(nsres)) {
477 ERR("GetRows failed: %08x\n", nsres);
478 return E_FAIL;
481 *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
483 nsIDOMHTMLCollection_Release(nscol);
484 return S_OK;
487 static HRESULT WINAPI HTMLTable_put_width(IHTMLTable *iface, VARIANT v)
489 HTMLTable *This = impl_from_IHTMLTable(iface);
490 nsAString val;
491 HRESULT hres;
492 nsresult nsres;
494 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
495 hres = var2str(&v, &val);
497 if (FAILED(hres)){
498 ERR("Set Width(%s) failed when initializing a nsAString, err = %08x\n",
499 debugstr_variant(&v), hres);
500 return hres;
503 nsres = nsIDOMHTMLTableElement_SetWidth(This->nstable, &val);
504 nsAString_Finish(&val);
506 if (NS_FAILED(nsres)){
507 ERR("Set Width(%s) failed, err = %08x\n", debugstr_variant(&v), nsres);
508 return E_FAIL;
510 return S_OK;
513 static HRESULT WINAPI HTMLTable_get_width(IHTMLTable *iface, VARIANT *p)
515 HTMLTable *This = impl_from_IHTMLTable(iface);
516 nsAString val;
517 BSTR bstr;
518 nsresult nsres;
519 HRESULT hres;
521 TRACE("(%p)->(%p)\n", This, p);
522 nsAString_Init(&val, NULL);
523 nsres = nsIDOMHTMLTableElement_GetWidth(This->nstable, &val);
524 if (NS_FAILED(nsres)){
525 ERR("Get Width failed!\n");
526 nsAString_Finish(&val);
527 return E_FAIL;
530 hres = nsstr_to_truncated_bstr(&val, &bstr);
531 nsAString_Finish(&val);
533 V_VT(p) = VT_BSTR;
534 V_BSTR(p) = bstr;
535 return hres;
538 static HRESULT WINAPI HTMLTable_put_height(IHTMLTable *iface, VARIANT v)
540 HTMLTable *This = impl_from_IHTMLTable(iface);
541 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
542 return E_NOTIMPL;
545 static HRESULT WINAPI HTMLTable_get_height(IHTMLTable *iface, VARIANT *p)
547 HTMLTable *This = impl_from_IHTMLTable(iface);
548 FIXME("(%p)->(%p)\n", This, p);
549 return E_NOTIMPL;
552 static HRESULT WINAPI HTMLTable_put_dataPageSize(IHTMLTable *iface, LONG v)
554 HTMLTable *This = impl_from_IHTMLTable(iface);
555 FIXME("(%p)->(%d)\n", This, v);
556 return E_NOTIMPL;
559 static HRESULT WINAPI HTMLTable_get_dataPageSize(IHTMLTable *iface, LONG *p)
561 HTMLTable *This = impl_from_IHTMLTable(iface);
562 FIXME("(%p)->(%p)\n", This, p);
563 return E_NOTIMPL;
566 static HRESULT WINAPI HTMLTable_nextPage(IHTMLTable *iface)
568 HTMLTable *This = impl_from_IHTMLTable(iface);
569 FIXME("(%p)\n", This);
570 return E_NOTIMPL;
573 static HRESULT WINAPI HTMLTable_previousPage(IHTMLTable *iface)
575 HTMLTable *This = impl_from_IHTMLTable(iface);
576 FIXME("(%p)\n", This);
577 return E_NOTIMPL;
580 static HRESULT WINAPI HTMLTable_get_tHead(IHTMLTable *iface, IHTMLTableSection **p)
582 HTMLTable *This = impl_from_IHTMLTable(iface);
583 FIXME("(%p)->(%p)\n", This, p);
584 return E_NOTIMPL;
587 static HRESULT WINAPI HTMLTable_get_tFoot(IHTMLTable *iface, IHTMLTableSection **p)
589 HTMLTable *This = impl_from_IHTMLTable(iface);
590 FIXME("(%p)->(%p)\n", This, p);
591 return E_NOTIMPL;
594 static HRESULT WINAPI HTMLTable_get_tBodies(IHTMLTable *iface, IHTMLElementCollection **p)
596 HTMLTable *This = impl_from_IHTMLTable(iface);
597 nsIDOMHTMLCollection *nscol = NULL;
598 nsresult nsres;
600 TRACE("(%p)->(%p)\n", This, p);
602 nsres = nsIDOMHTMLTableElement_GetTBodies(This->nstable, &nscol);
603 if(NS_FAILED(nsres)) {
604 ERR("GetTBodies failed: %08x\n", nsres);
605 return E_FAIL;
608 *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
610 nsIDOMHTMLCollection_Release(nscol);
611 return S_OK;
614 static HRESULT WINAPI HTMLTable_get_caption(IHTMLTable *iface, IHTMLTableCaption **p)
616 HTMLTable *This = impl_from_IHTMLTable(iface);
617 FIXME("(%p)->(%p)\n", This, p);
618 return E_NOTIMPL;
621 static HRESULT WINAPI HTMLTable_createTHead(IHTMLTable *iface, IDispatch **head)
623 HTMLTable *This = impl_from_IHTMLTable(iface);
624 FIXME("(%p)->(%p)\n", This, head);
625 return E_NOTIMPL;
628 static HRESULT WINAPI HTMLTable_deleteTHead(IHTMLTable *iface)
630 HTMLTable *This = impl_from_IHTMLTable(iface);
631 FIXME("(%p)\n", This);
632 return E_NOTIMPL;
635 static HRESULT WINAPI HTMLTable_createTFoot(IHTMLTable *iface, IDispatch **foot)
637 HTMLTable *This = impl_from_IHTMLTable(iface);
638 FIXME("(%p)->(%p)\n", This, foot);
639 return E_NOTIMPL;
642 static HRESULT WINAPI HTMLTable_deleteTFoot(IHTMLTable *iface)
644 HTMLTable *This = impl_from_IHTMLTable(iface);
645 FIXME("(%p)\n", This);
646 return E_NOTIMPL;
649 static HRESULT WINAPI HTMLTable_createCaption(IHTMLTable *iface, IHTMLTableCaption **caption)
651 HTMLTable *This = impl_from_IHTMLTable(iface);
652 FIXME("(%p)->(%p)\n", This, caption);
653 return E_NOTIMPL;
656 static HRESULT WINAPI HTMLTable_deleteCaption(IHTMLTable *iface)
658 HTMLTable *This = impl_from_IHTMLTable(iface);
659 FIXME("(%p)\n", This);
660 return E_NOTIMPL;
663 static HRESULT WINAPI HTMLTable_insertRow(IHTMLTable *iface, LONG index, IDispatch **row)
665 HTMLTable *This = impl_from_IHTMLTable(iface);
666 nsIDOMHTMLElement *nselem;
667 HTMLElement *elem;
668 nsresult nsres;
669 HRESULT hres;
671 TRACE("(%p)->(%d %p)\n", This, index, row);
672 nsres = nsIDOMHTMLTableElement_InsertRow(This->nstable, index, &nselem);
673 if(NS_FAILED(nsres)) {
674 ERR("Insert Row at %d failed: %08x\n", index, nsres);
675 return E_FAIL;
678 hres = HTMLTableRow_Create(This->element.node.doc, nselem, &elem);
679 nsIDOMHTMLElement_Release(nselem);
680 if (FAILED(hres)) {
681 ERR("Create TableRow failed: %08x\n", hres);
682 return hres;
685 *row = (IDispatch *)&elem->IHTMLElement_iface;
686 return S_OK;
689 static HRESULT WINAPI HTMLTable_deleteRow(IHTMLTable *iface, LONG index)
691 HTMLTable *This = impl_from_IHTMLTable(iface);
692 nsresult nsres;
694 TRACE("(%p)->(%d)\n", This, index);
695 nsres = nsIDOMHTMLTableElement_DeleteRow(This->nstable, index);
696 if(NS_FAILED(nsres)) {
697 ERR("Delete Row failed: %08x\n", nsres);
698 return E_FAIL;
700 return S_OK;
703 static HRESULT WINAPI HTMLTable_get_readyState(IHTMLTable *iface, BSTR *p)
705 HTMLTable *This = impl_from_IHTMLTable(iface);
706 FIXME("(%p)->(%p)\n", This, p);
707 return E_NOTIMPL;
710 static HRESULT WINAPI HTMLTable_put_onreadystatechange(IHTMLTable *iface, VARIANT v)
712 HTMLTable *This = impl_from_IHTMLTable(iface);
713 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
714 return E_NOTIMPL;
717 static HRESULT WINAPI HTMLTable_get_onreadystatechange(IHTMLTable *iface, VARIANT *p)
719 HTMLTable *This = impl_from_IHTMLTable(iface);
720 FIXME("(%p)->(%p)\n", This, p);
721 return E_NOTIMPL;
724 static const IHTMLTableVtbl HTMLTableVtbl = {
725 HTMLTable_QueryInterface,
726 HTMLTable_AddRef,
727 HTMLTable_Release,
728 HTMLTable_GetTypeInfoCount,
729 HTMLTable_GetTypeInfo,
730 HTMLTable_GetIDsOfNames,
731 HTMLTable_Invoke,
732 HTMLTable_put_cols,
733 HTMLTable_get_cols,
734 HTMLTable_put_border,
735 HTMLTable_get_border,
736 HTMLTable_put_frame,
737 HTMLTable_get_frame,
738 HTMLTable_put_rules,
739 HTMLTable_get_rules,
740 HTMLTable_put_cellSpacing,
741 HTMLTable_get_cellSpacing,
742 HTMLTable_put_cellPadding,
743 HTMLTable_get_cellPadding,
744 HTMLTable_put_background,
745 HTMLTable_get_background,
746 HTMLTable_put_bgColor,
747 HTMLTable_get_bgColor,
748 HTMLTable_put_borderColor,
749 HTMLTable_get_borderColor,
750 HTMLTable_put_borderColorLight,
751 HTMLTable_get_borderColorLight,
752 HTMLTable_put_borderColorDark,
753 HTMLTable_get_borderColorDark,
754 HTMLTable_put_align,
755 HTMLTable_get_align,
756 HTMLTable_refresh,
757 HTMLTable_get_rows,
758 HTMLTable_put_width,
759 HTMLTable_get_width,
760 HTMLTable_put_height,
761 HTMLTable_get_height,
762 HTMLTable_put_dataPageSize,
763 HTMLTable_get_dataPageSize,
764 HTMLTable_nextPage,
765 HTMLTable_previousPage,
766 HTMLTable_get_tHead,
767 HTMLTable_get_tFoot,
768 HTMLTable_get_tBodies,
769 HTMLTable_get_caption,
770 HTMLTable_createTHead,
771 HTMLTable_deleteTHead,
772 HTMLTable_createTFoot,
773 HTMLTable_deleteTFoot,
774 HTMLTable_createCaption,
775 HTMLTable_deleteCaption,
776 HTMLTable_insertRow,
777 HTMLTable_deleteRow,
778 HTMLTable_get_readyState,
779 HTMLTable_put_onreadystatechange,
780 HTMLTable_get_onreadystatechange
783 /* IHTMLTable2 */
784 static HRESULT WINAPI HTMLTable2_QueryInterface(IHTMLTable2 *iface,
785 REFIID riid, void **ppv)
787 HTMLTable *This = impl_from_IHTMLTable2(iface);
789 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
792 static ULONG WINAPI HTMLTable2_AddRef(IHTMLTable2 *iface)
794 HTMLTable *This = impl_from_IHTMLTable2(iface);
796 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
799 static ULONG WINAPI HTMLTable2_Release(IHTMLTable2 *iface)
801 HTMLTable *This = impl_from_IHTMLTable2(iface);
803 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
806 static HRESULT WINAPI HTMLTable2_GetTypeInfoCount(IHTMLTable2 *iface, UINT *pctinfo)
808 HTMLTable *This = impl_from_IHTMLTable2(iface);
809 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
812 static HRESULT WINAPI HTMLTable2_GetTypeInfo(IHTMLTable2 *iface, UINT iTInfo,
813 LCID lcid, ITypeInfo **ppTInfo)
815 HTMLTable *This = impl_from_IHTMLTable2(iface);
816 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
817 ppTInfo);
820 static HRESULT WINAPI HTMLTable2_GetIDsOfNames(IHTMLTable2 *iface, REFIID riid,
821 LPOLESTR *rgszNames, UINT cNames,
822 LCID lcid, DISPID *rgDispId)
824 HTMLTable *This = impl_from_IHTMLTable2(iface);
825 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
826 cNames, lcid, rgDispId);
829 static HRESULT WINAPI HTMLTable2_Invoke(IHTMLTable2 *iface, DISPID dispIdMember,
830 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
831 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
833 HTMLTable *This = impl_from_IHTMLTable2(iface);
834 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
835 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
838 static HRESULT WINAPI HTMLTable2_firstPage(IHTMLTable2 *iface)
840 HTMLTable *This = impl_from_IHTMLTable2(iface);
841 FIXME("(%p)->()\n", This);
842 return E_NOTIMPL;
845 static HRESULT WINAPI HTMLTable2_lastPage(IHTMLTable2 *iface)
847 HTMLTable *This = impl_from_IHTMLTable2(iface);
848 FIXME("(%p)->()\n", This);
849 return E_NOTIMPL;
852 static HRESULT WINAPI HTMLTable2_cells(IHTMLTable2 *iface, IHTMLElementCollection **p)
854 HTMLTable *This = impl_from_IHTMLTable2(iface);
855 FIXME("(%p)->(%p)\n", This, p);
856 return E_NOTIMPL;
859 static HRESULT WINAPI HTMLTable2_moveRow(IHTMLTable2 *iface, LONG indexFrom, LONG indexTo, IDispatch **row)
861 HTMLTable *This = impl_from_IHTMLTable2(iface);
862 FIXME("(%p)->(%d %d %p)\n", This, indexFrom, indexTo, row);
863 return E_NOTIMPL;
867 static const IHTMLTable2Vtbl HTMLTable2Vtbl = {
868 HTMLTable2_QueryInterface,
869 HTMLTable2_AddRef,
870 HTMLTable2_Release,
871 HTMLTable2_GetTypeInfoCount,
872 HTMLTable2_GetTypeInfo,
873 HTMLTable2_GetIDsOfNames,
874 HTMLTable2_Invoke,
875 HTMLTable2_firstPage,
876 HTMLTable2_lastPage,
877 HTMLTable2_cells,
878 HTMLTable2_moveRow
881 /* IHTMLTable3 */
882 static HRESULT WINAPI HTMLTable3_QueryInterface(IHTMLTable3 *iface,
883 REFIID riid, void **ppv)
885 HTMLTable *This = impl_from_IHTMLTable3(iface);
887 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
890 static ULONG WINAPI HTMLTable3_AddRef(IHTMLTable3 *iface)
892 HTMLTable *This = impl_from_IHTMLTable3(iface);
894 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
897 static ULONG WINAPI HTMLTable3_Release(IHTMLTable3 *iface)
899 HTMLTable *This = impl_from_IHTMLTable3(iface);
901 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
904 static HRESULT WINAPI HTMLTable3_GetTypeInfoCount(IHTMLTable3 *iface, UINT *pctinfo)
906 HTMLTable *This = impl_from_IHTMLTable3(iface);
907 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
910 static HRESULT WINAPI HTMLTable3_GetTypeInfo(IHTMLTable3 *iface, UINT iTInfo,
911 LCID lcid, ITypeInfo **ppTInfo)
913 HTMLTable *This = impl_from_IHTMLTable3(iface);
914 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
915 ppTInfo);
918 static HRESULT WINAPI HTMLTable3_GetIDsOfNames(IHTMLTable3 *iface, REFIID riid,
919 LPOLESTR *rgszNames, UINT cNames,
920 LCID lcid, DISPID *rgDispId)
922 HTMLTable *This = impl_from_IHTMLTable3(iface);
923 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
924 cNames, lcid, rgDispId);
927 static HRESULT WINAPI HTMLTable3_Invoke(IHTMLTable3 *iface, DISPID dispIdMember,
928 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
929 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
931 HTMLTable *This = impl_from_IHTMLTable3(iface);
932 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
933 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
936 static HRESULT WINAPI HTMLTable3_put_summary(IHTMLTable3 *iface, BSTR v)
938 HTMLTable *This = impl_from_IHTMLTable3(iface);
939 nsAString str;
940 nsresult nsres;
942 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
944 nsAString_InitDepend(&str, v);
946 nsres = nsIDOMHTMLTableElement_SetSummary(This->nstable, &str);
948 nsAString_Finish(&str);
949 if (NS_FAILED(nsres)) {
950 ERR("Set summary(%s) failed: %08x\n", debugstr_w(v), nsres);
951 return E_FAIL;
953 return S_OK;
956 static HRESULT WINAPI HTMLTable3_get_summary(IHTMLTable3 *iface, BSTR * p)
958 HTMLTable *This = impl_from_IHTMLTable3(iface);
959 nsAString str;
960 nsresult nsres;
962 TRACE("(%p)->(%p)\n", This, p);
964 nsAString_Init(&str, NULL);
965 nsres = nsIDOMHTMLTableElement_GetSummary(This->nstable, &str);
967 return return_nsstr(nsres, &str, p);
970 static const IHTMLTable3Vtbl HTMLTable3Vtbl = {
971 HTMLTable3_QueryInterface,
972 HTMLTable3_AddRef,
973 HTMLTable3_Release,
974 HTMLTable3_GetTypeInfoCount,
975 HTMLTable3_GetTypeInfo,
976 HTMLTable3_GetIDsOfNames,
977 HTMLTable3_Invoke,
978 HTMLTable3_put_summary,
979 HTMLTable3_get_summary
982 static inline HTMLTable *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
984 return CONTAINING_RECORD(iface, HTMLTable, element.node);
987 static HRESULT HTMLTable_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
989 HTMLTable *This = impl_from_HTMLDOMNode(iface);
991 *ppv = NULL;
993 if(IsEqualGUID(&IID_IUnknown, riid)) {
994 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
995 *ppv = &This->IHTMLTable_iface;
996 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
997 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
998 *ppv = &This->IHTMLTable_iface;
999 }else if(IsEqualGUID(&IID_IHTMLTable, riid)) {
1000 TRACE("(%p)->(IID_IHTMLTable %p)\n", This, ppv);
1001 *ppv = &This->IHTMLTable_iface;
1002 }else if(IsEqualGUID(&IID_IHTMLTable2, riid)) {
1003 TRACE("(%p)->(IID_IHTMLTable2 %p)\n", This, ppv);
1004 *ppv = &This->IHTMLTable2_iface;
1005 }else if(IsEqualGUID(&IID_IHTMLTable3, riid)) {
1006 TRACE("(%p)->(IID_IHTMLTable3 %p)\n", This, ppv);
1007 *ppv = &This->IHTMLTable3_iface;
1010 if(*ppv) {
1011 IUnknown_AddRef((IUnknown*)*ppv);
1012 return S_OK;
1015 return HTMLElement_QI(&This->element.node, riid, ppv);
1018 static void HTMLTable_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1020 HTMLTable *This = impl_from_HTMLDOMNode(iface);
1022 if(This->nstable)
1023 note_cc_edge((nsISupports*)This->nstable, "This->nstable", cb);
1026 static void HTMLTable_unlink(HTMLDOMNode *iface)
1028 HTMLTable *This = impl_from_HTMLDOMNode(iface);
1030 if(This->nstable) {
1031 nsIDOMHTMLTableElement *nstable = This->nstable;
1033 This->nstable = NULL;
1034 nsIDOMHTMLTableElement_Release(nstable);
1038 static const cpc_entry_t HTMLTable_cpc[] = {
1039 {&DIID_HTMLTableEvents},
1040 HTMLELEMENT_CPC,
1041 {NULL}
1044 static const NodeImplVtbl HTMLTableImplVtbl = {
1045 HTMLTable_QI,
1046 HTMLElement_destructor,
1047 HTMLTable_cpc,
1048 HTMLElement_clone,
1049 HTMLElement_handle_event,
1050 HTMLElement_get_attr_col,
1051 NULL,
1052 NULL,
1053 NULL,
1054 NULL,
1055 NULL,
1056 NULL,
1057 NULL,
1058 NULL,
1059 NULL,
1060 HTMLTable_traverse,
1061 HTMLTable_unlink
1064 static const tid_t HTMLTable_iface_tids[] = {
1065 HTMLELEMENT_TIDS,
1066 IHTMLTable_tid,
1067 IHTMLTable2_tid,
1068 IHTMLTable3_tid,
1072 static dispex_static_data_t HTMLTable_dispex = {
1073 NULL,
1074 DispHTMLTable_tid,
1075 NULL,
1076 HTMLTable_iface_tids
1079 HRESULT HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
1081 HTMLTable *ret;
1082 nsresult nsres;
1084 ret = heap_alloc_zero(sizeof(HTMLTable));
1085 if(!ret)
1086 return E_OUTOFMEMORY;
1088 ret->element.node.vtbl = &HTMLTableImplVtbl;
1089 ret->IHTMLTable_iface.lpVtbl = &HTMLTableVtbl;
1090 ret->IHTMLTable2_iface.lpVtbl = &HTMLTable2Vtbl;
1091 ret->IHTMLTable3_iface.lpVtbl = &HTMLTable3Vtbl;
1093 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTable_dispex);
1095 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableElement, (void**)&ret->nstable);
1096 assert(nsres == NS_OK);
1098 *elem = &ret->element;
1099 return S_OK;