2 * Copyright 2008 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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 IHTMLTableRow IHTMLTableRow_iface
;
40 nsIDOMHTMLTableRowElement
*nsrow
;
43 static inline HTMLTableRow
*impl_from_IHTMLTableRow(IHTMLTableRow
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLTableRow
, IHTMLTableRow_iface
);
48 static HRESULT WINAPI
HTMLTableRow_QueryInterface(IHTMLTableRow
*iface
,
49 REFIID riid
, void **ppv
)
51 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLTableRow_AddRef(IHTMLTableRow
*iface
)
58 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLTableRow_Release(IHTMLTableRow
*iface
)
65 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLTableRow_GetTypeInfoCount(IHTMLTableRow
*iface
, UINT
*pctinfo
)
72 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLTableRow_GetTypeInfo(IHTMLTableRow
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLTableRow_GetIDsOfNames(IHTMLTableRow
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
,
86 LCID lcid
, DISPID
*rgDispId
)
88 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
90 cNames
, lcid
, rgDispId
);
93 static HRESULT WINAPI
HTMLTableRow_Invoke(IHTMLTableRow
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
98 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
99 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLTableRow_put_align(IHTMLTableRow
*iface
, BSTR v
)
104 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
108 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
110 nsAString_InitDepend(&val
, v
);
112 nsres
= nsIDOMHTMLTableRowElement_SetAlign(This
->nsrow
, &val
);
113 nsAString_Finish(&val
);
114 if (NS_FAILED(nsres
)){
115 ERR("Set Align(%s) failed!\n", debugstr_w(v
));
121 static HRESULT WINAPI
HTMLTableRow_get_align(IHTMLTableRow
*iface
, BSTR
*p
)
123 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
127 TRACE("(%p)->(%p)\n", This
, p
);
129 nsAString_Init(&val
, NULL
);
130 nsres
= nsIDOMHTMLTableRowElement_GetAlign(This
->nsrow
, &val
);
132 return return_nsstr(nsres
, &val
, p
);
135 static HRESULT WINAPI
HTMLTableRow_put_vAlign(IHTMLTableRow
*iface
, BSTR v
)
137 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
141 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
143 nsAString_InitDepend(&val
, v
);
145 nsres
= nsIDOMHTMLTableRowElement_SetVAlign(This
->nsrow
, &val
);
146 nsAString_Finish(&val
);
148 if (NS_FAILED(nsres
)){
149 ERR("Set VAlign(%s) failed!\n", debugstr_w(v
));
156 static HRESULT WINAPI
HTMLTableRow_get_vAlign(IHTMLTableRow
*iface
, BSTR
*p
)
158 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
162 TRACE("(%p)->(%p)\n", This
, p
);
164 nsAString_Init(&val
, NULL
);
165 nsres
= nsIDOMHTMLTableRowElement_GetVAlign(This
->nsrow
, &val
);
167 return return_nsstr(nsres
, &val
, p
);
170 static HRESULT WINAPI
HTMLTableRow_put_bgColor(IHTMLTableRow
*iface
, VARIANT v
)
172 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
176 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
178 if (!variant_to_nscolor(&v
, &val
))
181 nsres
= nsIDOMHTMLTableRowElement_SetBgColor(This
->nsrow
, &val
);
182 nsAString_Finish(&val
);
184 if (NS_FAILED(nsres
)){
185 ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v
));
192 static HRESULT WINAPI
HTMLTableRow_get_bgColor(IHTMLTableRow
*iface
, VARIANT
*p
)
194 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
198 const PRUnichar
*color
;
200 TRACE("(%p)->(%p)\n", This
, p
);
202 nsAString_Init(&strColor
, NULL
);
203 nsres
= nsIDOMHTMLTableRowElement_GetBgColor(This
->nsrow
, &strColor
);
205 if(NS_SUCCEEDED(nsres
)) {
206 nsAString_GetData(&strColor
, &color
);
208 hres
= nscolor_to_str(color
, &V_BSTR(p
));
210 ERR("SetBgColor failed: %08x\n", nsres
);
214 nsAString_Finish(&strColor
);
218 static HRESULT WINAPI
HTMLTableRow_put_borderColor(IHTMLTableRow
*iface
, VARIANT v
)
220 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
221 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
225 static HRESULT WINAPI
HTMLTableRow_get_borderColor(IHTMLTableRow
*iface
, VARIANT
*p
)
227 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
228 FIXME("(%p)->(%p)\n", This
, p
);
232 static HRESULT WINAPI
HTMLTableRow_put_borderColorLight(IHTMLTableRow
*iface
, VARIANT v
)
234 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
235 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
239 static HRESULT WINAPI
HTMLTableRow_get_borderColorLight(IHTMLTableRow
*iface
, VARIANT
*p
)
241 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
242 FIXME("(%p)->(%p)\n", This
, p
);
246 static HRESULT WINAPI
HTMLTableRow_put_borderColorDark(IHTMLTableRow
*iface
, VARIANT v
)
248 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
249 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
253 static HRESULT WINAPI
HTMLTableRow_get_borderColorDark(IHTMLTableRow
*iface
, VARIANT
*p
)
255 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
256 FIXME("(%p)->(%p)\n", This
, p
);
260 static HRESULT WINAPI
HTMLTableRow_get_rowIndex(IHTMLTableRow
*iface
, LONG
*p
)
262 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
265 TRACE("(%p)->(%p)\n", This
, p
);
266 nsres
= nsIDOMHTMLTableRowElement_GetRowIndex(This
->nsrow
, p
);
267 if(NS_FAILED(nsres
)) {
268 ERR("Get rowIndex failed: %08x\n", nsres
);
274 static HRESULT WINAPI
HTMLTableRow_get_sectionRowIndex(IHTMLTableRow
*iface
, LONG
*p
)
276 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
279 TRACE("(%p)->(%p)\n", This
, p
);
280 nsres
= nsIDOMHTMLTableRowElement_GetSectionRowIndex(This
->nsrow
, p
);
281 if(NS_FAILED(nsres
)) {
282 ERR("Get selectionRowIndex failed: %08x\n", nsres
);
288 static HRESULT WINAPI
HTMLTableRow_get_cells(IHTMLTableRow
*iface
, IHTMLElementCollection
**p
)
290 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
291 nsIDOMHTMLCollection
*nscol
;
294 TRACE("(%p)->(%p)\n", This
, p
);
296 nsres
= nsIDOMHTMLTableRowElement_GetCells(This
->nsrow
, &nscol
);
297 if(NS_FAILED(nsres
)) {
298 ERR("GetCells failed: %08x\n", nsres
);
302 *p
= create_collection_from_htmlcol(This
->element
.node
.doc
, nscol
);
304 nsIDOMHTMLCollection_Release(nscol
);
308 static HRESULT WINAPI
HTMLTableRow_insertCell(IHTMLTableRow
*iface
, LONG index
, IDispatch
**row
)
310 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
311 nsIDOMHTMLElement
*nselem
;
316 TRACE("(%p)->(%d %p)\n", This
, index
, row
);
317 nsres
= nsIDOMHTMLTableRowElement_InsertCell(This
->nsrow
, index
, &nselem
);
318 if(NS_FAILED(nsres
)) {
319 ERR("Insert Cell at %d failed: %08x\n", index
, nsres
);
323 hres
= HTMLTableCell_Create(This
->element
.node
.doc
, nselem
, &elem
);
324 nsIDOMHTMLElement_Release(nselem
);
326 ERR("Create TableCell failed: %08x\n", hres
);
330 *row
= (IDispatch
*)&elem
->IHTMLElement_iface
;
334 static HRESULT WINAPI
HTMLTableRow_deleteCell(IHTMLTableRow
*iface
, LONG index
)
336 HTMLTableRow
*This
= impl_from_IHTMLTableRow(iface
);
339 TRACE("(%p)->(%d)\n", This
, index
);
340 nsres
= nsIDOMHTMLTableRowElement_DeleteCell(This
->nsrow
, index
);
341 if(NS_FAILED(nsres
)) {
342 ERR("Delete Cell failed: %08x\n", nsres
);
348 static const IHTMLTableRowVtbl HTMLTableRowVtbl
= {
349 HTMLTableRow_QueryInterface
,
351 HTMLTableRow_Release
,
352 HTMLTableRow_GetTypeInfoCount
,
353 HTMLTableRow_GetTypeInfo
,
354 HTMLTableRow_GetIDsOfNames
,
356 HTMLTableRow_put_align
,
357 HTMLTableRow_get_align
,
358 HTMLTableRow_put_vAlign
,
359 HTMLTableRow_get_vAlign
,
360 HTMLTableRow_put_bgColor
,
361 HTMLTableRow_get_bgColor
,
362 HTMLTableRow_put_borderColor
,
363 HTMLTableRow_get_borderColor
,
364 HTMLTableRow_put_borderColorLight
,
365 HTMLTableRow_get_borderColorLight
,
366 HTMLTableRow_put_borderColorDark
,
367 HTMLTableRow_get_borderColorDark
,
368 HTMLTableRow_get_rowIndex
,
369 HTMLTableRow_get_sectionRowIndex
,
370 HTMLTableRow_get_cells
,
371 HTMLTableRow_insertCell
,
372 HTMLTableRow_deleteCell
375 static inline HTMLTableRow
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
377 return CONTAINING_RECORD(iface
, HTMLTableRow
, element
.node
);
380 static HRESULT
HTMLTableRow_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
382 HTMLTableRow
*This
= impl_from_HTMLDOMNode(iface
);
386 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
387 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
388 *ppv
= &This
->IHTMLTableRow_iface
;
389 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
390 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
391 *ppv
= &This
->IHTMLTableRow_iface
;
392 }else if(IsEqualGUID(&IID_IHTMLTableRow
, riid
)) {
393 TRACE("(%p)->(IID_IHTMLTableRow %p)\n", This
, ppv
);
394 *ppv
= &This
->IHTMLTableRow_iface
;
398 IUnknown_AddRef((IUnknown
*)*ppv
);
402 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
405 static void HTMLTableRow_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
407 HTMLTableRow
*This
= impl_from_HTMLDOMNode(iface
);
410 note_cc_edge((nsISupports
*)This
->nsrow
, "This->nstablerow", cb
);
413 static void HTMLTableRow_unlink(HTMLDOMNode
*iface
)
415 HTMLTableRow
*This
= impl_from_HTMLDOMNode(iface
);
418 nsIDOMHTMLTableRowElement
*nsrow
= This
->nsrow
;
421 nsIDOMHTMLTableRowElement_Release(nsrow
);
425 static const NodeImplVtbl HTMLTableRowImplVtbl
= {
428 HTMLElement_destructor
,
431 HTMLElement_handle_event
,
432 HTMLElement_get_attr_col
,
441 HTMLTableRow_traverse
,
445 static const tid_t HTMLTableRow_iface_tids
[] = {
451 static dispex_static_data_t HTMLTableRow_dispex
= {
453 DispHTMLTableRow_tid
,
454 HTMLTableRow_iface_tids
,
455 HTMLElement_init_dispex_info
458 HRESULT
HTMLTableRow_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
463 ret
= heap_alloc_zero(sizeof(HTMLTableRow
));
465 return E_OUTOFMEMORY
;
467 ret
->IHTMLTableRow_iface
.lpVtbl
= &HTMLTableRowVtbl
;
468 ret
->element
.node
.vtbl
= &HTMLTableRowImplVtbl
;
470 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTableRow_dispex
);
472 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTableRowElement
, (void**)&ret
->nsrow
);
473 assert(nsres
== NS_OK
);
475 *elem
= &ret
->element
;