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);
143 TRACE("(%p)->(%p)\n", This, range);
145 *range = (IDispatch*)HTMLTxtRange_Create(This->nsselection);
149 static HRESULT WINAPI HTMLSelectionObject_empty(IHTMLSelectionObject *iface)
151 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
152 FIXME("(%p)\n", This);
156 static HRESULT WINAPI HTMLSelectionObject_clear(IHTMLSelectionObject *iface)
158 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
159 FIXME("(%p)\n", This);
163 static HRESULT WINAPI HTMLSelectionObject_get_type(IHTMLSelectionObject *iface, BSTR *p)
165 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
166 PRInt32 range_cnt = 0;
168 static const WCHAR wszNone[] = {'N','o','n','e',0};
169 static const WCHAR wszText[] = {'T','e','x','t',0};
171 TRACE("(%p)->(%p)\n", This, p);
173 if(This->nsselection)
174 nsISelection_GetRangeCount(This->nsselection, &range_cnt);
176 *p = SysAllocString(range_cnt ? wszText : wszNone); /* FIXME: control */
180 #undef HTMLSELOBJ_THIS
182 static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = {
183 HTMLSelectionObject_QueryInterface,
184 HTMLSelectionObject_AddRef,
185 HTMLSelectionObject_Release,
186 HTMLSelectionObject_GetTypeInfoCount,
187 HTMLSelectionObject_GetTypeInfo,
188 HTMLSelectionObject_GetIDsOfNames,
189 HTMLSelectionObject_Invoke,
190 HTMLSelectionObject_createRange,
191 HTMLSelectionObject_empty,
192 HTMLSelectionObject_clear,
193 HTMLSelectionObject_get_type
196 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection *nsselection)
198 HTMLSelectionObject *ret = mshtml_alloc(sizeof(HTMLSelectionObject));
200 ret->lpHTMLSelectionObjectVtbl = &HTMLSelectionObjectVtbl;
202 ret->nsselection = nsselection; /* We shouldn't call AddRef here */
204 return HTMLSELOBJ(ret);