1b2ec7867SKatayama Hirofumi MZ /*
2b2ec7867SKatayama Hirofumi MZ * PROJECT: ReactOS msctfime.ime
3b2ec7867SKatayama Hirofumi MZ * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4980ebf06SKatayama Hirofumi MZ * PURPOSE: The bridge of msctfime.ime
5b2ec7867SKatayama Hirofumi MZ * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6b2ec7867SKatayama Hirofumi MZ */
7b2ec7867SKatayama Hirofumi MZ
8b2ec7867SKatayama Hirofumi MZ #include "msctfime.h"
9b2ec7867SKatayama Hirofumi MZ
10b2ec7867SKatayama Hirofumi MZ WINE_DEFAULT_DEBUG_CHANNEL(msctfime);
11b2ec7867SKatayama Hirofumi MZ
12b2ec7867SKatayama Hirofumi MZ /// @implemented
CicBridge()13b2ec7867SKatayama Hirofumi MZ CicBridge::CicBridge()
14b2ec7867SKatayama Hirofumi MZ {
15b2ec7867SKatayama Hirofumi MZ m_bImmxInited = FALSE;
16b2ec7867SKatayama Hirofumi MZ m_bUnknown1 = FALSE;
17b2ec7867SKatayama Hirofumi MZ m_bDeactivating = FALSE;
18b2ec7867SKatayama Hirofumi MZ m_bUnknown2 = FALSE;
19b2ec7867SKatayama Hirofumi MZ m_pKeystrokeMgr = NULL;
20b2ec7867SKatayama Hirofumi MZ m_pDocMgr = NULL;
21b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink = NULL;
22b2ec7867SKatayama Hirofumi MZ m_cliendId = 0;
23b2ec7867SKatayama Hirofumi MZ m_cRefs = 1;
24b2ec7867SKatayama Hirofumi MZ }
25b2ec7867SKatayama Hirofumi MZ
26b2ec7867SKatayama Hirofumi MZ /// @implemented
QueryInterface(REFIID riid,LPVOID * ppvObj)27b2ec7867SKatayama Hirofumi MZ STDMETHODIMP CicBridge::QueryInterface(REFIID riid, LPVOID* ppvObj)
28b2ec7867SKatayama Hirofumi MZ {
29*c5e64563SKatayama Hirofumi MZ static const QITAB c_tab[] =
30*c5e64563SKatayama Hirofumi MZ {
31*c5e64563SKatayama Hirofumi MZ QITABENT(CicBridge, ITfSysHookSink),
32*c5e64563SKatayama Hirofumi MZ { NULL }
33*c5e64563SKatayama Hirofumi MZ };
34*c5e64563SKatayama Hirofumi MZ return ::QISearch(this, c_tab, riid, ppvObj);
35b2ec7867SKatayama Hirofumi MZ }
36b2ec7867SKatayama Hirofumi MZ
37b2ec7867SKatayama Hirofumi MZ /// @implemented
STDMETHODIMP_(ULONG)38b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) CicBridge::AddRef()
39b2ec7867SKatayama Hirofumi MZ {
40b2ec7867SKatayama Hirofumi MZ return ::InterlockedIncrement(&m_cRefs);
41b2ec7867SKatayama Hirofumi MZ }
42b2ec7867SKatayama Hirofumi MZ
43b2ec7867SKatayama Hirofumi MZ /// @implemented
STDMETHODIMP_(ULONG)44b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) CicBridge::Release()
45b2ec7867SKatayama Hirofumi MZ {
46b2ec7867SKatayama Hirofumi MZ if (::InterlockedDecrement(&m_cRefs) == 0)
47b2ec7867SKatayama Hirofumi MZ {
48b2ec7867SKatayama Hirofumi MZ delete this;
49b2ec7867SKatayama Hirofumi MZ return 0;
50b2ec7867SKatayama Hirofumi MZ }
51b2ec7867SKatayama Hirofumi MZ return m_cRefs;
52b2ec7867SKatayama Hirofumi MZ }
53b2ec7867SKatayama Hirofumi MZ
54b2ec7867SKatayama Hirofumi MZ /// @implemented
~CicBridge()55b2ec7867SKatayama Hirofumi MZ CicBridge::~CicBridge()
56b2ec7867SKatayama Hirofumi MZ {
57b2ec7867SKatayama Hirofumi MZ TLS *pTLS = TLS::PeekTLS();
58b2ec7867SKatayama Hirofumi MZ if (!pTLS || !pTLS->m_pThreadMgr)
59b2ec7867SKatayama Hirofumi MZ return;
60b2ec7867SKatayama Hirofumi MZ
61b2ec7867SKatayama Hirofumi MZ if (SUCCEEDED(DeactivateIMMX(pTLS, pTLS->m_pThreadMgr)))
62b2ec7867SKatayama Hirofumi MZ UnInitIMMX(pTLS);
63b2ec7867SKatayama Hirofumi MZ }
64b2ec7867SKatayama Hirofumi MZ
65980ebf06SKatayama Hirofumi MZ /// @implemented
66980ebf06SKatayama Hirofumi MZ ITfDocumentMgr*
GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT> & imeContext)67980ebf06SKatayama Hirofumi MZ CicBridge::GetDocumentManager(_Inout_ CicIMCCLock<CTFIMECONTEXT>& imeContext)
68b2ec7867SKatayama Hirofumi MZ {
69b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
70980ebf06SKatayama Hirofumi MZ if (!pCicIC)
71980ebf06SKatayama Hirofumi MZ return NULL;
72980ebf06SKatayama Hirofumi MZ
73980ebf06SKatayama Hirofumi MZ pCicIC->m_pDocumentMgr->AddRef();
74980ebf06SKatayama Hirofumi MZ return pCicIC->m_pDocumentMgr;
75b2ec7867SKatayama Hirofumi MZ }
76b2ec7867SKatayama Hirofumi MZ
77980ebf06SKatayama Hirofumi MZ /// @implemented
78b2ec7867SKatayama Hirofumi MZ HRESULT
CreateInputContext(_Inout_ TLS * pTLS,_In_ HIMC hIMC)79b2ec7867SKatayama Hirofumi MZ CicBridge::CreateInputContext(
80b2ec7867SKatayama Hirofumi MZ _Inout_ TLS *pTLS,
81b2ec7867SKatayama Hirofumi MZ _In_ HIMC hIMC)
82b2ec7867SKatayama Hirofumi MZ {
83b2ec7867SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
84f53f1334SKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
85f53f1334SKatayama Hirofumi MZ return imcLock.m_hr;
86b2ec7867SKatayama Hirofumi MZ
87b2ec7867SKatayama Hirofumi MZ if (!imcLock.get().hCtfImeContext)
88b2ec7867SKatayama Hirofumi MZ {
89b2ec7867SKatayama Hirofumi MZ HIMCC hCtfImeContext = ImmCreateIMCC(sizeof(CTFIMECONTEXT));
90b2ec7867SKatayama Hirofumi MZ if (!hCtfImeContext)
91b2ec7867SKatayama Hirofumi MZ return E_OUTOFMEMORY;
92b2ec7867SKatayama Hirofumi MZ imcLock.get().hCtfImeContext = hCtfImeContext;
93b2ec7867SKatayama Hirofumi MZ }
94b2ec7867SKatayama Hirofumi MZ
95b2ec7867SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
96b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
97980ebf06SKatayama Hirofumi MZ if (pCicIC)
98980ebf06SKatayama Hirofumi MZ return S_OK;
99980ebf06SKatayama Hirofumi MZ
100b2ec7867SKatayama Hirofumi MZ pCicIC = new(cicNoThrow) CicInputContext(m_cliendId, &m_LibThread, hIMC);
101b2ec7867SKatayama Hirofumi MZ if (!pCicIC)
102b2ec7867SKatayama Hirofumi MZ {
103b2ec7867SKatayama Hirofumi MZ imeContext.unlock();
104b2ec7867SKatayama Hirofumi MZ imcLock.unlock();
105b2ec7867SKatayama Hirofumi MZ DestroyInputContext(pTLS, hIMC);
106b2ec7867SKatayama Hirofumi MZ return E_OUTOFMEMORY;
107b2ec7867SKatayama Hirofumi MZ }
108b2ec7867SKatayama Hirofumi MZ
109b2ec7867SKatayama Hirofumi MZ if (!pTLS->m_pThreadMgr)
110b2ec7867SKatayama Hirofumi MZ {
111b2ec7867SKatayama Hirofumi MZ pCicIC->Release();
112b2ec7867SKatayama Hirofumi MZ imeContext.unlock();
113b2ec7867SKatayama Hirofumi MZ imcLock.unlock();
114b2ec7867SKatayama Hirofumi MZ DestroyInputContext(pTLS, hIMC);
115b2ec7867SKatayama Hirofumi MZ return E_NOINTERFACE;
116b2ec7867SKatayama Hirofumi MZ }
117b2ec7867SKatayama Hirofumi MZ
118b2ec7867SKatayama Hirofumi MZ imeContext.get().m_pCicIC = pCicIC;
119b2ec7867SKatayama Hirofumi MZ
120f53f1334SKatayama Hirofumi MZ HRESULT hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock);
121b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
122b2ec7867SKatayama Hirofumi MZ {
123b2ec7867SKatayama Hirofumi MZ pCicIC->Release();
124b2ec7867SKatayama Hirofumi MZ imeContext.get().m_pCicIC = NULL;
125980ebf06SKatayama Hirofumi MZ return hr;
126b2ec7867SKatayama Hirofumi MZ }
127980ebf06SKatayama Hirofumi MZ
128980ebf06SKatayama Hirofumi MZ HWND hWnd = imcLock.get().hWnd;
129980ebf06SKatayama Hirofumi MZ if (hWnd && hWnd == ::GetFocus())
130b2ec7867SKatayama Hirofumi MZ {
131980ebf06SKatayama Hirofumi MZ ITfDocumentMgr *pDocMgr = GetDocumentManager(imeContext);
132980ebf06SKatayama Hirofumi MZ if (pDocMgr)
133b2ec7867SKatayama Hirofumi MZ {
134980ebf06SKatayama Hirofumi MZ SetAssociate(pTLS, hWnd, hIMC, pTLS->m_pThreadMgr, pDocMgr);
135980ebf06SKatayama Hirofumi MZ pDocMgr->Release();
136b2ec7867SKatayama Hirofumi MZ }
137b2ec7867SKatayama Hirofumi MZ }
138b2ec7867SKatayama Hirofumi MZ
139980ebf06SKatayama Hirofumi MZ return hr;
140b2ec7867SKatayama Hirofumi MZ }
141b2ec7867SKatayama Hirofumi MZ
142b2ec7867SKatayama Hirofumi MZ /// @implemented
DestroyInputContext(TLS * pTLS,HIMC hIMC)143b2ec7867SKatayama Hirofumi MZ HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC)
144b2ec7867SKatayama Hirofumi MZ {
145b2ec7867SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
146b2ec7867SKatayama Hirofumi MZ HRESULT hr = imcLock.m_hr;
147b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
148b2ec7867SKatayama Hirofumi MZ return hr;
149b2ec7867SKatayama Hirofumi MZ
150b2ec7867SKatayama Hirofumi MZ hr = E_FAIL;
151b2ec7867SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
152b2ec7867SKatayama Hirofumi MZ if (imeContext)
153b2ec7867SKatayama Hirofumi MZ hr = imeContext.m_hr;
154b2ec7867SKatayama Hirofumi MZ
155b2ec7867SKatayama Hirofumi MZ if (SUCCEEDED(hr) && !(imeContext.get().m_dwCicFlags & 1))
156b2ec7867SKatayama Hirofumi MZ {
157b2ec7867SKatayama Hirofumi MZ imeContext.get().m_dwCicFlags |= 1;
158b2ec7867SKatayama Hirofumi MZ
159b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
160b2ec7867SKatayama Hirofumi MZ if (pCicIC)
161b2ec7867SKatayama Hirofumi MZ {
162b2ec7867SKatayama Hirofumi MZ imeContext.get().m_pCicIC = NULL;
163b2ec7867SKatayama Hirofumi MZ hr = pCicIC->DestroyInputContext();
164b2ec7867SKatayama Hirofumi MZ pCicIC->Release();
165b2ec7867SKatayama Hirofumi MZ imeContext.get().m_pCicIC = NULL;
166b2ec7867SKatayama Hirofumi MZ }
167b2ec7867SKatayama Hirofumi MZ }
168b2ec7867SKatayama Hirofumi MZ
169b2ec7867SKatayama Hirofumi MZ if (imcLock.get().hCtfImeContext)
170b2ec7867SKatayama Hirofumi MZ {
171b2ec7867SKatayama Hirofumi MZ ImmDestroyIMCC(imcLock.get().hCtfImeContext);
172b2ec7867SKatayama Hirofumi MZ imcLock.get().hCtfImeContext = NULL;
173b2ec7867SKatayama Hirofumi MZ hr = S_OK;
174b2ec7867SKatayama Hirofumi MZ }
175b2ec7867SKatayama Hirofumi MZ
176b2ec7867SKatayama Hirofumi MZ return hr;
177b2ec7867SKatayama Hirofumi MZ }
178b2ec7867SKatayama Hirofumi MZ
1797d0b5482SKatayama Hirofumi MZ /// @implemented
180b2ec7867SKatayama Hirofumi MZ ITfContext *
GetInputContext(CicIMCCLock<CTFIMECONTEXT> & imeContext)181b2ec7867SKatayama Hirofumi MZ CicBridge::GetInputContext(CicIMCCLock<CTFIMECONTEXT>& imeContext)
182b2ec7867SKatayama Hirofumi MZ {
183b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
184b2ec7867SKatayama Hirofumi MZ if (!pCicIC)
185b2ec7867SKatayama Hirofumi MZ return NULL;
186b2ec7867SKatayama Hirofumi MZ return pCicIC->m_pContext;
187b2ec7867SKatayama Hirofumi MZ }
188b2ec7867SKatayama Hirofumi MZ
1897d0b5482SKatayama Hirofumi MZ /// @implemented
OnSetOpenStatus(TLS * pTLS,ITfThreadMgr_P * pThreadMgr,CicIMCLock & imcLock,CicInputContext * pCicIC)190b2ec7867SKatayama Hirofumi MZ HRESULT CicBridge::OnSetOpenStatus(
191b2ec7867SKatayama Hirofumi MZ TLS *pTLS,
192b2ec7867SKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
193b2ec7867SKatayama Hirofumi MZ CicIMCLock& imcLock,
194b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC)
195b2ec7867SKatayama Hirofumi MZ {
1967d0b5482SKatayama Hirofumi MZ if (!imcLock.get().fOpen && imcLock.ValidCompositionString())
1977d0b5482SKatayama Hirofumi MZ pCicIC->EscbCompComplete(imcLock);
1987d0b5482SKatayama Hirofumi MZ
1997d0b5482SKatayama Hirofumi MZ pTLS->m_bNowOpening = TRUE;
2007d0b5482SKatayama Hirofumi MZ HRESULT hr = SetCompartmentDWORD(m_cliendId, pThreadMgr,
2017d0b5482SKatayama Hirofumi MZ GUID_COMPARTMENT_KEYBOARD_OPENCLOSE,
2027d0b5482SKatayama Hirofumi MZ imcLock.get().fOpen, FALSE);
2037d0b5482SKatayama Hirofumi MZ pTLS->m_bNowOpening = FALSE;
2047d0b5482SKatayama Hirofumi MZ return hr;
205b2ec7867SKatayama Hirofumi MZ }
206b2ec7867SKatayama Hirofumi MZ
207b2ec7867SKatayama Hirofumi MZ /// Selects the IME context.
208b2ec7867SKatayama Hirofumi MZ /// @implemented
209b2ec7867SKatayama Hirofumi MZ HRESULT
SelectEx(_Inout_ TLS * pTLS,_Inout_ ITfThreadMgr_P * pThreadMgr,_In_ HIMC hIMC,_In_ BOOL fSelect,_In_ HKL hKL)210b2ec7867SKatayama Hirofumi MZ CicBridge::SelectEx(
211b2ec7867SKatayama Hirofumi MZ _Inout_ TLS *pTLS,
212b2ec7867SKatayama Hirofumi MZ _Inout_ ITfThreadMgr_P *pThreadMgr,
213b2ec7867SKatayama Hirofumi MZ _In_ HIMC hIMC,
214b2ec7867SKatayama Hirofumi MZ _In_ BOOL fSelect,
215b2ec7867SKatayama Hirofumi MZ _In_ HKL hKL)
216b2ec7867SKatayama Hirofumi MZ {
217b2ec7867SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
218b2ec7867SKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
219b2ec7867SKatayama Hirofumi MZ return imcLock.m_hr;
220b2ec7867SKatayama Hirofumi MZ
221b2ec7867SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
222b2ec7867SKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
223b2ec7867SKatayama Hirofumi MZ return imeContext.m_hr;
224b2ec7867SKatayama Hirofumi MZ
225b2ec7867SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
226b2ec7867SKatayama Hirofumi MZ if (pCicIC)
227b2ec7867SKatayama Hirofumi MZ pCicIC->m_bSelecting = TRUE;
228b2ec7867SKatayama Hirofumi MZ
229b2ec7867SKatayama Hirofumi MZ if (fSelect)
230b2ec7867SKatayama Hirofumi MZ {
231b2ec7867SKatayama Hirofumi MZ if (pCicIC)
23269b08be0SKatayama Hirofumi MZ pCicIC->m_bCandidateOpen = FALSE;
233b2ec7867SKatayama Hirofumi MZ if (imcLock.get().fOpen)
234b2ec7867SKatayama Hirofumi MZ OnSetOpenStatus(pTLS, pThreadMgr, imcLock, pCicIC);
235b2ec7867SKatayama Hirofumi MZ }
236b2ec7867SKatayama Hirofumi MZ else
237b2ec7867SKatayama Hirofumi MZ {
238b2ec7867SKatayama Hirofumi MZ ITfContext *pContext = GetInputContext(imeContext);
239b2ec7867SKatayama Hirofumi MZ pThreadMgr->RequestPostponedLock(pContext);
240b2ec7867SKatayama Hirofumi MZ if (pCicIC)
241b2ec7867SKatayama Hirofumi MZ pCicIC->m_bSelecting = FALSE;
242b2ec7867SKatayama Hirofumi MZ if (pContext)
243b2ec7867SKatayama Hirofumi MZ pContext->Release();
244b2ec7867SKatayama Hirofumi MZ }
245b2ec7867SKatayama Hirofumi MZ
246b2ec7867SKatayama Hirofumi MZ return imeContext.m_hr;
247b2ec7867SKatayama Hirofumi MZ }
248b2ec7867SKatayama Hirofumi MZ
249b2ec7867SKatayama Hirofumi MZ /// Used in CicBridge::EnumCreateInputContextCallback and
250b2ec7867SKatayama Hirofumi MZ /// CicBridge::EnumDestroyInputContextCallback.
251b2ec7867SKatayama Hirofumi MZ typedef struct ENUM_CREATE_DESTROY_IC
252b2ec7867SKatayama Hirofumi MZ {
253b2ec7867SKatayama Hirofumi MZ TLS *m_pTLS;
254b2ec7867SKatayama Hirofumi MZ CicBridge *m_pBridge;
255b2ec7867SKatayama Hirofumi MZ } ENUM_CREATE_DESTROY_IC, *PENUM_CREATE_DESTROY_IC;
256b2ec7867SKatayama Hirofumi MZ
257b2ec7867SKatayama Hirofumi MZ /// Creates input context for the current thread.
258b2ec7867SKatayama Hirofumi MZ /// @implemented
EnumCreateInputContextCallback(HIMC hIMC,LPARAM lParam)259b2ec7867SKatayama Hirofumi MZ BOOL CALLBACK CicBridge::EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam)
260b2ec7867SKatayama Hirofumi MZ {
261b2ec7867SKatayama Hirofumi MZ PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam;
262b2ec7867SKatayama Hirofumi MZ pData->m_pBridge->CreateInputContext(pData->m_pTLS, hIMC);
263b2ec7867SKatayama Hirofumi MZ return TRUE;
264b2ec7867SKatayama Hirofumi MZ }
265b2ec7867SKatayama Hirofumi MZ
266b2ec7867SKatayama Hirofumi MZ /// Destroys input context for the current thread.
267b2ec7867SKatayama Hirofumi MZ /// @implemented
EnumDestroyInputContextCallback(HIMC hIMC,LPARAM lParam)268b2ec7867SKatayama Hirofumi MZ BOOL CALLBACK CicBridge::EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam)
269b2ec7867SKatayama Hirofumi MZ {
270b2ec7867SKatayama Hirofumi MZ PENUM_CREATE_DESTROY_IC pData = (PENUM_CREATE_DESTROY_IC)lParam;
271b2ec7867SKatayama Hirofumi MZ pData->m_pBridge->DestroyInputContext(pData->m_pTLS, hIMC);
272b2ec7867SKatayama Hirofumi MZ return TRUE;
273b2ec7867SKatayama Hirofumi MZ }
274b2ec7867SKatayama Hirofumi MZ
275b2ec7867SKatayama Hirofumi MZ /// @implemented
276b2ec7867SKatayama Hirofumi MZ HRESULT
ActivateIMMX(_Inout_ TLS * pTLS,_Inout_ ITfThreadMgr_P * pThreadMgr)277b2ec7867SKatayama Hirofumi MZ CicBridge::ActivateIMMX(
278b2ec7867SKatayama Hirofumi MZ _Inout_ TLS *pTLS,
279b2ec7867SKatayama Hirofumi MZ _Inout_ ITfThreadMgr_P *pThreadMgr)
280b2ec7867SKatayama Hirofumi MZ {
281b2ec7867SKatayama Hirofumi MZ HRESULT hr = pThreadMgr->ActivateEx(&m_cliendId, 1);
282b2ec7867SKatayama Hirofumi MZ if (hr != S_OK)
283b2ec7867SKatayama Hirofumi MZ {
284b2ec7867SKatayama Hirofumi MZ m_cliendId = 0;
285b2ec7867SKatayama Hirofumi MZ return E_FAIL;
286b2ec7867SKatayama Hirofumi MZ }
287b2ec7867SKatayama Hirofumi MZ
288b2ec7867SKatayama Hirofumi MZ if (m_cActivateLocks++ != 0)
289b2ec7867SKatayama Hirofumi MZ return S_OK;
290b2ec7867SKatayama Hirofumi MZ
291b2ec7867SKatayama Hirofumi MZ ITfSourceSingle *pSource = NULL;
292b2ec7867SKatayama Hirofumi MZ hr = pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void**)&pSource);
293b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
294b2ec7867SKatayama Hirofumi MZ {
295b2ec7867SKatayama Hirofumi MZ DeactivateIMMX(pTLS, pThreadMgr);
296b2ec7867SKatayama Hirofumi MZ return hr;
297b2ec7867SKatayama Hirofumi MZ }
298b2ec7867SKatayama Hirofumi MZ
299b2ec7867SKatayama Hirofumi MZ CFunctionProvider *pProvider = new(cicNoThrow) CFunctionProvider(m_cliendId);
300b2ec7867SKatayama Hirofumi MZ if (!pProvider)
301b2ec7867SKatayama Hirofumi MZ {
302b2ec7867SKatayama Hirofumi MZ hr = E_FAIL;
303b2ec7867SKatayama Hirofumi MZ goto Finish;
304b2ec7867SKatayama Hirofumi MZ }
305b2ec7867SKatayama Hirofumi MZ
306b2ec7867SKatayama Hirofumi MZ pSource->AdviseSingleSink(m_cliendId, IID_ITfFunctionProvider, pProvider);
307b2ec7867SKatayama Hirofumi MZ pProvider->Release();
308b2ec7867SKatayama Hirofumi MZ
309b2ec7867SKatayama Hirofumi MZ if (!m_pDocMgr)
310b2ec7867SKatayama Hirofumi MZ {
311b2ec7867SKatayama Hirofumi MZ hr = pThreadMgr->CreateDocumentMgr(&m_pDocMgr);
312b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
313b2ec7867SKatayama Hirofumi MZ {
314b2ec7867SKatayama Hirofumi MZ hr = E_FAIL;
315b2ec7867SKatayama Hirofumi MZ goto Finish;
316b2ec7867SKatayama Hirofumi MZ }
317b2ec7867SKatayama Hirofumi MZ
318b2ec7867SKatayama Hirofumi MZ SetCompartmentDWORD(m_cliendId, m_pDocMgr, GUID_COMPARTMENT_CTFIME_DIMFLAGS, TRUE, FALSE);
319b2ec7867SKatayama Hirofumi MZ }
320b2ec7867SKatayama Hirofumi MZ
321b2ec7867SKatayama Hirofumi MZ pThreadMgr->SetSysHookSink(this);
322b2ec7867SKatayama Hirofumi MZ
323b2ec7867SKatayama Hirofumi MZ hr = S_OK;
324b2ec7867SKatayama Hirofumi MZ if (pTLS->m_bDestroyed)
325b2ec7867SKatayama Hirofumi MZ {
326b2ec7867SKatayama Hirofumi MZ ENUM_CREATE_DESTROY_IC Data = { pTLS, this };
327b2ec7867SKatayama Hirofumi MZ ImmEnumInputContext(0, CicBridge::EnumCreateInputContextCallback, (LPARAM)&Data);
328b2ec7867SKatayama Hirofumi MZ }
329b2ec7867SKatayama Hirofumi MZ
330b2ec7867SKatayama Hirofumi MZ Finish:
331b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
332b2ec7867SKatayama Hirofumi MZ DeactivateIMMX(pTLS, pThreadMgr);
333b2ec7867SKatayama Hirofumi MZ if (pSource)
334b2ec7867SKatayama Hirofumi MZ pSource->Release();
335b2ec7867SKatayama Hirofumi MZ return hr;
336b2ec7867SKatayama Hirofumi MZ }
337b2ec7867SKatayama Hirofumi MZ
338b2ec7867SKatayama Hirofumi MZ /// @implemented
339b2ec7867SKatayama Hirofumi MZ HRESULT
DeactivateIMMX(_Inout_ TLS * pTLS,_Inout_ ITfThreadMgr_P * pThreadMgr)340b2ec7867SKatayama Hirofumi MZ CicBridge::DeactivateIMMX(
341b2ec7867SKatayama Hirofumi MZ _Inout_ TLS *pTLS,
342b2ec7867SKatayama Hirofumi MZ _Inout_ ITfThreadMgr_P *pThreadMgr)
343b2ec7867SKatayama Hirofumi MZ {
344b2ec7867SKatayama Hirofumi MZ if (m_bDeactivating)
345b2ec7867SKatayama Hirofumi MZ return TRUE;
346b2ec7867SKatayama Hirofumi MZ
347b2ec7867SKatayama Hirofumi MZ m_bDeactivating = TRUE;
348b2ec7867SKatayama Hirofumi MZ
349b2ec7867SKatayama Hirofumi MZ if (m_cliendId)
350b2ec7867SKatayama Hirofumi MZ {
351b2ec7867SKatayama Hirofumi MZ ENUM_CREATE_DESTROY_IC Data = { pTLS, this };
352b2ec7867SKatayama Hirofumi MZ ImmEnumInputContext(0, CicBridge::EnumDestroyInputContextCallback, (LPARAM)&Data);
353b2ec7867SKatayama Hirofumi MZ pTLS->m_bDestroyed = TRUE;
354b2ec7867SKatayama Hirofumi MZ
355b2ec7867SKatayama Hirofumi MZ ITfSourceSingle *pSource = NULL;
356b2ec7867SKatayama Hirofumi MZ if (pThreadMgr->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK)
357b2ec7867SKatayama Hirofumi MZ pSource->UnadviseSingleSink(m_cliendId, IID_ITfFunctionProvider);
358b2ec7867SKatayama Hirofumi MZ
359b2ec7867SKatayama Hirofumi MZ m_cliendId = 0;
360b2ec7867SKatayama Hirofumi MZ
361b2ec7867SKatayama Hirofumi MZ while (m_cActivateLocks > 0)
362b2ec7867SKatayama Hirofumi MZ {
363b2ec7867SKatayama Hirofumi MZ --m_cActivateLocks;
364b2ec7867SKatayama Hirofumi MZ pThreadMgr->Deactivate();
365b2ec7867SKatayama Hirofumi MZ }
366b2ec7867SKatayama Hirofumi MZ
367b2ec7867SKatayama Hirofumi MZ if (pSource)
368b2ec7867SKatayama Hirofumi MZ pSource->Release();
369b2ec7867SKatayama Hirofumi MZ }
370b2ec7867SKatayama Hirofumi MZ
371b2ec7867SKatayama Hirofumi MZ if (m_pDocMgr)
372b2ec7867SKatayama Hirofumi MZ {
373b2ec7867SKatayama Hirofumi MZ m_pDocMgr->Release();
374b2ec7867SKatayama Hirofumi MZ m_pDocMgr = NULL;
375b2ec7867SKatayama Hirofumi MZ }
376b2ec7867SKatayama Hirofumi MZ
377b2ec7867SKatayama Hirofumi MZ pThreadMgr->SetSysHookSink(NULL);
378b2ec7867SKatayama Hirofumi MZ
379b2ec7867SKatayama Hirofumi MZ m_bDeactivating = FALSE;
380b2ec7867SKatayama Hirofumi MZ
381b2ec7867SKatayama Hirofumi MZ return S_OK;
382b2ec7867SKatayama Hirofumi MZ }
383b2ec7867SKatayama Hirofumi MZ
384b2ec7867SKatayama Hirofumi MZ /// @implemented
385b2ec7867SKatayama Hirofumi MZ HRESULT
InitIMMX(_Inout_ TLS * pTLS)386b2ec7867SKatayama Hirofumi MZ CicBridge::InitIMMX(_Inout_ TLS *pTLS)
387b2ec7867SKatayama Hirofumi MZ {
388b2ec7867SKatayama Hirofumi MZ if (m_bImmxInited)
389b2ec7867SKatayama Hirofumi MZ return S_OK;
390b2ec7867SKatayama Hirofumi MZ
391b2ec7867SKatayama Hirofumi MZ HRESULT hr = S_OK;
392b2ec7867SKatayama Hirofumi MZ if (!pTLS->m_pThreadMgr)
393b2ec7867SKatayama Hirofumi MZ {
394b2ec7867SKatayama Hirofumi MZ ITfThreadMgr *pThreadMgr = NULL;
395b2ec7867SKatayama Hirofumi MZ hr = TF_CreateThreadMgr(&pThreadMgr);
396b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
397b2ec7867SKatayama Hirofumi MZ return E_FAIL;
398b2ec7867SKatayama Hirofumi MZ
399b2ec7867SKatayama Hirofumi MZ hr = pThreadMgr->QueryInterface(IID_ITfThreadMgr_P, (void **)&pTLS->m_pThreadMgr);
400b2ec7867SKatayama Hirofumi MZ if (pThreadMgr)
401b2ec7867SKatayama Hirofumi MZ pThreadMgr->Release();
402b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
403b2ec7867SKatayama Hirofumi MZ return E_FAIL;
404b2ec7867SKatayama Hirofumi MZ }
405b2ec7867SKatayama Hirofumi MZ
406b2ec7867SKatayama Hirofumi MZ if (!m_pThreadMgrEventSink)
407b2ec7867SKatayama Hirofumi MZ {
408b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink =
409b2ec7867SKatayama Hirofumi MZ new(cicNoThrow) CThreadMgrEventSink(CThreadMgrEventSink::DIMCallback, NULL, NULL);
410b2ec7867SKatayama Hirofumi MZ if (!m_pThreadMgrEventSink)
411b2ec7867SKatayama Hirofumi MZ {
412b2ec7867SKatayama Hirofumi MZ UnInitIMMX(pTLS);
413b2ec7867SKatayama Hirofumi MZ return E_FAIL;
414b2ec7867SKatayama Hirofumi MZ }
415b2ec7867SKatayama Hirofumi MZ }
416b2ec7867SKatayama Hirofumi MZ
417b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink->SetCallbackPV(m_pThreadMgrEventSink);
418b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink->_Advise(pTLS->m_pThreadMgr);
419b2ec7867SKatayama Hirofumi MZ
420b2ec7867SKatayama Hirofumi MZ if (!pTLS->m_pProfile)
421b2ec7867SKatayama Hirofumi MZ {
422b2ec7867SKatayama Hirofumi MZ pTLS->m_pProfile = new(cicNoThrow) CicProfile();
423b2ec7867SKatayama Hirofumi MZ if (!pTLS->m_pProfile)
424b2ec7867SKatayama Hirofumi MZ return E_OUTOFMEMORY;
425b2ec7867SKatayama Hirofumi MZ
426b2ec7867SKatayama Hirofumi MZ hr = pTLS->m_pProfile->InitProfileInstance(pTLS);
427b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
428b2ec7867SKatayama Hirofumi MZ {
429b2ec7867SKatayama Hirofumi MZ UnInitIMMX(pTLS);
430b2ec7867SKatayama Hirofumi MZ return E_FAIL;
431b2ec7867SKatayama Hirofumi MZ }
432b2ec7867SKatayama Hirofumi MZ }
433b2ec7867SKatayama Hirofumi MZ
434b2ec7867SKatayama Hirofumi MZ hr = pTLS->m_pThreadMgr->QueryInterface(IID_ITfKeystrokeMgr_P, (void **)&m_pKeystrokeMgr);
435b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
436b2ec7867SKatayama Hirofumi MZ {
437b2ec7867SKatayama Hirofumi MZ UnInitIMMX(pTLS);
438b2ec7867SKatayama Hirofumi MZ return E_FAIL;
439b2ec7867SKatayama Hirofumi MZ }
440b2ec7867SKatayama Hirofumi MZ
441b2ec7867SKatayama Hirofumi MZ hr = InitDisplayAttrbuteLib(&m_LibThread);
442b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
443b2ec7867SKatayama Hirofumi MZ {
444b2ec7867SKatayama Hirofumi MZ UnInitIMMX(pTLS);
445b2ec7867SKatayama Hirofumi MZ return E_FAIL;
446b2ec7867SKatayama Hirofumi MZ }
447b2ec7867SKatayama Hirofumi MZ
448b2ec7867SKatayama Hirofumi MZ m_bImmxInited = TRUE;
449b2ec7867SKatayama Hirofumi MZ return S_OK;
450b2ec7867SKatayama Hirofumi MZ }
451b2ec7867SKatayama Hirofumi MZ
452b2ec7867SKatayama Hirofumi MZ /// @implemented
UnInitIMMX(_Inout_ TLS * pTLS)453b2ec7867SKatayama Hirofumi MZ BOOL CicBridge::UnInitIMMX(_Inout_ TLS *pTLS)
454b2ec7867SKatayama Hirofumi MZ {
455b2ec7867SKatayama Hirofumi MZ UninitDisplayAttrbuteLib(&m_LibThread);
456b2ec7867SKatayama Hirofumi MZ TFUninitLib_Thread(&m_LibThread);
457b2ec7867SKatayama Hirofumi MZ
458b2ec7867SKatayama Hirofumi MZ if (m_pKeystrokeMgr)
459b2ec7867SKatayama Hirofumi MZ {
460b2ec7867SKatayama Hirofumi MZ m_pKeystrokeMgr->Release();
461b2ec7867SKatayama Hirofumi MZ m_pKeystrokeMgr = NULL;
462b2ec7867SKatayama Hirofumi MZ }
463b2ec7867SKatayama Hirofumi MZ
464b2ec7867SKatayama Hirofumi MZ if (pTLS->m_pProfile)
465b2ec7867SKatayama Hirofumi MZ {
466b2ec7867SKatayama Hirofumi MZ pTLS->m_pProfile->Release();
467b2ec7867SKatayama Hirofumi MZ pTLS->m_pProfile = NULL;
468b2ec7867SKatayama Hirofumi MZ }
469b2ec7867SKatayama Hirofumi MZ
470b2ec7867SKatayama Hirofumi MZ if (m_pThreadMgrEventSink)
471b2ec7867SKatayama Hirofumi MZ {
472b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink->_Unadvise();
473b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink->Release();
474b2ec7867SKatayama Hirofumi MZ m_pThreadMgrEventSink = NULL;
475b2ec7867SKatayama Hirofumi MZ }
476b2ec7867SKatayama Hirofumi MZ
477b2ec7867SKatayama Hirofumi MZ if (pTLS->m_pThreadMgr)
478b2ec7867SKatayama Hirofumi MZ {
479b2ec7867SKatayama Hirofumi MZ pTLS->m_pThreadMgr->Release();
480b2ec7867SKatayama Hirofumi MZ pTLS->m_pThreadMgr = NULL;
481b2ec7867SKatayama Hirofumi MZ }
482b2ec7867SKatayama Hirofumi MZ
483b2ec7867SKatayama Hirofumi MZ m_bImmxInited = FALSE;
484b2ec7867SKatayama Hirofumi MZ return TRUE;
485b2ec7867SKatayama Hirofumi MZ }
486b2ec7867SKatayama Hirofumi MZ
487b2ec7867SKatayama Hirofumi MZ /// @implemented
OnPreFocusDIM(HWND hwnd)488b2ec7867SKatayama Hirofumi MZ STDMETHODIMP CicBridge::OnPreFocusDIM(HWND hwnd)
489b2ec7867SKatayama Hirofumi MZ {
490b2ec7867SKatayama Hirofumi MZ return S_OK;
491b2ec7867SKatayama Hirofumi MZ }
492b2ec7867SKatayama Hirofumi MZ
493b2ec7867SKatayama Hirofumi MZ /// @unimplemented
OnSysKeyboardProc(UINT,LONG)494b2ec7867SKatayama Hirofumi MZ STDMETHODIMP CicBridge::OnSysKeyboardProc(UINT, LONG)
495b2ec7867SKatayama Hirofumi MZ {
496b2ec7867SKatayama Hirofumi MZ return E_NOTIMPL;
497b2ec7867SKatayama Hirofumi MZ }
498b2ec7867SKatayama Hirofumi MZ
499b2ec7867SKatayama Hirofumi MZ /// @implemented
OnSysShellProc(INT,UINT,LONG)500b2ec7867SKatayama Hirofumi MZ STDMETHODIMP CicBridge::OnSysShellProc(INT, UINT, LONG)
501b2ec7867SKatayama Hirofumi MZ {
502b2ec7867SKatayama Hirofumi MZ return S_OK;
503b2ec7867SKatayama Hirofumi MZ }
504b2ec7867SKatayama Hirofumi MZ
505b2ec7867SKatayama Hirofumi MZ /// @implemented
506b2ec7867SKatayama Hirofumi MZ void
PostTransMsg(_In_ HWND hWnd,_In_ INT cTransMsgs,_In_ const TRANSMSG * pTransMsgs)507b2ec7867SKatayama Hirofumi MZ CicBridge::PostTransMsg(
508b2ec7867SKatayama Hirofumi MZ _In_ HWND hWnd,
509b2ec7867SKatayama Hirofumi MZ _In_ INT cTransMsgs,
510b2ec7867SKatayama Hirofumi MZ _In_ const TRANSMSG *pTransMsgs)
511b2ec7867SKatayama Hirofumi MZ {
512b2ec7867SKatayama Hirofumi MZ for (INT i = 0; i < cTransMsgs; ++i, ++pTransMsgs)
513b2ec7867SKatayama Hirofumi MZ {
514b2ec7867SKatayama Hirofumi MZ ::PostMessageW(hWnd, pTransMsgs->message, pTransMsgs->wParam, pTransMsgs->lParam);
515b2ec7867SKatayama Hirofumi MZ }
516b2ec7867SKatayama Hirofumi MZ }
517b2ec7867SKatayama Hirofumi MZ
518b2ec7867SKatayama Hirofumi MZ /// @implemented
519b2ec7867SKatayama Hirofumi MZ HRESULT
ConfigureGeneral(_Inout_ TLS * pTLS,_In_ ITfThreadMgr * pThreadMgr,_In_ HKL hKL,_In_ HWND hWnd)520b2ec7867SKatayama Hirofumi MZ CicBridge::ConfigureGeneral(
521b2ec7867SKatayama Hirofumi MZ _Inout_ TLS* pTLS,
522b2ec7867SKatayama Hirofumi MZ _In_ ITfThreadMgr *pThreadMgr,
523b2ec7867SKatayama Hirofumi MZ _In_ HKL hKL,
524b2ec7867SKatayama Hirofumi MZ _In_ HWND hWnd)
525b2ec7867SKatayama Hirofumi MZ {
526b2ec7867SKatayama Hirofumi MZ CicProfile *pProfile = pTLS->m_pProfile;
527b2ec7867SKatayama Hirofumi MZ if (!pProfile)
528b2ec7867SKatayama Hirofumi MZ return E_OUTOFMEMORY;
529b2ec7867SKatayama Hirofumi MZ
530b2ec7867SKatayama Hirofumi MZ TF_LANGUAGEPROFILE profile;
531b2ec7867SKatayama Hirofumi MZ HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile);
532b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
533b2ec7867SKatayama Hirofumi MZ return hr;
534b2ec7867SKatayama Hirofumi MZ
535b2ec7867SKatayama Hirofumi MZ ITfFunctionProvider *pProvider = NULL;
536b2ec7867SKatayama Hirofumi MZ hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider);
537b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
538b2ec7867SKatayama Hirofumi MZ return hr;
539b2ec7867SKatayama Hirofumi MZ
540b2ec7867SKatayama Hirofumi MZ ITfFnConfigure *pFnConfigure = NULL;
541b2ec7867SKatayama Hirofumi MZ hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigure, (IUnknown**)&pFnConfigure);
542b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
543b2ec7867SKatayama Hirofumi MZ {
544b2ec7867SKatayama Hirofumi MZ pProvider->Release();
545b2ec7867SKatayama Hirofumi MZ return hr;
546b2ec7867SKatayama Hirofumi MZ }
547b2ec7867SKatayama Hirofumi MZ
548b2ec7867SKatayama Hirofumi MZ hr = pFnConfigure->Show(hWnd, profile.langid, profile.guidProfile);
549b2ec7867SKatayama Hirofumi MZ
550b2ec7867SKatayama Hirofumi MZ pFnConfigure->Release();
551b2ec7867SKatayama Hirofumi MZ pProvider->Release();
552b2ec7867SKatayama Hirofumi MZ return hr;
553b2ec7867SKatayama Hirofumi MZ }
554b2ec7867SKatayama Hirofumi MZ
555b2ec7867SKatayama Hirofumi MZ /// @implemented
556b2ec7867SKatayama Hirofumi MZ HRESULT
ConfigureRegisterWord(_Inout_ TLS * pTLS,_In_ ITfThreadMgr * pThreadMgr,_In_ HKL hKL,_In_ HWND hWnd,_Inout_opt_ LPVOID lpData)557b2ec7867SKatayama Hirofumi MZ CicBridge::ConfigureRegisterWord(
558b2ec7867SKatayama Hirofumi MZ _Inout_ TLS* pTLS,
559b2ec7867SKatayama Hirofumi MZ _In_ ITfThreadMgr *pThreadMgr,
560b2ec7867SKatayama Hirofumi MZ _In_ HKL hKL,
561b2ec7867SKatayama Hirofumi MZ _In_ HWND hWnd,
562b2ec7867SKatayama Hirofumi MZ _Inout_opt_ LPVOID lpData)
563b2ec7867SKatayama Hirofumi MZ {
564b2ec7867SKatayama Hirofumi MZ CicProfile *pProfile = pTLS->m_pProfile;
565b2ec7867SKatayama Hirofumi MZ if (!pProfile)
566b2ec7867SKatayama Hirofumi MZ return E_OUTOFMEMORY;
567b2ec7867SKatayama Hirofumi MZ
568b2ec7867SKatayama Hirofumi MZ TF_LANGUAGEPROFILE profile;
569b2ec7867SKatayama Hirofumi MZ HRESULT hr = pProfile->GetActiveLanguageProfile(hKL, GUID_TFCAT_TIP_KEYBOARD, &profile);
570b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
571b2ec7867SKatayama Hirofumi MZ return hr;
572b2ec7867SKatayama Hirofumi MZ
573b2ec7867SKatayama Hirofumi MZ ITfFunctionProvider *pProvider = NULL;
574b2ec7867SKatayama Hirofumi MZ hr = pThreadMgr->GetFunctionProvider(profile.clsid, &pProvider);
575b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
576b2ec7867SKatayama Hirofumi MZ return hr;
577b2ec7867SKatayama Hirofumi MZ
578b2ec7867SKatayama Hirofumi MZ ITfFnConfigureRegisterWord *pFunction = NULL;
579b2ec7867SKatayama Hirofumi MZ hr = pProvider->GetFunction(GUID_NULL, IID_ITfFnConfigureRegisterWord, (IUnknown**)&pFunction);
580b2ec7867SKatayama Hirofumi MZ if (FAILED(hr))
581b2ec7867SKatayama Hirofumi MZ {
582b2ec7867SKatayama Hirofumi MZ pProvider->Release();
583b2ec7867SKatayama Hirofumi MZ return hr;
584b2ec7867SKatayama Hirofumi MZ }
585b2ec7867SKatayama Hirofumi MZ
586b2ec7867SKatayama Hirofumi MZ REGISTERWORDW* pRegWord = (REGISTERWORDW*)lpData;
587b2ec7867SKatayama Hirofumi MZ if (pRegWord)
588b2ec7867SKatayama Hirofumi MZ {
589b2ec7867SKatayama Hirofumi MZ if (pRegWord->lpWord)
590b2ec7867SKatayama Hirofumi MZ {
591b2ec7867SKatayama Hirofumi MZ hr = E_OUTOFMEMORY;
592b2ec7867SKatayama Hirofumi MZ BSTR bstrWord = SysAllocString(pRegWord->lpWord);
593b2ec7867SKatayama Hirofumi MZ if (bstrWord)
594b2ec7867SKatayama Hirofumi MZ {
595b2ec7867SKatayama Hirofumi MZ hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, bstrWord);
596b2ec7867SKatayama Hirofumi MZ SysFreeString(bstrWord);
597b2ec7867SKatayama Hirofumi MZ }
598b2ec7867SKatayama Hirofumi MZ }
599b2ec7867SKatayama Hirofumi MZ else
600b2ec7867SKatayama Hirofumi MZ {
601b2ec7867SKatayama Hirofumi MZ hr = pFunction->Show(hWnd, profile.langid, profile.guidProfile, NULL);
602b2ec7867SKatayama Hirofumi MZ }
603b2ec7867SKatayama Hirofumi MZ }
604b2ec7867SKatayama Hirofumi MZ
605b2ec7867SKatayama Hirofumi MZ pProvider->Release();
606b2ec7867SKatayama Hirofumi MZ pFunction->Release();
607b2ec7867SKatayama Hirofumi MZ return hr;
608b2ec7867SKatayama Hirofumi MZ }
609980ebf06SKatayama Hirofumi MZ
610980ebf06SKatayama Hirofumi MZ /// @unimplemented
SetAssociate(TLS * pTLS,HWND hWnd,HIMC hIMC,ITfThreadMgr_P * pThreadMgr,ITfDocumentMgr * pDocMgr)611980ebf06SKatayama Hirofumi MZ void CicBridge::SetAssociate(
612980ebf06SKatayama Hirofumi MZ TLS *pTLS,
613980ebf06SKatayama Hirofumi MZ HWND hWnd,
614980ebf06SKatayama Hirofumi MZ HIMC hIMC,
615980ebf06SKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
616980ebf06SKatayama Hirofumi MZ ITfDocumentMgr *pDocMgr)
617980ebf06SKatayama Hirofumi MZ {
618980ebf06SKatayama Hirofumi MZ //FIXME
619980ebf06SKatayama Hirofumi MZ }
620980ebf06SKatayama Hirofumi MZ
621980ebf06SKatayama Hirofumi MZ HRESULT
SetActiveContextAlways(TLS * pTLS,HIMC hIMC,BOOL fActive,HWND hWnd,HKL hKL)622980ebf06SKatayama Hirofumi MZ CicBridge::SetActiveContextAlways(TLS *pTLS, HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
623980ebf06SKatayama Hirofumi MZ {
624980ebf06SKatayama Hirofumi MZ auto pThreadMgr = pTLS->m_pThreadMgr;
625980ebf06SKatayama Hirofumi MZ if (!pThreadMgr)
626980ebf06SKatayama Hirofumi MZ return E_OUTOFMEMORY;
627980ebf06SKatayama Hirofumi MZ
628980ebf06SKatayama Hirofumi MZ if (fActive)
629980ebf06SKatayama Hirofumi MZ {
630980ebf06SKatayama Hirofumi MZ if (!hIMC)
631980ebf06SKatayama Hirofumi MZ {
632980ebf06SKatayama Hirofumi MZ SetAssociate(pTLS, hWnd, hIMC, pThreadMgr, m_pDocMgr);
633980ebf06SKatayama Hirofumi MZ return S_OK;
634980ebf06SKatayama Hirofumi MZ }
635980ebf06SKatayama Hirofumi MZ
636980ebf06SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
637980ebf06SKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
638980ebf06SKatayama Hirofumi MZ return imcLock.m_hr;
639980ebf06SKatayama Hirofumi MZ
640980ebf06SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
641980ebf06SKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
642980ebf06SKatayama Hirofumi MZ return imeContext.m_hr;
643980ebf06SKatayama Hirofumi MZ
644980ebf06SKatayama Hirofumi MZ if (hIMC == ::ImmGetContext(hWnd))
645980ebf06SKatayama Hirofumi MZ {
646980ebf06SKatayama Hirofumi MZ ITfDocumentMgr *pDocMgr = GetDocumentManager(imeContext);
647980ebf06SKatayama Hirofumi MZ if (pDocMgr)
648980ebf06SKatayama Hirofumi MZ {
649980ebf06SKatayama Hirofumi MZ SetAssociate(pTLS, imcLock.get().hWnd, hIMC, pThreadMgr, pDocMgr);
650980ebf06SKatayama Hirofumi MZ pDocMgr->Release();
651980ebf06SKatayama Hirofumi MZ }
652980ebf06SKatayama Hirofumi MZ }
653980ebf06SKatayama Hirofumi MZ
654980ebf06SKatayama Hirofumi MZ return S_OK;
655980ebf06SKatayama Hirofumi MZ }
656980ebf06SKatayama Hirofumi MZ
657980ebf06SKatayama Hirofumi MZ if (hIMC && !IsEALang(LOWORD(hKL)))
658980ebf06SKatayama Hirofumi MZ {
659980ebf06SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
660980ebf06SKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
661980ebf06SKatayama Hirofumi MZ return imcLock.m_hr;
662980ebf06SKatayama Hirofumi MZ
663980ebf06SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
664980ebf06SKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
665980ebf06SKatayama Hirofumi MZ return imeContext.m_hr;
666980ebf06SKatayama Hirofumi MZ
667980ebf06SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
668980ebf06SKatayama Hirofumi MZ if (!pCicIC->m_dwUnknown6_5[2] && !pCicIC->m_dwUnknown6_5[3])
669980ebf06SKatayama Hirofumi MZ ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
670980ebf06SKatayama Hirofumi MZ }
671980ebf06SKatayama Hirofumi MZ
672980ebf06SKatayama Hirofumi MZ if (!hIMC || (::GetFocus() != hWnd) || (hIMC != ::ImmGetContext(hWnd)))
673980ebf06SKatayama Hirofumi MZ SetAssociate(pTLS, hWnd, hIMC, pThreadMgr, m_pDocMgr);
674980ebf06SKatayama Hirofumi MZ
675980ebf06SKatayama Hirofumi MZ return S_OK;
676980ebf06SKatayama Hirofumi MZ }
677980ebf06SKatayama Hirofumi MZ
678980ebf06SKatayama Hirofumi MZ /// @unimplemented
679efa86fffSKatayama Hirofumi MZ BOOL
DoOpenCandidateHanja(ITfThreadMgr_P * pThreadMgr,CicIMCLock & imcLock,CicInputContext * pCicIC)680efa86fffSKatayama Hirofumi MZ CicBridge::DoOpenCandidateHanja(
681efa86fffSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
682efa86fffSKatayama Hirofumi MZ CicIMCLock& imcLock,
683efa86fffSKatayama Hirofumi MZ CicInputContext *pCicIC)
684efa86fffSKatayama Hirofumi MZ {
685efa86fffSKatayama Hirofumi MZ return FALSE;
686efa86fffSKatayama Hirofumi MZ }
687efa86fffSKatayama Hirofumi MZ
688efa86fffSKatayama Hirofumi MZ /// @unimplemented
689efa86fffSKatayama Hirofumi MZ HRESULT
OnSetConversionSentenceMode(ITfThreadMgr_P * pThreadMgr,CicIMCLock & imcLock,CicInputContext * pCicIC,DWORD dwValue,LANGID LangID)690efa86fffSKatayama Hirofumi MZ CicBridge::OnSetConversionSentenceMode(
691efa86fffSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
692efa86fffSKatayama Hirofumi MZ CicIMCLock& imcLock,
693efa86fffSKatayama Hirofumi MZ CicInputContext *pCicIC,
694efa86fffSKatayama Hirofumi MZ DWORD dwValue,
695efa86fffSKatayama Hirofumi MZ LANGID LangID)
696efa86fffSKatayama Hirofumi MZ {
697efa86fffSKatayama Hirofumi MZ return E_NOTIMPL;
698efa86fffSKatayama Hirofumi MZ }
699efa86fffSKatayama Hirofumi MZ
700efa86fffSKatayama Hirofumi MZ /// @implemented
Notify(TLS * pTLS,ITfThreadMgr_P * pThreadMgr,HIMC hIMC,DWORD dwAction,DWORD dwIndex,DWORD_PTR dwValue)701980ebf06SKatayama Hirofumi MZ HRESULT CicBridge::Notify(
702980ebf06SKatayama Hirofumi MZ TLS *pTLS,
703efa86fffSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
704980ebf06SKatayama Hirofumi MZ HIMC hIMC,
705980ebf06SKatayama Hirofumi MZ DWORD dwAction,
706980ebf06SKatayama Hirofumi MZ DWORD dwIndex,
707980ebf06SKatayama Hirofumi MZ DWORD_PTR dwValue)
708980ebf06SKatayama Hirofumi MZ {
709efa86fffSKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
710efa86fffSKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
711efa86fffSKatayama Hirofumi MZ return imcLock.m_hr;
712efa86fffSKatayama Hirofumi MZ
713efa86fffSKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
714efa86fffSKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
715efa86fffSKatayama Hirofumi MZ return imeContext.m_hr;
716efa86fffSKatayama Hirofumi MZ
717efa86fffSKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
718efa86fffSKatayama Hirofumi MZ if (!pCicIC)
719efa86fffSKatayama Hirofumi MZ return E_OUTOFMEMORY;
720efa86fffSKatayama Hirofumi MZ
721efa86fffSKatayama Hirofumi MZ CicProfile *pProfile = pTLS->m_pProfile;
722efa86fffSKatayama Hirofumi MZ if (!pProfile)
723efa86fffSKatayama Hirofumi MZ return E_OUTOFMEMORY;
724efa86fffSKatayama Hirofumi MZ
725efa86fffSKatayama Hirofumi MZ LANGID LangID;
726efa86fffSKatayama Hirofumi MZ pProfile->GetLangId(&LangID);
727efa86fffSKatayama Hirofumi MZ
728efa86fffSKatayama Hirofumi MZ switch (dwAction)
729efa86fffSKatayama Hirofumi MZ {
730efa86fffSKatayama Hirofumi MZ case NI_OPENCANDIDATE:
731efa86fffSKatayama Hirofumi MZ if (PRIMARYLANGID(LangID) == LANG_KOREAN)
732efa86fffSKatayama Hirofumi MZ {
733efa86fffSKatayama Hirofumi MZ if (DoOpenCandidateHanja(pThreadMgr, imcLock, pCicIC))
734efa86fffSKatayama Hirofumi MZ return S_OK;
735efa86fffSKatayama Hirofumi MZ return E_FAIL;
736efa86fffSKatayama Hirofumi MZ }
737efa86fffSKatayama Hirofumi MZ return E_NOTIMPL;
738efa86fffSKatayama Hirofumi MZ
739efa86fffSKatayama Hirofumi MZ case NI_COMPOSITIONSTR:
740efa86fffSKatayama Hirofumi MZ switch (dwIndex)
741efa86fffSKatayama Hirofumi MZ {
742efa86fffSKatayama Hirofumi MZ case CPS_COMPLETE:
743efa86fffSKatayama Hirofumi MZ pCicIC->EscbCompComplete(imcLock);
744efa86fffSKatayama Hirofumi MZ break;
745efa86fffSKatayama Hirofumi MZ
746efa86fffSKatayama Hirofumi MZ case CPS_CONVERT:
747efa86fffSKatayama Hirofumi MZ case CPS_REVERT:
748efa86fffSKatayama Hirofumi MZ return E_NOTIMPL;
749efa86fffSKatayama Hirofumi MZ
750efa86fffSKatayama Hirofumi MZ case CPS_CANCEL:
751efa86fffSKatayama Hirofumi MZ pCicIC->EscbCompCancel(imcLock);
752efa86fffSKatayama Hirofumi MZ break;
753efa86fffSKatayama Hirofumi MZ
754efa86fffSKatayama Hirofumi MZ default:
755efa86fffSKatayama Hirofumi MZ return E_FAIL;
756efa86fffSKatayama Hirofumi MZ }
757efa86fffSKatayama Hirofumi MZ return S_OK;
758efa86fffSKatayama Hirofumi MZ
759efa86fffSKatayama Hirofumi MZ case NI_CONTEXTUPDATED:
760efa86fffSKatayama Hirofumi MZ switch (dwValue)
761efa86fffSKatayama Hirofumi MZ {
762efa86fffSKatayama Hirofumi MZ case IMC_SETCONVERSIONMODE:
763efa86fffSKatayama Hirofumi MZ case IMC_SETSENTENCEMODE:
764efa86fffSKatayama Hirofumi MZ return OnSetConversionSentenceMode(pThreadMgr, imcLock, pCicIC, dwValue, LangID);
765efa86fffSKatayama Hirofumi MZ
766efa86fffSKatayama Hirofumi MZ case IMC_SETOPENSTATUS:
767efa86fffSKatayama Hirofumi MZ return OnSetOpenStatus(pTLS, pThreadMgr, imcLock, pCicIC);
768efa86fffSKatayama Hirofumi MZ
769efa86fffSKatayama Hirofumi MZ case IMC_SETCANDIDATEPOS:
770efa86fffSKatayama Hirofumi MZ return pCicIC->OnSetCandidatePos(pTLS, imcLock);
771efa86fffSKatayama Hirofumi MZ
772efa86fffSKatayama Hirofumi MZ case IMC_SETCOMPOSITIONFONT:
773efa86fffSKatayama Hirofumi MZ case IMC_SETCOMPOSITIONWINDOW:
774efa86fffSKatayama Hirofumi MZ return E_NOTIMPL;
775efa86fffSKatayama Hirofumi MZ
776efa86fffSKatayama Hirofumi MZ default:
777efa86fffSKatayama Hirofumi MZ return E_FAIL;
778efa86fffSKatayama Hirofumi MZ }
779efa86fffSKatayama Hirofumi MZ break;
780efa86fffSKatayama Hirofumi MZ
781efa86fffSKatayama Hirofumi MZ default:
782efa86fffSKatayama Hirofumi MZ return E_NOTIMPL;
783efa86fffSKatayama Hirofumi MZ }
784980ebf06SKatayama Hirofumi MZ }
785febb589eSKatayama Hirofumi MZ
786febb589eSKatayama Hirofumi MZ /// @unimplemented
ProcessKey(TLS * pTLS,ITfThreadMgr_P * pThreadMgr,HIMC hIMC,WPARAM wParam,LPARAM lParam,CONST LPBYTE lpbKeyState,INT * pnUnknown60)787febb589eSKatayama Hirofumi MZ BOOL CicBridge::ProcessKey(
788febb589eSKatayama Hirofumi MZ TLS *pTLS,
789febb589eSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
790febb589eSKatayama Hirofumi MZ HIMC hIMC,
791febb589eSKatayama Hirofumi MZ WPARAM wParam,
792febb589eSKatayama Hirofumi MZ LPARAM lParam,
793febb589eSKatayama Hirofumi MZ CONST LPBYTE lpbKeyState,
794febb589eSKatayama Hirofumi MZ INT *pnUnknown60)
795febb589eSKatayama Hirofumi MZ {
796febb589eSKatayama Hirofumi MZ return FALSE; // FIXME
797febb589eSKatayama Hirofumi MZ }
798febb589eSKatayama Hirofumi MZ
799febb589eSKatayama Hirofumi MZ /// @unimplemented
800febb589eSKatayama Hirofumi MZ HRESULT
ToAsciiEx(TLS * pTLS,ITfThreadMgr_P * pThreadMgr,UINT uVirtKey,UINT uScanCode,CONST LPBYTE lpbKeyState,LPTRANSMSGLIST lpTransBuf,UINT fuState,HIMC hIMC,UINT * pResult)801febb589eSKatayama Hirofumi MZ CicBridge::ToAsciiEx(
802febb589eSKatayama Hirofumi MZ TLS *pTLS,
803febb589eSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
804febb589eSKatayama Hirofumi MZ UINT uVirtKey,
805febb589eSKatayama Hirofumi MZ UINT uScanCode,
806febb589eSKatayama Hirofumi MZ CONST LPBYTE lpbKeyState,
807febb589eSKatayama Hirofumi MZ LPTRANSMSGLIST lpTransBuf,
808febb589eSKatayama Hirofumi MZ UINT fuState,
809febb589eSKatayama Hirofumi MZ HIMC hIMC,
810febb589eSKatayama Hirofumi MZ UINT *pResult)
811febb589eSKatayama Hirofumi MZ {
812febb589eSKatayama Hirofumi MZ return E_NOTIMPL; // FIXME
813febb589eSKatayama Hirofumi MZ }
814febb589eSKatayama Hirofumi MZ
815efa86fffSKatayama Hirofumi MZ /// @implemented
816febb589eSKatayama Hirofumi MZ BOOL
SetCompositionString(TLS * pTLS,ITfThreadMgr_P * pThreadMgr,HIMC hIMC,DWORD dwIndex,LPCVOID lpComp,DWORD dwCompLen,LPCVOID lpRead,DWORD dwReadLen)817febb589eSKatayama Hirofumi MZ CicBridge::SetCompositionString(
818febb589eSKatayama Hirofumi MZ TLS *pTLS,
819febb589eSKatayama Hirofumi MZ ITfThreadMgr_P *pThreadMgr,
820febb589eSKatayama Hirofumi MZ HIMC hIMC,
821febb589eSKatayama Hirofumi MZ DWORD dwIndex,
822febb589eSKatayama Hirofumi MZ LPCVOID lpComp,
823febb589eSKatayama Hirofumi MZ DWORD dwCompLen,
824febb589eSKatayama Hirofumi MZ LPCVOID lpRead,
825febb589eSKatayama Hirofumi MZ DWORD dwReadLen)
826febb589eSKatayama Hirofumi MZ {
827efa86fffSKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
828efa86fffSKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
829efa86fffSKatayama Hirofumi MZ return FALSE;
830efa86fffSKatayama Hirofumi MZ
831efa86fffSKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
832efa86fffSKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
833efa86fffSKatayama Hirofumi MZ return FALSE;
834efa86fffSKatayama Hirofumi MZ
835efa86fffSKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
836efa86fffSKatayama Hirofumi MZ auto pProfile = pTLS->m_pProfile;
837efa86fffSKatayama Hirofumi MZ if (!pCicIC || !pProfile)
838efa86fffSKatayama Hirofumi MZ return FALSE;
839efa86fffSKatayama Hirofumi MZ
840efa86fffSKatayama Hirofumi MZ UINT uCodePage;
841efa86fffSKatayama Hirofumi MZ pProfile->GetCodePageA(&uCodePage);
842efa86fffSKatayama Hirofumi MZ
843efa86fffSKatayama Hirofumi MZ LANGID LangID;
844efa86fffSKatayama Hirofumi MZ if (dwIndex != SCS_SETSTR ||
845efa86fffSKatayama Hirofumi MZ !lpComp || *(WORD*)lpComp ||
846efa86fffSKatayama Hirofumi MZ !dwCompLen ||
847efa86fffSKatayama Hirofumi MZ FAILED(pProfile->GetLangId(&LangID)) ||
848efa86fffSKatayama Hirofumi MZ PRIMARYLANGID(LangID) != LANG_KOREAN)
849efa86fffSKatayama Hirofumi MZ {
850efa86fffSKatayama Hirofumi MZ return pCicIC->SetCompositionString(imcLock, pThreadMgr, dwIndex,
851efa86fffSKatayama Hirofumi MZ lpComp, dwCompLen, lpRead, dwReadLen,
852efa86fffSKatayama Hirofumi MZ uCodePage);
853efa86fffSKatayama Hirofumi MZ }
854efa86fffSKatayama Hirofumi MZ
855efa86fffSKatayama Hirofumi MZ if (imcLock.get().fdwConversion & IME_CMODE_NATIVE)
856efa86fffSKatayama Hirofumi MZ {
857efa86fffSKatayama Hirofumi MZ ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
858efa86fffSKatayama Hirofumi MZ return TRUE;
859efa86fffSKatayama Hirofumi MZ }
860efa86fffSKatayama Hirofumi MZ
861efa86fffSKatayama Hirofumi MZ return FALSE;
862febb589eSKatayama Hirofumi MZ }
863febb589eSKatayama Hirofumi MZ
864febb589eSKatayama Hirofumi MZ /// @unimplemented
865febb589eSKatayama Hirofumi MZ LRESULT
EscHanjaMode(TLS * pTLS,HIMC hIMC,LPVOID lpData)8661ee01452SKatayama Hirofumi MZ CicBridge::EscHanjaMode(TLS *pTLS, HIMC hIMC, LPVOID lpData)
8671ee01452SKatayama Hirofumi MZ {
8681ee01452SKatayama Hirofumi MZ CicIMCLock imcLock(hIMC);
8691ee01452SKatayama Hirofumi MZ if (FAILED(imcLock.m_hr))
8701ee01452SKatayama Hirofumi MZ return imcLock.m_hr;
8711ee01452SKatayama Hirofumi MZ
8721ee01452SKatayama Hirofumi MZ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
8731ee01452SKatayama Hirofumi MZ if (FAILED(imeContext.m_hr))
8741ee01452SKatayama Hirofumi MZ return imeContext.m_hr;
8751ee01452SKatayama Hirofumi MZ
8761ee01452SKatayama Hirofumi MZ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
8771ee01452SKatayama Hirofumi MZ if (!pCicIC)
8781ee01452SKatayama Hirofumi MZ return TRUE;
8791ee01452SKatayama Hirofumi MZ
8801ee01452SKatayama Hirofumi MZ if (pCicIC->m_bCandidateOpen)
8811ee01452SKatayama Hirofumi MZ return TRUE;
8821ee01452SKatayama Hirofumi MZ
8831ee01452SKatayama Hirofumi MZ pCicIC->m_dwUnknown6_5[4] |= 0x1;
8841ee01452SKatayama Hirofumi MZ
8851ee01452SKatayama Hirofumi MZ //FIXME
8861ee01452SKatayama Hirofumi MZ
8871ee01452SKatayama Hirofumi MZ pCicIC->m_dwUnknown6_5[4] &= ~0x1;
8881ee01452SKatayama Hirofumi MZ
8891ee01452SKatayama Hirofumi MZ return TRUE;
8901ee01452SKatayama Hirofumi MZ }
8911ee01452SKatayama Hirofumi MZ
8921ee01452SKatayama Hirofumi MZ /// @implemented
8931ee01452SKatayama Hirofumi MZ LRESULT
EscapeKorean(TLS * pTLS,HIMC hIMC,UINT uSubFunc,LPVOID lpData)894febb589eSKatayama Hirofumi MZ CicBridge::EscapeKorean(TLS *pTLS, HIMC hIMC, UINT uSubFunc, LPVOID lpData)
895febb589eSKatayama Hirofumi MZ {
8961ee01452SKatayama Hirofumi MZ if (uSubFunc == IME_ESC_QUERY_SUPPORT)
8971ee01452SKatayama Hirofumi MZ return *(DWORD*)lpData == IME_ESC_HANJA_MODE;
8981ee01452SKatayama Hirofumi MZ if (uSubFunc == IME_ESC_HANJA_MODE)
8991ee01452SKatayama Hirofumi MZ return EscHanjaMode(pTLS, hIMC, lpData);
9001ee01452SKatayama Hirofumi MZ return 0;
901febb589eSKatayama Hirofumi MZ }
902febb589eSKatayama Hirofumi MZ
903febb589eSKatayama Hirofumi MZ /// @implemented
IsOwnDim(ITfDocumentMgr * pDocMgr)904febb589eSKatayama Hirofumi MZ BOOL CicBridge::IsOwnDim(ITfDocumentMgr *pDocMgr)
905febb589eSKatayama Hirofumi MZ {
906febb589eSKatayama Hirofumi MZ DWORD dwDimFlags = 0;
907febb589eSKatayama Hirofumi MZ HRESULT hr = ::GetCompartmentDWORD(pDocMgr, GUID_COMPARTMENT_CTFIME_DIMFLAGS,
908febb589eSKatayama Hirofumi MZ &dwDimFlags, FALSE);
909febb589eSKatayama Hirofumi MZ if (FAILED(hr))
910febb589eSKatayama Hirofumi MZ return FALSE;
911febb589eSKatayama Hirofumi MZ return !!(dwDimFlags & 0x1);
912febb589eSKatayama Hirofumi MZ }
913