loader: Add the CFBundleAllowMixedLocalizations key to the embedded Info.plist to...
[wine/multimedia.git] / dlls / mshtml / htmltablerow.c
blob48ceb9a38bdf7523b6dcc75e18e18c1f38d7374d
1 /*
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
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 IHTMLTableRow IHTMLTableRow_iface;
40 nsIDOMHTMLTableRowElement *nsrow;
41 } HTMLTableRow;
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,
81 ppTInfo);
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);
105 nsAString val;
106 nsresult nsres;
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));
116 return E_FAIL;
118 return S_OK;
121 static HRESULT WINAPI HTMLTableRow_get_align(IHTMLTableRow *iface, BSTR *p)
123 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
124 nsAString val;
125 nsresult nsres;
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);
138 nsAString val;
139 nsresult nsres;
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));
150 return E_FAIL;
153 return S_OK;
156 static HRESULT WINAPI HTMLTableRow_get_vAlign(IHTMLTableRow *iface, BSTR *p)
158 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
159 nsAString val;
160 nsresult nsres;
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);
173 nsAString val;
174 nsresult nsres;
176 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
178 if (!variant_to_nscolor(&v, &val))
179 return S_OK;
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));
186 return E_FAIL;
189 return S_OK;
192 static HRESULT WINAPI HTMLTableRow_get_bgColor(IHTMLTableRow *iface, VARIANT *p)
194 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
195 nsAString strColor;
196 nsresult nsres;
197 HRESULT hres;
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);
207 V_VT(p) = VT_BSTR;
208 hres = nscolor_to_str(color, &V_BSTR(p));
209 }else {
210 ERR("SetBgColor failed: %08x\n", nsres);
211 hres = E_FAIL;
214 nsAString_Finish(&strColor);
215 return hres;
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));
222 return E_NOTIMPL;
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);
229 return E_NOTIMPL;
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));
236 return E_NOTIMPL;
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);
243 return E_NOTIMPL;
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));
250 return E_NOTIMPL;
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);
257 return E_NOTIMPL;
260 static HRESULT WINAPI HTMLTableRow_get_rowIndex(IHTMLTableRow *iface, LONG *p)
262 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
263 nsresult nsres;
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);
269 return E_FAIL;
271 return S_OK;
274 static HRESULT WINAPI HTMLTableRow_get_sectionRowIndex(IHTMLTableRow *iface, LONG *p)
276 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
277 nsresult nsres;
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);
283 return E_FAIL;
285 return S_OK;
288 static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementCollection **p)
290 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
291 nsIDOMHTMLCollection *nscol;
292 nsresult nsres;
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);
299 return E_FAIL;
302 *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
304 nsIDOMHTMLCollection_Release(nscol);
305 return S_OK;
308 static HRESULT WINAPI HTMLTableRow_insertCell(IHTMLTableRow *iface, LONG index, IDispatch **row)
310 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
311 nsIDOMHTMLElement *nselem;
312 HTMLElement *elem;
313 nsresult nsres;
314 HRESULT hres;
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);
320 return E_FAIL;
323 hres = HTMLTableCell_Create(This->element.node.doc, nselem, &elem);
324 nsIDOMHTMLElement_Release(nselem);
325 if (FAILED(hres)) {
326 ERR("Create TableCell failed: %08x\n", hres);
327 return hres;
330 *row = (IDispatch *)&elem->IHTMLElement_iface;
331 return S_OK;
334 static HRESULT WINAPI HTMLTableRow_deleteCell(IHTMLTableRow *iface, LONG index)
336 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
337 nsresult nsres;
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);
343 return E_FAIL;
345 return S_OK;
348 static const IHTMLTableRowVtbl HTMLTableRowVtbl = {
349 HTMLTableRow_QueryInterface,
350 HTMLTableRow_AddRef,
351 HTMLTableRow_Release,
352 HTMLTableRow_GetTypeInfoCount,
353 HTMLTableRow_GetTypeInfo,
354 HTMLTableRow_GetIDsOfNames,
355 HTMLTableRow_Invoke,
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);
384 *ppv = NULL;
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;
397 if(*ppv) {
398 IUnknown_AddRef((IUnknown*)*ppv);
399 return S_OK;
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);
409 if(This->nsrow)
410 note_cc_edge((nsISupports*)This->nsrow, "This->nstablerow", cb);
413 static void HTMLTableRow_unlink(HTMLDOMNode *iface)
415 HTMLTableRow *This = impl_from_HTMLDOMNode(iface);
417 if(This->nsrow) {
418 nsIDOMHTMLTableRowElement *nsrow = This->nsrow;
420 This->nsrow = NULL;
421 nsIDOMHTMLTableRowElement_Release(nsrow);
425 static const NodeImplVtbl HTMLTableRowImplVtbl = {
426 HTMLTableRow_QI,
427 HTMLElement_destructor,
428 HTMLElement_cpc,
429 HTMLElement_clone,
430 HTMLElement_handle_event,
431 HTMLElement_get_attr_col,
432 NULL,
433 NULL,
434 NULL,
435 NULL,
436 NULL,
437 NULL,
438 NULL,
439 NULL,
440 NULL,
441 HTMLTableRow_traverse,
442 HTMLTableRow_unlink
445 static const tid_t HTMLTableRow_iface_tids[] = {
446 HTMLELEMENT_TIDS,
447 IHTMLTableRow_tid,
451 static dispex_static_data_t HTMLTableRow_dispex = {
452 NULL,
453 DispHTMLTableRow_tid,
454 NULL,
455 HTMLTableRow_iface_tids
458 HRESULT HTMLTableRow_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
460 HTMLTableRow *ret;
461 nsresult nsres;
463 ret = heap_alloc_zero(sizeof(HTMLTableRow));
464 if(!ret)
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;
476 return S_OK;