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
25 #include "wine/debug.h"
35 #include "msctf_internal.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msctf
);
39 typedef struct tagRange
{
40 ITfRangeACP ITfRangeACP_iface
;
45 TfGravity gravityStart
, gravityEnd
;
46 DWORD anchorStart
, anchorEnd
;
50 static inline Range
*impl_from_ITfRangeACP(ITfRangeACP
*iface
)
52 return CONTAINING_RECORD(iface
, Range
, ITfRangeACP_iface
);
55 static Range
*unsafe_impl_from_ITfRange(ITfRange
*iface
)
57 return CONTAINING_RECORD(iface
, Range
, ITfRangeACP_iface
);
60 static void Range_Destructor(Range
*This
)
62 TRACE("destroying %p\n", This
);
63 ITfContext_Release(This
->context
);
67 static HRESULT WINAPI
Range_QueryInterface(ITfRangeACP
*iface
, REFIID iid
, LPVOID
*ppvOut
)
69 Range
*range
= impl_from_ITfRangeACP(iface
);
73 if (IsEqualIID(iid
, &IID_IUnknown
) ||
74 IsEqualIID(iid
, &IID_ITfRange
) ||
75 IsEqualIID(iid
, &IID_ITfRangeACP
))
77 *ppvOut
= &range
->ITfRangeACP_iface
;
82 ITfRangeACP_AddRef(iface
);
86 WARN("unsupported interface: %s\n", debugstr_guid(iid
));
90 static ULONG WINAPI
Range_AddRef(ITfRangeACP
*iface
)
92 Range
*range
= impl_from_ITfRangeACP(iface
);
93 return InterlockedIncrement(&range
->refCount
);
96 static ULONG WINAPI
Range_Release(ITfRangeACP
*iface
)
98 Range
*range
= impl_from_ITfRangeACP(iface
);
101 ret
= InterlockedDecrement(&range
->refCount
);
103 Range_Destructor(range
);
107 static HRESULT WINAPI
Range_GetText(ITfRangeACP
*iface
, TfEditCookie ec
,
108 DWORD dwFlags
, WCHAR
*pchText
, ULONG cchMax
, ULONG
*pcch
)
110 FIXME("STUB:(%p)\n", iface
);
114 static HRESULT WINAPI
Range_SetText(ITfRangeACP
*iface
, TfEditCookie ec
,
115 DWORD dwFlags
, const WCHAR
*pchText
, LONG cch
)
117 FIXME("STUB:(%p)\n", iface
);
121 static HRESULT WINAPI
Range_GetFormattedText(ITfRangeACP
*iface
, TfEditCookie ec
,
122 IDataObject
**ppDataObject
)
124 FIXME("STUB:(%p)\n", iface
);
128 static HRESULT WINAPI
Range_GetEmbedded(ITfRangeACP
*iface
, TfEditCookie ec
,
129 REFGUID rguidService
, REFIID riid
, IUnknown
**ppunk
)
131 FIXME("STUB:(%p)\n", iface
);
135 static HRESULT WINAPI
Range_InsertEmbedded(ITfRangeACP
*iface
, TfEditCookie ec
,
136 DWORD dwFlags
, IDataObject
*pDataObject
)
138 FIXME("STUB:(%p)\n", iface
);
142 static HRESULT WINAPI
Range_ShiftStart(ITfRangeACP
*iface
, TfEditCookie ec
,
143 LONG cchReq
, LONG
*pcch
, const TF_HALTCOND
*pHalt
)
145 FIXME("STUB:(%p)\n", iface
);
149 static HRESULT WINAPI
Range_ShiftEnd(ITfRangeACP
*iface
, TfEditCookie ec
,
150 LONG cchReq
, LONG
*pcch
, const TF_HALTCOND
*pHalt
)
152 FIXME("STUB:(%p)\n", iface
);
156 static HRESULT WINAPI
Range_ShiftStartToRange(ITfRangeACP
*iface
, TfEditCookie ec
,
157 ITfRange
*pRange
, TfAnchor aPos
)
159 FIXME("STUB:(%p)\n", iface
);
163 static HRESULT WINAPI
Range_ShiftEndToRange(ITfRangeACP
*iface
, TfEditCookie ec
,
164 ITfRange
*pRange
, TfAnchor aPos
)
166 FIXME("STUB:(%p)\n", iface
);
170 static HRESULT WINAPI
Range_ShiftStartRegion(ITfRangeACP
*iface
, TfEditCookie ec
,
171 TfShiftDir dir
, BOOL
*pfNoRegion
)
173 FIXME("STUB:(%p)\n", iface
);
177 static HRESULT WINAPI
Range_ShiftEndRegion(ITfRangeACP
*iface
, TfEditCookie ec
,
178 TfShiftDir dir
, BOOL
*pfNoRegion
)
180 FIXME("STUB:(%p)\n", iface
);
184 static HRESULT WINAPI
Range_IsEmpty(ITfRangeACP
*iface
, TfEditCookie ec
,
187 FIXME("STUB:(%p)\n", iface
);
191 static HRESULT WINAPI
Range_Collapse(ITfRangeACP
*iface
, TfEditCookie ec
,
194 Range
*range
= impl_from_ITfRangeACP(iface
);
196 TRACE("%p, %li, %i.\n", iface
, ec
, aPos
);
200 case TF_ANCHOR_START
:
201 range
->anchorEnd
= range
->anchorStart
;
204 range
->anchorStart
= range
->anchorEnd
;
213 static HRESULT WINAPI
Range_IsEqualStart(ITfRangeACP
*iface
, TfEditCookie ec
,
214 ITfRange
*pWith
, TfAnchor aPos
, BOOL
*pfEqual
)
216 FIXME("STUB:(%p)\n", iface
);
220 static HRESULT WINAPI
Range_IsEqualEnd(ITfRangeACP
*iface
, TfEditCookie ec
,
221 ITfRange
*pWith
, TfAnchor aPos
, BOOL
*pfEqual
)
223 FIXME("STUB:(%p)\n", iface
);
227 static HRESULT WINAPI
Range_CompareStart(ITfRangeACP
*iface
, TfEditCookie ec
,
228 ITfRange
*pWith
, TfAnchor aPos
, LONG
*plResult
)
230 FIXME("STUB:(%p)\n", iface
);
234 static HRESULT WINAPI
Range_CompareEnd(ITfRangeACP
*iface
, TfEditCookie ec
,
235 ITfRange
*pWith
, TfAnchor aPos
, LONG
*plResult
)
237 FIXME("STUB:(%p)\n", iface
);
241 static HRESULT WINAPI
Range_AdjustForInsert(ITfRangeACP
*iface
, TfEditCookie ec
,
242 ULONG cchInsert
, BOOL
*pfInsertOk
)
244 FIXME("STUB:(%p)\n", iface
);
248 static HRESULT WINAPI
Range_GetGravity(ITfRangeACP
*iface
,
249 TfGravity
*pgStart
, TfGravity
*pgEnd
)
251 FIXME("STUB:(%p)\n", iface
);
255 static HRESULT WINAPI
Range_SetGravity(ITfRangeACP
*iface
, TfEditCookie ec
,
256 TfGravity gStart
, TfGravity gEnd
)
258 FIXME("STUB:(%p)\n", iface
);
262 static HRESULT WINAPI
Range_Clone(ITfRangeACP
*iface
, ITfRange
**ppClone
)
264 FIXME("STUB:(%p)\n", iface
);
268 static HRESULT WINAPI
Range_GetContext(ITfRangeACP
*iface
, ITfContext
**context
)
270 Range
*range
= impl_from_ITfRangeACP(iface
);
272 TRACE("%p, %p.\n", iface
, context
);
277 *context
= range
->context
;
278 ITfContext_AddRef(*context
);
283 static HRESULT WINAPI
Range_GetExtent(ITfRangeACP
*iface
, LONG
*anchor
, LONG
*count
)
285 FIXME("%p, %p, %p.\n", iface
, anchor
, count
);
290 static HRESULT WINAPI
Range_SetExtent(ITfRangeACP
*iface
, LONG anchor
, LONG count
)
292 FIXME("%p, %ld, %ld.\n", iface
, anchor
, count
);
297 static const ITfRangeACPVtbl rangevtbl
=
299 Range_QueryInterface
,
304 Range_GetFormattedText
,
306 Range_InsertEmbedded
,
309 Range_ShiftStartToRange
,
310 Range_ShiftEndToRange
,
311 Range_ShiftStartRegion
,
312 Range_ShiftEndRegion
,
319 Range_AdjustForInsert
,
328 HRESULT
Range_Constructor(ITfContext
*context
, DWORD anchorStart
, DWORD anchorEnd
, ITfRange
**ppOut
)
332 This
= calloc(1, sizeof(Range
));
334 return E_OUTOFMEMORY
;
336 TRACE("(%p) %p\n", This
, context
);
338 This
->ITfRangeACP_iface
.lpVtbl
= &rangevtbl
;
340 This
->context
= context
;
341 ITfContext_AddRef(This
->context
);
342 This
->anchorStart
= anchorStart
;
343 This
->anchorEnd
= anchorEnd
;
345 *ppOut
= (ITfRange
*)&This
->ITfRangeACP_iface
;
347 TRACE("returning %p\n", *ppOut
);
352 /* Internal conversion functions */
354 HRESULT
TF_SELECTION_to_TS_SELECTION_ACP(const TF_SELECTION
*tf
, TS_SELECTION_ACP
*tsAcp
)
358 if (!tf
|| !tsAcp
|| !tf
->range
)
361 This
= unsafe_impl_from_ITfRange(tf
->range
);
363 tsAcp
->acpStart
= This
->anchorStart
;
364 tsAcp
->acpEnd
= This
->anchorEnd
;
365 tsAcp
->style
.ase
= tf
->style
.ase
;
366 tsAcp
->style
.fInterimChar
= tf
->style
.fInterimChar
;