ReactOS 0.4.15-dev-7931-gfd331f1
context.c
Go to the documentation of this file.
1/*
2 * ITfContext implementation
3 *
4 * Copyright 2009 Aric Stewart, CodeWeavers
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include <stdarg.h>
22
23#define COBJMACROS
24
25#include "wine/debug.h"
26#include "windef.h"
27#include "winbase.h"
28#include "winreg.h"
29#include "winuser.h"
30#include "shlwapi.h"
31#include "winerror.h"
32#include "objbase.h"
33#include "olectl.h"
34
35#include "msctf.h"
36#include "msctf_internal.h"
37
39
40typedef struct tagContext {
43 /* const ITfContextCompositionVtbl *ContextCompositionVtbl; */
45 /* const ITfContextOwnerServicesVtbl *ContextOwnerServicesVtbl; */
47 /* const ITfMouseTrackerVtbl *MouseTrackerVtbl; */
48 /* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */
54
55 /* Aggregation */
57
62
65
67
68 /* kept as separate lists to reduce unnecessary iterations */
74
75} Context;
76
77typedef struct tagEditCookie {
81
83{
84 return CONTAINING_RECORD(iface, Context, ITfContext_iface);
85}
86
88{
89 return CONTAINING_RECORD(iface, Context, ITfSource_iface);
90}
91
93{
94 return CONTAINING_RECORD(iface, Context, ITfContextOwnerCompositionServices_iface);
95}
96
98{
99 return CONTAINING_RECORD(iface, Context, ITfInsertAtSelection_iface);
100}
101
103{
104 return CONTAINING_RECORD(iface, Context, ITfSourceSingle_iface);
105}
106
108{
109 return CONTAINING_RECORD(iface, Context, ITextStoreACPSink_iface);
110}
111
113{
114 return CONTAINING_RECORD(iface, Context, ITextStoreACPServices_iface);
115}
116
118{
120 TRACE("destroying %p\n", This);
121
122 if (This->pITextStoreACP)
123 ITextStoreACP_Release(This->pITextStoreACP);
124
125 if (This->pITfContextOwnerCompositionSink)
126 ITfContextOwnerCompositionSink_Release(This->pITfContextOwnerCompositionSink);
127
128 if (This->defaultCookie)
129 {
130 cookie = remove_Cookie(This->defaultCookie);
132 This->defaultCookie = 0;
133 }
134
135 free_sinks(&This->pContextKeyEventSink);
136 free_sinks(&This->pEditTransactionSink);
137 free_sinks(&This->pStatusSink);
138 free_sinks(&This->pTextEditSink);
139 free_sinks(&This->pTextLayoutSink);
140
141 CompartmentMgr_Destructor(This->CompartmentMgr);
143}
144
146{
148 *ppvOut = NULL;
149
150 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfContext))
151 {
152 *ppvOut = &This->ITfContext_iface;
153 }
154 else if (IsEqualIID(iid, &IID_ITfSource))
155 {
156 *ppvOut = &This->ITfSource_iface;
157 }
158 else if (IsEqualIID(iid, &IID_ITfContextOwnerCompositionServices))
159 {
160 *ppvOut = &This->ITfContextOwnerCompositionServices_iface;
161 }
162 else if (IsEqualIID(iid, &IID_ITfInsertAtSelection))
163 {
164 *ppvOut = &This->ITfInsertAtSelection_iface;
165 }
166 else if (IsEqualIID(iid, &IID_ITfCompartmentMgr))
167 {
168 *ppvOut = This->CompartmentMgr;
169 }
170 else if (IsEqualIID(iid, &IID_ITfSourceSingle))
171 {
172 *ppvOut = &This->ITfSourceSingle_iface;
173 }
174
175 if (*ppvOut)
176 {
177 ITfContext_AddRef(iface);
178 return S_OK;
179 }
180
181 WARN("unsupported interface: %s\n", debugstr_guid(iid));
182 return E_NOINTERFACE;
183}
184
186{
188 return InterlockedIncrement(&This->refCount);
189}
190
192{
194 ULONG ret;
195
196 ret = InterlockedDecrement(&This->refCount);
197 if (ret == 0)
199 return ret;
200}
201
202/*****************************************************
203 * ITfContext functions
204 *****************************************************/
207 HRESULT *phrSession)
208{
210 HRESULT hr;
211 DWORD dwLockFlags = 0x0;
212
213 TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession);
214
215 if (!(dwFlags & TF_ES_READ) && !(dwFlags & TF_ES_READWRITE))
216 {
217 *phrSession = E_FAIL;
218 return E_INVALIDARG;
219 }
220
221 if (!This->pITextStoreACP)
222 {
223 FIXME("No ITextStoreACP available\n");
224 *phrSession = E_FAIL;
225 return E_FAIL;
226 }
227
228 if (!(dwFlags & TF_ES_ASYNC))
229 dwLockFlags |= TS_LF_SYNC;
230
231 if ((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE)
232 dwLockFlags |= TS_LF_READWRITE;
233 else if (dwFlags & TF_ES_READ)
234 dwLockFlags |= TS_LF_READ;
235
236 if (!This->documentStatus.dwDynamicFlags)
237 ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
238
239 if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (This->documentStatus.dwDynamicFlags & TS_SD_READONLY))
240 {
241 *phrSession = TS_E_READONLY;
242 return S_OK;
243 }
244
245 if (FAILED (ITfEditSession_QueryInterface(pes, &IID_ITfEditSession, (LPVOID*)&This->currentEditSession)))
246 {
247 *phrSession = E_FAIL;
248 return E_INVALIDARG;
249 }
250
251 hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession);
252
253 return hr;
254}
255
258 BOOL *pfWriteSession)
259{
261 FIXME("STUB:(%p)\n",This);
262 return E_NOTIMPL;
263}
264
266 TfEditCookie ec, ULONG ulIndex, ULONG ulCount,
267 TF_SELECTION *pSelection, ULONG *pcFetched)
268{
271 ULONG count, i;
272 ULONG totalFetched = 0;
273 HRESULT hr = S_OK;
274
275 if (!pSelection || !pcFetched)
276 return E_INVALIDARG;
277
278 *pcFetched = 0;
279
280 if (!This->connected)
281 return TF_E_DISCONNECTED;
282
284 return TF_E_NOLOCK;
285
286 if (!This->pITextStoreACP)
287 {
288 FIXME("Context does not have a ITextStoreACP\n");
289 return E_NOTIMPL;
290 }
291
293
294 if (ulIndex == TF_DEFAULT_SELECTION)
295 count = 1;
296 else
297 count = ulCount;
298
299 for (i = 0; i < count; i++)
300 {
301 DWORD fetched;
302 TS_SELECTION_ACP acps;
303
304 hr = ITextStoreACP_GetSelection(This->pITextStoreACP, ulIndex + i,
305 1, &acps, &fetched);
306
307 if (hr == TS_E_NOLOCK)
308 return TF_E_NOLOCK;
309 else if (SUCCEEDED(hr))
310 {
311 pSelection[totalFetched].style.ase = acps.style.ase;
312 pSelection[totalFetched].style.fInterimChar = acps.style.fInterimChar;
313 Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, acps.acpStart, acps.acpEnd, &pSelection[totalFetched].range);
314 totalFetched ++;
315 }
316 else
317 break;
318 }
319
320 *pcFetched = totalFetched;
321
322 return hr;
323}
324
326 TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
327{
329 TS_SELECTION_ACP *acp;
330 ULONG i;
331 HRESULT hr;
332
333 TRACE("(%p) %i %i %p\n",This,ec,ulCount,pSelection);
334
335 if (!This->pITextStoreACP)
336 {
337 FIXME("Context does not have a ITextStoreACP\n");
338 return E_NOTIMPL;
339 }
340
342 return TF_E_NOLOCK;
343
344 acp = HeapAlloc(GetProcessHeap(), 0, sizeof(TS_SELECTION_ACP) * ulCount);
345 if (!acp)
346 return E_OUTOFMEMORY;
347
348 for (i = 0; i < ulCount; i++)
349 if (FAILED(TF_SELECTION_to_TS_SELECTION_ACP(&pSelection[i], &acp[i])))
350 {
351 TRACE("Selection Conversion Failed\n");
352 HeapFree(GetProcessHeap(), 0 , acp);
353 return E_FAIL;
354 }
355
356 hr = ITextStoreACP_SetSelection(This->pITextStoreACP, ulCount, acp);
357
358 HeapFree(GetProcessHeap(), 0, acp);
359
360 return hr;
361}
362
364 TfEditCookie ec, ITfRange **ppStart)
365{
368 TRACE("(%p) %i %p\n",This,ec,ppStart);
369
370 if (!ppStart)
371 return E_INVALIDARG;
372
373 *ppStart = NULL;
374
375 if (!This->connected)
376 return TF_E_DISCONNECTED;
377
379 return TF_E_NOLOCK;
380
382 return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, 0, 0, ppStart);
383}
384
386 TfEditCookie ec, ITfRange **ppEnd)
387{
390 LONG end;
391 TRACE("(%p) %i %p\n",This,ec,ppEnd);
392
393 if (!ppEnd)
394 return E_INVALIDARG;
395
396 *ppEnd = NULL;
397
398 if (!This->connected)
399 return TF_E_DISCONNECTED;
400
402 return TF_E_NOLOCK;
403
404 if (!This->pITextStoreACP)
405 {
406 FIXME("Context does not have a ITextStoreACP\n");
407 return E_NOTIMPL;
408 }
409
411 ITextStoreACP_GetEndACP(This->pITextStoreACP,&end);
412
413 return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, end, end, ppEnd);
414}
415
417 ITfContextView **ppView)
418{
420 FIXME("STUB:(%p)\n",This);
421 return E_NOTIMPL;
422}
423
425 IEnumTfContextViews **ppEnum)
426{
428 FIXME("STUB:(%p)\n",This);
429 return E_NOTIMPL;
430}
431
433 TF_STATUS *pdcs)
434{
436 TRACE("(%p) %p\n",This,pdcs);
437
438 if (!This->connected)
439 return TF_E_DISCONNECTED;
440
441 if (!pdcs)
442 return E_INVALIDARG;
443
444 if (!This->pITextStoreACP)
445 {
446 FIXME("Context does not have a ITextStoreACP\n");
447 return E_NOTIMPL;
448 }
449
450 ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
451
452 *pdcs = This->documentStatus;
453
454 return S_OK;
455}
456
458 REFGUID guidProp, ITfProperty **ppProp)
459{
461 FIXME("STUB:(%p)\n",This);
462 return E_NOTIMPL;
463}
464
466 REFGUID guidProp, ITfReadOnlyProperty **ppProp)
467{
469 FIXME("STUB:(%p)\n",This);
470 return E_NOTIMPL;
471}
472
474 const GUID **prgProp, ULONG cProp, const GUID **prgAppProp,
475 ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
476{
478 FIXME("STUB:(%p)\n",This);
479 return E_NOTIMPL;
480}
481
483 IEnumTfProperties **ppEnum)
484{
486 FIXME("STUB:(%p)\n",This);
487 return E_NOTIMPL;
488}
489
491 ITfDocumentMgr **ppDm)
492{
494 TRACE("(%p) %p\n",This,ppDm);
495
496 if (!ppDm)
497 return E_INVALIDARG;
498
499 *ppDm = This->manager;
500 if (!This->manager)
501 return S_FALSE;
502
503 ITfDocumentMgr_AddRef(This->manager);
504
505 return S_OK;
506}
507
509 TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
510{
512 FIXME("STUB:(%p)\n",This);
513 return E_NOTIMPL;
514}
515
516static const ITfContextVtbl ContextVtbl =
517{
536};
537
538/*****************************************************
539 * ITfSource functions
540 *****************************************************/
542{
544 return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
545}
546
548{
550 return ITfContext_AddRef(&This->ITfContext_iface);
551}
552
554{
556 return ITfContext_Release(&This->ITfContext_iface);
557}
558
560 REFIID riid, IUnknown *punk, DWORD *pdwCookie)
561{
563
564 TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
565
566 if (!riid || !punk || !pdwCookie)
567 return E_INVALIDARG;
568
569 if (IsEqualIID(riid, &IID_ITfTextEditSink))
570 return advise_sink(&This->pTextEditSink, &IID_ITfTextEditSink, COOKIE_MAGIC_CONTEXTSINK, punk, pdwCookie);
571
572 FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
573 return E_NOTIMPL;
574}
575
577{
579
580 TRACE("(%p) %x\n",This,pdwCookie);
581
583 return E_INVALIDARG;
584
585 return unadvise_sink(pdwCookie);
586}
587
588static const ITfSourceVtbl ContextSourceVtbl =
589{
595};
596
597/*****************************************************
598 * ITfContextOwnerCompositionServices functions
599 *****************************************************/
601 REFIID iid, LPVOID *ppvOut)
602{
604 return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
605}
606
608{
610 return ITfContext_AddRef(&This->ITfContext_iface);
611}
612
614{
616 return ITfContext_Release(&This->ITfContext_iface);
617}
618
620 TfEditCookie ecWrite, ITfRange *pCompositionRange, ITfCompositionSink *pSink, ITfComposition **ppComposition)
621{
623 FIXME("STUB:(%p) %#x %p %p %p\n", This, ecWrite, pCompositionRange, pSink, ppComposition);
624 return E_NOTIMPL;
625}
626
629{
631 FIXME("STUB:(%p) %p\n", This, ppEnum);
632 return E_NOTIMPL;
633}
634
636 TfEditCookie ecRead, ITfRange *pTestRange, IEnumITfCompositionView **ppEnum)
637{
639 FIXME("STUB:(%p) %#x %p %p\n", This, ecRead, pTestRange, ppEnum);
640 return E_NOTIMPL;
641}
642
644 TfEditCookie ecWrite, ITfCompositionView *pComposition, ITfCompositionSink *pSink, ITfComposition **ppComposition)
645{
647 FIXME("STUB:(%p) %#x %p %p %p\n", This, ecWrite, pComposition, pSink, ppComposition);
648 return E_NOTIMPL;
649}
650
652 ITfCompositionView *pComposition)
653{
655 FIXME("STUB:(%p) %p\n", This, pComposition);
656 return E_NOTIMPL;
657}
658
659static const ITfContextOwnerCompositionServicesVtbl ContextOwnerCompositionServicesVtbl =
660{
669};
670
671/*****************************************************
672 * ITfInsertAtSelection functions
673 *****************************************************/
675{
677 return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
678}
679
681{
683 return ITfContext_AddRef(&This->ITfContext_iface);
684}
685
687{
689 return ITfContext_Release(&This->ITfContext_iface);
690}
691
694 const WCHAR *pchText, LONG cch, ITfRange **ppRange)
695{
698 LONG acpStart, acpEnd;
699 TS_TEXTCHANGE change;
700 HRESULT hr;
701
702 TRACE("(%p) %i %x %s %p\n",This, ec, dwFlags, debugstr_wn(pchText,cch), ppRange);
703
704 if (!This->connected)
705 return TF_E_DISCONNECTED;
706
708 return TF_E_NOLOCK;
709
711
712 if ((cookie->lockType & TS_LF_READWRITE) != TS_LF_READWRITE )
713 return TS_E_READONLY;
714
715 if (!This->pITextStoreACP)
716 {
717 FIXME("Context does not have a ITextStoreACP\n");
718 return E_NOTIMPL;
719 }
720
721 hr = ITextStoreACP_InsertTextAtSelection(This->pITextStoreACP, dwFlags, pchText, cch, &acpStart, &acpEnd, &change);
722 if (SUCCEEDED(hr))
723 Range_Constructor(&This->ITfContext_iface, This->pITextStoreACP, cookie->lockType, change.acpStart, change.acpNewEnd, ppRange);
724
725 return hr;
726}
727
730 IDataObject *pDataObject, ITfRange **ppRange)
731{
733 FIXME("STUB:(%p)\n",This);
734 return E_NOTIMPL;
735}
736
737static const ITfInsertAtSelectionVtbl InsertAtSelectionVtbl =
738{
744};
745
746/*****************************************************
747 * ITfSourceSingle functions
748 *****************************************************/
750{
752 return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
753}
754
756{
758 return ITfContext_AddRef(&This->ITfContext_iface);
759}
760
762{
764 return ITfContext_Release(&This->ITfContext_iface);
765}
766
769{
771 FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk);
772 return E_NOTIMPL;
773}
774
777{
779 FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid));
780 return E_NOTIMPL;
781}
782
783static const ITfSourceSingleVtbl ContextSourceSingleVtbl =
784{
790};
791
792/**************************************************************************
793 * ITextStoreACPSink
794 **************************************************************************/
795
797{
799
800 *ppvOut = NULL;
801
802 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITextStoreACPSink))
803 {
804 *ppvOut = &This->ITextStoreACPSink_iface;
805 }
806 else if (IsEqualIID(iid, &IID_ITextStoreACPServices))
807 *ppvOut = &This->ITextStoreACPServices_iface;
808
809 if (*ppvOut)
810 {
811 ITextStoreACPSink_AddRef(iface);
812 return S_OK;
813 }
814
815 WARN("unsupported interface: %s\n", debugstr_guid(iid));
816 return E_NOINTERFACE;
817}
818
820{
822 return ITfContext_AddRef(&This->ITfContext_iface);
823}
824
826{
828 return ITfContext_Release(&This->ITfContext_iface);
829}
830
831/*****************************************************
832 * ITextStoreACPSink functions
833 *****************************************************/
834
836 DWORD dwFlags, const TS_TEXTCHANGE *pChange)
837{
839 FIXME("STUB:(%p)\n",This);
840 return S_OK;
841}
842
844{
846 FIXME("STUB:(%p)\n",This);
847 return S_OK;
848}
849
851 TsLayoutCode lcode, TsViewCookie vcView)
852{
854 FIXME("STUB:(%p)\n",This);
855 return S_OK;
856}
857
860{
862 HRESULT hr, hrSession;
863
864 TRACE("(%p) %x\n",This, dwFlags);
865
866 if (!This->pITextStoreACP)
867 {
868 FIXME("Context does not have a ITextStoreACP\n");
869 return E_NOTIMPL;
870 }
871
872 hr = ITextStoreACP_RequestLock(This->pITextStoreACP, TS_LF_READ, &hrSession);
873
874 if(SUCCEEDED(hr) && SUCCEEDED(hrSession))
875 This->documentStatus.dwDynamicFlags = dwFlags;
876
877 return S_OK;
878}
879
881 LONG acpStart, LONG acpEnd, ULONG cAttrs, const TS_ATTRID *paAttrs)
882{
884 FIXME("STUB:(%p)\n",This);
885 return E_NOTIMPL;
886}
887
889 DWORD dwLockFlags)
890{
892 HRESULT hr;
893 EditCookie *cookie,*sinkcookie;
894 TfEditCookie ec;
895 struct list *cursor;
896
897 TRACE("(%p) %x\n",This, dwLockFlags);
898
899 if (!This->currentEditSession)
900 {
901 FIXME("OnLockGranted called for something other than an EditSession\n");
902 return S_OK;
903 }
904
906 if (!cookie)
907 return E_OUTOFMEMORY;
908
909 sinkcookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
910 if (!sinkcookie)
911 {
913 return E_OUTOFMEMORY;
914 }
915
916 cookie->lockType = dwLockFlags;
917 cookie->pOwningContext = This;
919
920 hr = ITfEditSession_DoEditSession(This->currentEditSession, ec);
921
922 if ((dwLockFlags&TS_LF_READWRITE) == TS_LF_READWRITE)
923 {
925 TfEditCookie sc;
926
927 sinkcookie->lockType = TS_LF_READ;
928 sinkcookie->pOwningContext = This;
930
931 /*TODO: implement ITfEditRecord */
932 SINK_FOR_EACH(cursor, &This->pTextEditSink, ITfTextEditSink, sink)
933 {
934 ITfTextEditSink_OnEndEdit(sink, &This->ITfContext_iface, sc, NULL);
935 }
936 sinkcookie = remove_Cookie(sc);
937 }
938 HeapFree(GetProcessHeap(),0,sinkcookie);
939
940 ITfEditSession_Release(This->currentEditSession);
941 This->currentEditSession = NULL;
942
943 /* Edit Cookie is only valid during the edit session */
944 cookie = remove_Cookie(ec);
946
947 return hr;
948}
949
951{
953 FIXME("STUB:(%p)\n",This);
954 return E_NOTIMPL;
955}
956
958{
960 FIXME("STUB:(%p)\n",This);
961 return E_NOTIMPL;
962}
963
964static const ITextStoreACPSinkVtbl TextStoreACPSinkVtbl =
965{
977};
978
980{
982 return ITextStoreACPSink_QueryInterface(&This->ITextStoreACPSink_iface, riid, obj);
983}
984
986{
988 return ITextStoreACPSink_AddRef(&This->ITextStoreACPSink_iface);
989}
990
992{
994 return ITextStoreACPSink_Release(&This->ITextStoreACPSink_iface);
995}
996
999{
1001
1002 FIXME("stub: %p %p %p %p %p\n", This, prop, range, header, stream);
1003
1004 return E_NOTIMPL;
1005}
1006
1009{
1011
1012 FIXME("stub: %p %p %p %p %p\n", This, prop, header, stream, loader);
1013
1014 return E_NOTIMPL;
1015}
1016
1018{
1020
1021 FIXME("stub: %p %p\n", This, prop);
1022
1023 return E_NOTIMPL;
1024}
1025
1028{
1030
1031 FIXME("stub: %p %d %d %p\n", This, start, end, range);
1032
1033 return S_OK;
1034}
1035
1036static const ITextStoreACPServicesVtbl TextStoreACPServicesVtbl =
1037{
1045};
1046
1048{
1049 Context *This;
1051
1053 if (This == NULL)
1054 return E_OUTOFMEMORY;
1055
1057 if (cookie == NULL)
1058 {
1060 return E_OUTOFMEMORY;
1061 }
1062
1063 TRACE("(%p) %x %p %p %p\n",This, tidOwner, punk, ppOut, pecTextStore);
1064
1065 This->ITfContext_iface.lpVtbl= &ContextVtbl;
1066 This->ITfSource_iface.lpVtbl = &ContextSourceVtbl;
1067 This->ITfContextOwnerCompositionServices_iface.lpVtbl = &ContextOwnerCompositionServicesVtbl;
1068 This->ITfInsertAtSelection_iface.lpVtbl = &InsertAtSelectionVtbl;
1069 This->ITfSourceSingle_iface.lpVtbl = &ContextSourceSingleVtbl;
1070 This->ITextStoreACPSink_iface.lpVtbl = &TextStoreACPSinkVtbl;
1071 This->ITextStoreACPServices_iface.lpVtbl = &TextStoreACPServicesVtbl;
1072 This->refCount = 1;
1073 This->tidOwner = tidOwner;
1074 This->connected = FALSE;
1075 This->manager = mgr;
1076
1077 CompartmentMgr_Constructor((IUnknown*)&This->ITfContext_iface, &IID_IUnknown, (IUnknown**)&This->CompartmentMgr);
1078
1079 cookie->lockType = TF_ES_READ;
1080 cookie->pOwningContext = This;
1081
1082 if (punk)
1083 {
1084 IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
1085 (LPVOID*)&This->pITextStoreACP);
1086
1087 IUnknown_QueryInterface(punk, &IID_ITfContextOwnerCompositionSink,
1088 (LPVOID*)&This->pITfContextOwnerCompositionSink);
1089
1090 if (!This->pITextStoreACP && !This->pITfContextOwnerCompositionSink)
1091 FIXME("Unhandled pUnk\n");
1092 }
1093
1095 *pecTextStore = This->defaultCookie;
1096
1097 list_init(&This->pContextKeyEventSink);
1098 list_init(&This->pEditTransactionSink);
1099 list_init(&This->pStatusSink);
1100 list_init(&This->pTextEditSink);
1101 list_init(&This->pTextLayoutSink);
1102
1103 *ppOut = &This->ITfContext_iface;
1104 TRACE("returning %p\n", *ppOut);
1105
1106 return S_OK;
1107}
1108
1110{
1112
1113 if (This->pITextStoreACP)
1114 ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink,
1115 (IUnknown*)&This->ITextStoreACPSink_iface, TS_AS_ALL_SINKS);
1116 This->connected = TRUE;
1117 This->manager = manager;
1118 return S_OK;
1119}
1120
1122{
1124
1125 if (This->pITextStoreACP)
1126 ITextStoreACP_UnadviseSink(This->pITextStoreACP, (IUnknown*)&This->ITextStoreACPSink_iface);
1127 This->connected = FALSE;
1128 This->manager = NULL;
1129 return S_OK;
1130}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_init(struct list_entry *head)
Definition: list.h:51
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
Definition: list.h:37
HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *iface)
HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void Context_AddRef(context_t *context)
Definition: context.c:78
void Context_Release(context_t *context)
Definition: context.c:106
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static HRESULT WINAPI TextStoreACPServices_Serialize(ITextStoreACPServices *iface, ITfProperty *prop, ITfRange *range, TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream)
Definition: context.c:997
static HRESULT WINAPI Context_GetActiveView(ITfContext *iface, ITfContextView **ppView)
Definition: context.c:416
static HRESULT WINAPI Context_GetStart(ITfContext *iface, TfEditCookie ec, ITfRange **ppStart)
Definition: context.c:363
static ULONG WINAPI TextStoreACPSink_AddRef(ITextStoreACPSink *iface)
Definition: context.c:819
static const ITfContextVtbl ContextVtbl
Definition: context.c:516
static HRESULT WINAPI ContextOwnerCompositionServices_StartComposition(ITfContextOwnerCompositionServices *iface, TfEditCookie ecWrite, ITfRange *pCompositionRange, ITfCompositionSink *pSink, ITfComposition **ppComposition)
Definition: context.c:619
static const ITextStoreACPSinkVtbl TextStoreACPSinkVtbl
Definition: context.c:964
static HRESULT WINAPI ContextOwnerCompositionServices_TakeOwnership(ITfContextOwnerCompositionServices *iface, TfEditCookie ecWrite, ITfCompositionView *pComposition, ITfCompositionSink *pSink, ITfComposition **ppComposition)
Definition: context.c:643
HRESULT Context_Uninitialize(ITfContext *iface)
Definition: context.c:1121
static HRESULT WINAPI SourceSingle_UnadviseSingleSink(ITfSourceSingle *iface, TfClientId tid, REFIID riid)
Definition: context.c:775
static Context * impl_from_ITfContextOwnerCompositionServices(ITfContextOwnerCompositionServices *iface)
Definition: context.c:92
static ULONG WINAPI ContextOwnerCompositionServices_AddRef(ITfContextOwnerCompositionServices *iface)
Definition: context.c:607
static HRESULT WINAPI Context_TrackProperties(ITfContext *iface, const GUID **prgProp, ULONG cProp, const GUID **prgAppProp, ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
Definition: context.c:473
static HRESULT WINAPI InsertAtSelection_InsertEmbeddedAtSelection(ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, IDataObject *pDataObject, ITfRange **ppRange)
Definition: context.c:728
static HRESULT WINAPI Context_SetSelection(ITfContext *iface, TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
Definition: context.c:325
static HRESULT WINAPI TextStoreACPSink_QueryInterface(ITextStoreACPSink *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:796
static ULONG WINAPI InsertAtSelection_Release(ITfInsertAtSelection *iface)
Definition: context.c:686
static Context * impl_from_ITfSourceSingle(ITfSourceSingle *iface)
Definition: context.c:102
static Context * impl_from_ITextStoreACPServices(ITextStoreACPServices *iface)
Definition: context.c:112
static HRESULT WINAPI Context_GetAppProperty(ITfContext *iface, REFGUID guidProp, ITfReadOnlyProperty **ppProp)
Definition: context.c:465
static HRESULT WINAPI ContextOwnerCompositionServices_TerminateComposition(ITfContextOwnerCompositionServices *iface, ITfCompositionView *pComposition)
Definition: context.c:651
static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface, DWORD dwLockFlags)
Definition: context.c:888
static void Context_Destructor(Context *This)
Definition: context.c:117
static ULONG WINAPI ContextOwnerCompositionServices_Release(ITfContextOwnerCompositionServices *iface)
Definition: context.c:613
static HRESULT WINAPI InsertAtSelection_QueryInterface(ITfInsertAtSelection *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:674
static HRESULT WINAPI TextStoreACPServices_Unserialize(ITextStoreACPServices *iface, ITfProperty *prop, const TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream, ITfPersistentPropertyLoaderACP *loader)
Definition: context.c:1007
static HRESULT WINAPI ContextOwnerCompositionServices_QueryInterface(ITfContextOwnerCompositionServices *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:600
static HRESULT WINAPI TextStoreACPSink_OnLayoutChange(ITextStoreACPSink *iface, TsLayoutCode lcode, TsViewCookie vcView)
Definition: context.c:850
static HRESULT WINAPI TextStoreACPServices_QueryInterface(ITextStoreACPServices *iface, REFIID riid, void **obj)
Definition: context.c:979
static ULONG WINAPI InsertAtSelection_AddRef(ITfInsertAtSelection *iface)
Definition: context.c:680
static HRESULT WINAPI Context_GetStatus(ITfContext *iface, TF_STATUS *pdcs)
Definition: context.c:432
HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfDocumentMgr *mgr, ITfContext **ppOut, TfEditCookie *pecTextStore)
Definition: context.c:1047
static ULONG WINAPI SourceSingle_AddRef(ITfSourceSingle *iface)
Definition: context.c:755
static HRESULT WINAPI TextStoreACPSink_OnTextChange(ITextStoreACPSink *iface, DWORD dwFlags, const TS_TEXTCHANGE *pChange)
Definition: context.c:835
static ULONG WINAPI ContextSource_AddRef(ITfSource *iface)
Definition: context.c:547
static HRESULT WINAPI Context_GetEnd(ITfContext *iface, TfEditCookie ec, ITfRange **ppEnd)
Definition: context.c:385
static const ITextStoreACPServicesVtbl TextStoreACPServicesVtbl
Definition: context.c:1036
static HRESULT WINAPI SourceSingle_AdviseSingleSink(ITfSourceSingle *iface, TfClientId tid, REFIID riid, IUnknown *punk)
Definition: context.c:767
struct tagEditCookie EditCookie
static ULONG WINAPI TextStoreACPServices_Release(ITextStoreACPServices *iface)
Definition: context.c:991
static Context * impl_from_ITfSource(ITfSource *iface)
Definition: context.c:87
static HRESULT WINAPI TextStoreACPServices_ForceLoadProperty(ITextStoreACPServices *iface, ITfProperty *prop)
Definition: context.c:1017
static Context * impl_from_ITfContext(ITfContext *iface)
Definition: context.c:82
static HRESULT WINAPI Context_EnumProperties(ITfContext *iface, IEnumTfProperties **ppEnum)
Definition: context.c:482
static Context * impl_from_ITfInsertAtSelection(ITfInsertAtSelection *iface)
Definition: context.c:97
static HRESULT WINAPI Context_RequestEditSession(ITfContext *iface, TfClientId tid, ITfEditSession *pes, DWORD dwFlags, HRESULT *phrSession)
Definition: context.c:205
static HRESULT WINAPI TextStoreACPSink_OnAttrsChange(ITextStoreACPSink *iface, LONG acpStart, LONG acpEnd, ULONG cAttrs, const TS_ATTRID *paAttrs)
Definition: context.c:880
static ULONG WINAPI TextStoreACPServices_AddRef(ITextStoreACPServices *iface)
Definition: context.c:985
static HRESULT WINAPI TextStoreACPSink_OnSelectionChange(ITextStoreACPSink *iface)
Definition: context.c:843
static HRESULT WINAPI TextStoreACPSink_OnStatusChange(ITextStoreACPSink *iface, DWORD dwFlags)
Definition: context.c:858
static HRESULT WINAPI TextStoreACPServices_CreateRange(ITextStoreACPServices *iface, LONG start, LONG end, ITfRangeACP **range)
Definition: context.c:1026
static HRESULT WINAPI SourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:749
HRESULT Context_Initialize(ITfContext *iface, ITfDocumentMgr *manager)
Definition: context.c:1109
static HRESULT WINAPI TextStoreACPSink_OnStartEditTransaction(ITextStoreACPSink *iface)
Definition: context.c:950
static HRESULT WINAPI Context_InWriteSession(ITfContext *iface, TfClientId tid, BOOL *pfWriteSession)
Definition: context.c:256
static ULONG WINAPI TextStoreACPSink_Release(ITextStoreACPSink *iface)
Definition: context.c:825
static HRESULT WINAPI Context_EnumViews(ITfContext *iface, IEnumTfContextViews **ppEnum)
Definition: context.c:424
static HRESULT WINAPI ContextSource_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:541
static HRESULT WINAPI ContextOwnerCompositionServices_FindComposition(ITfContextOwnerCompositionServices *iface, TfEditCookie ecRead, ITfRange *pTestRange, IEnumITfCompositionView **ppEnum)
Definition: context.c:635
static const ITfSourceSingleVtbl ContextSourceSingleVtbl
Definition: context.c:783
static const ITfInsertAtSelectionVtbl InsertAtSelectionVtbl
Definition: context.c:737
static HRESULT WINAPI Context_GetSelection(ITfContext *iface, TfEditCookie ec, ULONG ulIndex, ULONG ulCount, TF_SELECTION *pSelection, ULONG *pcFetched)
Definition: context.c:265
static HRESULT WINAPI TextStoreACPSink_OnEndEditTransaction(ITextStoreACPSink *iface)
Definition: context.c:957
static const ITfSourceVtbl ContextSourceVtbl
Definition: context.c:588
static const ITfContextOwnerCompositionServicesVtbl ContextOwnerCompositionServicesVtbl
Definition: context.c:659
static HRESULT WINAPI Context_GetProperty(ITfContext *iface, REFGUID guidProp, ITfProperty **ppProp)
Definition: context.c:457
static HRESULT WINAPI Context_GetDocumentMgr(ITfContext *iface, ITfDocumentMgr **ppDm)
Definition: context.c:490
static HRESULT WINAPI ContextSource_AdviseSink(ITfSource *iface, REFIID riid, IUnknown *punk, DWORD *pdwCookie)
Definition: context.c:559
static HRESULT WINAPI ContextOwnerCompositionServices_EnumCompositions(ITfContextOwnerCompositionServices *iface, IEnumITfCompositionView **ppEnum)
Definition: context.c:627
static HRESULT WINAPI ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
Definition: context.c:576
static Context * impl_from_ITextStoreACPSink(ITextStoreACPSink *iface)
Definition: context.c:107
static ULONG WINAPI ContextSource_Release(ITfSource *iface)
Definition: context.c:553
static HRESULT WINAPI Context_QueryInterface(ITfContext *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:145
static ULONG WINAPI SourceSingle_Release(ITfSourceSingle *iface)
Definition: context.c:761
static HRESULT WINAPI InsertAtSelection_InsertTextAtSelection(ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, const WCHAR *pchText, LONG cch, ITfRange **ppRange)
Definition: context.c:692
static HRESULT WINAPI Context_CreateRangeBackup(ITfContext *iface, TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
Definition: context.c:508
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLint * range
Definition: glext.h:7539
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const char cursor[]
Definition: icontest.c:13
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_wn
Definition: kernel32.h:33
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static TfClientId tid
DWORD get_Cookie_magic(DWORD id)
Definition: msctf.c:233
LPVOID remove_Cookie(DWORD id)
Definition: msctf.c:259
HRESULT unadvise_sink(DWORD cookie)
Definition: msctf.c:312
void free_sinks(struct list *sink_list)
Definition: msctf.c:324
DWORD generate_Cookie(DWORD magic, LPVOID data)
Definition: msctf.c:189
HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie)
Definition: msctf.c:285
LPVOID get_Cookie_data(DWORD id)
Definition: msctf.c:246
DWORD TfClientId
Definition: msctf.idl:105
DWORD TfEditCookie
Definition: msctf.idl:104
HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut) DECLSPEC_HIDDEN
Definition: range.c:325
#define SINK_FOR_EACH(cursor, list, type, elem)
#define COOKIE_MAGIC_EDITCOOKIE
HRESULT TF_SELECTION_to_TS_SELECTION_ACP(const TF_SELECTION *tf, TS_SELECTION_ACP *tsAcp) DECLSPEC_HIDDEN
Definition: range.c:351
#define COOKIE_MAGIC_CONTEXTSINK
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
TsActiveSelEnd ase
Definition: textstor.idl:86
TS_SELECTIONSTYLE style
Definition: textstor.idl:94
LONG acpNewEnd
Definition: textstor.idl:81
Definition: scsiwmi.h:51
Definition: cookie.c:34
Definition: parse.h:23
LONG refCount
Definition: context.c:52
ITfInsertAtSelection ITfInsertAtSelection_iface
Definition: context.c:46
struct list pContextKeyEventSink
Definition: context.c:69
struct list pTextEditSink
Definition: context.c:72
ITfContextOwnerCompositionServices ITfContextOwnerCompositionServices_iface
Definition: context.c:44
ITfCompartmentMgr * CompartmentMgr
Definition: context.c:56
ITfSourceSingle ITfSourceSingle_iface
Definition: context.c:49
ITfSource ITfSource_iface
Definition: context.c:42
TfEditCookie defaultCookie
Definition: context.c:59
ITfEditSession * currentEditSession
Definition: context.c:66
BOOL connected
Definition: context.c:53
ITextStoreACPServices ITextStoreACPServices_iface
Definition: context.c:51
struct list pEditTransactionSink
Definition: context.c:70
struct list pTextLayoutSink
Definition: context.c:73
ITfContextOwnerCompositionSink * pITfContextOwnerCompositionSink
Definition: context.c:64
ITextStoreACPSink ITextStoreACPSink_iface
Definition: context.c:50
struct list pStatusSink
Definition: context.c:71
TfClientId tidOwner
Definition: context.c:58
TS_STATUS documentStatus
Definition: context.c:60
ITfContext ITfContext_iface
Definition: context.c:41
ITfDocumentMgr * manager
Definition: context.c:61
ITextStoreACP * pITextStoreACP
Definition: context.c:63
DWORD lockType
Definition: context.c:78
Context * pOwningContext
Definition: context.c:79
const DWORD TS_LF_READWRITE
Definition: textstor.idl:58
DWORD TsViewCookie
Definition: textstor.idl:111
TsLayoutCode
Definition: textstor.idl:110
const DWORD TS_LF_SYNC
Definition: textstor.idl:56
const DWORD TS_SD_READONLY
Definition: textstor.idl:40
const DWORD TS_LF_READ
Definition: textstor.idl:57
const DWORD TS_AS_ALL_SINKS
Definition: textstor.idl:54
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
__wchar_t WCHAR
Definition: xmlstorage.h:180