2 * Copyright 2006-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
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 static const WCHAR brW[] = {'b','r',0};
43 const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl;
44 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
54 #define HTMLTXTRANGE(x) ((IHTMLTxtRange*) &(x)->lpHTMLTxtRangeVtbl)
78 static HTMLTxtRange *get_range_object(HTMLDocument *doc, IHTMLTxtRange *iface)
82 LIST_FOR_EACH_ENTRY(iter, &doc->range_list, HTMLTxtRange, entry) {
83 if(HTMLTXTRANGE(iter) == iface)
87 ERR("Could not find range in document\n");
91 static range_unit_t string_to_unit(LPCWSTR str)
93 static const WCHAR characterW[] =
94 {'c','h','a','r','a','c','t','e','r',0};
95 static const WCHAR wordW[] =
97 static const WCHAR sentenceW[] =
98 {'s','e','n','t','e','n','c','e',0};
99 static const WCHAR texteditW[] =
100 {'t','e','x','t','e','d','i','t',0};
102 if(!strcmpiW(str, characterW)) return RU_CHAR;
103 if(!strcmpiW(str, wordW)) return RU_WORD;
104 if(!strcmpiW(str, sentenceW)) return RU_SENTENCE;
105 if(!strcmpiW(str, texteditW)) return RU_TEXTEDIT;
110 static int string_to_nscmptype(LPCWSTR str)
112 static const WCHAR seW[] = {'S','t','a','r','t','T','o','E','n','d',0};
113 static const WCHAR ssW[] = {'S','t','a','r','t','T','o','S','t','a','r','t',0};
114 static const WCHAR esW[] = {'E','n','d','T','o','S','t','a','r','t',0};
115 static const WCHAR eeW[] = {'E','n','d','T','o','E','n','d',0};
117 if(!strcmpiW(str, seW)) return NS_START_TO_END;
118 if(!strcmpiW(str, ssW)) return NS_START_TO_START;
119 if(!strcmpiW(str, esW)) return NS_END_TO_START;
120 if(!strcmpiW(str, eeW)) return NS_END_TO_END;
125 static PRUint16 get_node_type(nsIDOMNode *node)
130 nsIDOMNode_GetNodeType(node, &type);
135 static BOOL is_br_node(nsIDOMNode *node)
139 const PRUnichar *tag;
143 nsres = nsIDOMNode_QueryInterface(node, &IID_nsIDOMElement, (void**)&elem);
147 nsAString_Init(&tag_str, NULL);
148 nsIDOMElement_GetTagName(elem, &tag_str);
149 nsIDOMElement_Release(elem);
150 nsAString_GetData(&tag_str, &tag);
152 if(!strcmpiW(tag, brW))
155 nsAString_Finish(&tag_str);
160 static inline void wstrbuf_init(wstrbuf_t *buf)
164 buf->buf = heap_alloc(buf->size * sizeof(WCHAR));
168 static inline void wstrbuf_finish(wstrbuf_t *buf)
173 static void wstrbuf_append_len(wstrbuf_t *buf, LPCWSTR str, int len)
175 if(buf->len+len >= buf->size) {
176 buf->size = 2*buf->len+len;
177 buf->buf = heap_realloc(buf->buf, buf->size * sizeof(WCHAR));
180 memcpy(buf->buf+buf->len, str, len*sizeof(WCHAR));
182 buf->buf[buf->len] = 0;
185 static inline void wstrbuf_append(wstrbuf_t *buf, LPCWSTR str)
187 wstrbuf_append_len(buf, str, strlenW(str));
190 static void wstrbuf_append_nodetxt(wstrbuf_t *buf, LPCWSTR str, int len)
192 const WCHAR *s = str;
195 TRACE("%s\n", debugstr_wn(str, len));
197 if(buf->len+len >= buf->size) {
198 buf->size = 2*buf->len+len;
199 buf->buf = heap_realloc(buf->buf, buf->size * sizeof(WCHAR));
202 if(buf->len && isspaceW(buf->buf[buf->len-1])) {
203 while(s < str+len && isspaceW(*s))
207 d = buf->buf+buf->len;
212 while(s < str+len && isspaceW(*s))
219 buf->len = d - buf->buf;
223 static void wstrbuf_append_node(wstrbuf_t *buf, nsIDOMNode *node)
226 switch(get_node_type(node)) {
230 const PRUnichar *data;
232 nsIDOMNode_QueryInterface(node, &IID_nsIDOMText, (void**)&nstext);
234 nsAString_Init(&data_str, NULL);
235 nsIDOMText_GetData(nstext, &data_str);
236 nsAString_GetData(&data_str, &data);
237 wstrbuf_append_nodetxt(buf, data, strlenW(data));
238 nsAString_Finish(&data_str);
240 nsIDOMText_Release(nstext);
245 if(is_br_node(node)) {
246 static const WCHAR endlW[] = {'\r','\n'};
247 wstrbuf_append_len(buf, endlW, 2);
252 static BOOL fill_nodestr(dompos_t *pos)
257 if(pos->type != TEXT_NODE)
260 nsres = nsIDOMNode_QueryInterface(pos->node, &IID_nsIDOMText, (void**)&text);
264 nsAString_Init(&pos->str, NULL);
265 nsIDOMText_GetData(text, &pos->str);
266 nsIDOMText_Release(text);
267 nsAString_GetData(&pos->str, &pos->p);
270 pos->off = *pos->p ? strlenW(pos->p)-1 : 0;
275 static nsIDOMNode *next_node(nsIDOMNode *iter)
277 nsIDOMNode *ret, *tmp;
283 nsres = nsIDOMNode_GetFirstChild(iter, &ret);
284 if(NS_SUCCEEDED(nsres) && ret)
287 nsIDOMNode_AddRef(iter);
290 nsres = nsIDOMNode_GetNextSibling(iter, &ret);
291 if(NS_SUCCEEDED(nsres) && ret) {
292 nsIDOMNode_Release(iter);
296 nsres = nsIDOMNode_GetParentNode(iter, &tmp);
297 nsIDOMNode_Release(iter);
299 }while(NS_SUCCEEDED(nsres) && iter);
304 static nsIDOMNode *prev_node(HTMLTxtRange *This, nsIDOMNode *iter)
306 nsIDOMNode *ret, *tmp;
310 nsIDOMHTMLDocument *nshtmldoc;
311 nsIDOMHTMLElement *nselem;
312 nsIDOMDocument *nsdoc;
314 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc);
315 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
316 nsIDOMDocument_Release(nsdoc);
317 nsIDOMHTMLDocument_GetBody(nshtmldoc, &nselem);
318 nsIDOMHTMLDocument_Release(nshtmldoc);
320 nsIDOMElement_GetLastChild(nselem, &tmp);
322 return (nsIDOMNode*)nselem;
326 nsIDOMNode_GetLastChild(ret, &tmp);
329 nsIDOMElement_Release(nselem);
334 nsres = nsIDOMNode_GetLastChild(iter, &ret);
335 if(NS_SUCCEEDED(nsres) && ret)
338 nsIDOMNode_AddRef(iter);
341 nsres = nsIDOMNode_GetPreviousSibling(iter, &ret);
342 if(NS_SUCCEEDED(nsres) && ret) {
343 nsIDOMNode_Release(iter);
347 nsres = nsIDOMNode_GetParentNode(iter, &tmp);
348 nsIDOMNode_Release(iter);
350 }while(NS_SUCCEEDED(nsres) && iter);
355 static nsIDOMNode *get_child_node(nsIDOMNode *node, PRUint32 off)
357 nsIDOMNodeList *node_list;
358 nsIDOMNode *ret = NULL;
360 nsIDOMNode_GetChildNodes(node, &node_list);
361 nsIDOMNodeList_Item(node_list, off, &ret);
362 nsIDOMNodeList_Release(node_list);
367 static void get_cur_pos(HTMLTxtRange *This, BOOL start, dompos_t *pos)
376 nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
381 nsIDOMRange_GetStartContainer(This->nsrange, &node);
382 nsIDOMRange_GetStartOffset(This->nsrange, &off);
384 nsIDOMRange_GetEndContainer(This->nsrange, &node);
385 nsIDOMRange_GetEndOffset(This->nsrange, &off);
388 pos->type = get_node_type(node);
389 if(pos->type == ELEMENT_NODE) {
391 pos->node = get_child_node(node, off);
394 pos->node = off ? get_child_node(node, off-1) : prev_node(This, node);
398 pos->type = get_node_type(pos->node);
399 nsIDOMNode_Release(node);
407 pos->node = prev_node(This, node);
409 nsIDOMNode_Release(node);
412 if(pos->type == TEXT_NODE)
416 static void set_range_pos(HTMLTxtRange *This, BOOL start, dompos_t *pos)
421 if(pos->type == TEXT_NODE)
422 nsres = nsIDOMRange_SetStart(This->nsrange, pos->node, pos->off);
424 nsres = nsIDOMRange_SetStartBefore(This->nsrange, pos->node);
426 if(pos->type == TEXT_NODE && pos->p[pos->off+1])
427 nsres = nsIDOMRange_SetEnd(This->nsrange, pos->node, pos->off+1);
429 nsres = nsIDOMRange_SetEndAfter(This->nsrange, pos->node);
433 ERR("failed: %p %08x\n", pos->node, nsres);
436 static inline void dompos_release(dompos_t *pos)
439 nsIDOMNode_Release(pos->node);
442 nsAString_Finish(&pos->str);
445 static inline void dompos_addref(dompos_t *pos)
448 nsIDOMNode_AddRef(pos->node);
450 if(pos->type == TEXT_NODE)
454 static inline BOOL dompos_cmp(const dompos_t *pos1, const dompos_t *pos2)
456 return pos1->node == pos2->node && pos1->off == pos2->off;
459 static void range_to_string(HTMLTxtRange *This, wstrbuf_t *buf)
461 nsIDOMNode *iter, *tmp;
462 dompos_t start_pos, end_pos;
465 nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
473 get_cur_pos(This, FALSE, &end_pos);
474 get_cur_pos(This, TRUE, &start_pos);
476 if(start_pos.type == TEXT_NODE) {
477 if(start_pos.node == end_pos.node) {
478 wstrbuf_append_nodetxt(buf, start_pos.p+start_pos.off, end_pos.off-start_pos.off+1);
479 iter = start_pos.node;
480 nsIDOMNode_AddRef(iter);
482 wstrbuf_append_nodetxt(buf, start_pos.p+start_pos.off, strlenW(start_pos.p+start_pos.off));
483 iter = next_node(start_pos.node);
486 iter = start_pos.node;
487 nsIDOMNode_AddRef(iter);
490 while(iter != end_pos.node) {
491 wstrbuf_append_node(buf, iter);
492 tmp = next_node(iter);
493 nsIDOMNode_Release(iter);
497 nsIDOMNode_AddRef(end_pos.node);
499 if(start_pos.node != end_pos.node) {
500 if(end_pos.type == TEXT_NODE)
501 wstrbuf_append_nodetxt(buf, end_pos.p, end_pos.off+1);
503 wstrbuf_append_node(buf, end_pos.node);
506 nsIDOMNode_Release(iter);
507 dompos_release(&start_pos);
508 dompos_release(&end_pos);
513 for(p = buf->buf+buf->len-1; p >= buf->buf && isspaceW(*p); p--);
515 p = strchrW(p, '\r');
521 static WCHAR get_pos_char(const dompos_t *pos)
525 return pos->p[pos->off];
527 if(is_br_node(pos->node))
534 static void end_space(const dompos_t *pos, dompos_t *new_pos)
539 dompos_addref(new_pos);
541 if(pos->type != TEXT_NODE)
544 p = new_pos->p+new_pos->off;
546 if(!*p || !isspace(*p))
549 while(p[1] && isspace(p[1]))
552 new_pos->off = p - new_pos->p;
555 static WCHAR next_char(const dompos_t *pos, dompos_t *new_pos)
557 nsIDOMNode *iter, *tmp;
558 dompos_t last_space, tmp_pos;
562 if(pos->type == TEXT_NODE && pos->off != -1 && pos->p[pos->off]) {
566 while(isspaceW(*++p));
570 if(*p && isspaceW(*p)) {
572 while(p[1] && isspaceW(p[1]))
578 new_pos->off = p - pos->p;
579 dompos_addref(new_pos);
581 return cspace ? cspace : *p;
584 last_space.off = p - pos->p;
585 dompos_addref(&last_space);
589 iter = next_node(pos->node);
592 switch(get_node_type(iter)) {
595 tmp_pos.type = TEXT_NODE;
596 dompos_addref(&tmp_pos);
601 dompos_release(&tmp_pos);
603 }else if(isspaceW(*p)) {
605 dompos_release(&last_space);
609 while(p[1] && isspaceW(p[1]))
612 tmp_pos.off = p-tmp_pos.p;
615 last_space = tmp_pos;
620 nsIDOMNode_Release(iter);
623 *new_pos = last_space;
624 dompos_release(&tmp_pos);
625 nsIDOMNode_Release(iter);
633 nsIDOMNode_Release(iter);
637 if(!is_br_node(iter))
641 dompos_release(&last_space);
644 nsIDOMNode_AddRef(iter);
645 last_space.node = iter;
646 last_space.type = ELEMENT_NODE;
652 iter = next_node(iter);
653 nsIDOMNode_Release(tmp);
657 *new_pos = last_space;
660 dompos_addref(new_pos);
666 static WCHAR prev_char(HTMLTxtRange *This, const dompos_t *pos, dompos_t *new_pos)
668 nsIDOMNode *iter, *tmp;
670 BOOL skip_space = FALSE;
672 if(pos->type == TEXT_NODE && isspaceW(pos->p[pos->off]))
675 if(pos->type == TEXT_NODE && pos->off) {
676 p = pos->p+pos->off-1;
679 while(p >= pos->p && isspace(*p))
685 new_pos->off = p-pos->p;
686 dompos_addref(new_pos);
687 return new_pos->p[new_pos->off];
691 iter = prev_node(This, pos->node);
694 switch(get_node_type(iter)) {
699 tmp_pos.type = TEXT_NODE;
700 dompos_addref(&tmp_pos);
702 p = tmp_pos.p + strlenW(tmp_pos.p)-1;
705 while(p >= tmp_pos.p && isspaceW(*p))
710 dompos_release(&tmp_pos);
714 tmp_pos.off = p-tmp_pos.p;
716 nsIDOMNode_Release(iter);
721 if(!is_br_node(iter))
729 new_pos->node = iter;
730 new_pos->type = ELEMENT_NODE;
737 iter = prev_node(This, iter);
738 nsIDOMNode_Release(tmp);
742 dompos_addref(new_pos);
746 static long move_next_chars(long cnt, const dompos_t *pos, BOOL col, const dompos_t *bound_pos,
747 BOOL *bounded, dompos_t *new_pos)
760 end_space(pos, new_pos);
764 c = next_char(pos, &iter);
769 c = next_char(&tmp, &iter);
770 dompos_release(&tmp);
775 if(bound_pos && dompos_cmp(&tmp, bound_pos)) {
785 static long move_prev_chars(HTMLTxtRange *This, long cnt, const dompos_t *pos, BOOL end,
786 const dompos_t *bound_pos, BOOL *bounded, dompos_t *new_pos)
795 c = prev_char(This, pos, &iter);
799 while(c && ret < cnt) {
801 c = prev_char(This, &tmp, &iter);
802 dompos_release(&tmp);
811 if(bound_pos && dompos_cmp(&iter, bound_pos)) {
818 return bounded && *bounded ? ret+1 : ret;
821 static long find_prev_space(HTMLTxtRange *This, const dompos_t *pos, BOOL first_space, dompos_t *ret)
826 c = prev_char(This, pos, &iter);
827 if(!c || (first_space && isspaceW(c))) {
834 c = prev_char(This, &tmp, &iter);
835 if(!c || isspaceW(c)) {
836 dompos_release(&iter);
839 dompos_release(&tmp);
846 static int find_word_end(const dompos_t *pos, dompos_t *ret)
851 c = get_pos_char(pos);
858 c = next_char(pos, &iter);
869 while(c && !isspaceW(c)) {
871 c = next_char(&tmp, &iter);
873 dompos_release(&iter);
877 dompos_release(&tmp);
885 static long move_next_words(long cnt, const dompos_t *pos, dompos_t *new_pos)
891 c = get_pos_char(pos);
893 end_space(pos, &iter);
896 c = next_char(pos, &iter);
901 while(c && ret < cnt) {
903 c = next_char(&tmp, &iter);
904 dompos_release(&tmp);
913 static long move_prev_words(HTMLTxtRange *This, long cnt, const dompos_t *pos, dompos_t *new_pos)
919 dompos_addref(&iter);
922 if(!find_prev_space(This, &iter, FALSE, &tmp))
925 dompos_release(&iter);
934 #define HTMLTXTRANGE_THIS(iface) DEFINE_THIS(HTMLTxtRange, HTMLTxtRange, iface)
936 static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID riid, void **ppv)
938 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
942 if(IsEqualGUID(&IID_IUnknown, riid)) {
943 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
944 *ppv = HTMLTXTRANGE(This);
945 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
946 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
947 *ppv = HTMLTXTRANGE(This);
948 }else if(IsEqualGUID(&IID_IHTMLTxtRange, riid)) {
949 TRACE("(%p)->(IID_IHTMLTxtRange %p)\n", This, ppv);
950 *ppv = HTMLTXTRANGE(This);
951 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
952 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
953 *ppv = CMDTARGET(This);
957 IUnknown_AddRef((IUnknown*)*ppv);
961 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
962 return E_NOINTERFACE;
965 static ULONG WINAPI HTMLTxtRange_AddRef(IHTMLTxtRange *iface)
967 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
968 LONG ref = InterlockedIncrement(&This->ref);
970 TRACE("(%p) ref=%d\n", This, ref);
975 static ULONG WINAPI HTMLTxtRange_Release(IHTMLTxtRange *iface)
977 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
978 LONG ref = InterlockedDecrement(&This->ref);
980 TRACE("(%p) ref=%d\n", This, ref);
984 nsISelection_Release(This->nsrange);
986 list_remove(&This->entry);
993 static HRESULT WINAPI HTMLTxtRange_GetTypeInfoCount(IHTMLTxtRange *iface, UINT *pctinfo)
995 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
996 FIXME("(%p)->(%p)\n", This, pctinfo);
1000 static HRESULT WINAPI HTMLTxtRange_GetTypeInfo(IHTMLTxtRange *iface, UINT iTInfo,
1001 LCID lcid, ITypeInfo **ppTInfo)
1003 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1004 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1008 static HRESULT WINAPI HTMLTxtRange_GetIDsOfNames(IHTMLTxtRange *iface, REFIID riid,
1009 LPOLESTR *rgszNames, UINT cNames,
1010 LCID lcid, DISPID *rgDispId)
1012 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1013 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1018 static HRESULT WINAPI HTMLTxtRange_Invoke(IHTMLTxtRange *iface, DISPID dispIdMember,
1019 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1020 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1022 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1023 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1024 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1028 static HRESULT WINAPI HTMLTxtRange_get_htmlText(IHTMLTxtRange *iface, BSTR *p)
1030 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1032 TRACE("(%p)->(%p)\n", This, p);
1037 nsIDOMDocumentFragment *fragment;
1040 nsres = nsIDOMRange_CloneContents(This->nsrange, &fragment);
1041 if(NS_SUCCEEDED(nsres)) {
1042 const PRUnichar *nstext;
1045 nsAString_Init(&nsstr, NULL);
1046 nsnode_to_nsstring((nsIDOMNode*)fragment, &nsstr);
1047 nsIDOMDocumentFragment_Release(fragment);
1049 nsAString_GetData(&nsstr, &nstext);
1050 *p = SysAllocString(nstext);
1052 nsAString_Finish(&nsstr);
1057 const WCHAR emptyW[] = {0};
1058 *p = SysAllocString(emptyW);
1061 TRACE("return %s\n", debugstr_w(*p));
1065 static HRESULT WINAPI HTMLTxtRange_put_text(IHTMLTxtRange *iface, BSTR v)
1067 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1068 nsIDOMDocument *nsdoc;
1069 nsIDOMText *text_node;
1073 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1076 return MSHTML_E_NODOC;
1078 nsres = nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc);
1079 if(NS_FAILED(nsres)) {
1080 ERR("GetDocument failed: %08x\n", nsres);
1084 nsAString_Init(&text_str, v);
1085 nsres = nsIDOMDocument_CreateTextNode(nsdoc, &text_str, &text_node);
1086 nsIDOMDocument_Release(nsdoc);
1087 nsAString_Finish(&text_str);
1088 if(NS_FAILED(nsres)) {
1089 ERR("CreateTextNode failed: %08x\n", nsres);
1092 nsres = nsIDOMRange_DeleteContents(This->nsrange);
1093 if(NS_FAILED(nsres))
1094 ERR("DeleteContents failed: %08x\n", nsres);
1096 nsres = nsIDOMRange_InsertNode(This->nsrange, (nsIDOMNode*)text_node);
1097 if(NS_FAILED(nsres))
1098 ERR("InsertNode failed: %08x\n", nsres);
1100 nsres = nsIDOMRange_SetEndAfter(This->nsrange, (nsIDOMNode*)text_node);
1101 if(NS_FAILED(nsres))
1102 ERR("SetEndAfter failed: %08x\n", nsres);
1104 return IHTMLTxtRange_collapse(HTMLTXTRANGE(This), VARIANT_FALSE);
1107 static HRESULT WINAPI HTMLTxtRange_get_text(IHTMLTxtRange *iface, BSTR *p)
1109 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1112 TRACE("(%p)->(%p)\n", This, p);
1119 range_to_string(This, &buf);
1121 *p = SysAllocString(buf.buf);
1122 wstrbuf_finish(&buf);
1124 TRACE("ret %s\n", debugstr_w(*p));
1128 static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElement **parent)
1130 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1131 nsIDOMNode *nsnode, *tmp;
1134 TRACE("(%p)->(%p)\n", This, parent);
1136 nsIDOMRange_GetCommonAncestorContainer(This->nsrange, &nsnode);
1137 while(nsnode && get_node_type(nsnode) != ELEMENT_NODE) {
1138 nsIDOMNode_GetParentNode(nsnode, &tmp);
1139 nsIDOMNode_Release(nsnode);
1148 node = get_node(This->doc, nsnode);
1149 nsIDOMNode_Release(nsnode);
1151 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)parent);
1154 static HRESULT WINAPI HTMLTxtRange_duplicate(IHTMLTxtRange *iface, IHTMLTxtRange **Duplicate)
1156 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1157 nsIDOMRange *nsrange = NULL;
1159 TRACE("(%p)->(%p)\n", This, Duplicate);
1161 nsIDOMRange_CloneRange(This->nsrange, &nsrange);
1162 *Duplicate = HTMLTxtRange_Create(This->doc, nsrange);
1163 nsIDOMRange_Release(nsrange);
1168 static HRESULT WINAPI HTMLTxtRange_inRange(IHTMLTxtRange *iface, IHTMLTxtRange *Range,
1169 VARIANT_BOOL *InRange)
1171 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1172 HTMLTxtRange *src_range;
1176 TRACE("(%p)->(%p %p)\n", This, Range, InRange);
1178 *InRange = VARIANT_FALSE;
1180 src_range = get_range_object(This->doc, Range);
1184 nsres = nsIDOMRange_CompareBoundaryPoints(This->nsrange, NS_START_TO_START,
1185 src_range->nsrange, &nsret);
1186 if(NS_SUCCEEDED(nsres) && nsret <= 0) {
1187 nsres = nsIDOMRange_CompareBoundaryPoints(This->nsrange, NS_END_TO_END,
1188 src_range->nsrange, &nsret);
1189 if(NS_SUCCEEDED(nsres) && nsret >= 0)
1190 *InRange = VARIANT_TRUE;
1193 if(NS_FAILED(nsres))
1194 ERR("CompareBoundaryPoints failed: %08x\n", nsres);
1199 static HRESULT WINAPI HTMLTxtRange_isEqual(IHTMLTxtRange *iface, IHTMLTxtRange *Range,
1200 VARIANT_BOOL *IsEqual)
1202 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1203 HTMLTxtRange *src_range;
1207 TRACE("(%p)->(%p %p)\n", This, Range, IsEqual);
1209 *IsEqual = VARIANT_FALSE;
1211 src_range = get_range_object(This->doc, Range);
1215 nsres = nsIDOMRange_CompareBoundaryPoints(This->nsrange, NS_START_TO_START,
1216 src_range->nsrange, &nsret);
1217 if(NS_SUCCEEDED(nsres) && !nsret) {
1218 nsres = nsIDOMRange_CompareBoundaryPoints(This->nsrange, NS_END_TO_END,
1219 src_range->nsrange, &nsret);
1220 if(NS_SUCCEEDED(nsres) && !nsret)
1221 *IsEqual = VARIANT_TRUE;
1224 if(NS_FAILED(nsres))
1225 ERR("CompareBoundaryPoints failed: %08x\n", nsres);
1230 static HRESULT WINAPI HTMLTxtRange_scrollIntoView(IHTMLTxtRange *iface, VARIANT_BOOL fStart)
1232 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1233 FIXME("(%p)->(%x)\n", This, fStart);
1237 static HRESULT WINAPI HTMLTxtRange_collapse(IHTMLTxtRange *iface, VARIANT_BOOL Start)
1239 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1241 TRACE("(%p)->(%x)\n", This, Start);
1243 nsIDOMRange_Collapse(This->nsrange, Start != VARIANT_FALSE);
1247 static HRESULT WINAPI HTMLTxtRange_expand(IHTMLTxtRange *iface, BSTR Unit, VARIANT_BOOL *Success)
1249 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1252 TRACE("(%p)->(%s %p)\n", This, debugstr_w(Unit), Success);
1254 unit = string_to_unit(Unit);
1255 if(unit == RU_UNKNOWN)
1256 return E_INVALIDARG;
1258 *Success = VARIANT_FALSE;
1262 dompos_t end_pos, start_pos, new_start_pos, new_end_pos;
1265 nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
1267 get_cur_pos(This, TRUE, &start_pos);
1268 get_cur_pos(This, FALSE, &end_pos);
1270 if(find_word_end(&end_pos, &new_end_pos) || collapsed) {
1271 set_range_pos(This, FALSE, &new_end_pos);
1272 *Success = VARIANT_TRUE;
1275 if(start_pos.type && (get_pos_char(&end_pos) || !dompos_cmp(&new_end_pos, &end_pos))) {
1276 if(find_prev_space(This, &start_pos, TRUE, &new_start_pos)) {
1277 set_range_pos(This, TRUE, &new_start_pos);
1278 *Success = VARIANT_TRUE;
1280 dompos_release(&new_start_pos);
1283 dompos_release(&new_end_pos);
1284 dompos_release(&end_pos);
1285 dompos_release(&start_pos);
1291 nsIDOMDocument *nsdoc;
1292 nsIDOMHTMLDocument *nshtmldoc;
1293 nsIDOMHTMLElement *nsbody = NULL;
1296 nsres = nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc);
1297 if(NS_FAILED(nsres) || !nsdoc) {
1298 ERR("GetDocument failed: %08x\n", nsres);
1302 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
1303 nsIDOMDocument_Release(nsdoc);
1305 nsres = nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
1306 nsIDOMHTMLDocument_Release(nshtmldoc);
1307 if(NS_FAILED(nsres) || !nsbody) {
1308 ERR("Could not get body: %08x\n", nsres);
1312 nsres = nsIDOMRange_SelectNodeContents(This->nsrange, (nsIDOMNode*)nsbody);
1313 nsIDOMHTMLElement_Release(nsbody);
1314 if(NS_FAILED(nsres)) {
1315 ERR("Collapse failed: %08x\n", nsres);
1319 *Success = VARIANT_TRUE;
1324 FIXME("Unimplemented unit %s\n", debugstr_w(Unit));
1330 static HRESULT WINAPI HTMLTxtRange_move(IHTMLTxtRange *iface, BSTR Unit,
1331 long Count, long *ActualCount)
1333 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1336 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
1338 unit = string_to_unit(Unit);
1339 if(unit == RU_UNKNOWN)
1340 return E_INVALIDARG;
1344 return IHTMLTxtRange_collapse(HTMLTXTRANGE(This), TRUE);
1349 dompos_t cur_pos, new_pos;
1351 get_cur_pos(This, TRUE, &cur_pos);
1354 *ActualCount = move_next_chars(Count, &cur_pos, TRUE, NULL, NULL, &new_pos);
1355 set_range_pos(This, FALSE, &new_pos);
1356 dompos_release(&new_pos);
1358 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), FALSE);
1360 *ActualCount = -move_prev_chars(This, -Count, &cur_pos, FALSE, NULL, NULL, &new_pos);
1361 set_range_pos(This, TRUE, &new_pos);
1362 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), TRUE);
1363 dompos_release(&new_pos);
1366 dompos_release(&cur_pos);
1371 dompos_t cur_pos, new_pos;
1373 get_cur_pos(This, TRUE, &cur_pos);
1376 *ActualCount = move_next_words(Count, &cur_pos, &new_pos);
1377 set_range_pos(This, FALSE, &new_pos);
1378 dompos_release(&new_pos);
1379 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), FALSE);
1381 *ActualCount = -move_prev_words(This, -Count, &cur_pos, &new_pos);
1382 set_range_pos(This, TRUE, &new_pos);
1383 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), TRUE);
1384 dompos_release(&new_pos);
1387 dompos_release(&cur_pos);
1392 FIXME("unimplemented unit %s\n", debugstr_w(Unit));
1395 TRACE("ret %ld\n", *ActualCount);
1399 static HRESULT WINAPI HTMLTxtRange_moveStart(IHTMLTxtRange *iface, BSTR Unit,
1400 long Count, long *ActualCount)
1402 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1405 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
1407 unit = string_to_unit(Unit);
1408 if(unit == RU_UNKNOWN)
1409 return E_INVALIDARG;
1418 dompos_t start_pos, end_pos, new_pos;
1421 get_cur_pos(This, TRUE, &start_pos);
1422 get_cur_pos(This, FALSE, &end_pos);
1423 nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
1428 *ActualCount = move_next_chars(Count, &start_pos, collapsed, &end_pos, &bounded, &new_pos);
1429 set_range_pos(This, !bounded, &new_pos);
1431 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), FALSE);
1433 *ActualCount = -move_prev_chars(This, -Count, &start_pos, FALSE, NULL, NULL, &new_pos);
1434 set_range_pos(This, TRUE, &new_pos);
1437 dompos_release(&start_pos);
1438 dompos_release(&end_pos);
1439 dompos_release(&new_pos);
1444 FIXME("unimplemented unit %s\n", debugstr_w(Unit));
1450 static HRESULT WINAPI HTMLTxtRange_moveEnd(IHTMLTxtRange *iface, BSTR Unit,
1451 long Count, long *ActualCount)
1453 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1456 TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(Unit), Count, ActualCount);
1458 unit = string_to_unit(Unit);
1459 if(unit == RU_UNKNOWN)
1460 return E_INVALIDARG;
1469 dompos_t start_pos, end_pos, new_pos;
1472 get_cur_pos(This, TRUE, &start_pos);
1473 get_cur_pos(This, FALSE, &end_pos);
1474 nsIDOMRange_GetCollapsed(This->nsrange, &collapsed);
1477 *ActualCount = move_next_chars(Count, &end_pos, collapsed, NULL, NULL, &new_pos);
1478 set_range_pos(This, FALSE, &new_pos);
1482 *ActualCount = -move_prev_chars(This, -Count, &end_pos, TRUE, &start_pos, &bounded, &new_pos);
1483 set_range_pos(This, bounded, &new_pos);
1485 IHTMLTxtRange_collapse(HTMLTXTRANGE(This), TRUE);
1488 dompos_release(&start_pos);
1489 dompos_release(&end_pos);
1490 dompos_release(&new_pos);
1495 FIXME("unimplemented unit %s\n", debugstr_w(Unit));
1501 static HRESULT WINAPI HTMLTxtRange_select(IHTMLTxtRange *iface)
1503 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1505 TRACE("(%p)\n", This);
1507 if(This->doc->nscontainer) {
1508 nsIDOMWindow *dom_window = NULL;
1509 nsISelection *nsselection;
1511 nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &dom_window);
1512 nsIDOMWindow_GetSelection(dom_window, &nsselection);
1513 nsIDOMWindow_Release(dom_window);
1515 nsISelection_RemoveAllRanges(nsselection);
1516 nsISelection_AddRange(nsselection, This->nsrange);
1518 nsISelection_Release(nsselection);
1524 static HRESULT WINAPI HTMLTxtRange_pasteHTML(IHTMLTxtRange *iface, BSTR html)
1526 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1527 FIXME("(%p)->(%s)\n", This, debugstr_w(html));
1531 static HRESULT WINAPI HTMLTxtRange_moveToElementText(IHTMLTxtRange *iface, IHTMLElement *element)
1533 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1534 FIXME("(%p)->(%p)\n", This, element);
1538 static HRESULT WINAPI HTMLTxtRange_setEndPoint(IHTMLTxtRange *iface, BSTR how,
1539 IHTMLTxtRange *SourceRange)
1541 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1542 FIXME("(%p)->(%s %p)\n", This, debugstr_w(how), SourceRange);
1546 static HRESULT WINAPI HTMLTxtRange_compareEndPoints(IHTMLTxtRange *iface, BSTR how,
1547 IHTMLTxtRange *SourceRange, long *ret)
1549 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1550 HTMLTxtRange *src_range;
1555 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(how), SourceRange, ret);
1557 nscmpt = string_to_nscmptype(how);
1559 return E_INVALIDARG;
1561 src_range = get_range_object(This->doc, SourceRange);
1565 nsres = nsIDOMRange_CompareBoundaryPoints(This->nsrange, nscmpt, src_range->nsrange, &nsret);
1566 if(NS_FAILED(nsres))
1567 ERR("CompareBoundaryPoints failed: %08x\n", nsres);
1573 static HRESULT WINAPI HTMLTxtRange_findText(IHTMLTxtRange *iface, BSTR String,
1574 long count, long Flags, VARIANT_BOOL *Success)
1576 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1577 FIXME("(%p)->(%s %ld %08lx %p)\n", This, debugstr_w(String), count, Flags, Success);
1581 static HRESULT WINAPI HTMLTxtRange_moveToPoint(IHTMLTxtRange *iface, long x, long y)
1583 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1584 FIXME("(%p)->(%ld %ld)\n", This, x, y);
1588 static HRESULT WINAPI HTMLTxtRange_getBookmark(IHTMLTxtRange *iface, BSTR *Bookmark)
1590 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1591 FIXME("(%p)->(%p)\n", This, Bookmark);
1595 static HRESULT WINAPI HTMLTxtRange_moveToBookmark(IHTMLTxtRange *iface, BSTR Bookmark,
1596 VARIANT_BOOL *Success)
1598 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1599 FIXME("(%p)->(%s %p)\n", This, debugstr_w(Bookmark), Success);
1603 static HRESULT WINAPI HTMLTxtRange_queryCommandSupported(IHTMLTxtRange *iface, BSTR cmdID,
1604 VARIANT_BOOL *pfRet)
1606 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1607 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1611 static HRESULT WINAPI HTMLTxtRange_queryCommandEnabled(IHTMLTxtRange *iface, BSTR cmdID,
1612 VARIANT_BOOL *pfRet)
1614 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1615 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1619 static HRESULT WINAPI HTMLTxtRange_queryCommandState(IHTMLTxtRange *iface, BSTR cmdID,
1620 VARIANT_BOOL *pfRet)
1622 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1623 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1627 static HRESULT WINAPI HTMLTxtRange_queryCommandIndeterm(IHTMLTxtRange *iface, BSTR cmdID,
1628 VARIANT_BOOL *pfRet)
1630 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1631 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1635 static HRESULT WINAPI HTMLTxtRange_queryCommandText(IHTMLTxtRange *iface, BSTR cmdID,
1638 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1639 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pcmdText);
1643 static HRESULT WINAPI HTMLTxtRange_queryCommandValue(IHTMLTxtRange *iface, BSTR cmdID,
1646 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1647 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pcmdValue);
1651 static HRESULT WINAPI HTMLTxtRange_execCommand(IHTMLTxtRange *iface, BSTR cmdID,
1652 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1654 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1655 FIXME("(%p)->(%s %x v %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
1659 static HRESULT WINAPI HTMLTxtRange_execCommandShowHelp(IHTMLTxtRange *iface, BSTR cmdID,
1660 VARIANT_BOOL *pfRet)
1662 HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
1663 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1667 #undef HTMLTXTRANGE_THIS
1669 static const IHTMLTxtRangeVtbl HTMLTxtRangeVtbl = {
1670 HTMLTxtRange_QueryInterface,
1671 HTMLTxtRange_AddRef,
1672 HTMLTxtRange_Release,
1673 HTMLTxtRange_GetTypeInfoCount,
1674 HTMLTxtRange_GetTypeInfo,
1675 HTMLTxtRange_GetIDsOfNames,
1676 HTMLTxtRange_Invoke,
1677 HTMLTxtRange_get_htmlText,
1678 HTMLTxtRange_put_text,
1679 HTMLTxtRange_get_text,
1680 HTMLTxtRange_parentElement,
1681 HTMLTxtRange_duplicate,
1682 HTMLTxtRange_inRange,
1683 HTMLTxtRange_isEqual,
1684 HTMLTxtRange_scrollIntoView,
1685 HTMLTxtRange_collapse,
1686 HTMLTxtRange_expand,
1688 HTMLTxtRange_moveStart,
1689 HTMLTxtRange_moveEnd,
1690 HTMLTxtRange_select,
1691 HTMLTxtRange_pasteHTML,
1692 HTMLTxtRange_moveToElementText,
1693 HTMLTxtRange_setEndPoint,
1694 HTMLTxtRange_compareEndPoints,
1695 HTMLTxtRange_findText,
1696 HTMLTxtRange_moveToPoint,
1697 HTMLTxtRange_getBookmark,
1698 HTMLTxtRange_moveToBookmark,
1699 HTMLTxtRange_queryCommandSupported,
1700 HTMLTxtRange_queryCommandEnabled,
1701 HTMLTxtRange_queryCommandState,
1702 HTMLTxtRange_queryCommandIndeterm,
1703 HTMLTxtRange_queryCommandText,
1704 HTMLTxtRange_queryCommandValue,
1705 HTMLTxtRange_execCommand,
1706 HTMLTxtRange_execCommandShowHelp
1709 #define OLECMDTRG_THIS(iface) DEFINE_THIS(HTMLTxtRange, OleCommandTarget, iface)
1711 static HRESULT WINAPI RangeCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
1713 HTMLTxtRange *This = OLECMDTRG_THIS(iface);
1714 return IHTMLTxtRange_QueryInterface(HTMLTXTRANGE(This), riid, ppv);
1717 static ULONG WINAPI RangeCommandTarget_AddRef(IOleCommandTarget *iface)
1719 HTMLTxtRange *This = OLECMDTRG_THIS(iface);
1720 return IHTMLTxtRange_AddRef(HTMLTXTRANGE(This));
1723 static ULONG WINAPI RangeCommandTarget_Release(IOleCommandTarget *iface)
1725 HTMLTxtRange *This = OLECMDTRG_THIS(iface);
1726 return IHTMLTxtRange_Release(HTMLTXTRANGE(This));
1729 static HRESULT WINAPI RangeCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1730 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
1732 HTMLTxtRange *This = OLECMDTRG_THIS(iface);
1733 FIXME("(%p)->(%s %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1737 static HRESULT exec_indent(HTMLTxtRange *This, VARIANT *in, VARIANT *out)
1739 nsIDOMDocumentFragment *fragment;
1740 nsIDOMElement *blockquote_elem, *p_elem;
1741 nsIDOMDocument *nsdoc;
1745 static const PRUnichar blockquoteW[] = {'B','L','O','C','K','Q','U','O','T','E',0};
1746 static const PRUnichar pW[] = {'P',0};
1748 TRACE("(%p)->(%p %p)\n", This, in, out);
1750 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc);
1752 nsAString_Init(&tag_str, blockquoteW);
1753 nsIDOMDocument_CreateElement(nsdoc, &tag_str, &blockquote_elem);
1754 nsAString_Finish(&tag_str);
1756 nsAString_Init(&tag_str, pW);
1757 nsIDOMDocument_CreateElement(nsdoc, &tag_str, &p_elem);
1758 nsAString_Finish(&tag_str);
1760 nsIDOMDocument_Release(nsdoc);
1762 nsIDOMRange_ExtractContents(This->nsrange, &fragment);
1763 nsIDOMElement_AppendChild(p_elem, (nsIDOMNode*)fragment, &tmp);
1764 nsIDOMDocumentFragment_Release(fragment);
1765 nsIDOMNode_Release(tmp);
1767 nsIDOMElement_AppendChild(blockquote_elem, (nsIDOMNode*)p_elem, &tmp);
1768 nsIDOMElement_Release(p_elem);
1769 nsIDOMNode_Release(tmp);
1771 nsIDOMRange_InsertNode(This->nsrange, (nsIDOMNode*)blockquote_elem);
1772 nsIDOMElement_Release(blockquote_elem);
1777 static HRESULT WINAPI RangeCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1778 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1780 HTMLTxtRange *This = OLECMDTRG_THIS(iface);
1782 TRACE("(%p)->(%s %d %x %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
1783 nCmdexecopt, pvaIn, pvaOut);
1785 if(pguidCmdGroup && IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
1788 return exec_indent(This, pvaIn, pvaOut);
1790 FIXME("Unsupported cmdid %d of CGID_MSHTML\n", nCmdID);
1793 FIXME("Unsupported cmd %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
1799 #undef OLECMDTRG_THIS
1801 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
1802 RangeCommandTarget_QueryInterface,
1803 RangeCommandTarget_AddRef,
1804 RangeCommandTarget_Release,
1805 RangeCommandTarget_QueryStatus,
1806 RangeCommandTarget_Exec
1809 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument *doc, nsIDOMRange *nsrange)
1811 HTMLTxtRange *ret = heap_alloc(sizeof(HTMLTxtRange));
1813 ret->lpHTMLTxtRangeVtbl = &HTMLTxtRangeVtbl;
1814 ret->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
1818 nsIDOMRange_AddRef(nsrange);
1819 ret->nsrange = nsrange;
1822 list_add_head(&doc->range_list, &ret->entry);
1824 return HTMLTXTRANGE(ret);
1827 void detach_ranges(HTMLDocument *This)
1831 LIST_FOR_EACH_ENTRY(iter, &This->range_list, HTMLTxtRange, entry) {