push e9c4c6cdd0babd7b2cb4288f191bb331b756eaf2
[wine/hacks.git] / dlls / msctf / range.c
blob63181afdff27d47824d4716a2fb50f5e72d749b0
1 /*
2 * ITfRange 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
21 #include "config.h"
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "shlwapi.h"
33 #include "winerror.h"
34 #include "objbase.h"
36 #include "wine/unicode.h"
38 #include "msctf.h"
39 #include "msctf_internal.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
43 typedef struct tagRange {
44 const ITfRangeVtbl *RangeVtbl;
45 /* const ITfRangeACPVtb *RangeACPVtbl; */
46 LONG refCount;
48 ITextStoreACP *pITextStoreACP;
49 ITfContext *pITfContext;
51 DWORD lockType;
52 TfGravity gravityStart, gravityEnd;
53 DWORD anchorStart, anchorEnd;
55 } Range;
57 static void Range_Destructor(Range *This)
59 TRACE("destroying %p\n", This);
60 HeapFree(GetProcessHeap(),0,This);
63 static HRESULT WINAPI Range_QueryInterface(ITfRange *iface, REFIID iid, LPVOID *ppvOut)
65 Range *This = (Range*)iface;
66 *ppvOut = NULL;
68 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfRange))
70 *ppvOut = This;
73 if (*ppvOut)
75 IUnknown_AddRef(iface);
76 return S_OK;
79 WARN("unsupported interface: %s\n", debugstr_guid(iid));
80 return E_NOINTERFACE;
83 static ULONG WINAPI Range_AddRef(ITfRange *iface)
85 Range *This = (Range *)iface;
86 return InterlockedIncrement(&This->refCount);
89 static ULONG WINAPI Range_Release(ITfRange *iface)
91 Range *This = (Range *)iface;
92 ULONG ret;
94 ret = InterlockedDecrement(&This->refCount);
95 if (ret == 0)
96 Range_Destructor(This);
97 return ret;
100 /*****************************************************
101 * ITfRange functions
102 *****************************************************/
104 static HRESULT WINAPI Range_GetText(ITfRange *iface, TfEditCookie ec,
105 DWORD dwFlags, WCHAR *pchText, ULONG cchMax, ULONG *pcch)
107 Range *This = (Range *)iface;
108 FIXME("STUB:(%p)\n",This);
109 return E_NOTIMPL;
112 static HRESULT WINAPI Range_SetText(ITfRange *iface, TfEditCookie ec,
113 DWORD dwFlags, const WCHAR *pchText, LONG cch)
115 Range *This = (Range *)iface;
116 FIXME("STUB:(%p)\n",This);
117 return E_NOTIMPL;
120 static HRESULT WINAPI Range_GetFormattedText(ITfRange *iface, TfEditCookie ec,
121 IDataObject **ppDataObject)
123 Range *This = (Range *)iface;
124 FIXME("STUB:(%p)\n",This);
125 return E_NOTIMPL;
128 static HRESULT WINAPI Range_GetEmbedded(ITfRange *iface, TfEditCookie ec,
129 REFGUID rguidService, REFIID riid, IUnknown **ppunk)
131 Range *This = (Range *)iface;
132 FIXME("STUB:(%p)\n",This);
133 return E_NOTIMPL;
136 static HRESULT WINAPI Range_InsertEmbedded(ITfRange *iface, TfEditCookie ec,
137 DWORD dwFlags, IDataObject *pDataObject)
139 Range *This = (Range *)iface;
140 FIXME("STUB:(%p)\n",This);
141 return E_NOTIMPL;
144 static HRESULT WINAPI Range_ShiftStart(ITfRange *iface, TfEditCookie ec,
145 LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
147 Range *This = (Range *)iface;
148 FIXME("STUB:(%p)\n",This);
149 return E_NOTIMPL;
152 static HRESULT WINAPI Range_ShiftEnd(ITfRange *iface, TfEditCookie ec,
153 LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
155 Range *This = (Range *)iface;
156 FIXME("STUB:(%p)\n",This);
157 return E_NOTIMPL;
160 static HRESULT WINAPI Range_ShiftStartToRange(ITfRange *iface, TfEditCookie ec,
161 ITfRange *pRange, TfAnchor aPos)
163 Range *This = (Range *)iface;
164 FIXME("STUB:(%p)\n",This);
165 return E_NOTIMPL;
168 static HRESULT WINAPI Range_ShiftEndToRange(ITfRange *iface, TfEditCookie ec,
169 ITfRange *pRange, TfAnchor aPos)
171 Range *This = (Range *)iface;
172 FIXME("STUB:(%p)\n",This);
173 return E_NOTIMPL;
176 static HRESULT WINAPI Range_ShiftStartRegion(ITfRange *iface, TfEditCookie ec,
177 TfShiftDir dir, BOOL *pfNoRegion)
179 Range *This = (Range *)iface;
180 FIXME("STUB:(%p)\n",This);
181 return E_NOTIMPL;
184 static HRESULT WINAPI Range_ShiftEndRegion(ITfRange *iface, TfEditCookie ec,
185 TfShiftDir dir, BOOL *pfNoRegion)
187 Range *This = (Range *)iface;
188 FIXME("STUB:(%p)\n",This);
189 return E_NOTIMPL;
192 static HRESULT WINAPI Range_IsEmpty(ITfRange *iface, TfEditCookie ec,
193 BOOL *pfEmpty)
195 Range *This = (Range *)iface;
196 FIXME("STUB:(%p)\n",This);
197 return E_NOTIMPL;
200 static HRESULT WINAPI Range_Collapse(ITfRange *iface, TfEditCookie ec,
201 TfAnchor aPos)
203 Range *This = (Range *)iface;
204 FIXME("STUB:(%p)\n",This);
205 return E_NOTIMPL;
208 static HRESULT WINAPI Range_IsEqualStart(ITfRange *iface, TfEditCookie ec,
209 ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
211 Range *This = (Range *)iface;
212 FIXME("STUB:(%p)\n",This);
213 return E_NOTIMPL;
216 static HRESULT WINAPI Range_IsEqualEnd(ITfRange *iface, TfEditCookie ec,
217 ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
219 Range *This = (Range *)iface;
220 FIXME("STUB:(%p)\n",This);
221 return E_NOTIMPL;
224 static HRESULT WINAPI Range_CompareStart(ITfRange *iface, TfEditCookie ec,
225 ITfRange *pWith, TfAnchor aPos, LONG *plResult)
227 Range *This = (Range *)iface;
228 FIXME("STUB:(%p)\n",This);
229 return E_NOTIMPL;
232 static HRESULT WINAPI Range_CompareEnd(ITfRange *iface, TfEditCookie ec,
233 ITfRange *pWith, TfAnchor aPos, LONG *plResult)
235 Range *This = (Range *)iface;
236 FIXME("STUB:(%p)\n",This);
237 return E_NOTIMPL;
240 static HRESULT WINAPI Range_AdjustForInsert(ITfRange *iface, TfEditCookie ec,
241 ULONG cchInsert, BOOL *pfInsertOk)
243 Range *This = (Range *)iface;
244 FIXME("STUB:(%p)\n",This);
245 return E_NOTIMPL;
248 static HRESULT WINAPI Range_GetGravity(ITfRange *iface,
249 TfGravity *pgStart, TfGravity *pgEnd)
251 Range *This = (Range *)iface;
252 FIXME("STUB:(%p)\n",This);
253 return E_NOTIMPL;
256 static HRESULT WINAPI Range_SetGravity(ITfRange *iface, TfEditCookie ec,
257 TfGravity gStart, TfGravity gEnd)
259 Range *This = (Range *)iface;
260 FIXME("STUB:(%p)\n",This);
261 return E_NOTIMPL;
264 static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone)
266 Range *This = (Range *)iface;
267 FIXME("STUB:(%p)\n",This);
268 return E_NOTIMPL;
271 static HRESULT WINAPI Range_GetContext(ITfRange *iface, ITfContext **ppContext)
273 Range *This = (Range *)iface;
274 TRACE("(%p)\n",This);
275 if (!ppContext)
276 return E_INVALIDARG;
277 *ppContext = This->pITfContext;
278 return S_OK;
281 static const ITfRangeVtbl Range_RangeVtbl =
283 Range_QueryInterface,
284 Range_AddRef,
285 Range_Release,
287 Range_GetText,
288 Range_SetText,
289 Range_GetFormattedText,
290 Range_GetEmbedded,
291 Range_InsertEmbedded,
292 Range_ShiftStart,
293 Range_ShiftEnd,
294 Range_ShiftStartToRange,
295 Range_ShiftEndToRange,
296 Range_ShiftStartRegion,
297 Range_ShiftEndRegion,
298 Range_IsEmpty,
299 Range_Collapse,
300 Range_IsEqualStart,
301 Range_IsEqualEnd,
302 Range_CompareStart,
303 Range_CompareEnd,
304 Range_AdjustForInsert,
305 Range_GetGravity,
306 Range_SetGravity,
307 Range_Clone,
308 Range_GetContext
311 HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut)
313 Range *This;
315 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Range));
316 if (This == NULL)
317 return E_OUTOFMEMORY;
319 TRACE("(%p) %p %p\n",This, context, textstore);
321 This->RangeVtbl= &Range_RangeVtbl;
322 This->refCount = 1;
323 This->pITfContext = context;
324 This->pITextStoreACP = textstore;
325 This->lockType = lockType;
326 This->anchorStart = anchorStart;
327 This->anchorEnd = anchorEnd;
329 *ppOut = (ITfRange*)This;
330 TRACE("returning %p\n", This);
332 return S_OK;