msvcrt: ungetc must create a buffer, even if _IONBF has been set with setvbuf.
[wine/multimedia.git] / dlls / mshtml / htmltextnode.c
blob58422de780f52c42f5027ffc7bb684bd035982d3
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
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "mshtml_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct HTMLDOMTextNode {
36 HTMLDOMNode node;
37 IHTMLDOMTextNode IHTMLDOMTextNode_iface;
39 nsIDOMText *nstext;
42 static inline HTMLDOMTextNode *impl_from_IHTMLDOMTextNode(IHTMLDOMTextNode *iface)
44 return CONTAINING_RECORD(iface, HTMLDOMTextNode, IHTMLDOMTextNode_iface);
47 static HRESULT WINAPI HTMLDOMTextNode_QueryInterface(IHTMLDOMTextNode *iface,
48 REFIID riid, void **ppv)
50 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
52 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
55 static ULONG WINAPI HTMLDOMTextNode_AddRef(IHTMLDOMTextNode *iface)
57 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
59 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
62 static ULONG WINAPI HTMLDOMTextNode_Release(IHTMLDOMTextNode *iface)
64 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
66 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
69 static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfoCount(IHTMLDOMTextNode *iface, UINT *pctinfo)
71 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
75 static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfo(IHTMLDOMTextNode *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
79 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
82 static HRESULT WINAPI HTMLDOMTextNode_GetIDsOfNames(IHTMLDOMTextNode *iface, REFIID riid,
83 LPOLESTR *rgszNames, UINT cNames,
84 LCID lcid, DISPID *rgDispId)
86 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
87 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
88 lcid, rgDispId);
91 static HRESULT WINAPI HTMLDOMTextNode_Invoke(IHTMLDOMTextNode *iface, DISPID dispIdMember,
92 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
93 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
95 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
96 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
97 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 static HRESULT WINAPI HTMLDOMTextNode_put_data(IHTMLDOMTextNode *iface, BSTR v)
102 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
103 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
104 return E_NOTIMPL;
107 static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p)
109 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
110 FIXME("(%p)->(%p)\n", This, p);
111 return E_NOTIMPL;
114 static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String)
116 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
117 FIXME("(%p)->(%p)\n", This, String);
118 return E_NOTIMPL;
121 static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
123 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
124 PRUint32 length = 0;
125 nsresult nsres;
127 TRACE("(%p)->(%p)\n", This, p);
129 nsres = nsIDOMText_GetLength(This->nstext, &length);
130 if(NS_FAILED(nsres))
131 ERR("GetLength failed: %08x\n", nsres);
133 *p = length;
134 return S_OK;
137 static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
139 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
140 FIXME("(%p)->(%d %p)\n", This, offset, pRetNode);
141 return E_NOTIMPL;
144 static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl = {
145 HTMLDOMTextNode_QueryInterface,
146 HTMLDOMTextNode_AddRef,
147 HTMLDOMTextNode_Release,
148 HTMLDOMTextNode_GetTypeInfoCount,
149 HTMLDOMTextNode_GetTypeInfo,
150 HTMLDOMTextNode_GetIDsOfNames,
151 HTMLDOMTextNode_Invoke,
152 HTMLDOMTextNode_put_data,
153 HTMLDOMTextNode_get_data,
154 HTMLDOMTextNode_toString,
155 HTMLDOMTextNode_get_length,
156 HTMLDOMTextNode_splitText
159 static inline HTMLDOMTextNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
161 return CONTAINING_RECORD(iface, HTMLDOMTextNode, node);
164 static HRESULT HTMLDOMTextNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
166 HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
168 *ppv = NULL;
170 if(IsEqualGUID(&IID_IHTMLDOMTextNode, riid)) {
171 TRACE("(%p)->(IID_IHTMLDOMTextNode %p)\n", This, ppv);
172 *ppv = &This->IHTMLDOMTextNode_iface;
173 }else {
174 return HTMLDOMNode_QI(&This->node, riid, ppv);
177 IUnknown_AddRef((IUnknown*)*ppv);
178 return S_OK;
181 static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface)
183 HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
185 if(This->nstext)
186 IHTMLDOMTextNode_Release(This->nstext);
188 HTMLDOMNode_destructor(&This->node);
191 static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
193 HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
194 HRESULT hres;
196 hres = HTMLDOMTextNode_Create(This->node.doc, nsnode, ret);
197 if(FAILED(hres))
198 return hres;
200 IHTMLDOMNode_AddRef(&(*ret)->IHTMLDOMNode_iface);
201 return S_OK;
204 static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = {
205 HTMLDOMTextNode_QI,
206 HTMLDOMTextNode_destructor,
207 HTMLDOMTextNode_clone
210 static const tid_t HTMLDOMTextNode_iface_tids[] = {
211 IHTMLDOMNode_tid,
212 IHTMLDOMNode2_tid,
213 IHTMLDOMTextNode_tid,
216 static dispex_static_data_t HTMLDOMTextNode_dispex = {
217 NULL,
218 DispHTMLDOMTextNode_tid,
220 HTMLDOMTextNode_iface_tids
223 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **node)
225 HTMLDOMTextNode *ret;
226 nsresult nsres;
228 ret = heap_alloc_zero(sizeof(*ret));
229 if(!ret)
230 return E_OUTOFMEMORY;
232 ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
233 ret->IHTMLDOMTextNode_iface.lpVtbl = &HTMLDOMTextNodeVtbl;
235 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
236 if(NS_FAILED(nsres)) {
237 ERR("Could not get nsIDOMText iface: %08x\n", nsres);
238 heap_free(ret);
239 return E_FAIL;
242 init_dispex(&ret->node.dispex, (IUnknown*)&ret->IHTMLDOMTextNode_iface,
243 &HTMLDOMTextNode_dispex);
244 HTMLDOMNode_Init(doc, &ret->node, nsnode);
246 *node = &ret->node;
247 return S_OK;