wined3d: Remove some unneeded context cache members from the device.
[wine/multimedia.git] / dlls / mshtml / selection.c
blobf5cc5aa381f2a30a990dd2dd013c84446ceb45e3
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 IHTMLSelectionObjectVtbl *lpHTMLSelectionObjectVtbl;
42 LONG ref;
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);
56 *ppv = NULL;
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);
69 if(*ppv) {
70 IUnknown_AddRef((IUnknown*)*ppv);
71 return S_OK;
74 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
75 return E_NOINTERFACE;
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);
85 return 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);
95 if(!ref) {
96 if(This->nsselection)
97 nsISelection_Release(This->nsselection);
98 mshtml_free(This);
101 return ref;
104 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfoCount(IHTMLSelectionObject *iface, UINT *pctinfo)
106 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
107 FIXME("(%p)->(%p)\n", This, pctinfo);
108 return E_NOTIMPL;
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);
116 return E_NOTIMPL;
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,
125 lcid, rgDispId);
126 return E_NOTIMPL;
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);
136 return E_NOTIMPL;
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);
146 return S_OK;
149 static HRESULT WINAPI HTMLSelectionObject_empty(IHTMLSelectionObject *iface)
151 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
152 FIXME("(%p)\n", This);
153 return E_NOTIMPL;
156 static HRESULT WINAPI HTMLSelectionObject_clear(IHTMLSelectionObject *iface)
158 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface);
159 FIXME("(%p)\n", This);
160 return E_NOTIMPL;
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 */
177 return S_OK;
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;
201 ret->ref = 1;
202 ret->nsselection = nsselection; /* We shouldn't call AddRef here */
204 return HTMLSELOBJ(ret);