2 * ITfContext implementation
4 * Copyright 2009 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
36 #include "wine/unicode.h"
39 #include "msctf_internal.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
43 typedef struct tagContext {
44 const ITfContextVtbl *ContextVtbl;
45 const ITfSourceVtbl *SourceVtbl;
49 IUnknown *punk; /* possible ITextStoreACP or ITfContextOwnerCompositionSink */
52 static inline Context *impl_from_ITfSourceVtbl(ITfSource *iface)
54 return (Context *)((char *)iface - FIELD_OFFSET(Context,SourceVtbl));
57 static void Context_Destructor(Context *This)
59 TRACE("destroying %p\n", This);
60 HeapFree(GetProcessHeap(),0,This);
63 static HRESULT WINAPI Context_QueryInterface(ITfContext *iface, REFIID iid, LPVOID *ppvOut)
65 Context *This = (Context *)iface;
68 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfContext))
72 else if (IsEqualIID(iid, &IID_ITfSource))
74 *ppvOut = &This->SourceVtbl;
79 IUnknown_AddRef(iface);
83 WARN("unsupported interface: %s\n", debugstr_guid(iid));
87 static ULONG WINAPI Context_AddRef(ITfContext *iface)
89 Context *This = (Context *)iface;
90 return InterlockedIncrement(&This->refCount);
93 static ULONG WINAPI Context_Release(ITfContext *iface)
95 Context *This = (Context *)iface;
98 ret = InterlockedDecrement(&This->refCount);
100 Context_Destructor(This);
104 /*****************************************************
105 * ITfContext functions
106 *****************************************************/
107 static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
108 TfClientId tid, ITfEditSession *pes, DWORD dwFlags,
111 Context *This = (Context *)iface;
112 FIXME("STUB:(%p)\n",This);
116 static HRESULT WINAPI Context_InWriteSession (ITfContext *iface,
118 BOOL *pfWriteSession)
120 Context *This = (Context *)iface;
121 FIXME("STUB:(%p)\n",This);
125 static HRESULT WINAPI Context_GetSelection (ITfContext *iface,
126 TfEditCookie ec, ULONG ulIndex, ULONG ulCount,
127 TF_SELECTION *pSelection, ULONG *pcFetched)
129 Context *This = (Context *)iface;
130 FIXME("STUB:(%p)\n",This);
134 static HRESULT WINAPI Context_SetSelection (ITfContext *iface,
135 TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
137 Context *This = (Context *)iface;
138 FIXME("STUB:(%p)\n",This);
142 static HRESULT WINAPI Context_GetStart (ITfContext *iface,
143 TfEditCookie ec, ITfRange **ppStart)
145 Context *This = (Context *)iface;
146 FIXME("STUB:(%p)\n",This);
150 static HRESULT WINAPI Context_GetEnd (ITfContext *iface,
151 TfEditCookie ec, ITfRange **ppEnd)
153 Context *This = (Context *)iface;
154 FIXME("STUB:(%p)\n",This);
158 static HRESULT WINAPI Context_GetActiveView (ITfContext *iface,
159 ITfContextView **ppView)
161 Context *This = (Context *)iface;
162 FIXME("STUB:(%p)\n",This);
166 static HRESULT WINAPI Context_EnumViews (ITfContext *iface,
167 IEnumTfContextViews **ppEnum)
169 Context *This = (Context *)iface;
170 FIXME("STUB:(%p)\n",This);
174 static HRESULT WINAPI Context_GetStatus (ITfContext *iface,
177 Context *This = (Context *)iface;
178 FIXME("STUB:(%p)\n",This);
182 static HRESULT WINAPI Context_GetProperty (ITfContext *iface,
183 REFGUID guidProp, ITfProperty **ppProp)
185 Context *This = (Context *)iface;
186 FIXME("STUB:(%p)\n",This);
190 static HRESULT WINAPI Context_GetAppProperty (ITfContext *iface,
191 REFGUID guidProp, ITfReadOnlyProperty **ppProp)
193 Context *This = (Context *)iface;
194 FIXME("STUB:(%p)\n",This);
198 static HRESULT WINAPI Context_TrackProperties (ITfContext *iface,
199 const GUID **prgProp, ULONG cProp, const GUID **prgAppProp,
200 ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
202 Context *This = (Context *)iface;
203 FIXME("STUB:(%p)\n",This);
207 static HRESULT WINAPI Context_EnumProperties (ITfContext *iface,
208 IEnumTfProperties **ppEnum)
210 Context *This = (Context *)iface;
211 FIXME("STUB:(%p)\n",This);
215 static HRESULT WINAPI Context_GetDocumentMgr (ITfContext *iface,
216 ITfDocumentMgr **ppDm)
218 Context *This = (Context *)iface;
219 FIXME("STUB:(%p)\n",This);
223 static HRESULT WINAPI Context_CreateRangeBackup (ITfContext *iface,
224 TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
226 Context *This = (Context *)iface;
227 FIXME("STUB:(%p)\n",This);
231 static const ITfContextVtbl Context_ContextVtbl =
233 Context_QueryInterface,
237 Context_RequestEditSession,
238 Context_InWriteSession,
239 Context_GetSelection,
240 Context_SetSelection,
243 Context_GetActiveView,
247 Context_GetAppProperty,
248 Context_TrackProperties,
249 Context_EnumProperties,
250 Context_GetDocumentMgr,
251 Context_CreateRangeBackup
254 static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
256 Context *This = impl_from_ITfSourceVtbl(iface);
257 return Context_QueryInterface((ITfContext *)This, iid, *ppvOut);
260 static ULONG WINAPI Source_AddRef(ITfSource *iface)
262 Context *This = impl_from_ITfSourceVtbl(iface);
263 return Context_AddRef((ITfContext *)This);
266 static ULONG WINAPI Source_Release(ITfSource *iface)
268 Context *This = impl_from_ITfSourceVtbl(iface);
269 return Context_Release((ITfContext *)This);
272 /*****************************************************
273 * ITfSource functions
274 *****************************************************/
275 static WINAPI HRESULT ContextSource_AdviseSink(ITfSource *iface,
276 REFIID riid, IUnknown *punk, DWORD *pdwCookie)
278 Context *This = impl_from_ITfSourceVtbl(iface);
279 FIXME("STUB:(%p)\n",This);
283 static WINAPI HRESULT ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
285 Context *This = impl_from_ITfSourceVtbl(iface);
286 FIXME("STUB:(%p)\n",This);
290 static const ITfSourceVtbl Context_SourceVtbl =
292 Source_QueryInterface,
296 ContextSource_AdviseSink,
297 ContextSource_UnadviseSink,
300 HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **ppOut, TfEditCookie *pecTextStore)
304 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Context));
306 return E_OUTOFMEMORY;
308 This->ContextVtbl= &Context_ContextVtbl;
309 This->SourceVtbl = &Context_SourceVtbl;
311 This->tidOwner = tidOwner;
314 TRACE("returning %p\n", This);
315 *ppOut = (ITfContext*)This;
317 *pecTextStore = 0xdeaddead;