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 IHTMLSelectionObjectVtbl *lpHTMLSelectionObjectVtbl;
44 nsISelection *nsselection;
45 } HTMLSelectionObject;
47 #define HTMLSELOBJ(x) ((IHTMLSelectionObject*) &(x)->lpHTMLSelectionObjectVtbl)
49 #define HTMLSELOBJ_THIS(iface) DEFINE_THIS(HTMLSelectionObject, HTMLSelectionObject, iface)
51 static HRESULT WINAPI HTMLSelectionObject_QueryInterface(IHTMLSelectionObject *iface,
52 REFIID riid, void **ppv)
54 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
58 if(IsEqualGUID(&IID_IUnknown, riid)) {
59 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60 *ppv = HTMLSELOBJ(This);
61 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
62 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
63 *ppv = HTMLSELOBJ(This);
64 }else if(IsEqualGUID(&IID_IHTMLSelectionObject, riid)) {
65 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
66 *ppv = HTMLSELOBJ(This);
70 IUnknown_AddRef((IUnknown*)*ppv);
74 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
78 static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface)
80 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
81 LONG ref = InterlockedIncrement(&This->ref);
83 TRACE("(%p) ref=%d\n", This, ref);
88 static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface)
90 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
91 LONG ref = InterlockedDecrement(&This->ref);
93 TRACE("(%p) ref=%d\n", This, ref);
97 nsISelection_Release(This->nsselection);
104 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfoCount(IHTMLSelectionObject *iface, UINT *pctinfo)
106 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
107 FIXME("(%p)->(%p)\n", This, pctinfo);
111 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfo(IHTMLSelectionObject *iface, UINT iTInfo,
112 LCID lcid, ITypeInfo **ppTInfo)
114 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
115 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
119 static HRESULT WINAPI HTMLSelectionObject_GetIDsOfNames(IHTMLSelectionObject *iface, REFIID riid,
120 LPOLESTR *rgszNames, UINT cNames,
121 LCID lcid, DISPID *rgDispId)
123 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
124 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
129 static HRESULT WINAPI HTMLSelectionObject_Invoke(IHTMLSelectionObject *iface, DISPID dispIdMember,
130 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
131 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
133 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
134 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
135 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
139 static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *iface, IDispatch **range)
141 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
142 nsIDOMRange *nsrange = NULL;
144 TRACE("(%p)->(%p)\n", This, range);
146 if(This->nsselection) {
147 PRInt32 nsrange_cnt = 0;
150 nsISelection_GetRangeCount(This->nsselection, &nsrange_cnt);
152 FIXME("range_cnt = %d\n", nsrange_cnt);
154 nsres = nsISelection_GetRangeAt(This->nsselection, 0, &nsrange);
156 ERR("GetRangeAt failed: %08x\n", nsres);
159 *range = (IDispatch*)HTMLTxtRange_Create(nsrange);
163 static HRESULT WINAPI HTMLSelectionObject_empty(IHTMLSelectionObject *iface)
165 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
166 FIXME("(%p)\n", This);
170 static HRESULT WINAPI HTMLSelectionObject_clear(IHTMLSelectionObject *iface)
172 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
173 FIXME("(%p)\n", This);
177 static HRESULT WINAPI HTMLSelectionObject_get_type(IHTMLSelectionObject *iface, BSTR *p)
179 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
180 PRBool collapsed = TRUE;
182 static const WCHAR wszNone[] = {'N','o','n','e',0};
183 static const WCHAR wszText[] = {'T','e','x','t',0};
185 TRACE("(%p)->(%p)\n", This, p);
187 if(This->nsselection)
188 nsISelection_GetIsCollapsed(This->nsselection, &collapsed);
190 *p = SysAllocString(collapsed ? wszNone : wszText); /* FIXME: control */
191 TRACE("ret %s\n", debugstr_w(*p));
195 #undef HTMLSELOBJ_THIS
197 static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = {
198 HTMLSelectionObject_QueryInterface,
199 HTMLSelectionObject_AddRef,
200 HTMLSelectionObject_Release,
201 HTMLSelectionObject_GetTypeInfoCount,
202 HTMLSelectionObject_GetTypeInfo,
203 HTMLSelectionObject_GetIDsOfNames,
204 HTMLSelectionObject_Invoke,
205 HTMLSelectionObject_createRange,
206 HTMLSelectionObject_empty,
207 HTMLSelectionObject_clear,
208 HTMLSelectionObject_get_type
211 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection *nsselection)
213 HTMLSelectionObject *ret = mshtml_alloc(sizeof(HTMLSelectionObject));
215 ret->lpHTMLSelectionObjectVtbl = &HTMLSelectionObjectVtbl;
217 ret->nsselection = nsselection; /* We shouldn't call AddRef here */
219 return HTMLSELOBJ(ret);