1c2c66affSColin Finck /*
2c2c66affSColin Finck * ITfContext implementation
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2009 Aric Stewart, CodeWeavers
5c2c66affSColin Finck *
6c2c66affSColin Finck * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck * License as published by the Free Software Foundation; either
9c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck *
11c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14c2c66affSColin Finck * Lesser General Public License for more details.
15c2c66affSColin Finck *
16c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck */
20c2c66affSColin Finck
21897e19b0SAmine Khaldi #include <stdarg.h>
22897e19b0SAmine Khaldi
23897e19b0SAmine Khaldi #define COBJMACROS
24897e19b0SAmine Khaldi
25897e19b0SAmine Khaldi #include "wine/debug.h"
26897e19b0SAmine Khaldi #include "windef.h"
27897e19b0SAmine Khaldi #include "winbase.h"
28897e19b0SAmine Khaldi #include "winreg.h"
29897e19b0SAmine Khaldi #include "winuser.h"
30897e19b0SAmine Khaldi #include "shlwapi.h"
31897e19b0SAmine Khaldi #include "winerror.h"
32897e19b0SAmine Khaldi #include "objbase.h"
33897e19b0SAmine Khaldi #include "olectl.h"
34897e19b0SAmine Khaldi
35897e19b0SAmine Khaldi #include "msctf.h"
36c2c66affSColin Finck #include "msctf_internal.h"
37c2c66affSColin Finck
38897e19b0SAmine Khaldi WINE_DEFAULT_DEBUG_CHANNEL(msctf);
39897e19b0SAmine Khaldi
40c2c66affSColin Finck typedef struct tagContext {
41c2c66affSColin Finck ITfContext ITfContext_iface;
42c2c66affSColin Finck ITfSource ITfSource_iface;
43c2c66affSColin Finck /* const ITfContextCompositionVtbl *ContextCompositionVtbl; */
44*ac50127eSAmine Khaldi ITfContextOwnerCompositionServices ITfContextOwnerCompositionServices_iface;
45c2c66affSColin Finck /* const ITfContextOwnerServicesVtbl *ContextOwnerServicesVtbl; */
46c2c66affSColin Finck ITfInsertAtSelection ITfInsertAtSelection_iface;
47c2c66affSColin Finck /* const ITfMouseTrackerVtbl *MouseTrackerVtbl; */
48c2c66affSColin Finck /* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */
49c2c66affSColin Finck ITfSourceSingle ITfSourceSingle_iface;
50c2c66affSColin Finck ITextStoreACPSink ITextStoreACPSink_iface;
51c2c66affSColin Finck ITextStoreACPServices ITextStoreACPServices_iface;
52c2c66affSColin Finck LONG refCount;
53c2c66affSColin Finck BOOL connected;
54c2c66affSColin Finck
55c2c66affSColin Finck /* Aggregation */
56c2c66affSColin Finck ITfCompartmentMgr *CompartmentMgr;
57c2c66affSColin Finck
58c2c66affSColin Finck TfClientId tidOwner;
59c2c66affSColin Finck TfEditCookie defaultCookie;
60c2c66affSColin Finck TS_STATUS documentStatus;
61c2c66affSColin Finck ITfDocumentMgr *manager;
62c2c66affSColin Finck
63c2c66affSColin Finck ITextStoreACP *pITextStoreACP;
64c2c66affSColin Finck ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink;
65c2c66affSColin Finck
66c2c66affSColin Finck ITfEditSession* currentEditSession;
67c2c66affSColin Finck
68c2c66affSColin Finck /* kept as separate lists to reduce unnecessary iterations */
69c2c66affSColin Finck struct list pContextKeyEventSink;
70c2c66affSColin Finck struct list pEditTransactionSink;
71c2c66affSColin Finck struct list pStatusSink;
72c2c66affSColin Finck struct list pTextEditSink;
73c2c66affSColin Finck struct list pTextLayoutSink;
74c2c66affSColin Finck
75c2c66affSColin Finck } Context;
76c2c66affSColin Finck
77c2c66affSColin Finck typedef struct tagEditCookie {
78c2c66affSColin Finck DWORD lockType;
79c2c66affSColin Finck Context *pOwningContext;
80c2c66affSColin Finck } EditCookie;
81c2c66affSColin Finck
impl_from_ITfContext(ITfContext * iface)82c2c66affSColin Finck static inline Context *impl_from_ITfContext(ITfContext *iface)
83c2c66affSColin Finck {
84c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITfContext_iface);
85c2c66affSColin Finck }
86c2c66affSColin Finck
impl_from_ITfSource(ITfSource * iface)87c2c66affSColin Finck static inline Context *impl_from_ITfSource(ITfSource *iface)
88c2c66affSColin Finck {
89c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITfSource_iface);
90c2c66affSColin Finck }
91c2c66affSColin Finck
impl_from_ITfContextOwnerCompositionServices(ITfContextOwnerCompositionServices * iface)92*ac50127eSAmine Khaldi static inline Context *impl_from_ITfContextOwnerCompositionServices(ITfContextOwnerCompositionServices *iface)
93*ac50127eSAmine Khaldi {
94*ac50127eSAmine Khaldi return CONTAINING_RECORD(iface, Context, ITfContextOwnerCompositionServices_iface);
95*ac50127eSAmine Khaldi }
96*ac50127eSAmine Khaldi
impl_from_ITfInsertAtSelection(ITfInsertAtSelection * iface)97c2c66affSColin Finck static inline Context *impl_from_ITfInsertAtSelection(ITfInsertAtSelection *iface)
98c2c66affSColin Finck {
99c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITfInsertAtSelection_iface);
100c2c66affSColin Finck }
101c2c66affSColin Finck
impl_from_ITfSourceSingle(ITfSourceSingle * iface)102c2c66affSColin Finck static inline Context *impl_from_ITfSourceSingle(ITfSourceSingle* iface)
103c2c66affSColin Finck {
104c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITfSourceSingle_iface);
105c2c66affSColin Finck }
106c2c66affSColin Finck
impl_from_ITextStoreACPSink(ITextStoreACPSink * iface)107c2c66affSColin Finck static inline Context *impl_from_ITextStoreACPSink(ITextStoreACPSink *iface)
108c2c66affSColin Finck {
109c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITextStoreACPSink_iface);
110c2c66affSColin Finck }
111c2c66affSColin Finck
impl_from_ITextStoreACPServices(ITextStoreACPServices * iface)112c2c66affSColin Finck static inline Context *impl_from_ITextStoreACPServices(ITextStoreACPServices *iface)
113c2c66affSColin Finck {
114c2c66affSColin Finck return CONTAINING_RECORD(iface, Context, ITextStoreACPServices_iface);
115c2c66affSColin Finck }
116c2c66affSColin Finck
Context_Destructor(Context * This)117c2c66affSColin Finck static void Context_Destructor(Context *This)
118c2c66affSColin Finck {
119c2c66affSColin Finck EditCookie *cookie;
120c2c66affSColin Finck TRACE("destroying %p\n", This);
121c2c66affSColin Finck
122c2c66affSColin Finck if (This->pITextStoreACP)
123c2c66affSColin Finck ITextStoreACP_Release(This->pITextStoreACP);
124c2c66affSColin Finck
125c2c66affSColin Finck if (This->pITfContextOwnerCompositionSink)
126c2c66affSColin Finck ITfContextOwnerCompositionSink_Release(This->pITfContextOwnerCompositionSink);
127c2c66affSColin Finck
128c2c66affSColin Finck if (This->defaultCookie)
129c2c66affSColin Finck {
130c2c66affSColin Finck cookie = remove_Cookie(This->defaultCookie);
131c2c66affSColin Finck HeapFree(GetProcessHeap(),0,cookie);
132c2c66affSColin Finck This->defaultCookie = 0;
133c2c66affSColin Finck }
134c2c66affSColin Finck
135c2c66affSColin Finck free_sinks(&This->pContextKeyEventSink);
136c2c66affSColin Finck free_sinks(&This->pEditTransactionSink);
137c2c66affSColin Finck free_sinks(&This->pStatusSink);
138c2c66affSColin Finck free_sinks(&This->pTextEditSink);
139c2c66affSColin Finck free_sinks(&This->pTextLayoutSink);
140c2c66affSColin Finck
141c2c66affSColin Finck CompartmentMgr_Destructor(This->CompartmentMgr);
142c2c66affSColin Finck HeapFree(GetProcessHeap(),0,This);
143c2c66affSColin Finck }
144c2c66affSColin Finck
Context_QueryInterface(ITfContext * iface,REFIID iid,LPVOID * ppvOut)145c2c66affSColin Finck static HRESULT WINAPI Context_QueryInterface(ITfContext *iface, REFIID iid, LPVOID *ppvOut)
146c2c66affSColin Finck {
147c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
148c2c66affSColin Finck *ppvOut = NULL;
149c2c66affSColin Finck
150c2c66affSColin Finck if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfContext))
151c2c66affSColin Finck {
152c2c66affSColin Finck *ppvOut = &This->ITfContext_iface;
153c2c66affSColin Finck }
154c2c66affSColin Finck else if (IsEqualIID(iid, &IID_ITfSource))
155c2c66affSColin Finck {
156c2c66affSColin Finck *ppvOut = &This->ITfSource_iface;
157c2c66affSColin Finck }
158*ac50127eSAmine Khaldi else if (IsEqualIID(iid, &IID_ITfContextOwnerCompositionServices))
159*ac50127eSAmine Khaldi {
160*ac50127eSAmine Khaldi *ppvOut = &This->ITfContextOwnerCompositionServices_iface;
161*ac50127eSAmine Khaldi }
162c2c66affSColin Finck else if (IsEqualIID(iid, &IID_ITfInsertAtSelection))
163c2c66affSColin Finck {
164c2c66affSColin Finck *ppvOut = &This->ITfInsertAtSelection_iface;
165c2c66affSColin Finck }
166c2c66affSColin Finck else if (IsEqualIID(iid, &IID_ITfCompartmentMgr))
167c2c66affSColin Finck {
168c2c66affSColin Finck *ppvOut = This->CompartmentMgr;
169c2c66affSColin Finck }
170c2c66affSColin Finck else if (IsEqualIID(iid, &IID_ITfSourceSingle))
171c2c66affSColin Finck {
172c2c66affSColin Finck *ppvOut = &This->ITfSourceSingle_iface;
173c2c66affSColin Finck }
174c2c66affSColin Finck
175c2c66affSColin Finck if (*ppvOut)
176c2c66affSColin Finck {
177c2c66affSColin Finck ITfContext_AddRef(iface);
178c2c66affSColin Finck return S_OK;
179c2c66affSColin Finck }
180c2c66affSColin Finck
181c2c66affSColin Finck WARN("unsupported interface: %s\n", debugstr_guid(iid));
182c2c66affSColin Finck return E_NOINTERFACE;
183c2c66affSColin Finck }
184c2c66affSColin Finck
Context_AddRef(ITfContext * iface)185c2c66affSColin Finck static ULONG WINAPI Context_AddRef(ITfContext *iface)
186c2c66affSColin Finck {
187c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
188c2c66affSColin Finck return InterlockedIncrement(&This->refCount);
189c2c66affSColin Finck }
190c2c66affSColin Finck
Context_Release(ITfContext * iface)191c2c66affSColin Finck static ULONG WINAPI Context_Release(ITfContext *iface)
192c2c66affSColin Finck {
193c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
194c2c66affSColin Finck ULONG ret;
195c2c66affSColin Finck
196c2c66affSColin Finck ret = InterlockedDecrement(&This->refCount);
197c2c66affSColin Finck if (ret == 0)
198c2c66affSColin Finck Context_Destructor(This);
199c2c66affSColin Finck return ret;
200c2c66affSColin Finck }
201c2c66affSColin Finck
202c2c66affSColin Finck /*****************************************************
203c2c66affSColin Finck * ITfContext functions
204c2c66affSColin Finck *****************************************************/
Context_RequestEditSession(ITfContext * iface,TfClientId tid,ITfEditSession * pes,DWORD dwFlags,HRESULT * phrSession)205c2c66affSColin Finck static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
206c2c66affSColin Finck TfClientId tid, ITfEditSession *pes, DWORD dwFlags,
207c2c66affSColin Finck HRESULT *phrSession)
208c2c66affSColin Finck {
209c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
210c2c66affSColin Finck HRESULT hr;
211c2c66affSColin Finck DWORD dwLockFlags = 0x0;
212c2c66affSColin Finck
213c2c66affSColin Finck TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession);
214c2c66affSColin Finck
215c2c66affSColin Finck if (!(dwFlags & TF_ES_READ) && !(dwFlags & TF_ES_READWRITE))
216c2c66affSColin Finck {
217c2c66affSColin Finck *phrSession = E_FAIL;
218c2c66affSColin Finck return E_INVALIDARG;
219c2c66affSColin Finck }
220c2c66affSColin Finck
221c2c66affSColin Finck if (!This->pITextStoreACP)
222c2c66affSColin Finck {
223c2c66affSColin Finck FIXME("No ITextStoreACP available\n");
224c2c66affSColin Finck *phrSession = E_FAIL;
225c2c66affSColin Finck return E_FAIL;
226c2c66affSColin Finck }
227c2c66affSColin Finck
228c2c66affSColin Finck if (!(dwFlags & TF_ES_ASYNC))
229c2c66affSColin Finck dwLockFlags |= TS_LF_SYNC;
230c2c66affSColin Finck
231c2c66affSColin Finck if ((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE)
232c2c66affSColin Finck dwLockFlags |= TS_LF_READWRITE;
233c2c66affSColin Finck else if (dwFlags & TF_ES_READ)
234c2c66affSColin Finck dwLockFlags |= TS_LF_READ;
235c2c66affSColin Finck
236c2c66affSColin Finck if (!This->documentStatus.dwDynamicFlags)
237c2c66affSColin Finck ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
238c2c66affSColin Finck
239c2c66affSColin Finck if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (This->documentStatus.dwDynamicFlags & TS_SD_READONLY))
240c2c66affSColin Finck {
241c2c66affSColin Finck *phrSession = TS_E_READONLY;
242c2c66affSColin Finck return S_OK;
243c2c66affSColin Finck }
244c2c66affSColin Finck
245c2c66affSColin Finck if (FAILED (ITfEditSession_QueryInterface(pes, &IID_ITfEditSession, (LPVOID*)&This->currentEditSession)))
246c2c66affSColin Finck {
247c2c66affSColin Finck *phrSession = E_FAIL;
248c2c66affSColin Finck return E_INVALIDARG;
249c2c66affSColin Finck }
250c2c66affSColin Finck
251c2c66affSColin Finck hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession);
252c2c66affSColin Finck
253c2c66affSColin Finck return hr;
254c2c66affSColin Finck }
255c2c66affSColin Finck
Context_InWriteSession(ITfContext * iface,TfClientId tid,BOOL * pfWriteSession)256c2c66affSColin Finck static HRESULT WINAPI Context_InWriteSession (ITfContext *iface,
257c2c66affSColin Finck TfClientId tid,
258c2c66affSColin Finck BOOL *pfWriteSession)
259c2c66affSColin Finck {
260c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
261c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
262c2c66affSColin Finck return E_NOTIMPL;
263c2c66affSColin Finck }
264c2c66affSColin Finck
Context_GetSelection(ITfContext * iface,TfEditCookie ec,ULONG ulIndex,ULONG ulCount,TF_SELECTION * pSelection,ULONG * pcFetched)265c2c66affSColin Finck static HRESULT WINAPI Context_GetSelection (ITfContext *iface,
266c2c66affSColin Finck TfEditCookie ec, ULONG ulIndex, ULONG ulCount,
267c2c66affSColin Finck TF_SELECTION *pSelection, ULONG *pcFetched)
268c2c66affSColin Finck {
269c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
270c2c66affSColin Finck EditCookie *cookie;
271c2c66affSColin Finck ULONG count, i;
272c2c66affSColin Finck ULONG totalFetched = 0;
273c2c66affSColin Finck HRESULT hr = S_OK;
274c2c66affSColin Finck
275c2c66affSColin Finck if (!pSelection || !pcFetched)
276c2c66affSColin Finck return E_INVALIDARG;
277c2c66affSColin Finck
278c2c66affSColin Finck *pcFetched = 0;
279c2c66affSColin Finck
280c2c66affSColin Finck if (!This->connected)
281c2c66affSColin Finck return TF_E_DISCONNECTED;
282c2c66affSColin Finck
283c2c66affSColin Finck if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE)
284c2c66affSColin Finck return TF_E_NOLOCK;
285c2c66affSColin Finck
286c2c66affSColin Finck if (!This->pITextStoreACP)
287c2c66affSColin Finck {
288c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
289c2c66affSColin Finck return E_NOTIMPL;
290c2c66affSColin Finck }
291c2c66affSColin Finck
292c2c66affSColin Finck cookie = get_Cookie_data(ec);
293c2c66affSColin Finck
294c2c66affSColin Finck if (ulIndex == TF_DEFAULT_SELECTION)
295c2c66affSColin Finck count = 1;
296c2c66affSColin Finck else
297c2c66affSColin Finck count = ulCount;
298c2c66affSColin Finck
299c2c66affSColin Finck for (i = 0; i < count; i++)
300c2c66affSColin Finck {
301c2c66affSColin Finck DWORD fetched;
302c2c66affSColin Finck TS_SELECTION_ACP acps;
303c2c66affSColin Finck
304c2c66affSColin Finck hr = ITextStoreACP_GetSelection(This->pITextStoreACP, ulIndex + i,
305c2c66affSColin Finck 1, &acps, &fetched);
306c2c66affSColin Finck
307c2c66affSColin Finck if (hr == TS_E_NOLOCK)
308c2c66affSColin Finck return TF_E_NOLOCK;
309c2c66affSColin Finck else if (SUCCEEDED(hr))
310c2c66affSColin Finck {
311c2c66affSColin Finck pSelection[totalFetched].style.ase = acps.style.ase;
312c2c66affSColin Finck pSelection[totalFetched].style.fInterimChar = acps.style.fInterimChar;
313c2c66affSColin Finck Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, acps.acpStart, acps.acpEnd, &pSelection[totalFetched].range);
314c2c66affSColin Finck totalFetched ++;
315c2c66affSColin Finck }
316c2c66affSColin Finck else
317c2c66affSColin Finck break;
318c2c66affSColin Finck }
319c2c66affSColin Finck
320c2c66affSColin Finck *pcFetched = totalFetched;
321c2c66affSColin Finck
322c2c66affSColin Finck return hr;
323c2c66affSColin Finck }
324c2c66affSColin Finck
Context_SetSelection(ITfContext * iface,TfEditCookie ec,ULONG ulCount,const TF_SELECTION * pSelection)325c2c66affSColin Finck static HRESULT WINAPI Context_SetSelection (ITfContext *iface,
326c2c66affSColin Finck TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
327c2c66affSColin Finck {
328c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
329c2c66affSColin Finck TS_SELECTION_ACP *acp;
330c2c66affSColin Finck ULONG i;
331c2c66affSColin Finck HRESULT hr;
332c2c66affSColin Finck
333c2c66affSColin Finck TRACE("(%p) %i %i %p\n",This,ec,ulCount,pSelection);
334c2c66affSColin Finck
335c2c66affSColin Finck if (!This->pITextStoreACP)
336c2c66affSColin Finck {
337c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
338c2c66affSColin Finck return E_NOTIMPL;
339c2c66affSColin Finck }
340c2c66affSColin Finck
341c2c66affSColin Finck if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE)
342c2c66affSColin Finck return TF_E_NOLOCK;
343c2c66affSColin Finck
344c2c66affSColin Finck acp = HeapAlloc(GetProcessHeap(), 0, sizeof(TS_SELECTION_ACP) * ulCount);
345c2c66affSColin Finck if (!acp)
346c2c66affSColin Finck return E_OUTOFMEMORY;
347c2c66affSColin Finck
348c2c66affSColin Finck for (i = 0; i < ulCount; i++)
349c2c66affSColin Finck if (FAILED(TF_SELECTION_to_TS_SELECTION_ACP(&pSelection[i], &acp[i])))
350c2c66affSColin Finck {
351c2c66affSColin Finck TRACE("Selection Conversion Failed\n");
352c2c66affSColin Finck HeapFree(GetProcessHeap(), 0 , acp);
353c2c66affSColin Finck return E_FAIL;
354c2c66affSColin Finck }
355c2c66affSColin Finck
356c2c66affSColin Finck hr = ITextStoreACP_SetSelection(This->pITextStoreACP, ulCount, acp);
357c2c66affSColin Finck
358c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, acp);
359c2c66affSColin Finck
360c2c66affSColin Finck return hr;
361c2c66affSColin Finck }
362c2c66affSColin Finck
Context_GetStart(ITfContext * iface,TfEditCookie ec,ITfRange ** ppStart)363c2c66affSColin Finck static HRESULT WINAPI Context_GetStart (ITfContext *iface,
364c2c66affSColin Finck TfEditCookie ec, ITfRange **ppStart)
365c2c66affSColin Finck {
366c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
367c2c66affSColin Finck EditCookie *cookie;
368c2c66affSColin Finck TRACE("(%p) %i %p\n",This,ec,ppStart);
369c2c66affSColin Finck
370c2c66affSColin Finck if (!ppStart)
371c2c66affSColin Finck return E_INVALIDARG;
372c2c66affSColin Finck
373c2c66affSColin Finck *ppStart = NULL;
374c2c66affSColin Finck
375c2c66affSColin Finck if (!This->connected)
376c2c66affSColin Finck return TF_E_DISCONNECTED;
377c2c66affSColin Finck
378c2c66affSColin Finck if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE)
379c2c66affSColin Finck return TF_E_NOLOCK;
380c2c66affSColin Finck
381c2c66affSColin Finck cookie = get_Cookie_data(ec);
382c2c66affSColin Finck return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, 0, 0, ppStart);
383c2c66affSColin Finck }
384c2c66affSColin Finck
Context_GetEnd(ITfContext * iface,TfEditCookie ec,ITfRange ** ppEnd)385c2c66affSColin Finck static HRESULT WINAPI Context_GetEnd (ITfContext *iface,
386c2c66affSColin Finck TfEditCookie ec, ITfRange **ppEnd)
387c2c66affSColin Finck {
388c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
389c2c66affSColin Finck EditCookie *cookie;
390c2c66affSColin Finck LONG end;
391c2c66affSColin Finck TRACE("(%p) %i %p\n",This,ec,ppEnd);
392c2c66affSColin Finck
393c2c66affSColin Finck if (!ppEnd)
394c2c66affSColin Finck return E_INVALIDARG;
395c2c66affSColin Finck
396c2c66affSColin Finck *ppEnd = NULL;
397c2c66affSColin Finck
398c2c66affSColin Finck if (!This->connected)
399c2c66affSColin Finck return TF_E_DISCONNECTED;
400c2c66affSColin Finck
401c2c66affSColin Finck if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE)
402c2c66affSColin Finck return TF_E_NOLOCK;
403c2c66affSColin Finck
404c2c66affSColin Finck if (!This->pITextStoreACP)
405c2c66affSColin Finck {
406c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
407c2c66affSColin Finck return E_NOTIMPL;
408c2c66affSColin Finck }
409c2c66affSColin Finck
410c2c66affSColin Finck cookie = get_Cookie_data(ec);
411c2c66affSColin Finck ITextStoreACP_GetEndACP(This->pITextStoreACP,&end);
412c2c66affSColin Finck
413c2c66affSColin Finck return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, end, end, ppEnd);
414c2c66affSColin Finck }
415c2c66affSColin Finck
Context_GetActiveView(ITfContext * iface,ITfContextView ** ppView)416c2c66affSColin Finck static HRESULT WINAPI Context_GetActiveView (ITfContext *iface,
417c2c66affSColin Finck ITfContextView **ppView)
418c2c66affSColin Finck {
419c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
420c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
421c2c66affSColin Finck return E_NOTIMPL;
422c2c66affSColin Finck }
423c2c66affSColin Finck
Context_EnumViews(ITfContext * iface,IEnumTfContextViews ** ppEnum)424c2c66affSColin Finck static HRESULT WINAPI Context_EnumViews (ITfContext *iface,
425c2c66affSColin Finck IEnumTfContextViews **ppEnum)
426c2c66affSColin Finck {
427c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
428c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
429c2c66affSColin Finck return E_NOTIMPL;
430c2c66affSColin Finck }
431c2c66affSColin Finck
Context_GetStatus(ITfContext * iface,TF_STATUS * pdcs)432c2c66affSColin Finck static HRESULT WINAPI Context_GetStatus (ITfContext *iface,
433c2c66affSColin Finck TF_STATUS *pdcs)
434c2c66affSColin Finck {
435c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
436c2c66affSColin Finck TRACE("(%p) %p\n",This,pdcs);
437c2c66affSColin Finck
438c2c66affSColin Finck if (!This->connected)
439c2c66affSColin Finck return TF_E_DISCONNECTED;
440c2c66affSColin Finck
441c2c66affSColin Finck if (!pdcs)
442c2c66affSColin Finck return E_INVALIDARG;
443c2c66affSColin Finck
444c2c66affSColin Finck if (!This->pITextStoreACP)
445c2c66affSColin Finck {
446c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
447c2c66affSColin Finck return E_NOTIMPL;
448c2c66affSColin Finck }
449c2c66affSColin Finck
450c2c66affSColin Finck ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
451c2c66affSColin Finck
452c2c66affSColin Finck *pdcs = This->documentStatus;
453c2c66affSColin Finck
454c2c66affSColin Finck return S_OK;
455c2c66affSColin Finck }
456c2c66affSColin Finck
Context_GetProperty(ITfContext * iface,REFGUID guidProp,ITfProperty ** ppProp)457c2c66affSColin Finck static HRESULT WINAPI Context_GetProperty (ITfContext *iface,
458c2c66affSColin Finck REFGUID guidProp, ITfProperty **ppProp)
459c2c66affSColin Finck {
460c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
461c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
462c2c66affSColin Finck return E_NOTIMPL;
463c2c66affSColin Finck }
464c2c66affSColin Finck
Context_GetAppProperty(ITfContext * iface,REFGUID guidProp,ITfReadOnlyProperty ** ppProp)465c2c66affSColin Finck static HRESULT WINAPI Context_GetAppProperty (ITfContext *iface,
466c2c66affSColin Finck REFGUID guidProp, ITfReadOnlyProperty **ppProp)
467c2c66affSColin Finck {
468c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
469c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
470c2c66affSColin Finck return E_NOTIMPL;
471c2c66affSColin Finck }
472c2c66affSColin Finck
Context_TrackProperties(ITfContext * iface,const GUID ** prgProp,ULONG cProp,const GUID ** prgAppProp,ULONG cAppProp,ITfReadOnlyProperty ** ppProperty)473c2c66affSColin Finck static HRESULT WINAPI Context_TrackProperties (ITfContext *iface,
474c2c66affSColin Finck const GUID **prgProp, ULONG cProp, const GUID **prgAppProp,
475c2c66affSColin Finck ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
476c2c66affSColin Finck {
477c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
478c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
479c2c66affSColin Finck return E_NOTIMPL;
480c2c66affSColin Finck }
481c2c66affSColin Finck
Context_EnumProperties(ITfContext * iface,IEnumTfProperties ** ppEnum)482c2c66affSColin Finck static HRESULT WINAPI Context_EnumProperties (ITfContext *iface,
483c2c66affSColin Finck IEnumTfProperties **ppEnum)
484c2c66affSColin Finck {
485c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
486c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
487c2c66affSColin Finck return E_NOTIMPL;
488c2c66affSColin Finck }
489c2c66affSColin Finck
Context_GetDocumentMgr(ITfContext * iface,ITfDocumentMgr ** ppDm)490c2c66affSColin Finck static HRESULT WINAPI Context_GetDocumentMgr (ITfContext *iface,
491c2c66affSColin Finck ITfDocumentMgr **ppDm)
492c2c66affSColin Finck {
493c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
494c2c66affSColin Finck TRACE("(%p) %p\n",This,ppDm);
495c2c66affSColin Finck
496c2c66affSColin Finck if (!ppDm)
497c2c66affSColin Finck return E_INVALIDARG;
498c2c66affSColin Finck
499c2c66affSColin Finck *ppDm = This->manager;
500c2c66affSColin Finck if (!This->manager)
501c2c66affSColin Finck return S_FALSE;
502c2c66affSColin Finck
503c2c66affSColin Finck ITfDocumentMgr_AddRef(This->manager);
504c2c66affSColin Finck
505c2c66affSColin Finck return S_OK;
506c2c66affSColin Finck }
507c2c66affSColin Finck
Context_CreateRangeBackup(ITfContext * iface,TfEditCookie ec,ITfRange * pRange,ITfRangeBackup ** ppBackup)508c2c66affSColin Finck static HRESULT WINAPI Context_CreateRangeBackup (ITfContext *iface,
509c2c66affSColin Finck TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
510c2c66affSColin Finck {
511c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
512c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
513c2c66affSColin Finck return E_NOTIMPL;
514c2c66affSColin Finck }
515c2c66affSColin Finck
516c2c66affSColin Finck static const ITfContextVtbl ContextVtbl =
517c2c66affSColin Finck {
518c2c66affSColin Finck Context_QueryInterface,
519c2c66affSColin Finck Context_AddRef,
520c2c66affSColin Finck Context_Release,
521c2c66affSColin Finck Context_RequestEditSession,
522c2c66affSColin Finck Context_InWriteSession,
523c2c66affSColin Finck Context_GetSelection,
524c2c66affSColin Finck Context_SetSelection,
525c2c66affSColin Finck Context_GetStart,
526c2c66affSColin Finck Context_GetEnd,
527c2c66affSColin Finck Context_GetActiveView,
528c2c66affSColin Finck Context_EnumViews,
529c2c66affSColin Finck Context_GetStatus,
530c2c66affSColin Finck Context_GetProperty,
531c2c66affSColin Finck Context_GetAppProperty,
532c2c66affSColin Finck Context_TrackProperties,
533c2c66affSColin Finck Context_EnumProperties,
534c2c66affSColin Finck Context_GetDocumentMgr,
535c2c66affSColin Finck Context_CreateRangeBackup
536c2c66affSColin Finck };
537c2c66affSColin Finck
538*ac50127eSAmine Khaldi /*****************************************************
539*ac50127eSAmine Khaldi * ITfSource functions
540*ac50127eSAmine Khaldi *****************************************************/
ContextSource_QueryInterface(ITfSource * iface,REFIID iid,LPVOID * ppvOut)541c2c66affSColin Finck static HRESULT WINAPI ContextSource_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
542c2c66affSColin Finck {
543c2c66affSColin Finck Context *This = impl_from_ITfSource(iface);
544c2c66affSColin Finck return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
545c2c66affSColin Finck }
546c2c66affSColin Finck
ContextSource_AddRef(ITfSource * iface)547c2c66affSColin Finck static ULONG WINAPI ContextSource_AddRef(ITfSource *iface)
548c2c66affSColin Finck {
549c2c66affSColin Finck Context *This = impl_from_ITfSource(iface);
550c2c66affSColin Finck return ITfContext_AddRef(&This->ITfContext_iface);
551c2c66affSColin Finck }
552c2c66affSColin Finck
ContextSource_Release(ITfSource * iface)553c2c66affSColin Finck static ULONG WINAPI ContextSource_Release(ITfSource *iface)
554c2c66affSColin Finck {
555c2c66affSColin Finck Context *This = impl_from_ITfSource(iface);
556c2c66affSColin Finck return ITfContext_Release(&This->ITfContext_iface);
557c2c66affSColin Finck }
558c2c66affSColin Finck
ContextSource_AdviseSink(ITfSource * iface,REFIID riid,IUnknown * punk,DWORD * pdwCookie)559c2c66affSColin Finck static HRESULT WINAPI ContextSource_AdviseSink(ITfSource *iface,
560c2c66affSColin Finck REFIID riid, IUnknown *punk, DWORD *pdwCookie)
561c2c66affSColin Finck {
562c2c66affSColin Finck Context *This = impl_from_ITfSource(iface);
563c2c66affSColin Finck
564c2c66affSColin Finck TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
565c2c66affSColin Finck
566c2c66affSColin Finck if (!riid || !punk || !pdwCookie)
567c2c66affSColin Finck return E_INVALIDARG;
568c2c66affSColin Finck
569c2c66affSColin Finck if (IsEqualIID(riid, &IID_ITfTextEditSink))
570c2c66affSColin Finck return advise_sink(&This->pTextEditSink, &IID_ITfTextEditSink, COOKIE_MAGIC_CONTEXTSINK, punk, pdwCookie);
571c2c66affSColin Finck
572c2c66affSColin Finck FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
573c2c66affSColin Finck return E_NOTIMPL;
574c2c66affSColin Finck }
575c2c66affSColin Finck
ContextSource_UnadviseSink(ITfSource * iface,DWORD pdwCookie)576c2c66affSColin Finck static HRESULT WINAPI ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
577c2c66affSColin Finck {
578c2c66affSColin Finck Context *This = impl_from_ITfSource(iface);
579c2c66affSColin Finck
580c2c66affSColin Finck TRACE("(%p) %x\n",This,pdwCookie);
581c2c66affSColin Finck
582c2c66affSColin Finck if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_CONTEXTSINK)
583c2c66affSColin Finck return E_INVALIDARG;
584c2c66affSColin Finck
585c2c66affSColin Finck return unadvise_sink(pdwCookie);
586c2c66affSColin Finck }
587c2c66affSColin Finck
588c2c66affSColin Finck static const ITfSourceVtbl ContextSourceVtbl =
589c2c66affSColin Finck {
590c2c66affSColin Finck ContextSource_QueryInterface,
591c2c66affSColin Finck ContextSource_AddRef,
592c2c66affSColin Finck ContextSource_Release,
593c2c66affSColin Finck ContextSource_AdviseSink,
594c2c66affSColin Finck ContextSource_UnadviseSink
595c2c66affSColin Finck };
596c2c66affSColin Finck
597c2c66affSColin Finck /*****************************************************
598*ac50127eSAmine Khaldi * ITfContextOwnerCompositionServices functions
599*ac50127eSAmine Khaldi *****************************************************/
ContextOwnerCompositionServices_QueryInterface(ITfContextOwnerCompositionServices * iface,REFIID iid,LPVOID * ppvOut)600*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_QueryInterface(ITfContextOwnerCompositionServices *iface,
601*ac50127eSAmine Khaldi REFIID iid, LPVOID *ppvOut)
602*ac50127eSAmine Khaldi {
603*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
604*ac50127eSAmine Khaldi return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
605*ac50127eSAmine Khaldi }
606*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_AddRef(ITfContextOwnerCompositionServices * iface)607*ac50127eSAmine Khaldi static ULONG WINAPI ContextOwnerCompositionServices_AddRef(ITfContextOwnerCompositionServices *iface)
608*ac50127eSAmine Khaldi {
609*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
610*ac50127eSAmine Khaldi return ITfContext_AddRef(&This->ITfContext_iface);
611*ac50127eSAmine Khaldi }
612*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_Release(ITfContextOwnerCompositionServices * iface)613*ac50127eSAmine Khaldi static ULONG WINAPI ContextOwnerCompositionServices_Release(ITfContextOwnerCompositionServices *iface)
614*ac50127eSAmine Khaldi {
615*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
616*ac50127eSAmine Khaldi return ITfContext_Release(&This->ITfContext_iface);
617*ac50127eSAmine Khaldi }
618*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_StartComposition(ITfContextOwnerCompositionServices * iface,TfEditCookie ecWrite,ITfRange * pCompositionRange,ITfCompositionSink * pSink,ITfComposition ** ppComposition)619*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_StartComposition(ITfContextOwnerCompositionServices *iface,
620*ac50127eSAmine Khaldi TfEditCookie ecWrite, ITfRange *pCompositionRange, ITfCompositionSink *pSink, ITfComposition **ppComposition)
621*ac50127eSAmine Khaldi {
622*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
623*ac50127eSAmine Khaldi FIXME("STUB:(%p) %#x %p %p %p\n", This, ecWrite, pCompositionRange, pSink, ppComposition);
624*ac50127eSAmine Khaldi return E_NOTIMPL;
625*ac50127eSAmine Khaldi }
626*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_EnumCompositions(ITfContextOwnerCompositionServices * iface,IEnumITfCompositionView ** ppEnum)627*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_EnumCompositions(ITfContextOwnerCompositionServices *iface,
628*ac50127eSAmine Khaldi IEnumITfCompositionView **ppEnum)
629*ac50127eSAmine Khaldi {
630*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
631*ac50127eSAmine Khaldi FIXME("STUB:(%p) %p\n", This, ppEnum);
632*ac50127eSAmine Khaldi return E_NOTIMPL;
633*ac50127eSAmine Khaldi }
634*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_FindComposition(ITfContextOwnerCompositionServices * iface,TfEditCookie ecRead,ITfRange * pTestRange,IEnumITfCompositionView ** ppEnum)635*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_FindComposition(ITfContextOwnerCompositionServices *iface,
636*ac50127eSAmine Khaldi TfEditCookie ecRead, ITfRange *pTestRange, IEnumITfCompositionView **ppEnum)
637*ac50127eSAmine Khaldi {
638*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
639*ac50127eSAmine Khaldi FIXME("STUB:(%p) %#x %p %p\n", This, ecRead, pTestRange, ppEnum);
640*ac50127eSAmine Khaldi return E_NOTIMPL;
641*ac50127eSAmine Khaldi }
642*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_TakeOwnership(ITfContextOwnerCompositionServices * iface,TfEditCookie ecWrite,ITfCompositionView * pComposition,ITfCompositionSink * pSink,ITfComposition ** ppComposition)643*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_TakeOwnership(ITfContextOwnerCompositionServices *iface,
644*ac50127eSAmine Khaldi TfEditCookie ecWrite, ITfCompositionView *pComposition, ITfCompositionSink *pSink, ITfComposition **ppComposition)
645*ac50127eSAmine Khaldi {
646*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
647*ac50127eSAmine Khaldi FIXME("STUB:(%p) %#x %p %p %p\n", This, ecWrite, pComposition, pSink, ppComposition);
648*ac50127eSAmine Khaldi return E_NOTIMPL;
649*ac50127eSAmine Khaldi }
650*ac50127eSAmine Khaldi
ContextOwnerCompositionServices_TerminateComposition(ITfContextOwnerCompositionServices * iface,ITfCompositionView * pComposition)651*ac50127eSAmine Khaldi static HRESULT WINAPI ContextOwnerCompositionServices_TerminateComposition(ITfContextOwnerCompositionServices *iface,
652*ac50127eSAmine Khaldi ITfCompositionView *pComposition)
653*ac50127eSAmine Khaldi {
654*ac50127eSAmine Khaldi Context *This = impl_from_ITfContextOwnerCompositionServices(iface);
655*ac50127eSAmine Khaldi FIXME("STUB:(%p) %p\n", This, pComposition);
656*ac50127eSAmine Khaldi return E_NOTIMPL;
657*ac50127eSAmine Khaldi }
658*ac50127eSAmine Khaldi
659*ac50127eSAmine Khaldi static const ITfContextOwnerCompositionServicesVtbl ContextOwnerCompositionServicesVtbl =
660*ac50127eSAmine Khaldi {
661*ac50127eSAmine Khaldi ContextOwnerCompositionServices_QueryInterface,
662*ac50127eSAmine Khaldi ContextOwnerCompositionServices_AddRef,
663*ac50127eSAmine Khaldi ContextOwnerCompositionServices_Release,
664*ac50127eSAmine Khaldi ContextOwnerCompositionServices_StartComposition,
665*ac50127eSAmine Khaldi ContextOwnerCompositionServices_EnumCompositions,
666*ac50127eSAmine Khaldi ContextOwnerCompositionServices_FindComposition,
667*ac50127eSAmine Khaldi ContextOwnerCompositionServices_TakeOwnership,
668*ac50127eSAmine Khaldi ContextOwnerCompositionServices_TerminateComposition
669*ac50127eSAmine Khaldi };
670*ac50127eSAmine Khaldi
671*ac50127eSAmine Khaldi /*****************************************************
672c2c66affSColin Finck * ITfInsertAtSelection functions
673c2c66affSColin Finck *****************************************************/
InsertAtSelection_QueryInterface(ITfInsertAtSelection * iface,REFIID iid,LPVOID * ppvOut)674c2c66affSColin Finck static HRESULT WINAPI InsertAtSelection_QueryInterface(ITfInsertAtSelection *iface, REFIID iid, LPVOID *ppvOut)
675c2c66affSColin Finck {
676c2c66affSColin Finck Context *This = impl_from_ITfInsertAtSelection(iface);
677c2c66affSColin Finck return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
678c2c66affSColin Finck }
679c2c66affSColin Finck
InsertAtSelection_AddRef(ITfInsertAtSelection * iface)680c2c66affSColin Finck static ULONG WINAPI InsertAtSelection_AddRef(ITfInsertAtSelection *iface)
681c2c66affSColin Finck {
682c2c66affSColin Finck Context *This = impl_from_ITfInsertAtSelection(iface);
683c2c66affSColin Finck return ITfContext_AddRef(&This->ITfContext_iface);
684c2c66affSColin Finck }
685c2c66affSColin Finck
InsertAtSelection_Release(ITfInsertAtSelection * iface)686c2c66affSColin Finck static ULONG WINAPI InsertAtSelection_Release(ITfInsertAtSelection *iface)
687c2c66affSColin Finck {
688c2c66affSColin Finck Context *This = impl_from_ITfInsertAtSelection(iface);
689c2c66affSColin Finck return ITfContext_Release(&This->ITfContext_iface);
690c2c66affSColin Finck }
691c2c66affSColin Finck
InsertAtSelection_InsertTextAtSelection(ITfInsertAtSelection * iface,TfEditCookie ec,DWORD dwFlags,const WCHAR * pchText,LONG cch,ITfRange ** ppRange)692c2c66affSColin Finck static HRESULT WINAPI InsertAtSelection_InsertTextAtSelection(
693c2c66affSColin Finck ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags,
694c2c66affSColin Finck const WCHAR *pchText, LONG cch, ITfRange **ppRange)
695c2c66affSColin Finck {
696c2c66affSColin Finck Context *This = impl_from_ITfInsertAtSelection(iface);
697c2c66affSColin Finck EditCookie *cookie;
698c2c66affSColin Finck LONG acpStart, acpEnd;
699c2c66affSColin Finck TS_TEXTCHANGE change;
700c2c66affSColin Finck HRESULT hr;
701c2c66affSColin Finck
702c2c66affSColin Finck TRACE("(%p) %i %x %s %p\n",This, ec, dwFlags, debugstr_wn(pchText,cch), ppRange);
703c2c66affSColin Finck
704c2c66affSColin Finck if (!This->connected)
705c2c66affSColin Finck return TF_E_DISCONNECTED;
706c2c66affSColin Finck
707c2c66affSColin Finck if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE)
708c2c66affSColin Finck return TF_E_NOLOCK;
709c2c66affSColin Finck
710c2c66affSColin Finck cookie = get_Cookie_data(ec);
711c2c66affSColin Finck
712c2c66affSColin Finck if ((cookie->lockType & TS_LF_READWRITE) != TS_LF_READWRITE )
713c2c66affSColin Finck return TS_E_READONLY;
714c2c66affSColin Finck
715c2c66affSColin Finck if (!This->pITextStoreACP)
716c2c66affSColin Finck {
717c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
718c2c66affSColin Finck return E_NOTIMPL;
719c2c66affSColin Finck }
720c2c66affSColin Finck
721c2c66affSColin Finck hr = ITextStoreACP_InsertTextAtSelection(This->pITextStoreACP, dwFlags, pchText, cch, &acpStart, &acpEnd, &change);
722c2c66affSColin Finck if (SUCCEEDED(hr))
723c2c66affSColin Finck Range_Constructor(&This->ITfContext_iface, This->pITextStoreACP, cookie->lockType, change.acpStart, change.acpNewEnd, ppRange);
724c2c66affSColin Finck
725c2c66affSColin Finck return hr;
726c2c66affSColin Finck }
727c2c66affSColin Finck
InsertAtSelection_InsertEmbeddedAtSelection(ITfInsertAtSelection * iface,TfEditCookie ec,DWORD dwFlags,IDataObject * pDataObject,ITfRange ** ppRange)728c2c66affSColin Finck static HRESULT WINAPI InsertAtSelection_InsertEmbeddedAtSelection(
729c2c66affSColin Finck ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags,
730c2c66affSColin Finck IDataObject *pDataObject, ITfRange **ppRange)
731c2c66affSColin Finck {
732c2c66affSColin Finck Context *This = impl_from_ITfInsertAtSelection(iface);
733c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
734c2c66affSColin Finck return E_NOTIMPL;
735c2c66affSColin Finck }
736c2c66affSColin Finck
737c2c66affSColin Finck static const ITfInsertAtSelectionVtbl InsertAtSelectionVtbl =
738c2c66affSColin Finck {
739c2c66affSColin Finck InsertAtSelection_QueryInterface,
740c2c66affSColin Finck InsertAtSelection_AddRef,
741c2c66affSColin Finck InsertAtSelection_Release,
742c2c66affSColin Finck InsertAtSelection_InsertTextAtSelection,
743c2c66affSColin Finck InsertAtSelection_InsertEmbeddedAtSelection,
744c2c66affSColin Finck };
745c2c66affSColin Finck
746c2c66affSColin Finck /*****************************************************
747c2c66affSColin Finck * ITfSourceSingle functions
748c2c66affSColin Finck *****************************************************/
SourceSingle_QueryInterface(ITfSourceSingle * iface,REFIID iid,LPVOID * ppvOut)749c2c66affSColin Finck static HRESULT WINAPI SourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut)
750c2c66affSColin Finck {
751c2c66affSColin Finck Context *This = impl_from_ITfSourceSingle(iface);
752c2c66affSColin Finck return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
753c2c66affSColin Finck }
754c2c66affSColin Finck
SourceSingle_AddRef(ITfSourceSingle * iface)755c2c66affSColin Finck static ULONG WINAPI SourceSingle_AddRef(ITfSourceSingle *iface)
756c2c66affSColin Finck {
757c2c66affSColin Finck Context *This = impl_from_ITfSourceSingle(iface);
758c2c66affSColin Finck return ITfContext_AddRef(&This->ITfContext_iface);
759c2c66affSColin Finck }
760c2c66affSColin Finck
SourceSingle_Release(ITfSourceSingle * iface)761c2c66affSColin Finck static ULONG WINAPI SourceSingle_Release(ITfSourceSingle *iface)
762c2c66affSColin Finck {
763c2c66affSColin Finck Context *This = impl_from_ITfSourceSingle(iface);
764c2c66affSColin Finck return ITfContext_Release(&This->ITfContext_iface);
765c2c66affSColin Finck }
766c2c66affSColin Finck
SourceSingle_AdviseSingleSink(ITfSourceSingle * iface,TfClientId tid,REFIID riid,IUnknown * punk)767c2c66affSColin Finck static HRESULT WINAPI SourceSingle_AdviseSingleSink( ITfSourceSingle *iface,
768c2c66affSColin Finck TfClientId tid, REFIID riid, IUnknown *punk)
769c2c66affSColin Finck {
770c2c66affSColin Finck Context *This = impl_from_ITfSourceSingle(iface);
771c2c66affSColin Finck FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk);
772c2c66affSColin Finck return E_NOTIMPL;
773c2c66affSColin Finck }
774c2c66affSColin Finck
SourceSingle_UnadviseSingleSink(ITfSourceSingle * iface,TfClientId tid,REFIID riid)775c2c66affSColin Finck static HRESULT WINAPI SourceSingle_UnadviseSingleSink( ITfSourceSingle *iface,
776c2c66affSColin Finck TfClientId tid, REFIID riid)
777c2c66affSColin Finck {
778c2c66affSColin Finck Context *This = impl_from_ITfSourceSingle(iface);
779c2c66affSColin Finck FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid));
780c2c66affSColin Finck return E_NOTIMPL;
781c2c66affSColin Finck }
782c2c66affSColin Finck
783c2c66affSColin Finck static const ITfSourceSingleVtbl ContextSourceSingleVtbl =
784c2c66affSColin Finck {
785c2c66affSColin Finck SourceSingle_QueryInterface,
786c2c66affSColin Finck SourceSingle_AddRef,
787c2c66affSColin Finck SourceSingle_Release,
788c2c66affSColin Finck SourceSingle_AdviseSingleSink,
789c2c66affSColin Finck SourceSingle_UnadviseSingleSink,
790c2c66affSColin Finck };
791c2c66affSColin Finck
792c2c66affSColin Finck /**************************************************************************
793c2c66affSColin Finck * ITextStoreACPSink
794c2c66affSColin Finck **************************************************************************/
795c2c66affSColin Finck
TextStoreACPSink_QueryInterface(ITextStoreACPSink * iface,REFIID iid,LPVOID * ppvOut)796c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_QueryInterface(ITextStoreACPSink *iface, REFIID iid, LPVOID *ppvOut)
797c2c66affSColin Finck {
798c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
799c2c66affSColin Finck
800c2c66affSColin Finck *ppvOut = NULL;
801c2c66affSColin Finck
802c2c66affSColin Finck if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITextStoreACPSink))
803c2c66affSColin Finck {
804c2c66affSColin Finck *ppvOut = &This->ITextStoreACPSink_iface;
805c2c66affSColin Finck }
806c2c66affSColin Finck else if (IsEqualIID(iid, &IID_ITextStoreACPServices))
807c2c66affSColin Finck *ppvOut = &This->ITextStoreACPServices_iface;
808c2c66affSColin Finck
809c2c66affSColin Finck if (*ppvOut)
810c2c66affSColin Finck {
811c2c66affSColin Finck ITextStoreACPSink_AddRef(iface);
812c2c66affSColin Finck return S_OK;
813c2c66affSColin Finck }
814c2c66affSColin Finck
815c2c66affSColin Finck WARN("unsupported interface: %s\n", debugstr_guid(iid));
816c2c66affSColin Finck return E_NOINTERFACE;
817c2c66affSColin Finck }
818c2c66affSColin Finck
TextStoreACPSink_AddRef(ITextStoreACPSink * iface)819c2c66affSColin Finck static ULONG WINAPI TextStoreACPSink_AddRef(ITextStoreACPSink *iface)
820c2c66affSColin Finck {
821c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
822c2c66affSColin Finck return ITfContext_AddRef(&This->ITfContext_iface);
823c2c66affSColin Finck }
824c2c66affSColin Finck
TextStoreACPSink_Release(ITextStoreACPSink * iface)825c2c66affSColin Finck static ULONG WINAPI TextStoreACPSink_Release(ITextStoreACPSink *iface)
826c2c66affSColin Finck {
827c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
828c2c66affSColin Finck return ITfContext_Release(&This->ITfContext_iface);
829c2c66affSColin Finck }
830c2c66affSColin Finck
831c2c66affSColin Finck /*****************************************************
832c2c66affSColin Finck * ITextStoreACPSink functions
833c2c66affSColin Finck *****************************************************/
834c2c66affSColin Finck
TextStoreACPSink_OnTextChange(ITextStoreACPSink * iface,DWORD dwFlags,const TS_TEXTCHANGE * pChange)835c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnTextChange(ITextStoreACPSink *iface,
836c2c66affSColin Finck DWORD dwFlags, const TS_TEXTCHANGE *pChange)
837c2c66affSColin Finck {
838c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
839c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
8404335e469SAmine Khaldi return S_OK;
841c2c66affSColin Finck }
842c2c66affSColin Finck
TextStoreACPSink_OnSelectionChange(ITextStoreACPSink * iface)843c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnSelectionChange(ITextStoreACPSink *iface)
844c2c66affSColin Finck {
845c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
846c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
8474335e469SAmine Khaldi return S_OK;
848c2c66affSColin Finck }
849c2c66affSColin Finck
TextStoreACPSink_OnLayoutChange(ITextStoreACPSink * iface,TsLayoutCode lcode,TsViewCookie vcView)850c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnLayoutChange(ITextStoreACPSink *iface,
851c2c66affSColin Finck TsLayoutCode lcode, TsViewCookie vcView)
852c2c66affSColin Finck {
853c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
854c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
8554335e469SAmine Khaldi return S_OK;
856c2c66affSColin Finck }
857c2c66affSColin Finck
TextStoreACPSink_OnStatusChange(ITextStoreACPSink * iface,DWORD dwFlags)858c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnStatusChange(ITextStoreACPSink *iface,
859c2c66affSColin Finck DWORD dwFlags)
860c2c66affSColin Finck {
861c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
862c2c66affSColin Finck HRESULT hr, hrSession;
863c2c66affSColin Finck
864c2c66affSColin Finck TRACE("(%p) %x\n",This, dwFlags);
865c2c66affSColin Finck
866c2c66affSColin Finck if (!This->pITextStoreACP)
867c2c66affSColin Finck {
868c2c66affSColin Finck FIXME("Context does not have a ITextStoreACP\n");
869c2c66affSColin Finck return E_NOTIMPL;
870c2c66affSColin Finck }
871c2c66affSColin Finck
872c2c66affSColin Finck hr = ITextStoreACP_RequestLock(This->pITextStoreACP, TS_LF_READ, &hrSession);
873c2c66affSColin Finck
874c2c66affSColin Finck if(SUCCEEDED(hr) && SUCCEEDED(hrSession))
875c2c66affSColin Finck This->documentStatus.dwDynamicFlags = dwFlags;
876c2c66affSColin Finck
877c2c66affSColin Finck return S_OK;
878c2c66affSColin Finck }
879c2c66affSColin Finck
TextStoreACPSink_OnAttrsChange(ITextStoreACPSink * iface,LONG acpStart,LONG acpEnd,ULONG cAttrs,const TS_ATTRID * paAttrs)880c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnAttrsChange(ITextStoreACPSink *iface,
881c2c66affSColin Finck LONG acpStart, LONG acpEnd, ULONG cAttrs, const TS_ATTRID *paAttrs)
882c2c66affSColin Finck {
883c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
884c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
885c2c66affSColin Finck return E_NOTIMPL;
886c2c66affSColin Finck }
887c2c66affSColin Finck
TextStoreACPSink_OnLockGranted(ITextStoreACPSink * iface,DWORD dwLockFlags)888c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface,
889c2c66affSColin Finck DWORD dwLockFlags)
890c2c66affSColin Finck {
891c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
892c2c66affSColin Finck HRESULT hr;
893c2c66affSColin Finck EditCookie *cookie,*sinkcookie;
894c2c66affSColin Finck TfEditCookie ec;
895c2c66affSColin Finck struct list *cursor;
896c2c66affSColin Finck
897c2c66affSColin Finck TRACE("(%p) %x\n",This, dwLockFlags);
898c2c66affSColin Finck
899c2c66affSColin Finck if (!This->currentEditSession)
900c2c66affSColin Finck {
901c2c66affSColin Finck FIXME("OnLockGranted called for something other than an EditSession\n");
902c2c66affSColin Finck return S_OK;
903c2c66affSColin Finck }
904c2c66affSColin Finck
905c2c66affSColin Finck cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
906c2c66affSColin Finck if (!cookie)
907c2c66affSColin Finck return E_OUTOFMEMORY;
908c2c66affSColin Finck
909c2c66affSColin Finck sinkcookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
910c2c66affSColin Finck if (!sinkcookie)
911c2c66affSColin Finck {
912c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, cookie);
913c2c66affSColin Finck return E_OUTOFMEMORY;
914c2c66affSColin Finck }
915c2c66affSColin Finck
916c2c66affSColin Finck cookie->lockType = dwLockFlags;
917c2c66affSColin Finck cookie->pOwningContext = This;
918c2c66affSColin Finck ec = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE, cookie);
919c2c66affSColin Finck
920c2c66affSColin Finck hr = ITfEditSession_DoEditSession(This->currentEditSession, ec);
921c2c66affSColin Finck
922c2c66affSColin Finck if ((dwLockFlags&TS_LF_READWRITE) == TS_LF_READWRITE)
923c2c66affSColin Finck {
924c2c66affSColin Finck ITfTextEditSink *sink;
925c2c66affSColin Finck TfEditCookie sc;
926c2c66affSColin Finck
927c2c66affSColin Finck sinkcookie->lockType = TS_LF_READ;
928c2c66affSColin Finck sinkcookie->pOwningContext = This;
929c2c66affSColin Finck sc = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE, sinkcookie);
930c2c66affSColin Finck
931c2c66affSColin Finck /*TODO: implement ITfEditRecord */
932c2c66affSColin Finck SINK_FOR_EACH(cursor, &This->pTextEditSink, ITfTextEditSink, sink)
933c2c66affSColin Finck {
934*ac50127eSAmine Khaldi ITfTextEditSink_OnEndEdit(sink, &This->ITfContext_iface, sc, NULL);
935c2c66affSColin Finck }
936c2c66affSColin Finck sinkcookie = remove_Cookie(sc);
937c2c66affSColin Finck }
938c2c66affSColin Finck HeapFree(GetProcessHeap(),0,sinkcookie);
939c2c66affSColin Finck
940c2c66affSColin Finck ITfEditSession_Release(This->currentEditSession);
941c2c66affSColin Finck This->currentEditSession = NULL;
942c2c66affSColin Finck
943c2c66affSColin Finck /* Edit Cookie is only valid during the edit session */
944c2c66affSColin Finck cookie = remove_Cookie(ec);
945c2c66affSColin Finck HeapFree(GetProcessHeap(),0,cookie);
946c2c66affSColin Finck
947c2c66affSColin Finck return hr;
948c2c66affSColin Finck }
949c2c66affSColin Finck
TextStoreACPSink_OnStartEditTransaction(ITextStoreACPSink * iface)950c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnStartEditTransaction(ITextStoreACPSink *iface)
951c2c66affSColin Finck {
952c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
953c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
954c2c66affSColin Finck return E_NOTIMPL;
955c2c66affSColin Finck }
956c2c66affSColin Finck
TextStoreACPSink_OnEndEditTransaction(ITextStoreACPSink * iface)957c2c66affSColin Finck static HRESULT WINAPI TextStoreACPSink_OnEndEditTransaction(ITextStoreACPSink *iface)
958c2c66affSColin Finck {
959c2c66affSColin Finck Context *This = impl_from_ITextStoreACPSink(iface);
960c2c66affSColin Finck FIXME("STUB:(%p)\n",This);
961c2c66affSColin Finck return E_NOTIMPL;
962c2c66affSColin Finck }
963c2c66affSColin Finck
964c2c66affSColin Finck static const ITextStoreACPSinkVtbl TextStoreACPSinkVtbl =
965c2c66affSColin Finck {
966c2c66affSColin Finck TextStoreACPSink_QueryInterface,
967c2c66affSColin Finck TextStoreACPSink_AddRef,
968c2c66affSColin Finck TextStoreACPSink_Release,
969c2c66affSColin Finck TextStoreACPSink_OnTextChange,
970c2c66affSColin Finck TextStoreACPSink_OnSelectionChange,
971c2c66affSColin Finck TextStoreACPSink_OnLayoutChange,
972c2c66affSColin Finck TextStoreACPSink_OnStatusChange,
973c2c66affSColin Finck TextStoreACPSink_OnAttrsChange,
974c2c66affSColin Finck TextStoreACPSink_OnLockGranted,
975c2c66affSColin Finck TextStoreACPSink_OnStartEditTransaction,
976c2c66affSColin Finck TextStoreACPSink_OnEndEditTransaction
977c2c66affSColin Finck };
978c2c66affSColin Finck
TextStoreACPServices_QueryInterface(ITextStoreACPServices * iface,REFIID riid,void ** obj)979c2c66affSColin Finck static HRESULT WINAPI TextStoreACPServices_QueryInterface(ITextStoreACPServices *iface, REFIID riid, void **obj)
980c2c66affSColin Finck {
981c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
982c2c66affSColin Finck return ITextStoreACPSink_QueryInterface(&This->ITextStoreACPSink_iface, riid, obj);
983c2c66affSColin Finck }
984c2c66affSColin Finck
TextStoreACPServices_AddRef(ITextStoreACPServices * iface)985c2c66affSColin Finck static ULONG WINAPI TextStoreACPServices_AddRef(ITextStoreACPServices *iface)
986c2c66affSColin Finck {
987c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
988c2c66affSColin Finck return ITextStoreACPSink_AddRef(&This->ITextStoreACPSink_iface);
989c2c66affSColin Finck }
990c2c66affSColin Finck
TextStoreACPServices_Release(ITextStoreACPServices * iface)991c2c66affSColin Finck static ULONG WINAPI TextStoreACPServices_Release(ITextStoreACPServices *iface)
992c2c66affSColin Finck {
993c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
994c2c66affSColin Finck return ITextStoreACPSink_Release(&This->ITextStoreACPSink_iface);
995c2c66affSColin Finck }
996c2c66affSColin Finck
TextStoreACPServices_Serialize(ITextStoreACPServices * iface,ITfProperty * prop,ITfRange * range,TF_PERSISTENT_PROPERTY_HEADER_ACP * header,IStream * stream)997c2c66affSColin Finck static HRESULT WINAPI TextStoreACPServices_Serialize(ITextStoreACPServices *iface, ITfProperty *prop, ITfRange *range,
998c2c66affSColin Finck TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream)
999c2c66affSColin Finck {
1000c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
1001c2c66affSColin Finck
1002c2c66affSColin Finck FIXME("stub: %p %p %p %p %p\n", This, prop, range, header, stream);
1003c2c66affSColin Finck
1004c2c66affSColin Finck return E_NOTIMPL;
1005c2c66affSColin Finck }
1006c2c66affSColin Finck
TextStoreACPServices_Unserialize(ITextStoreACPServices * iface,ITfProperty * prop,const TF_PERSISTENT_PROPERTY_HEADER_ACP * header,IStream * stream,ITfPersistentPropertyLoaderACP * loader)1007c2c66affSColin Finck static HRESULT WINAPI TextStoreACPServices_Unserialize(ITextStoreACPServices *iface, ITfProperty *prop,
1008c2c66affSColin Finck const TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream, ITfPersistentPropertyLoaderACP *loader)
1009c2c66affSColin Finck {
1010c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
1011c2c66affSColin Finck
1012c2c66affSColin Finck FIXME("stub: %p %p %p %p %p\n", This, prop, header, stream, loader);
1013c2c66affSColin Finck
1014c2c66affSColin Finck return E_NOTIMPL;
1015c2c66affSColin Finck }
1016c2c66affSColin Finck
TextStoreACPServices_ForceLoadProperty(ITextStoreACPServices * iface,ITfProperty * prop)1017c2c66affSColin Finck static HRESULT WINAPI TextStoreACPServices_ForceLoadProperty(ITextStoreACPServices *iface, ITfProperty *prop)
1018c2c66affSColin Finck {
1019c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
1020c2c66affSColin Finck
1021c2c66affSColin Finck FIXME("stub: %p %p\n", This, prop);
1022c2c66affSColin Finck
1023c2c66affSColin Finck return E_NOTIMPL;
1024c2c66affSColin Finck }
1025c2c66affSColin Finck
TextStoreACPServices_CreateRange(ITextStoreACPServices * iface,LONG start,LONG end,ITfRangeACP ** range)1026c2c66affSColin Finck static HRESULT WINAPI TextStoreACPServices_CreateRange(ITextStoreACPServices *iface,
1027c2c66affSColin Finck LONG start, LONG end, ITfRangeACP **range)
1028c2c66affSColin Finck {
1029c2c66affSColin Finck Context *This = impl_from_ITextStoreACPServices(iface);
1030c2c66affSColin Finck
1031c2c66affSColin Finck FIXME("stub: %p %d %d %p\n", This, start, end, range);
1032c2c66affSColin Finck
1033c2c66affSColin Finck return S_OK;
1034c2c66affSColin Finck }
1035c2c66affSColin Finck
1036c2c66affSColin Finck static const ITextStoreACPServicesVtbl TextStoreACPServicesVtbl =
1037c2c66affSColin Finck {
1038c2c66affSColin Finck TextStoreACPServices_QueryInterface,
1039c2c66affSColin Finck TextStoreACPServices_AddRef,
1040c2c66affSColin Finck TextStoreACPServices_Release,
1041c2c66affSColin Finck TextStoreACPServices_Serialize,
1042c2c66affSColin Finck TextStoreACPServices_Unserialize,
1043c2c66affSColin Finck TextStoreACPServices_ForceLoadProperty,
1044c2c66affSColin Finck TextStoreACPServices_CreateRange
1045c2c66affSColin Finck };
1046c2c66affSColin Finck
Context_Constructor(TfClientId tidOwner,IUnknown * punk,ITfDocumentMgr * mgr,ITfContext ** ppOut,TfEditCookie * pecTextStore)1047c2c66affSColin Finck HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfDocumentMgr *mgr, ITfContext **ppOut, TfEditCookie *pecTextStore)
1048c2c66affSColin Finck {
1049c2c66affSColin Finck Context *This;
1050c2c66affSColin Finck EditCookie *cookie;
1051c2c66affSColin Finck
1052c2c66affSColin Finck This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Context));
1053c2c66affSColin Finck if (This == NULL)
1054c2c66affSColin Finck return E_OUTOFMEMORY;
1055c2c66affSColin Finck
1056c2c66affSColin Finck cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
1057c2c66affSColin Finck if (cookie == NULL)
1058c2c66affSColin Finck {
1059c2c66affSColin Finck HeapFree(GetProcessHeap(),0,This);
1060c2c66affSColin Finck return E_OUTOFMEMORY;
1061c2c66affSColin Finck }
1062c2c66affSColin Finck
1063c2c66affSColin Finck TRACE("(%p) %x %p %p %p\n",This, tidOwner, punk, ppOut, pecTextStore);
1064c2c66affSColin Finck
1065c2c66affSColin Finck This->ITfContext_iface.lpVtbl= &ContextVtbl;
1066c2c66affSColin Finck This->ITfSource_iface.lpVtbl = &ContextSourceVtbl;
1067*ac50127eSAmine Khaldi This->ITfContextOwnerCompositionServices_iface.lpVtbl = &ContextOwnerCompositionServicesVtbl;
1068c2c66affSColin Finck This->ITfInsertAtSelection_iface.lpVtbl = &InsertAtSelectionVtbl;
1069c2c66affSColin Finck This->ITfSourceSingle_iface.lpVtbl = &ContextSourceSingleVtbl;
1070c2c66affSColin Finck This->ITextStoreACPSink_iface.lpVtbl = &TextStoreACPSinkVtbl;
1071c2c66affSColin Finck This->ITextStoreACPServices_iface.lpVtbl = &TextStoreACPServicesVtbl;
1072c2c66affSColin Finck This->refCount = 1;
1073c2c66affSColin Finck This->tidOwner = tidOwner;
1074c2c66affSColin Finck This->connected = FALSE;
1075c2c66affSColin Finck This->manager = mgr;
1076c2c66affSColin Finck
1077c2c66affSColin Finck CompartmentMgr_Constructor((IUnknown*)&This->ITfContext_iface, &IID_IUnknown, (IUnknown**)&This->CompartmentMgr);
1078c2c66affSColin Finck
1079c2c66affSColin Finck cookie->lockType = TF_ES_READ;
1080c2c66affSColin Finck cookie->pOwningContext = This;
1081c2c66affSColin Finck
1082c2c66affSColin Finck if (punk)
1083c2c66affSColin Finck {
1084c2c66affSColin Finck IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
1085c2c66affSColin Finck (LPVOID*)&This->pITextStoreACP);
1086c2c66affSColin Finck
1087c2c66affSColin Finck IUnknown_QueryInterface(punk, &IID_ITfContextOwnerCompositionSink,
1088c2c66affSColin Finck (LPVOID*)&This->pITfContextOwnerCompositionSink);
1089c2c66affSColin Finck
1090c2c66affSColin Finck if (!This->pITextStoreACP && !This->pITfContextOwnerCompositionSink)
1091c2c66affSColin Finck FIXME("Unhandled pUnk\n");
1092c2c66affSColin Finck }
1093c2c66affSColin Finck
1094c2c66affSColin Finck This->defaultCookie = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE,cookie);
1095c2c66affSColin Finck *pecTextStore = This->defaultCookie;
1096c2c66affSColin Finck
1097c2c66affSColin Finck list_init(&This->pContextKeyEventSink);
1098c2c66affSColin Finck list_init(&This->pEditTransactionSink);
1099c2c66affSColin Finck list_init(&This->pStatusSink);
1100c2c66affSColin Finck list_init(&This->pTextEditSink);
1101c2c66affSColin Finck list_init(&This->pTextLayoutSink);
1102c2c66affSColin Finck
1103c2c66affSColin Finck *ppOut = &This->ITfContext_iface;
1104c2c66affSColin Finck TRACE("returning %p\n", *ppOut);
1105c2c66affSColin Finck
1106c2c66affSColin Finck return S_OK;
1107c2c66affSColin Finck }
1108c2c66affSColin Finck
Context_Initialize(ITfContext * iface,ITfDocumentMgr * manager)1109c2c66affSColin Finck HRESULT Context_Initialize(ITfContext *iface, ITfDocumentMgr *manager)
1110c2c66affSColin Finck {
1111c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
1112c2c66affSColin Finck
1113c2c66affSColin Finck if (This->pITextStoreACP)
1114c2c66affSColin Finck ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink,
1115c2c66affSColin Finck (IUnknown*)&This->ITextStoreACPSink_iface, TS_AS_ALL_SINKS);
1116c2c66affSColin Finck This->connected = TRUE;
1117c2c66affSColin Finck This->manager = manager;
1118c2c66affSColin Finck return S_OK;
1119c2c66affSColin Finck }
1120c2c66affSColin Finck
Context_Uninitialize(ITfContext * iface)1121c2c66affSColin Finck HRESULT Context_Uninitialize(ITfContext *iface)
1122c2c66affSColin Finck {
1123c2c66affSColin Finck Context *This = impl_from_ITfContext(iface);
1124c2c66affSColin Finck
1125c2c66affSColin Finck if (This->pITextStoreACP)
1126c2c66affSColin Finck ITextStoreACP_UnadviseSink(This->pITextStoreACP, (IUnknown*)&This->ITextStoreACPSink_iface);
1127c2c66affSColin Finck This->connected = FALSE;
1128c2c66affSColin Finck This->manager = NULL;
1129c2c66affSColin Finck return S_OK;
1130c2c66affSColin Finck }
1131