ReactOS 0.4.15-dev-7961-gdcf9eb0
inputcontext.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS msctfime.ime
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Input Context of msctfime.ime
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "msctfime.h"
9
11
12/***********************************************************************
13 * CInputContextOwner
14 */
15
18{
19 m_dwCookie = -1;
20 m_fnCallback = fnCallback;
21 m_cRefs = 1;
22 m_pCallbackPV = pCallbackPV;
23}
24
27{
28}
29
32{
33 ITfSource *pSource = NULL;
34
36
38 if (SUCCEEDED(m_pContext->QueryInterface(IID_ITfSource, (LPVOID*)&pSource)) &&
39 SUCCEEDED(pSource->AdviseSink(IID_ITfContextOwner,
40 static_cast<ITfContextOwner*>(this), &m_dwCookie)))
41 {
42 m_pContext = pContext;
44 hr = S_OK;
45 }
46
47 if (pSource)
48 pSource->Release();
49
50 return hr;
51}
52
55{
56 ITfSource *pSource = NULL;
57
59 if (m_pContext)
60 {
61 if (SUCCEEDED(m_pContext->QueryInterface(IID_ITfSource, (LPVOID*)&pSource)) &&
62 SUCCEEDED(pSource->UnadviseSink(m_dwCookie)))
63 {
64 hr = S_OK;
65 }
66 }
67
68 if (m_pContext)
69 {
72 }
73
74 if (pSource)
75 pSource->Release();
76
77 return hr;
78}
79
82{
83 static const QITAB c_tab[] =
84 {
87 { NULL }
88 };
89 return ::QISearch(this, c_tab, riid, ppvObj);
90}
91
94{
95 return ++m_cRefs;
96}
97
100{
101 if (--m_cRefs == 0)
102 {
103 delete this;
104 return 0;
105 }
106 return m_cRefs;
107}
108
112 const POINT *ptScreen,
114 LONG *pacp)
115{
116 return E_NOTIMPL;
117}
118
122 LONG acpStart,
123 LONG acpEnd,
124 RECT *prc,
125 BOOL *pfClipped)
126{
127 return E_NOTIMPL;
128}
129
132{
133 return m_fnCallback(2, &prc, m_pCallbackPV);
134}
135
138{
139 return m_fnCallback(6, &pdcs, m_pCallbackPV);
140}
141
144{
145 return m_fnCallback(7, &phwnd, m_pCallbackPV);
146}
147
150{
151 return E_NOTIMPL;
152}
153
155{
159};
160
164 ITfMouseSink *pSink,
165 DWORD *pdwCookie)
166{
167 MOUSE_SINK_ARGS args = { range, pSink, pdwCookie };
168 return m_fnCallback(9, &args, m_pCallbackPV);
169}
170
173{
174 return m_fnCallback(10, &dwCookie, m_pCallbackPV);
175}
176
177/***********************************************************************
178 * CicInputContext
179 */
180
183 _In_ TfClientId cliendId,
184 _Inout_ PCIC_LIBTHREAD pLibThread,
185 _In_ HIMC hIMC)
186{
187 m_hIMC = hIMC;
188 m_dwQueryPos = 0;
189 m_cRefs = 1;
190}
191
194{
195 static const QITAB c_tab[] =
196 {
199 { NULL }
200 };
201 return ::QISearch(this, c_tab, riid, ppvObj);
202}
203
206{
207 return ::InterlockedIncrement(&m_cRefs);
208}
209
212{
214 {
215 delete this;
216 return 0;
217 }
218 return m_cRefs;
219}
220
224 ITfCompositionView *pComposition,
225 BOOL *pfOk)
226{
227 if ((m_cCompLocks <= 0) || m_bReconverting)
228 {
229 *pfOk = TRUE;
230 ++m_cCompLocks;
231 }
232 else
233 {
234 *pfOk = FALSE;
235 }
236 return S_OK;
237}
238
242 ITfCompositionView *pComposition,
243 ITfRange *pRangeNew)
244{
245 return S_OK;
246}
247
251 ITfCompositionView *pComposition)
252{
253 --m_cCompLocks;
254 return S_OK;
255}
256
260 _Inout_ CicIMCLock& imcLock,
261 _In_ BYTE iAtom,
262 _Out_opt_ LPDWORD pdwGuidAtom)
263{
264 CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr);
265 if (FAILED(imeContext.m_hr))
266 return imeContext.m_hr;
267
268 HRESULT hr = E_FAIL;
269 if (iAtom < m_cGuidAtoms)
270 {
271 *pdwGuidAtom = m_adwGuidAtoms[iAtom];
272 hr = S_OK;
273 }
274
275 return hr;
276}
277
281 _Inout_ ITfThreadMgr *pThreadMgr,
282 _Inout_ CicIMCLock& imcLock)
283{
284 //FIXME
285 return E_NOTIMPL;
286}
287
291{
292 ITfSourceSingle *pSource = NULL;
293
294 if (m_pContext && m_pContext->QueryInterface(IID_ITfSourceSingle, (void **)&pSource) == S_OK)
295 pSource->UnadviseSingleSink(m_clientId, IID_ITfCleanupContextSink);
296
297 //FIXME: m_dwUnknown5
298
300 {
304 }
305
307 {
311 }
312
314 {
318 }
319
321 {
325 }
326
327 if (m_pDocumentMgr)
329
330 if (m_pContext)
331 {
332 ClearCompartment(m_clientId, m_pContext, GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0);
335 }
336
338 {
341 }
342
343 // FIXME: m_pICOwnerCallback
344
345 if (m_pDocumentMgr)
346 {
349 }
350
351 if (pSource)
352 pSource->Release();
353
354 return S_OK;
355}
356
360{
361 return S_OK;
362}
363
367 _In_ TfEditCookie ecWrite,
368 _Inout_ ITfContext *pic)
369{
370 TLS *pTLS = TLS::PeekTLS();
371 if (!pTLS || !pTLS->m_pProfile)
372 return E_OUTOFMEMORY;
373
375 pTLS->m_pProfile->GetLangId(&LangID);
376
377 IMEINFO IMEInfo;
379 if (Inquire(&IMEInfo, szPath, 0, (HKL)UlongToHandle(LangID)) != S_OK)
380 return E_FAIL;
381
382 ITfProperty *pProp = NULL;
384 return S_OK;
385
386 HRESULT hr = pic->GetProperty(GUID_PROP_COMPOSING, &pProp);
387 if (FAILED(hr))
388 return S_OK;
389
390 IEnumTfRanges *pRanges = NULL;
391 hr = pProp->EnumRanges(ecWrite, &pRanges, NULL);
392 if (SUCCEEDED(hr))
393 {
394 ITfRange *pRange = NULL;
395 while (pRanges->Next(1, &pRange, 0) == S_OK)
396 {
397 VARIANT vari;
398 V_VT(&vari) = VT_EMPTY;
399 pProp->GetValue(ecWrite, pRange, &vari);
400 if (V_VT(&vari) == VT_I4)
401 {
402 if (V_I4(&vari))
403 pProp->Clear(ecWrite, pRange);
404 }
405 pRange->Release();
406 pRange = NULL;
407 }
408 pRanges->Release();
409 }
410 pProp->Release();
411
412 return S_OK;
413}
414
417{
418 return E_NOTIMPL;
419}
420
423{
424 return E_NOTIMPL;
425}
426
429{
430 return E_NOTIMPL;
431}
432
435{
436 return E_NOTIMPL;
437}
438
441{
442 return E_NOTIMPL;
443}
444
447{
448 return E_NOTIMPL;
449}
450
454 DWORD dwUnknown58,
455 DWORD dwUnknown59,
456 UINT keys,
457 CicIMCLock& imcLock)
458{
459 return E_NOTIMPL;
460}
461
465 CicIMCLock& imcLock,
466 ITfThreadMgr_P *pThreadMgr,
467 UINT uCodePage,
468 UINT uMsg,
469 BOOL bUndo)
470{
471 return E_NOTIMPL;
472}
473
475{
476 m_dwUnknown8 = 0;
480 m_dwQueryPos = 0;
481}
482
485{
486 return E_NOTIMPL;
487}
488
491 CicIMCLock& imcLock,
492 ITfThreadMgr_P *pThreadMgr,
493 DWORD dwIndex,
494 LPCVOID lpComp,
495 DWORD dwCompLen,
496 LPCVOID lpRead,
497 DWORD dwReadLen,
498 UINT uCodePage)
499{
500 return FALSE;
501}
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
HRESULT _Unadvise()
@implemented
Definition: sinks.cpp:100
HRESULT m_hr
Definition: cicimc.h:32
STDMETHODIMP GetACPFromPoint(const POINT *ptScreen, DWORD dwFlags, LONG *pacp) override
@unimplemented
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj) override
@implemented
STDMETHODIMP UnadviseMouseSink(DWORD dwCookie) override
@implemented
HRESULT _Advise(IUnknown *pContext)
@implemented
FN_IC_OWNER_CALLBACK m_fnCallback
Definition: inputcontext.h:31
STDMETHODIMP GetScreenExt(RECT *prc) override
@implemented
STDMETHODIMP GetTextExt(LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped) override
@unimplemented
HRESULT _Unadvise()
@implemented
IUnknown * m_pContext
Definition: inputcontext.h:29
STDMETHODIMP GetStatus(TF_STATUS *pdcs) override
@implemented
STDMETHODIMP AdviseMouseSink(ITfRangeACP *range, ITfMouseSink *pSink, DWORD *pdwCookie) override
@implemented
virtual ~CInputContextOwner()
@implemented
CInputContextOwner(FN_IC_OWNER_CALLBACK fnCallback, LPVOID pCallbackPV)
@unimplemented
STDMETHODIMP GetWnd(HWND *phwnd) override
@unimplemented
STDMETHODIMP GetAttribute(REFGUID rguidAttribute, VARIANT *pvarValue) override
@unimplemented
HRESULT _Unadvise()
@implemented
Definition: sinks.cpp:248
ITfContextOwnerServices * m_pContextOwnerServices
Definition: inputcontext.h:84
STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition) override
@implemented
STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk) override
@implemented
ITfContext * m_pContext
Definition: inputcontext.h:83
HRESULT SetupReconvertString(CicIMCLock &imcLock, ITfThreadMgr_P *pThreadMgr, UINT uCodePage, UINT uMsg, BOOL bUndo)
@unimplemented
CicInputContext(_In_ TfClientId cliendId, _Inout_ PCIC_LIBTHREAD pLibThread, _In_ HIMC hIMC)
@unimplemented
STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew) override
@implemented
BOOL SetCompositionString(CicIMCLock &imcLock, ITfThreadMgr_P *pThreadMgr, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen, UINT uCodePage)
@unimplemented
HRESULT EscbCompComplete(CicIMCLock &imcLock)
@unimplemented
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj) override
@implemented
STDMETHODIMP OnCleanupContext(_In_ TfEditCookie ecWrite, _Inout_ ITfContext *pic) override
@implemented
HRESULT DelayedReconvertFuncCall(CicIMCLock &imcLock)
@unimplemented
void ClearPrevCandidatePos()
HRESULT EscbClearDocFeedBuffer(CicIMCLock &imcLock, BOOL bFlag)
@unimplemented
CCompartmentEventSink * m_pCompEventSink2
Definition: inputcontext.h:88
HRESULT EndReconvertString(CicIMCLock &imcLock)
@unimplemented
ITfDocumentMgr * m_pDocumentMgr
Definition: inputcontext.h:82
CCompartmentEventSink * m_pCompEventSink1
Definition: inputcontext.h:87
HRESULT GetGuidAtom(_Inout_ CicIMCLock &imcLock, _In_ BYTE iAtom, _Out_opt_ LPDWORD pdwGuidAtom)
@implemented
CTextEventSink * m_pTextEventSink
Definition: inputcontext.h:86
HRESULT SetupDocFeedString(CicIMCLock &imcLock, UINT uCodePage)
@unimplemented
HRESULT OnSetCandidatePos(TLS *pTLS, CicIMCLock &imcLock)
@unimplemented
HRESULT DestroyInputContext()
@unimplemented
CInputContextOwner * m_pInputContextOwner
Definition: inputcontext.h:89
HRESULT EscbCompCancel(CicIMCLock &imcLock)
@unimplemented
DWORD m_adwGuidAtoms[256]
Definition: inputcontext.h:104
HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock &imcLock)
@unimplemented
HRESULT MsImeMouseHandler(DWORD dwUnknown58, DWORD dwUnknown59, UINT keys, CicIMCLock &imcLock)
@unimplemented
STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) override
@implemented
TfClientId m_clientId
Definition: inputcontext.h:109
CANDIDATEFORM m_CandForm
Definition: inputcontext.h:107
HRESULT GetLangId(_Out_ LANGID *pLangID)
@implemented
Definition: profile.cpp:114
Definition: tls.h:14
static TLS * PeekTLS()
@implemented
Definition: tls.cpp:41
CicProfile * m_pProfile
Definition: tls.h:20
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
DWORD HIMC
Definition: dimm.idl:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT ClearCompartment(TfClientId tid, IUnknown *pUnknown, REFGUID rguid, BOOL bThread)
@implemented
Definition: misc.cpp:331
#define MAX_PATH
Definition: compat.h:34
@ VT_I4
Definition: compat.h:2298
@ VT_EMPTY
Definition: compat.h:2295
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLint * range
Definition: glext.h:7539
#define IME_PROP_COMPLETE_ON_UNSELECT
Definition: imm.h:250
REFIID riid
Definition: atlbase.h:39
HRESULT(CALLBACK * FN_IC_OWNER_CALLBACK)(UINT uType, LPVOID args, LPVOID param)
Definition: inputcontext.h:18
HRESULT Next([in] ULONG ulCount, [out, size_is(ulCount), length_is(*pcFetched)] ITfRange **ppRange, [out] ULONG *pcFetched)
HRESULT Pop([in] DWORD dwFlags)
HRESULT Clear([in] TfEditCookie ec, [in] ITfRange *pRange)
HRESULT GetValue([in] TfEditCookie ec, [in] ITfRange *pRange, [out] VARIANT *pvarValue)
HRESULT EnumRanges([in] TfEditCookie ec, [out] IEnumTfRanges **ppEnum, [in] ITfRange *pTargetRange)
HRESULT UnadviseSingleSink([in] TfClientId tid, [in] REFIID riid)
HRESULT AdviseSink([in] REFIID riid, [in, iid_is(riid)] IUnknown *punk, [out] DWORD *pdwCookie)
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
USHORT LANGID
Definition: mui.h:9
LPCWSTR szPath
Definition: env.c:37
#define _Out_opt_
Definition: ms_sal.h:346
#define _Inout_
Definition: ms_sal.h:378
#define _In_
Definition: ms_sal.h:308
DWORD TfClientId
Definition: msctf.idl:105
EXTERN_C const GUID GUID_PROP_COMPOSING
Definition: msctf.idl:79
UINT_PTR HKL
Definition: msctf.idl:143
DWORD TfEditCookie
Definition: msctf.idl:104
HRESULT Inquire(_Out_ LPIMEINFO lpIMEInfo, _Out_ LPWSTR lpszWndClass, _In_ DWORD dwSystemInfoFlags, _In_ HKL hKL)
Definition: msctfime.cpp:97
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define V_VT(A)
Definition: oleauto.h:211
#define V_I4(A)
Definition: oleauto.h:247
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define QITABENT(Cthis, Ifoo)
Definition: shlwapi.h:2094
ITfMouseSink * pSink
ITfRangeACP * range
Definition: scsiwmi.h:51
DWORD fdwProperty
Definition: immdev.h:22
Definition: match.c:390
uint32_t * LPDWORD
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
#define ZeroMemory
Definition: winbase.h:1712
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
CONST void * LPCVOID
Definition: windef.h:191
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193