ReactOS  0.4.13-dev-100-gc8611ae
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 "config.h"
22 
23 #include <stdarg.h>
24 
25 #define COBJMACROS
26 
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "shlwapi.h"
33 #include "winerror.h"
34 #include "objbase.h"
35 #include "olectl.h"
36 
37 #include "wine/unicode.h"
38 
39 #include "msctf.h"
40 #include "msctf_internal.h"
41 
43 
44 typedef struct tagContext {
47  /* const ITfContextCompositionVtbl *ContextCompositionVtbl; */
48  /* const ITfContextOwnerCompositionServicesVtbl *ContextOwnerCompositionServicesVtbl; */
49  /* const ITfContextOwnerServicesVtbl *ContextOwnerServicesVtbl; */
51  /* const ITfMouseTrackerVtbl *MouseTrackerVtbl; */
52  /* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */
58 
59  /* Aggregation */
61 
66 
69 
71 
72  /* kept as separate lists to reduce unnecessary iterations */
75  struct list pStatusSink;
78 
79 } Context;
80 
81 typedef struct tagEditCookie {
84 } EditCookie;
85 
86 static inline Context *impl_from_ITfContext(ITfContext *iface)
87 {
88  return CONTAINING_RECORD(iface, Context, ITfContext_iface);
89 }
90 
91 static inline Context *impl_from_ITfSource(ITfSource *iface)
92 {
93  return CONTAINING_RECORD(iface, Context, ITfSource_iface);
94 }
95 
97 {
98  return CONTAINING_RECORD(iface, Context, ITfInsertAtSelection_iface);
99 }
100 
102 {
103  return CONTAINING_RECORD(iface, Context, ITfSourceSingle_iface);
104 }
105 
107 {
108  return CONTAINING_RECORD(iface, Context, ITextStoreACPSink_iface);
109 }
110 
112 {
113  return CONTAINING_RECORD(iface, Context, ITextStoreACPServices_iface);
114 }
115 
117 {
118  EditCookie *cookie;
119  TRACE("destroying %p\n", This);
120 
121  if (This->pITextStoreACP)
122  ITextStoreACP_Release(This->pITextStoreACP);
123 
124  if (This->pITfContextOwnerCompositionSink)
125  ITfContextOwnerCompositionSink_Release(This->pITfContextOwnerCompositionSink);
126 
127  if (This->defaultCookie)
128  {
129  cookie = remove_Cookie(This->defaultCookie);
130  HeapFree(GetProcessHeap(),0,cookie);
131  This->defaultCookie = 0;
132  }
133 
134  free_sinks(&This->pContextKeyEventSink);
135  free_sinks(&This->pEditTransactionSink);
136  free_sinks(&This->pStatusSink);
137  free_sinks(&This->pTextEditSink);
138  free_sinks(&This->pTextLayoutSink);
139 
140  CompartmentMgr_Destructor(This->CompartmentMgr);
142 }
143 
145 {
147  *ppvOut = NULL;
148 
149  if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfContext))
150  {
151  *ppvOut = &This->ITfContext_iface;
152  }
153  else if (IsEqualIID(iid, &IID_ITfSource))
154  {
155  *ppvOut = &This->ITfSource_iface;
156  }
157  else if (IsEqualIID(iid, &IID_ITfInsertAtSelection))
158  {
159  *ppvOut = &This->ITfInsertAtSelection_iface;
160  }
161  else if (IsEqualIID(iid, &IID_ITfCompartmentMgr))
162  {
163  *ppvOut = This->CompartmentMgr;
164  }
165  else if (IsEqualIID(iid, &IID_ITfSourceSingle))
166  {
167  *ppvOut = &This->ITfSourceSingle_iface;
168  }
169 
170  if (*ppvOut)
171  {
172  ITfContext_AddRef(iface);
173  return S_OK;
174  }
175 
176  WARN("unsupported interface: %s\n", debugstr_guid(iid));
177  return E_NOINTERFACE;
178 }
179 
181 {
183  return InterlockedIncrement(&This->refCount);
184 }
185 
187 {
189  ULONG ret;
190 
191  ret = InterlockedDecrement(&This->refCount);
192  if (ret == 0)
194  return ret;
195 }
196 
197 /*****************************************************
198  * ITfContext functions
199  *****************************************************/
202  HRESULT *phrSession)
203 {
205  HRESULT hr;
206  DWORD dwLockFlags = 0x0;
207 
208  TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession);
209 
210  if (!(dwFlags & TF_ES_READ) && !(dwFlags & TF_ES_READWRITE))
211  {
212  *phrSession = E_FAIL;
213  return E_INVALIDARG;
214  }
215 
216  if (!This->pITextStoreACP)
217  {
218  FIXME("No ITextStoreACP available\n");
219  *phrSession = E_FAIL;
220  return E_FAIL;
221  }
222 
223  if (!(dwFlags & TF_ES_ASYNC))
224  dwLockFlags |= TS_LF_SYNC;
225 
226  if ((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE)
227  dwLockFlags |= TS_LF_READWRITE;
228  else if (dwFlags & TF_ES_READ)
229  dwLockFlags |= TS_LF_READ;
230 
231  if (!This->documentStatus.dwDynamicFlags)
232  ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
233 
234  if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (This->documentStatus.dwDynamicFlags & TS_SD_READONLY))
235  {
236  *phrSession = TS_E_READONLY;
237  return S_OK;
238  }
239 
240  if (FAILED (ITfEditSession_QueryInterface(pes, &IID_ITfEditSession, (LPVOID*)&This->currentEditSession)))
241  {
242  *phrSession = E_FAIL;
243  return E_INVALIDARG;
244  }
245 
246  hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession);
247 
248  return hr;
249 }
250 
252  TfClientId tid,
253  BOOL *pfWriteSession)
254 {
256  FIXME("STUB:(%p)\n",This);
257  return E_NOTIMPL;
258 }
259 
261  TfEditCookie ec, ULONG ulIndex, ULONG ulCount,
262  TF_SELECTION *pSelection, ULONG *pcFetched)
263 {
265  EditCookie *cookie;
266  ULONG count, i;
267  ULONG totalFetched = 0;
268  HRESULT hr = S_OK;
269 
270  if (!pSelection || !pcFetched)
271  return E_INVALIDARG;
272 
273  *pcFetched = 0;
274 
275  if (!This->connected)
276  return TF_E_DISCONNECTED;
277 
279  return TF_E_NOLOCK;
280 
281  if (!This->pITextStoreACP)
282  {
283  FIXME("Context does not have a ITextStoreACP\n");
284  return E_NOTIMPL;
285  }
286 
287  cookie = get_Cookie_data(ec);
288 
289  if (ulIndex == TF_DEFAULT_SELECTION)
290  count = 1;
291  else
292  count = ulCount;
293 
294  for (i = 0; i < count; i++)
295  {
296  DWORD fetched;
297  TS_SELECTION_ACP acps;
298 
299  hr = ITextStoreACP_GetSelection(This->pITextStoreACP, ulIndex + i,
300  1, &acps, &fetched);
301 
302  if (hr == TS_E_NOLOCK)
303  return TF_E_NOLOCK;
304  else if (SUCCEEDED(hr))
305  {
306  pSelection[totalFetched].style.ase = acps.style.ase;
307  pSelection[totalFetched].style.fInterimChar = acps.style.fInterimChar;
308  Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, acps.acpStart, acps.acpEnd, &pSelection[totalFetched].range);
309  totalFetched ++;
310  }
311  else
312  break;
313  }
314 
315  *pcFetched = totalFetched;
316 
317  return hr;
318 }
319 
321  TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
322 {
324  TS_SELECTION_ACP *acp;
325  ULONG i;
326  HRESULT hr;
327 
328  TRACE("(%p) %i %i %p\n",This,ec,ulCount,pSelection);
329 
330  if (!This->pITextStoreACP)
331  {
332  FIXME("Context does not have a ITextStoreACP\n");
333  return E_NOTIMPL;
334  }
335 
337  return TF_E_NOLOCK;
338 
339  acp = HeapAlloc(GetProcessHeap(), 0, sizeof(TS_SELECTION_ACP) * ulCount);
340  if (!acp)
341  return E_OUTOFMEMORY;
342 
343  for (i = 0; i < ulCount; i++)
344  if (FAILED(TF_SELECTION_to_TS_SELECTION_ACP(&pSelection[i], &acp[i])))
345  {
346  TRACE("Selection Conversion Failed\n");
347  HeapFree(GetProcessHeap(), 0 , acp);
348  return E_FAIL;
349  }
350 
351  hr = ITextStoreACP_SetSelection(This->pITextStoreACP, ulCount, acp);
352 
353  HeapFree(GetProcessHeap(), 0, acp);
354 
355  return hr;
356 }
357 
359  TfEditCookie ec, ITfRange **ppStart)
360 {
362  EditCookie *cookie;
363  TRACE("(%p) %i %p\n",This,ec,ppStart);
364 
365  if (!ppStart)
366  return E_INVALIDARG;
367 
368  *ppStart = NULL;
369 
370  if (!This->connected)
371  return TF_E_DISCONNECTED;
372 
374  return TF_E_NOLOCK;
375 
376  cookie = get_Cookie_data(ec);
377  return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, 0, 0, ppStart);
378 }
379 
381  TfEditCookie ec, ITfRange **ppEnd)
382 {
384  EditCookie *cookie;
385  LONG end;
386  TRACE("(%p) %i %p\n",This,ec,ppEnd);
387 
388  if (!ppEnd)
389  return E_INVALIDARG;
390 
391  *ppEnd = NULL;
392 
393  if (!This->connected)
394  return TF_E_DISCONNECTED;
395 
397  return TF_E_NOLOCK;
398 
399  if (!This->pITextStoreACP)
400  {
401  FIXME("Context does not have a ITextStoreACP\n");
402  return E_NOTIMPL;
403  }
404 
405  cookie = get_Cookie_data(ec);
406  ITextStoreACP_GetEndACP(This->pITextStoreACP,&end);
407 
408  return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, end, end, ppEnd);
409 }
410 
412  ITfContextView **ppView)
413 {
415  FIXME("STUB:(%p)\n",This);
416  return E_NOTIMPL;
417 }
418 
420  IEnumTfContextViews **ppEnum)
421 {
423  FIXME("STUB:(%p)\n",This);
424  return E_NOTIMPL;
425 }
426 
428  TF_STATUS *pdcs)
429 {
431  TRACE("(%p) %p\n",This,pdcs);
432 
433  if (!This->connected)
434  return TF_E_DISCONNECTED;
435 
436  if (!pdcs)
437  return E_INVALIDARG;
438 
439  if (!This->pITextStoreACP)
440  {
441  FIXME("Context does not have a ITextStoreACP\n");
442  return E_NOTIMPL;
443  }
444 
445  ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
446 
447  *pdcs = This->documentStatus;
448 
449  return S_OK;
450 }
451 
453  REFGUID guidProp, ITfProperty **ppProp)
454 {
456  FIXME("STUB:(%p)\n",This);
457  return E_NOTIMPL;
458 }
459 
461  REFGUID guidProp, ITfReadOnlyProperty **ppProp)
462 {
464  FIXME("STUB:(%p)\n",This);
465  return E_NOTIMPL;
466 }
467 
469  const GUID **prgProp, ULONG cProp, const GUID **prgAppProp,
470  ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
471 {
473  FIXME("STUB:(%p)\n",This);
474  return E_NOTIMPL;
475 }
476 
478  IEnumTfProperties **ppEnum)
479 {
481  FIXME("STUB:(%p)\n",This);
482  return E_NOTIMPL;
483 }
484 
486  ITfDocumentMgr **ppDm)
487 {
489  TRACE("(%p) %p\n",This,ppDm);
490 
491  if (!ppDm)
492  return E_INVALIDARG;
493 
494  *ppDm = This->manager;
495  if (!This->manager)
496  return S_FALSE;
497 
498  ITfDocumentMgr_AddRef(This->manager);
499 
500  return S_OK;
501 }
502 
504  TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
505 {
507  FIXME("STUB:(%p)\n",This);
508  return E_NOTIMPL;
509 }
510 
511 static const ITfContextVtbl ContextVtbl =
512 {
531 };
532 
534 {
535  Context *This = impl_from_ITfSource(iface);
536  return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
537 }
538 
540 {
541  Context *This = impl_from_ITfSource(iface);
542  return ITfContext_AddRef(&This->ITfContext_iface);
543 }
544 
546 {
547  Context *This = impl_from_ITfSource(iface);
548  return ITfContext_Release(&This->ITfContext_iface);
549 }
550 
551 /*****************************************************
552  * ITfSource functions
553  *****************************************************/
555  REFIID riid, IUnknown *punk, DWORD *pdwCookie)
556 {
557  Context *This = impl_from_ITfSource(iface);
558 
559  TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
560 
561  if (!riid || !punk || !pdwCookie)
562  return E_INVALIDARG;
563 
564  if (IsEqualIID(riid, &IID_ITfTextEditSink))
565  return advise_sink(&This->pTextEditSink, &IID_ITfTextEditSink, COOKIE_MAGIC_CONTEXTSINK, punk, pdwCookie);
566 
567  FIXME("(%p) Unhandled Sink: %s\n",This,debugstr_guid(riid));
568  return E_NOTIMPL;
569 }
570 
572 {
573  Context *This = impl_from_ITfSource(iface);
574 
575  TRACE("(%p) %x\n",This,pdwCookie);
576 
578  return E_INVALIDARG;
579 
580  return unadvise_sink(pdwCookie);
581 }
582 
583 static const ITfSourceVtbl ContextSourceVtbl =
584 {
590 };
591 
592 /*****************************************************
593  * ITfInsertAtSelection functions
594  *****************************************************/
596 {
598  return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
599 }
600 
602 {
604  return ITfContext_AddRef(&This->ITfContext_iface);
605 }
606 
608 {
610  return ITfContext_Release(&This->ITfContext_iface);
611 }
612 
615  const WCHAR *pchText, LONG cch, ITfRange **ppRange)
616 {
618  EditCookie *cookie;
619  LONG acpStart, acpEnd;
620  TS_TEXTCHANGE change;
621  HRESULT hr;
622 
623  TRACE("(%p) %i %x %s %p\n",This, ec, dwFlags, debugstr_wn(pchText,cch), ppRange);
624 
625  if (!This->connected)
626  return TF_E_DISCONNECTED;
627 
629  return TF_E_NOLOCK;
630 
631  cookie = get_Cookie_data(ec);
632 
633  if ((cookie->lockType & TS_LF_READWRITE) != TS_LF_READWRITE )
634  return TS_E_READONLY;
635 
636  if (!This->pITextStoreACP)
637  {
638  FIXME("Context does not have a ITextStoreACP\n");
639  return E_NOTIMPL;
640  }
641 
642  hr = ITextStoreACP_InsertTextAtSelection(This->pITextStoreACP, dwFlags, pchText, cch, &acpStart, &acpEnd, &change);
643  if (SUCCEEDED(hr))
644  Range_Constructor(&This->ITfContext_iface, This->pITextStoreACP, cookie->lockType, change.acpStart, change.acpNewEnd, ppRange);
645 
646  return hr;
647 }
648 
651  IDataObject *pDataObject, ITfRange **ppRange)
652 {
654  FIXME("STUB:(%p)\n",This);
655  return E_NOTIMPL;
656 }
657 
658 static const ITfInsertAtSelectionVtbl InsertAtSelectionVtbl =
659 {
665 };
666 
667 /*****************************************************
668  * ITfSourceSingle functions
669  *****************************************************/
671 {
673  return ITfContext_QueryInterface(&This->ITfContext_iface, iid, ppvOut);
674 }
675 
677 {
679  return ITfContext_AddRef(&This->ITfContext_iface);
680 }
681 
683 {
685  return ITfContext_Release(&This->ITfContext_iface);
686 }
687 
690 {
692  FIXME("STUB:(%p) %i %s %p\n",This, tid, debugstr_guid(riid),punk);
693  return E_NOTIMPL;
694 }
695 
698 {
700  FIXME("STUB:(%p) %i %s\n",This, tid, debugstr_guid(riid));
701  return E_NOTIMPL;
702 }
703 
704 static const ITfSourceSingleVtbl ContextSourceSingleVtbl =
705 {
711 };
712 
713 /**************************************************************************
714  * ITextStoreACPSink
715  **************************************************************************/
716 
718 {
720 
721  *ppvOut = NULL;
722 
723  if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITextStoreACPSink))
724  {
725  *ppvOut = &This->ITextStoreACPSink_iface;
726  }
727  else if (IsEqualIID(iid, &IID_ITextStoreACPServices))
728  *ppvOut = &This->ITextStoreACPServices_iface;
729 
730  if (*ppvOut)
731  {
732  ITextStoreACPSink_AddRef(iface);
733  return S_OK;
734  }
735 
736  WARN("unsupported interface: %s\n", debugstr_guid(iid));
737  return E_NOINTERFACE;
738 }
739 
741 {
743  return ITfContext_AddRef(&This->ITfContext_iface);
744 }
745 
747 {
749  return ITfContext_Release(&This->ITfContext_iface);
750 }
751 
752 /*****************************************************
753  * ITextStoreACPSink functions
754  *****************************************************/
755 
757  DWORD dwFlags, const TS_TEXTCHANGE *pChange)
758 {
760  FIXME("STUB:(%p)\n",This);
761  return S_OK;
762 }
763 
765 {
767  FIXME("STUB:(%p)\n",This);
768  return S_OK;
769 }
770 
772  TsLayoutCode lcode, TsViewCookie vcView)
773 {
775  FIXME("STUB:(%p)\n",This);
776  return S_OK;
777 }
778 
780  DWORD dwFlags)
781 {
783  HRESULT hr, hrSession;
784 
785  TRACE("(%p) %x\n",This, dwFlags);
786 
787  if (!This->pITextStoreACP)
788  {
789  FIXME("Context does not have a ITextStoreACP\n");
790  return E_NOTIMPL;
791  }
792 
793  hr = ITextStoreACP_RequestLock(This->pITextStoreACP, TS_LF_READ, &hrSession);
794 
795  if(SUCCEEDED(hr) && SUCCEEDED(hrSession))
796  This->documentStatus.dwDynamicFlags = dwFlags;
797 
798  return S_OK;
799 }
800 
802  LONG acpStart, LONG acpEnd, ULONG cAttrs, const TS_ATTRID *paAttrs)
803 {
805  FIXME("STUB:(%p)\n",This);
806  return E_NOTIMPL;
807 }
808 
810  DWORD dwLockFlags)
811 {
813  HRESULT hr;
814  EditCookie *cookie,*sinkcookie;
815  TfEditCookie ec;
816  struct list *cursor;
817 
818  TRACE("(%p) %x\n",This, dwLockFlags);
819 
820  if (!This->currentEditSession)
821  {
822  FIXME("OnLockGranted called for something other than an EditSession\n");
823  return S_OK;
824  }
825 
826  cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
827  if (!cookie)
828  return E_OUTOFMEMORY;
829 
830  sinkcookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
831  if (!sinkcookie)
832  {
833  HeapFree(GetProcessHeap(), 0, cookie);
834  return E_OUTOFMEMORY;
835  }
836 
837  cookie->lockType = dwLockFlags;
838  cookie->pOwningContext = This;
840 
841  hr = ITfEditSession_DoEditSession(This->currentEditSession, ec);
842 
843  if ((dwLockFlags&TS_LF_READWRITE) == TS_LF_READWRITE)
844  {
846  TfEditCookie sc;
847 
848  sinkcookie->lockType = TS_LF_READ;
849  sinkcookie->pOwningContext = This;
850  sc = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE, sinkcookie);
851 
852  /*TODO: implement ITfEditRecord */
853  SINK_FOR_EACH(cursor, &This->pTextEditSink, ITfTextEditSink, sink)
854  {
855  ITfTextEditSink_OnEndEdit(sink, (ITfContext*) &This->ITfContext_iface, sc, NULL);
856  }
857  sinkcookie = remove_Cookie(sc);
858  }
859  HeapFree(GetProcessHeap(),0,sinkcookie);
860 
861  ITfEditSession_Release(This->currentEditSession);
862  This->currentEditSession = NULL;
863 
864  /* Edit Cookie is only valid during the edit session */
865  cookie = remove_Cookie(ec);
866  HeapFree(GetProcessHeap(),0,cookie);
867 
868  return hr;
869 }
870 
872 {
874  FIXME("STUB:(%p)\n",This);
875  return E_NOTIMPL;
876 }
877 
879 {
881  FIXME("STUB:(%p)\n",This);
882  return E_NOTIMPL;
883 }
884 
885 static const ITextStoreACPSinkVtbl TextStoreACPSinkVtbl =
886 {
898 };
899 
901 {
903  return ITextStoreACPSink_QueryInterface(&This->ITextStoreACPSink_iface, riid, obj);
904 }
905 
907 {
909  return ITextStoreACPSink_AddRef(&This->ITextStoreACPSink_iface);
910 }
911 
913 {
915  return ITextStoreACPSink_Release(&This->ITextStoreACPSink_iface);
916 }
917 
920 {
922 
923  FIXME("stub: %p %p %p %p %p\n", This, prop, range, header, stream);
924 
925  return E_NOTIMPL;
926 }
927 
930 {
932 
933  FIXME("stub: %p %p %p %p %p\n", This, prop, header, stream, loader);
934 
935  return E_NOTIMPL;
936 }
937 
939 {
941 
942  FIXME("stub: %p %p\n", This, prop);
943 
944  return E_NOTIMPL;
945 }
946 
949 {
951 
952  FIXME("stub: %p %d %d %p\n", This, start, end, range);
953 
954  return S_OK;
955 }
956 
957 static const ITextStoreACPServicesVtbl TextStoreACPServicesVtbl =
958 {
966 };
967 
969 {
970  Context *This;
971  EditCookie *cookie;
972 
974  if (This == NULL)
975  return E_OUTOFMEMORY;
976 
977  cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
978  if (cookie == NULL)
979  {
981  return E_OUTOFMEMORY;
982  }
983 
984  TRACE("(%p) %x %p %p %p\n",This, tidOwner, punk, ppOut, pecTextStore);
985 
986  This->ITfContext_iface.lpVtbl= &ContextVtbl;
987  This->ITfSource_iface.lpVtbl = &ContextSourceVtbl;
988  This->ITfInsertAtSelection_iface.lpVtbl = &InsertAtSelectionVtbl;
989  This->ITfSourceSingle_iface.lpVtbl = &ContextSourceSingleVtbl;
990  This->ITextStoreACPSink_iface.lpVtbl = &TextStoreACPSinkVtbl;
991  This->ITextStoreACPServices_iface.lpVtbl = &TextStoreACPServicesVtbl;
992  This->refCount = 1;
993  This->tidOwner = tidOwner;
994  This->connected = FALSE;
995  This->manager = mgr;
996 
997  CompartmentMgr_Constructor((IUnknown*)&This->ITfContext_iface, &IID_IUnknown, (IUnknown**)&This->CompartmentMgr);
998 
999  cookie->lockType = TF_ES_READ;
1000  cookie->pOwningContext = This;
1001 
1002  if (punk)
1003  {
1004  IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
1005  (LPVOID*)&This->pITextStoreACP);
1006 
1007  IUnknown_QueryInterface(punk, &IID_ITfContextOwnerCompositionSink,
1008  (LPVOID*)&This->pITfContextOwnerCompositionSink);
1009 
1010  if (!This->pITextStoreACP && !This->pITfContextOwnerCompositionSink)
1011  FIXME("Unhandled pUnk\n");
1012  }
1013 
1014  This->defaultCookie = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE,cookie);
1015  *pecTextStore = This->defaultCookie;
1016 
1017  list_init(&This->pContextKeyEventSink);
1018  list_init(&This->pEditTransactionSink);
1019  list_init(&This->pStatusSink);
1020  list_init(&This->pTextEditSink);
1021  list_init(&This->pTextLayoutSink);
1022 
1023  *ppOut = &This->ITfContext_iface;
1024  TRACE("returning %p\n", *ppOut);
1025 
1026  return S_OK;
1027 }
1028 
1030 {
1031  Context *This = impl_from_ITfContext(iface);
1032 
1033  if (This->pITextStoreACP)
1034  ITextStoreACP_AdviseSink(This->pITextStoreACP, &IID_ITextStoreACPSink,
1035  (IUnknown*)&This->ITextStoreACPSink_iface, TS_AS_ALL_SINKS);
1036  This->connected = TRUE;
1037  This->manager = manager;
1038  return S_OK;
1039 }
1040 
1042 {
1043  Context *This = impl_from_ITfContext(iface);
1044 
1045  if (This->pITextStoreACP)
1046  ITextStoreACP_UnadviseSink(This->pITextStoreACP, (IUnknown*)&This->ITextStoreACPSink_iface);
1047  This->connected = FALSE;
1048  This->manager = NULL;
1049  return S_OK;
1050 }
TS_SELECTIONSTYLE style
Definition: textstor.idl:94
static HRESULT WINAPI Context_TrackProperties(ITfContext *iface, const GUID **prgProp, ULONG cProp, const GUID **prgAppProp, ULONG cAppProp, ITfReadOnlyProperty **ppProperty)
Definition: context.c:468
LPVOID get_Cookie_data(DWORD id)
Definition: msctf.c:248
static HRESULT WINAPI TextStoreACPServices_Unserialize(ITextStoreACPServices *iface, ITfProperty *prop, const TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream, ITfPersistentPropertyLoaderACP *loader)
Definition: context.c:928
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
ITfContextOwnerCompositionSink * pITfContextOwnerCompositionSink
Definition: context.c:68
ITfInsertAtSelection ITfInsertAtSelection_iface
Definition: context.c:50
DWORD lockType
Definition: context.c:82
HRESULT hr
Definition: shlfolder.c:183
static HRESULT WINAPI TextStoreACPServices_QueryInterface(ITextStoreACPServices *iface, REFIID riid, void **obj)
Definition: context.c:900
Definition: scsiwmi.h:51
static HRESULT WINAPI Context_RequestEditSession(ITfContext *iface, TfClientId tid, ITfEditSession *pes, DWORD dwFlags, HRESULT *phrSession)
Definition: context.c:200
static Context * impl_from_ITfSourceSingle(ITfSourceSingle *iface)
Definition: context.c:101
static HRESULT WINAPI TextStoreACPSink_OnAttrsChange(ITextStoreACPSink *iface, LONG acpStart, LONG acpEnd, ULONG cAttrs, const TS_ATTRID *paAttrs)
Definition: context.c:801
DWORD TfEditCookie
Definition: msctf.idl:67
static HRESULT WINAPI TextStoreACPSink_QueryInterface(ITextStoreACPSink *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:717
static const ITextStoreACPServicesVtbl TextStoreACPServicesVtbl
Definition: context.c:957
REFIID riid
Definition: precomp.h:44
LONG refCount
Definition: context.c:56
static HRESULT WINAPI TextStoreACPServices_CreateRange(ITextStoreACPServices *iface, LONG start, LONG end, ITfRangeACP **range)
Definition: context.c:947
static HRESULT WINAPI Context_CreateRangeBackup(ITfContext *iface, TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup)
Definition: context.c:503
static ULONG WINAPI TextStoreACPSink_Release(ITextStoreACPSink *iface)
Definition: context.c:746
GLuint GLuint GLsizei count
Definition: gl.h:1545
static HRESULT WINAPI Context_GetDocumentMgr(ITfContext *iface, ITfDocumentMgr **ppDm)
Definition: context.c:485
static HRESULT WINAPI Context_EnumViews(ITfContext *iface, IEnumTfContextViews **ppEnum)
Definition: context.c:419
static HRESULT WINAPI TextStoreACPServices_ForceLoadProperty(ITextStoreACPServices *iface, ITfProperty *prop)
Definition: context.c:938
void free_sinks(struct list *sink_list)
Definition: msctf.c:326
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT WINAPI Context_SetSelection(ITfContext *iface, TfEditCookie ec, ULONG ulCount, const TF_SELECTION *pSelection)
Definition: context.c:320
TS_STATUS documentStatus
Definition: context.c:64
#define SINK_FOR_EACH(cursor, list, type, elem)
static Context * impl_from_ITextStoreACPServices(ITextStoreACPServices *iface)
Definition: context.c:111
HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie)
Definition: msctf.c:287
static HRESULT WINAPI TextStoreACPSink_OnEndEditTransaction(ITextStoreACPSink *iface)
Definition: context.c:878
static HRESULT WINAPI TextStoreACPServices_Serialize(ITextStoreACPServices *iface, ITfProperty *prop, ITfRange *range, TF_PERSISTENT_PROPERTY_HEADER_ACP *header, IStream *stream)
Definition: context.c:918
static HRESULT WINAPI Context_GetStatus(ITfContext *iface, TF_STATUS *pdcs)
Definition: context.c:427
TfClientId tidOwner
Definition: context.c:62
struct list pTextLayoutSink
Definition: context.c:77
static HRESULT WINAPI ContextSource_AdviseSink(ITfSource *iface, REFIID riid, IUnknown *punk, DWORD *pdwCookie)
Definition: context.c:554
const DWORD TS_LF_READWRITE
Definition: textstor.idl:58
void Context_AddRef(context_t *context)
Definition: context.c:78
GLuint GLuint end
Definition: gl.h:1545
DWORD get_Cookie_magic(DWORD id)
Definition: msctf.c:235
static HRESULT WINAPI TextStoreACPSink_OnStatusChange(ITextStoreACPSink *iface, DWORD dwFlags)
Definition: context.c:779
static const ITfSourceVtbl ContextSourceVtbl
Definition: context.c:583
static ULONG WINAPI TextStoreACPSink_AddRef(ITextStoreACPSink *iface)
Definition: context.c:740
ITextStoreACPServices ITextStoreACPServices_iface
Definition: context.c:55
#define E_FAIL
Definition: ddrawi.h:102
DWORD TsViewCookie
Definition: textstor.idl:111
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
void Context_Release(context_t *context)
Definition: context.c:106
static HRESULT WINAPI InsertAtSelection_InsertEmbeddedAtSelection(ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, IDataObject *pDataObject, ITfRange **ppRange)
Definition: context.c:649
static ULONG WINAPI InsertAtSelection_Release(ITfInsertAtSelection *iface)
Definition: context.c:607
static HRESULT WINAPI ContextSource_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:533
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
static ULONG WINAPI InsertAtSelection_AddRef(ITfInsertAtSelection *iface)
Definition: context.c:601
LONG acpNewEnd
Definition: textstor.idl:81
static const ITfContextVtbl ContextVtbl
Definition: context.c:511
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ITfCompartmentMgr * CompartmentMgr
Definition: context.c:60
LPVOID remove_Cookie(DWORD id)
Definition: msctf.c:261
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL connected
Definition: context.c:57
static Context * impl_from_ITfContext(ITfContext *iface)
Definition: context.c:86
struct list pStatusSink
Definition: context.c:75
static HRESULT WINAPI Context_GetProperty(ITfContext *iface, REFGUID guidProp, ITfProperty **ppProp)
Definition: context.c:452
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
static HRESULT WINAPI SourceSingle_AdviseSingleSink(ITfSourceSingle *iface, TfClientId tid, REFIID riid, IUnknown *punk)
Definition: context.c:688
#define E_INVALIDARG
Definition: ddrawi.h:101
static HRESULT WINAPI Context_GetSelection(ITfContext *iface, TfEditCookie ec, ULONG ulIndex, ULONG ulCount, TF_SELECTION *pSelection, ULONG *pcFetched)
Definition: context.c:260
struct tagEditCookie EditCookie
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
static const ITfInsertAtSelectionVtbl InsertAtSelectionVtbl
Definition: context.c:658
static Context * impl_from_ITfInsertAtSelection(ITfInsertAtSelection *iface)
Definition: context.c:96
HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfDocumentMgr *mgr, ITfContext **ppOut, TfEditCookie *pecTextStore)
Definition: context.c:968
struct list pTextEditSink
Definition: context.c:76
ITfSource ITfSource_iface
Definition: context.c:46
HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut) DECLSPEC_HIDDEN
Definition: range.c:329
Context * pOwningContext
Definition: context.c:83
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ITfContext ITfContext_iface
Definition: context.c:45
static HRESULT WINAPI TextStoreACPSink_OnStartEditTransaction(ITextStoreACPSink *iface)
Definition: context.c:871
ITextStoreACP * pITextStoreACP
Definition: context.c:67
static HRESULT WINAPI Context_GetStart(ITfContext *iface, TfEditCookie ec, ITfRange **ppStart)
Definition: context.c:358
static Context * impl_from_ITextStoreACPSink(ITextStoreACPSink *iface)
Definition: context.c:106
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static Context * impl_from_ITfSource(ITfSource *iface)
Definition: context.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
static ULONG WINAPI ContextSource_Release(ITfSource *iface)
Definition: context.c:545
LONG HRESULT
Definition: typedefs.h:77
WINE_DEFAULT_DEBUG_CHANNEL(d3d)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
#define COOKIE_MAGIC_EDITCOOKIE
static ULONG WINAPI TextStoreACPServices_AddRef(ITextStoreACPServices *iface)
Definition: context.c:906
unsigned long DWORD
Definition: ntddk_ex.h:95
#define COOKIE_MAGIC_CONTEXTSINK
const DWORD TS_LF_READ
Definition: textstor.idl:57
static ULONG WINAPI SourceSingle_Release(ITfSourceSingle *iface)
Definition: context.c:682
TfEditCookie defaultCookie
Definition: context.c:63
int ret
ITfSourceSingle ITfSourceSingle_iface
Definition: context.c:53
#define InterlockedDecrement
Definition: armddk.h:52
Definition: parse.h:22
static HRESULT WINAPI ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
Definition: context.c:571
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _list.h:228
const DWORD TS_AS_ALL_SINKS
Definition: textstor.idl:54
const DWORD TS_LF_SYNC
Definition: textstor.idl:56
ITfDocumentMgr * manager
Definition: context.c:65
ITfEditSession * currentEditSession
Definition: context.c:70
#define debugstr_wn
Definition: kernel32.h:33
static HRESULT WINAPI SourceSingle_UnadviseSingleSink(ITfSourceSingle *iface, TfClientId tid, REFIID riid)
Definition: context.c:696
static void Context_Destructor(Context *This)
Definition: context.c:116
HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *iface)
GLenum GLint * range
Definition: glext.h:7539
static HRESULT WINAPI TextStoreACPSink_OnLayoutChange(ITextStoreACPSink *iface, TsLayoutCode lcode, TsViewCookie vcView)
Definition: context.c:771
static ULONG WINAPI SourceSingle_AddRef(ITfSourceSingle *iface)
Definition: context.c:676
static HRESULT WINAPI Context_EnumProperties(ITfContext *iface, IEnumTfProperties **ppEnum)
Definition: context.c:477
static HRESULT WINAPI SourceSingle_QueryInterface(ITfSourceSingle *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:670
ITextStoreACPSink ITextStoreACPSink_iface
Definition: context.c:54
ULONG ulIndex
Definition: symbols.c:92
#define S_OK
Definition: intsafe.h:59
static ULONG WINAPI ContextSource_AddRef(ITfSource *iface)
Definition: context.c:539
static HRESULT WINAPI Context_QueryInterface(ITfContext *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:144
#define InterlockedIncrement
Definition: armddk.h:53
const char cursor[]
Definition: icontest.c:13
TsActiveSelEnd ase
Definition: textstor.idl:86
GLuint start
Definition: gl.h:1545
static HRESULT WINAPI Context_GetActiveView(ITfContext *iface, ITfContextView **ppView)
Definition: context.c:411
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI Context_InWriteSession(ITfContext *iface, TfClientId tid, BOOL *pfWriteSession)
Definition: context.c:251
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static HRESULT WINAPI TextStoreACPSink_OnTextChange(ITextStoreACPSink *iface, DWORD dwFlags, const TS_TEXTCHANGE *pChange)
Definition: context.c:756
static HRESULT WINAPI InsertAtSelection_QueryInterface(ITfInsertAtSelection *iface, REFIID iid, LPVOID *ppvOut)
Definition: context.c:595
HRESULT unadvise_sink(DWORD cookie)
Definition: msctf.c:314
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
struct tagContext Context
Definition: acpixf.h:1012
unsigned int ULONG
Definition: retypes.h:1
HRESULT TF_SELECTION_to_TS_SELECTION_ACP(const TF_SELECTION *tf, TS_SELECTION_ACP *tsAcp) DECLSPEC_HIDDEN
Definition: range.c:355
static HRESULT WINAPI Context_GetAppProperty(ITfContext *iface, REFGUID guidProp, ITfReadOnlyProperty **ppProp)
Definition: context.c:460
static HRESULT WINAPI Context_GetEnd(ITfContext *iface, TfEditCookie ec, ITfRange **ppEnd)
Definition: context.c:380
HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut)
DWORD TfClientId
Definition: msctf.idl:68
const DWORD TS_SD_READONLY
Definition: textstor.idl:40
static ULONG WINAPI TextStoreACPServices_Release(ITextStoreACPServices *iface)
Definition: context.c:912
struct list pEditTransactionSink
Definition: context.c:74
static const ITfSourceSingleVtbl ContextSourceSingleVtbl
Definition: context.c:704
struct list pContextKeyEventSink
Definition: context.c:73
HRESULT Context_Initialize(ITfContext *iface, ITfDocumentMgr *manager)
Definition: context.c:1029
static TfClientId tid
#define HeapFree(x, y, z)
Definition: compat.h:394
static HRESULT WINAPI TextStoreACPSink_OnSelectionChange(ITextStoreACPSink *iface)
Definition: context.c:764
struct CFHEADER header
Definition: fdi.c:109
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
static HRESULT WINAPI InsertAtSelection_InsertTextAtSelection(ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, const WCHAR *pchText, LONG cch, ITfRange **ppRange)
Definition: context.c:613
static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface, DWORD dwLockFlags)
Definition: context.c:809
#define SUCCEEDED(hr)
Definition: intsafe.h:57
DWORD generate_Cookie(DWORD magic, LPVOID data)
Definition: msctf.c:191
HRESULT Context_Uninitialize(ITfContext *iface)
Definition: context.c:1041
TsLayoutCode
Definition: textstor.idl:110
static const ITextStoreACPSinkVtbl TextStoreACPSinkVtbl
Definition: context.c:885