kernel32: Add proper English messages for all error codes.
[wine.git] / dlls / mshtml / htmlanchor.c
blob90ece1de00fea6f76f01f1c2db1f460755206575
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 <stdio.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 IHTMLAnchorElement IHTMLAnchorElement_iface;
40 nsIDOMHTMLAnchorElement *nsanchor;
41 } HTMLAnchorElement;
43 static inline HTMLAnchorElement *impl_from_IHTMLAnchorElement(IHTMLAnchorElement *iface)
45 return CONTAINING_RECORD(iface, HTMLAnchorElement, IHTMLAnchorElement_iface);
48 static HRESULT WINAPI HTMLAnchorElement_QueryInterface(IHTMLAnchorElement *iface,
49 REFIID riid, void **ppv)
51 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLAnchorElement_AddRef(IHTMLAnchorElement *iface)
58 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLAnchorElement_Release(IHTMLAnchorElement *iface)
65 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLAnchorElement_GetTypeInfoCount(IHTMLAnchorElement *iface, UINT *pctinfo)
72 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLAnchorElement_GetTypeInfo(IHTMLAnchorElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLAnchorElement_GetIDsOfNames(IHTMLAnchorElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLAnchorElement_Invoke(IHTMLAnchorElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
98 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLAnchorElement_put_href(IHTMLAnchorElement *iface, BSTR v)
104 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
105 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
106 return E_NOTIMPL;
109 static HRESULT WINAPI HTMLAnchorElement_get_href(IHTMLAnchorElement *iface, BSTR *p)
111 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
112 nsAString href_str;
113 nsresult nsres;
114 HRESULT hres;
116 TRACE("(%p)->(%p)\n", This, p);
118 nsAString_Init(&href_str, NULL);
119 nsres = nsIDOMHTMLAnchorElement_GetHref(This->nsanchor, &href_str);
120 if(NS_SUCCEEDED(nsres)) {
121 const PRUnichar *href;
123 nsAString_GetData(&href_str, &href);
124 hres = nsuri_to_url(href, TRUE, p);
125 }else {
126 ERR("GetHref failed: %08x\n", nsres);
127 hres = E_FAIL;
130 nsAString_Finish(&href_str);
131 return hres;
134 static HRESULT WINAPI HTMLAnchorElement_put_target(IHTMLAnchorElement *iface, BSTR v)
136 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
137 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
138 return E_NOTIMPL;
141 static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p)
143 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
144 FIXME("(%p)->(%p)\n", This, p);
145 return E_NOTIMPL;
148 static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v)
150 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
151 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152 return E_NOTIMPL;
155 static HRESULT WINAPI HTMLAnchorElement_get_rel(IHTMLAnchorElement *iface, BSTR *p)
157 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
158 FIXME("(%p)->(%p)\n", This, p);
159 return E_NOTIMPL;
162 static HRESULT WINAPI HTMLAnchorElement_put_rev(IHTMLAnchorElement *iface, BSTR v)
164 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
165 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLAnchorElement_get_rev(IHTMLAnchorElement *iface, BSTR *p)
171 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
172 FIXME("(%p)->(%p)\n", This, p);
173 return E_NOTIMPL;
176 static HRESULT WINAPI HTMLAnchorElement_put_urn(IHTMLAnchorElement *iface, BSTR v)
178 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
179 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
180 return E_NOTIMPL;
183 static HRESULT WINAPI HTMLAnchorElement_get_urn(IHTMLAnchorElement *iface, BSTR *p)
185 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
186 FIXME("(%p)->(%p)\n", This, p);
187 return E_NOTIMPL;
190 static HRESULT WINAPI HTMLAnchorElement_put_Methods(IHTMLAnchorElement *iface, BSTR v)
192 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
193 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
194 return E_NOTIMPL;
197 static HRESULT WINAPI HTMLAnchorElement_get_Methods(IHTMLAnchorElement *iface, BSTR *p)
199 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
200 FIXME("(%p)->(%p)\n", This, p);
201 return E_NOTIMPL;
204 static HRESULT WINAPI HTMLAnchorElement_put_name(IHTMLAnchorElement *iface, BSTR v)
206 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
207 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
208 return E_NOTIMPL;
211 static HRESULT WINAPI HTMLAnchorElement_get_name(IHTMLAnchorElement *iface, BSTR *p)
213 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
214 FIXME("(%p)->(%p)\n", This, p);
215 return E_NOTIMPL;
218 static HRESULT WINAPI HTMLAnchorElement_put_host(IHTMLAnchorElement *iface, BSTR v)
220 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
221 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
222 return E_NOTIMPL;
225 static HRESULT WINAPI HTMLAnchorElement_get_host(IHTMLAnchorElement *iface, BSTR *p)
227 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
228 FIXME("(%p)->(%p)\n", This, p);
229 return E_NOTIMPL;
232 static HRESULT WINAPI HTMLAnchorElement_put_hostname(IHTMLAnchorElement *iface, BSTR v)
234 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
235 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
236 return E_NOTIMPL;
239 static HRESULT WINAPI HTMLAnchorElement_get_hostname(IHTMLAnchorElement *iface, BSTR *p)
241 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
242 FIXME("(%p)->(%p)\n", This, p);
243 return E_NOTIMPL;
246 static HRESULT WINAPI HTMLAnchorElement_put_pathname(IHTMLAnchorElement *iface, BSTR v)
248 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
249 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
250 return E_NOTIMPL;
253 static HRESULT WINAPI HTMLAnchorElement_get_pathname(IHTMLAnchorElement *iface, BSTR *p)
255 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
256 FIXME("(%p)->(%p)\n", This, p);
257 return E_NOTIMPL;
260 static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v)
262 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
263 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
264 return E_NOTIMPL;
267 static HRESULT WINAPI HTMLAnchorElement_get_port(IHTMLAnchorElement *iface, BSTR *p)
269 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
270 FIXME("(%p)->(%p)\n", This, p);
271 return E_NOTIMPL;
274 static HRESULT WINAPI HTMLAnchorElement_put_protocol(IHTMLAnchorElement *iface, BSTR v)
276 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
277 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
278 return E_NOTIMPL;
281 static HRESULT WINAPI HTMLAnchorElement_get_protocol(IHTMLAnchorElement *iface, BSTR *p)
283 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
284 FIXME("(%p)->(%p)\n", This, p);
285 return E_NOTIMPL;
288 static HRESULT WINAPI HTMLAnchorElement_put_search(IHTMLAnchorElement *iface, BSTR v)
290 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
291 FIXME("(%p)->(%p)\n", This, debugstr_w(v));
292 return E_NOTIMPL;
295 static HRESULT WINAPI HTMLAnchorElement_get_search(IHTMLAnchorElement *iface, BSTR *p)
297 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
298 FIXME("(%p)->(%p)\n", This, p);
299 return E_NOTIMPL;
302 static HRESULT WINAPI HTMLAnchorElement_put_hash(IHTMLAnchorElement *iface, BSTR v)
304 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
305 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
306 return E_NOTIMPL;
309 static HRESULT WINAPI HTMLAnchorElement_get_hash(IHTMLAnchorElement *iface, BSTR *p)
311 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
312 FIXME("(%p)->(%p)\n", This, p);
313 return E_NOTIMPL;
316 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
318 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
320 TRACE("(%p)->()\n", This);
322 return IHTMLElement2_put_onblur(&This->element.IHTMLElement2_iface, v);
325 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
327 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
329 TRACE("(%p)->(%p)\n", This, p);
331 return IHTMLElement2_get_onblur(&This->element.IHTMLElement2_iface, p);
334 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
336 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
338 TRACE("(%p)->()\n", This);
340 return IHTMLElement2_put_onfocus(&This->element.IHTMLElement2_iface, v);
343 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
345 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
347 TRACE("(%p)->(%p)\n", This, p);
349 return IHTMLElement2_get_onfocus(&This->element.IHTMLElement2_iface, p);
352 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
354 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
356 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
358 return IHTMLElement2_put_accessKey(&This->element.IHTMLElement2_iface, v);
361 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
363 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
365 TRACE("(%p)->(%p)\n", This, p);
367 return IHTMLElement2_get_accessKey(&This->element.IHTMLElement2_iface, p);
370 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
372 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
373 FIXME("(%p)->(%p)\n", This, p);
374 return E_NOTIMPL;
377 static HRESULT WINAPI HTMLAnchorElement_get_mimeType(IHTMLAnchorElement *iface, BSTR *p)
379 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
380 FIXME("(%p)->(%p)\n", This, p);
381 return E_NOTIMPL;
384 static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface, BSTR *p)
386 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
387 FIXME("(%p)->(%p)\n", This, p);
388 return E_NOTIMPL;
391 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
393 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
395 TRACE("(%p)->()\n", This);
397 return IHTMLElement2_put_tabIndex(&This->element.IHTMLElement2_iface, v);
400 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
402 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
404 TRACE("(%p)->(%p)\n", This, p);
406 return IHTMLElement2_get_tabIndex(&This->element.IHTMLElement2_iface, p);
409 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
411 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
413 TRACE("(%p)\n", This);
415 return IHTMLElement2_focus(&This->element.IHTMLElement2_iface);
418 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
420 HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
422 TRACE("(%p)\n", This);
424 return IHTMLElement2_blur(&This->element.IHTMLElement2_iface);
427 static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
428 HTMLAnchorElement_QueryInterface,
429 HTMLAnchorElement_AddRef,
430 HTMLAnchorElement_Release,
431 HTMLAnchorElement_GetTypeInfoCount,
432 HTMLAnchorElement_GetTypeInfo,
433 HTMLAnchorElement_GetIDsOfNames,
434 HTMLAnchorElement_Invoke,
435 HTMLAnchorElement_put_href,
436 HTMLAnchorElement_get_href,
437 HTMLAnchorElement_put_target,
438 HTMLAnchorElement_get_target,
439 HTMLAnchorElement_put_rel,
440 HTMLAnchorElement_get_rel,
441 HTMLAnchorElement_put_rev,
442 HTMLAnchorElement_get_rev,
443 HTMLAnchorElement_put_urn,
444 HTMLAnchorElement_get_urn,
445 HTMLAnchorElement_put_Methods,
446 HTMLAnchorElement_get_Methods,
447 HTMLAnchorElement_put_name,
448 HTMLAnchorElement_get_name,
449 HTMLAnchorElement_put_host,
450 HTMLAnchorElement_get_host,
451 HTMLAnchorElement_put_hostname,
452 HTMLAnchorElement_get_hostname,
453 HTMLAnchorElement_put_pathname,
454 HTMLAnchorElement_get_pathname,
455 HTMLAnchorElement_put_port,
456 HTMLAnchorElement_get_port,
457 HTMLAnchorElement_put_protocol,
458 HTMLAnchorElement_get_protocol,
459 HTMLAnchorElement_put_search,
460 HTMLAnchorElement_get_search,
461 HTMLAnchorElement_put_hash,
462 HTMLAnchorElement_get_hash,
463 HTMLAnchorElement_put_onblur,
464 HTMLAnchorElement_get_onblur,
465 HTMLAnchorElement_put_onfocus,
466 HTMLAnchorElement_get_onfocus,
467 HTMLAnchorElement_put_accessKey,
468 HTMLAnchorElement_get_accessKey,
469 HTMLAnchorElement_get_protocolLong,
470 HTMLAnchorElement_get_mimeType,
471 HTMLAnchorElement_get_nameProp,
472 HTMLAnchorElement_put_tabIndex,
473 HTMLAnchorElement_get_tabIndex,
474 HTMLAnchorElement_focus,
475 HTMLAnchorElement_blur
478 static inline HTMLAnchorElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
480 return CONTAINING_RECORD(iface, HTMLAnchorElement, element.node);
483 static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
485 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
487 *ppv = NULL;
489 if(IsEqualGUID(&IID_IUnknown, riid)) {
490 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
491 *ppv = &This->IHTMLAnchorElement_iface;
492 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
493 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
494 *ppv = &This->IHTMLAnchorElement_iface;
495 }else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
496 TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
497 *ppv = &This->IHTMLAnchorElement_iface;
500 if(*ppv) {
501 IUnknown_AddRef((IUnknown*)*ppv);
502 return S_OK;
505 return HTMLElement_QI(&This->element.node, riid, ppv);
508 static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
510 HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface);
512 if(This->nsanchor)
513 nsIDOMHTMLAnchorElement_Release(This->nsanchor);
515 HTMLElement_destructor(&This->element.node);
518 static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
519 HTMLAnchorElement_QI,
520 HTMLAnchorElement_destructor,
521 HTMLElement_clone
524 static const tid_t HTMLAnchorElement_iface_tids[] = {
525 IHTMLAnchorElement_tid,
526 HTMLELEMENT_TIDS,
527 IHTMLTextContainer_tid,
528 IHTMLUniqueName_tid,
532 static dispex_static_data_t HTMLAnchorElement_dispex = {
533 NULL,
534 DispHTMLAnchorElement_tid,
535 NULL,
536 HTMLAnchorElement_iface_tids
539 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
541 HTMLAnchorElement *ret;
542 nsresult nsres;
544 ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
545 if(!ret)
546 return E_OUTOFMEMORY;
548 ret->IHTMLAnchorElement_iface.lpVtbl = &HTMLAnchorElementVtbl;
549 ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
551 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLAnchorElement, (void**)&ret->nsanchor);
552 if(NS_FAILED(nsres)) {
553 ERR("Could not get nsIDOMHTMLAnchorElement iface: %08x\n", nsres);
554 heap_free(ret);
555 return E_FAIL;
558 HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
560 *elem = &ret->element;
561 return S_OK;