msi: Split process_handle() into two separate functions.
[wine/hacks.git] / dlls / mshtml / txtrange.c
blobeb83fd07ed1b4b4ad3e99b9d0260e95b729ac4b6
1 /*
2 * Copyright 2006 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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 typedef struct {
40 const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl;
42 LONG ref;
44 nsISelection *nsselection;
45 } HTMLTxtRange;
47 #define HTMLTXTRANGE(x) ((IHTMLTxtRange*) &(x)->lpHTMLTxtRangeVtbl)
49 #define HTMLTXTRANGE_THIS(iface) DEFINE_THIS(HTMLTxtRange, HTMLTxtRange, iface)
51 static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID riid, void **ppv)
53 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
55 *ppv = NULL;
57 if(IsEqualGUID(&IID_IUnknown, riid)) {
58 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
59 *ppv = HTMLTXTRANGE(This);
60 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
61 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
62 *ppv = HTMLTXTRANGE(This);
63 }else if(IsEqualGUID(&IID_IHTMLTxtRange, riid)) {
64 TRACE("(%p)->(IID_IHTMLTxtRange %p)\n", This, ppv);
65 *ppv = HTMLTXTRANGE(This);
68 if(*ppv) {
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
73 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
74 return E_NOINTERFACE;
77 static ULONG WINAPI HTMLTxtRange_AddRef(IHTMLTxtRange *iface)
79 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
80 LONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
84 return ref;
87 static ULONG WINAPI HTMLTxtRange_Release(IHTMLTxtRange *iface)
89 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
90 LONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p) ref=%d\n", This, ref);
94 if(!ref) {
95 if(This->nsselection)
96 nsISelection_Release(This->nsselection);
97 mshtml_free(This);
100 return ref;
103 static HRESULT WINAPI HTMLTxtRange_GetTypeInfoCount(IHTMLTxtRange *iface, UINT *pctinfo)
105 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
106 FIXME("(%p)->(%p)\n", This, pctinfo);
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLTxtRange_GetTypeInfo(IHTMLTxtRange *iface, UINT iTInfo,
111 LCID lcid, ITypeInfo **ppTInfo)
113 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
114 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
115 return E_NOTIMPL;
118 static HRESULT WINAPI HTMLTxtRange_GetIDsOfNames(IHTMLTxtRange *iface, REFIID riid,
119 LPOLESTR *rgszNames, UINT cNames,
120 LCID lcid, DISPID *rgDispId)
122 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
123 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
124 lcid, rgDispId);
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLTxtRange_Invoke(IHTMLTxtRange *iface, DISPID dispIdMember,
129 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
130 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
132 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
133 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
134 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLTxtRange_get_htmlText(IHTMLTxtRange *iface, BSTR *p)
140 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
141 FIXME("(%p)->(%p)\n", This, p);
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLTxtRange_put_text(IHTMLTxtRange *iface, BSTR v)
147 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
148 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
149 return E_NOTIMPL;
152 static HRESULT WINAPI HTMLTxtRange_get_text(IHTMLTxtRange *iface, BSTR *p)
154 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
155 PRUnichar *nstext = NULL;
156 nsresult nsres;
158 TRACE("(%p)->(%p)\n", This, p);
160 if(!This->nsselection) {
161 static const WCHAR empty[] = {0};
162 *p = SysAllocString(empty);
163 return S_OK;
166 nsres = nsISelection_ToString(This->nsselection, &nstext);
167 if(NS_FAILED(nsres) || !nstext) {
168 ERR("toString failed: %08x\n", nsres);
169 return E_FAIL;
172 *p = SysAllocString(nstext);
173 nsfree(nstext);
174 return S_OK;
177 static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElement **parent)
179 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
180 FIXME("(%p)->(%p)\n", This, parent);
181 return E_NOTIMPL;
184 static HRESULT WINAPI HTMLTxtRange_duplicate(IHTMLTxtRange *iface, IHTMLTxtRange **Duplicate)
186 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
187 FIXME("(%p)->(%p)\n", This, Duplicate);
188 return E_NOTIMPL;
191 static HRESULT WINAPI HTMLTxtRange_inRange(IHTMLTxtRange *iface, IHTMLTxtRange *Range,
192 VARIANT_BOOL *InRange)
194 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
195 FIXME("(%p)->(%p %p)\n", This, Range, InRange);
196 return E_NOTIMPL;
199 static HRESULT WINAPI HTMLTxtRange_isEqual(IHTMLTxtRange *iface, IHTMLTxtRange *Range,
200 VARIANT_BOOL *IsEqual)
202 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
203 FIXME("(%p)->()\n", This);
204 return E_NOTIMPL;
207 static HRESULT WINAPI HTMLTxtRange_scrollIntoView(IHTMLTxtRange *iface, VARIANT_BOOL fStart)
209 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
210 FIXME("(%p)->(%x)\n", This, fStart);
211 return E_NOTIMPL;
214 static HRESULT WINAPI HTMLTxtRange_collapse(IHTMLTxtRange *iface, VARIANT_BOOL Start)
216 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
217 FIXME("(%p)->(%x)\n", This, Start);
218 return E_NOTIMPL;
221 static HRESULT WINAPI HTMLTxtRange_expand(IHTMLTxtRange *iface, BSTR Unit, VARIANT_BOOL *Success)
223 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
224 FIXME("(%p)->(%s %p)\n", This, debugstr_w(Unit), Success);
225 return E_NOTIMPL;
228 static HRESULT WINAPI HTMLTxtRange_move(IHTMLTxtRange *iface, BSTR Unit,
229 long Count, long *ActualCount)
231 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
232 FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLTxtRange_moveStart(IHTMLTxtRange *iface, BSTR Unit,
237 long Count, long *ActualCount)
239 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
240 FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
241 return E_NOTIMPL;
244 static HRESULT WINAPI HTMLTxtRange_moveEnd(IHTMLTxtRange *iface, BSTR Unit,
245 long Count, long *ActualCount)
247 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
248 FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
249 return E_NOTIMPL;
252 static HRESULT WINAPI HTMLTxtRange_select(IHTMLTxtRange *iface)
254 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
255 FIXME("(%p)->()\n", This);
256 return E_NOTIMPL;
259 static HRESULT WINAPI HTMLTxtRange_pasteHTML(IHTMLTxtRange *iface, BSTR html)
261 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
262 FIXME("(%p)->(%s)\n", This, debugstr_w(html));
263 return E_NOTIMPL;
266 static HRESULT WINAPI HTMLTxtRange_moveToElementText(IHTMLTxtRange *iface, IHTMLElement *element)
268 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
269 FIXME("(%p)->(%p)\n", This, element);
270 return E_NOTIMPL;
273 static HRESULT WINAPI HTMLTxtRange_setEndPoint(IHTMLTxtRange *iface, BSTR how,
274 IHTMLTxtRange *SourceRange)
276 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
277 FIXME("(%p)->(%s %p)\n", This, debugstr_w(how), SourceRange);
278 return E_NOTIMPL;
281 static HRESULT WINAPI HTMLTxtRange_compareEndPoints(IHTMLTxtRange *iface, BSTR how,
282 IHTMLTxtRange *SourceRange, long *ret)
284 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
285 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(how), SourceRange, ret);
286 return E_NOTIMPL;
289 static HRESULT WINAPI HTMLTxtRange_findText(IHTMLTxtRange *iface, BSTR String,
290 long count, long Flags, VARIANT_BOOL *Success)
292 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
293 FIXME("(%p)->(%s %ld %08lx %p)\n", This, debugstr_w(String), count, Flags, Success);
294 return E_NOTIMPL;
297 static HRESULT WINAPI HTMLTxtRange_moveToPoint(IHTMLTxtRange *iface, long x, long y)
299 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
300 FIXME("(%p)->(%ld %ld)\n", This, x, y);
301 return E_NOTIMPL;
304 static HRESULT WINAPI HTMLTxtRange_getBookmark(IHTMLTxtRange *iface, BSTR *Bookmark)
306 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
307 FIXME("(%p)->(%p)\n", This, Bookmark);
308 return E_NOTIMPL;
311 static HRESULT WINAPI HTMLTxtRange_moveToBookmark(IHTMLTxtRange *iface, BSTR Bookmark,
312 VARIANT_BOOL *Success)
314 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
315 FIXME("(%p)->(%s %p)\n", This, debugstr_w(Bookmark), Success);
316 return E_NOTIMPL;
319 static HRESULT WINAPI HTMLTxtRange_queryCommandSupported(IHTMLTxtRange *iface, BSTR cmdID,
320 VARIANT_BOOL *pfRet)
322 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
323 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
324 return E_NOTIMPL;
327 static HRESULT WINAPI HTMLTxtRange_queryCommandEnabled(IHTMLTxtRange *iface, BSTR cmdID,
328 VARIANT_BOOL *pfRet)
330 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
331 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
332 return E_NOTIMPL;
335 static HRESULT WINAPI HTMLTxtRange_queryCommandState(IHTMLTxtRange *iface, BSTR cmdID,
336 VARIANT_BOOL *pfRet)
338 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
339 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
340 return E_NOTIMPL;
343 static HRESULT WINAPI HTMLTxtRange_queryCommandIndeterm(IHTMLTxtRange *iface, BSTR cmdID,
344 VARIANT_BOOL *pfRet)
346 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
347 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
348 return E_NOTIMPL;
351 static HRESULT WINAPI HTMLTxtRange_queryCommandText(IHTMLTxtRange *iface, BSTR cmdID,
352 BSTR *pcmdText)
354 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
355 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pcmdText);
356 return E_NOTIMPL;
359 static HRESULT WINAPI HTMLTxtRange_queryCommandValue(IHTMLTxtRange *iface, BSTR cmdID,
360 VARIANT *pcmdValue)
362 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
363 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pcmdValue);
364 return E_NOTIMPL;
367 static HRESULT WINAPI HTMLTxtRange_execCommand(IHTMLTxtRange *iface, BSTR cmdID,
368 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
370 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
371 FIXME("(%p)->(%s %x v %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
372 return E_NOTIMPL;
375 static HRESULT WINAPI HTMLTxtRange_execCommandShowHelp(IHTMLTxtRange *iface, BSTR cmdID,
376 VARIANT_BOOL *pfRet)
378 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
379 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
380 return E_NOTIMPL;
383 #undef HTMLTXTRANGE_THIS
385 static const IHTMLTxtRangeVtbl HTMLTxtRangeVtbl = {
386 HTMLTxtRange_QueryInterface,
387 HTMLTxtRange_AddRef,
388 HTMLTxtRange_Release,
389 HTMLTxtRange_GetTypeInfoCount,
390 HTMLTxtRange_GetTypeInfo,
391 HTMLTxtRange_GetIDsOfNames,
392 HTMLTxtRange_Invoke,
393 HTMLTxtRange_get_htmlText,
394 HTMLTxtRange_put_text,
395 HTMLTxtRange_get_text,
396 HTMLTxtRange_parentElement,
397 HTMLTxtRange_duplicate,
398 HTMLTxtRange_inRange,
399 HTMLTxtRange_isEqual,
400 HTMLTxtRange_scrollIntoView,
401 HTMLTxtRange_collapse,
402 HTMLTxtRange_expand,
403 HTMLTxtRange_move,
404 HTMLTxtRange_moveStart,
405 HTMLTxtRange_moveEnd,
406 HTMLTxtRange_select,
407 HTMLTxtRange_pasteHTML,
408 HTMLTxtRange_moveToElementText,
409 HTMLTxtRange_setEndPoint,
410 HTMLTxtRange_compareEndPoints,
411 HTMLTxtRange_findText,
412 HTMLTxtRange_moveToPoint,
413 HTMLTxtRange_getBookmark,
414 HTMLTxtRange_moveToBookmark,
415 HTMLTxtRange_queryCommandSupported,
416 HTMLTxtRange_queryCommandEnabled,
417 HTMLTxtRange_queryCommandState,
418 HTMLTxtRange_queryCommandIndeterm,
419 HTMLTxtRange_queryCommandText,
420 HTMLTxtRange_queryCommandValue,
421 HTMLTxtRange_execCommand,
422 HTMLTxtRange_execCommandShowHelp
425 IHTMLTxtRange *HTMLTxtRange_Create(nsISelection *nsselection)
427 HTMLTxtRange *ret = mshtml_alloc(sizeof(HTMLTxtRange));
429 ret->lpHTMLTxtRangeVtbl = &HTMLTxtRangeVtbl;
430 ret->ref = 1;
432 if(nsselection)
433 nsISelection_AddRef(nsselection);
434 ret->nsselection = nsselection;
436 return HTMLTXTRANGE(ret);