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
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
40 const IHTMLTxtRangeVtbl
*lpHTMLTxtRangeVtbl
;
44 nsISelection
*nsselection
;
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
);
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
);
69 IUnknown_AddRef((IUnknown
*)*ppv
);
73 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
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
);
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
);
96 nsISelection_Release(This
->nsselection
);
103 static HRESULT WINAPI
HTMLTxtRange_GetTypeInfoCount(IHTMLTxtRange
*iface
, UINT
*pctinfo
)
105 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
106 FIXME("(%p)->(%p)\n", This
, pctinfo
);
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
);
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
,
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
);
138 static HRESULT WINAPI
HTMLTxtRange_get_htmlText(IHTMLTxtRange
*iface
, BSTR
*p
)
140 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
141 FIXME("(%p)->(%p)\n", This
, p
);
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
));
152 static HRESULT WINAPI
HTMLTxtRange_get_text(IHTMLTxtRange
*iface
, BSTR
*p
)
154 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
155 PRUnichar
*nstext
= NULL
;
158 TRACE("(%p)->(%p)\n", This
, p
);
160 if(!This
->nsselection
) {
161 static const WCHAR empty
[] = {0};
162 *p
= SysAllocString(empty
);
166 nsres
= nsISelection_ToString(This
->nsselection
, &nstext
);
167 if(NS_FAILED(nsres
) || !nstext
) {
168 ERR("toString failed: %08x\n", nsres
);
172 *p
= SysAllocString(nstext
);
177 static HRESULT WINAPI
HTMLTxtRange_parentElement(IHTMLTxtRange
*iface
, IHTMLElement
**parent
)
179 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
180 FIXME("(%p)->(%p)\n", This
, parent
);
184 static HRESULT WINAPI
HTMLTxtRange_duplicate(IHTMLTxtRange
*iface
, IHTMLTxtRange
**Duplicate
)
186 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
187 FIXME("(%p)->(%p)\n", This
, Duplicate
);
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
);
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
);
207 static HRESULT WINAPI
HTMLTxtRange_scrollIntoView(IHTMLTxtRange
*iface
, VARIANT_BOOL fStart
)
209 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
210 FIXME("(%p)->(%x)\n", This
, fStart
);
214 static HRESULT WINAPI
HTMLTxtRange_collapse(IHTMLTxtRange
*iface
, VARIANT_BOOL Start
)
216 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
217 FIXME("(%p)->(%x)\n", This
, Start
);
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
);
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
);
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
);
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
);
252 static HRESULT WINAPI
HTMLTxtRange_select(IHTMLTxtRange
*iface
)
254 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
255 FIXME("(%p)->()\n", This
);
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
));
266 static HRESULT WINAPI
HTMLTxtRange_moveToElementText(IHTMLTxtRange
*iface
, IHTMLElement
*element
)
268 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
269 FIXME("(%p)->(%p)\n", This
, element
);
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
);
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
);
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
);
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
);
304 static HRESULT WINAPI
HTMLTxtRange_getBookmark(IHTMLTxtRange
*iface
, BSTR
*Bookmark
)
306 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
307 FIXME("(%p)->(%p)\n", This
, Bookmark
);
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
);
319 static HRESULT WINAPI
HTMLTxtRange_queryCommandSupported(IHTMLTxtRange
*iface
, BSTR cmdID
,
322 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
323 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
327 static HRESULT WINAPI
HTMLTxtRange_queryCommandEnabled(IHTMLTxtRange
*iface
, BSTR cmdID
,
330 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
331 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
335 static HRESULT WINAPI
HTMLTxtRange_queryCommandState(IHTMLTxtRange
*iface
, BSTR cmdID
,
338 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
339 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
343 static HRESULT WINAPI
HTMLTxtRange_queryCommandIndeterm(IHTMLTxtRange
*iface
, BSTR cmdID
,
346 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
347 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
351 static HRESULT WINAPI
HTMLTxtRange_queryCommandText(IHTMLTxtRange
*iface
, BSTR cmdID
,
354 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
355 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pcmdText
);
359 static HRESULT WINAPI
HTMLTxtRange_queryCommandValue(IHTMLTxtRange
*iface
, BSTR cmdID
,
362 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
363 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pcmdValue
);
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
);
375 static HRESULT WINAPI
HTMLTxtRange_execCommandShowHelp(IHTMLTxtRange
*iface
, BSTR cmdID
,
378 HTMLTxtRange
*This
= HTMLTXTRANGE_THIS(iface
);
379 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
383 #undef HTMLTXTRANGE_THIS
385 static const IHTMLTxtRangeVtbl HTMLTxtRangeVtbl
= {
386 HTMLTxtRange_QueryInterface
,
388 HTMLTxtRange_Release
,
389 HTMLTxtRange_GetTypeInfoCount
,
390 HTMLTxtRange_GetTypeInfo
,
391 HTMLTxtRange_GetIDsOfNames
,
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
,
404 HTMLTxtRange_moveStart
,
405 HTMLTxtRange_moveEnd
,
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
;
433 nsISelection_AddRef(nsselection
);
434 ret
->nsselection
= nsselection
;
436 return HTMLTXTRANGE(ret
);