-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadMgrEventSink.cpp
More file actions
146 lines (119 loc) · 4 KB
/
ThreadMgrEventSink.cpp
File metadata and controls
146 lines (119 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//////////////////////////////////////////////////////////////////////
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) 2003 Microsoft Corporation. All rights reserved.
//
// ThreadMgrEventSink.cpp
//
// ITfThreadMgrEventSink implementation.
//
//////////////////////////////////////////////////////////////////////
#include "Globals.h"
#include "TextService.h"
//+---------------------------------------------------------------------------
//
// OnInitDocumentMgr
//
// Sink called by the framework just before the first context is pushed onto
// a document.
//----------------------------------------------------------------------------
STDAPI CTextService::OnInitDocumentMgr(ITfDocumentMgr *pDocMgr)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// OnUninitDocumentMgr
//
// Sink called by the framework just after the last context is popped off a
// document.
//----------------------------------------------------------------------------
STDAPI CTextService::OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// OnSetFocus
//
// Sink called by the framework when focus changes from one document to
// another. Either document may be NULL, meaning previously there was no
// focus document, or now no document holds the input focus.
//----------------------------------------------------------------------------
STDAPI CTextService::OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus)
{
UNREFERENCED_PARAMETER(pDocMgrPrevFocus);
_ReloadSettings();
//
// Whenever focus is changed, we initialize the TextEditSink.
//
_InitTextEditSink(pDocMgrFocus);
_UpdateInputScopeForDocumentMgr(pDocMgrFocus);
return S_OK;
}
//+---------------------------------------------------------------------------
//
// OnPushContext
//
// Sink called by the framework when a context is pushed.
//----------------------------------------------------------------------------
STDAPI CTextService::OnPushContext(ITfContext *pContext)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// OnPopContext
//
// Sink called by the framework when a context is popped.
//----------------------------------------------------------------------------
STDAPI CTextService::OnPopContext(ITfContext *pContext)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// _InitThreadMgrEventSink
//
// Advise our sink.
//----------------------------------------------------------------------------
BOOL CTextService::_InitThreadMgrEventSink()
{
ITfSource *pSource;
BOOL fRet;
if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK)
return FALSE;
fRet = FALSE;
if (pSource->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *)this, &_dwThreadMgrEventSinkCookie) != S_OK)
{
// make sure we don't try to Unadvise _dwThreadMgrEventSinkCookie later
_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
goto Exit;
}
fRet = TRUE;
Exit:
pSource->Release();
return fRet;
}
//+---------------------------------------------------------------------------
//
// _UninitThreadMgrEventSink
//
// Unadvise our sink.
//----------------------------------------------------------------------------
void CTextService::_UninitThreadMgrEventSink()
{
ITfSource *pSource;
if (_dwThreadMgrEventSinkCookie == TF_INVALID_COOKIE)
return; // never Advised
if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK)
{
pSource->UnadviseSink(_dwThreadMgrEventSinkCookie);
pSource->Release();
}
_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
}