ReactOS 0.4.16-dev-106-g10b08aa
profile.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: Profile of msctfime.ime
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "msctfime.h"
9
11
14{
15 m_dwFlags &= 0xFFFFFFF0;
16 m_cRefs = 1;
19 m_LangID1 = 0;
21 m_LangID2 = 0;
22 m_dwUnknown1 = 0;
23}
24
27{
28 if (m_pIPProfiles)
29 {
30 if (m_LangID1)
31 m_pIPProfiles->ChangeCurrentLanguage(m_LangID1);
32
33 m_pIPProfiles->Release();
35 }
36
38 {
42 }
43}
44
47{
48 *ppvObj = NULL;
49 return E_NOINTERFACE;
50}
51
54{
55 return ::InterlockedIncrement(&m_cRefs);
56}
57
60{
62 {
63 delete this;
64 return 0;
65 }
66 return m_cRefs;
67}
68
72 REFGUID rguid1,
73 REFGUID rguid2,
74 BOOL fActivated,
75 LPVOID pUserData)
76{
77 CicProfile *pThis = (CicProfile *)pUserData;
78 pThis->m_dwFlags &= ~0xE;
79 return 0;
80}
81
84{
85 if (!puCodePage)
86 return E_INVALIDARG;
87
88 if (m_dwFlags & 2)
89 {
90 *puCodePage = m_nCodePage;
91 return S_OK;
92 }
93
94 *puCodePage = 0;
95
98 if (FAILED(hr))
99 return E_FAIL;
100
101 WCHAR szBuff[12];
103 if (cch)
104 {
105 szBuff[cch] = 0;
106 m_nCodePage = *puCodePage = wcstoul(szBuff, NULL, 10);
107 m_dwFlags |= 2;
108 }
109
110 return S_OK;
111}
112
115{
116 *pLangID = 0;
117
118 if (!m_pIPProfiles)
119 return E_FAIL;
120
121 if (m_dwFlags & 4)
122 {
123 *pLangID = m_LangID2;
124 return S_OK;
125 }
126
127 HRESULT hr = m_pIPProfiles->GetCurrentLanguage(pLangID);
128 if (SUCCEEDED(hr))
129 {
130 m_dwFlags |= 4;
131 m_LangID2 = *pLangID;
132 }
133
134 return hr;
135}
136
140{
142 if (FAILED(hr))
143 return hr;
144
146 {
150 if (!pSink)
151 {
152 m_pIPProfiles->Release();
154 return E_FAIL;
155 }
157 }
158
159 if (pTLS->m_pThreadMgr)
160 m_pActiveLanguageProfileNotifySink->_Advise(pTLS->m_pThreadMgr);
161
162 return hr;
163}
164
168 _In_ HKL hKL,
169 _In_ REFGUID rguid,
170 _Out_ TF_LANGUAGEPROFILE *pProfile)
171{
172 return E_NOTIMPL;
173}
174
178{
179 return TRUE;
180}
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
#define cicNoThrow
Definition: cicbase.h:34
HRESULT _Advise(ITfThreadMgr *pThreadMgr)
@implemented
Definition: sinks.cpp:472
HRESULT _Unadvise()
@implemented
Definition: sinks.cpp:502
DWORD m_dwFlags
Definition: profile.h:19
UINT m_nCodePage
Definition: profile.h:20
LANGID m_LangID1
Definition: profile.h:17
static INT CALLBACK ActiveLanguageProfileNotifySinkCallback(REFGUID rguid1, REFGUID rguid2, BOOL fActivated, LPVOID pUserData)
@implemented
Definition: profile.cpp:71
HRESULT GetLangId(_Out_ LANGID *pLangID)
@implemented
Definition: profile.cpp:114
DWORD m_dwUnknown1
Definition: profile.h:23
HRESULT GetActiveLanguageProfile(_In_ HKL hKL, _In_ REFGUID rguid, _Out_ TF_LANGUAGEPROFILE *pProfile)
@unimplemented
Definition: profile.cpp:167
LONG m_cRefs
Definition: profile.h:24
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj) override
@implemented
Definition: profile.cpp:46
LANGID m_LangID2
Definition: profile.h:21
CicProfile()
@implemented
Definition: profile.cpp:13
HRESULT GetCodePageA(_Out_ UINT *puCodePage)
@implemented
Definition: profile.cpp:83
BOOL IsIME(HKL hKL)
Definition: profile.cpp:177
virtual ~CicProfile()
@implemented
Definition: profile.cpp:26
ITfInputProcessorProfiles * m_pIPProfiles
Definition: profile.h:15
CActiveLanguageProfileNotifySink * m_pActiveLanguageProfileNotifySink
Definition: profile.h:16
HRESULT InitProfileInstance(_Inout_ TLS *pTLS)
@implemented
Definition: profile.cpp:139
Definition: tls.h:14
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define CALLBACK
Definition: compat.h:35
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
unsigned int BOOL
Definition: ntddk_ex.h:94
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
REFIID riid
Definition: atlbase.h:39
ULONG AddRef()
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
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
HRESULT WINAPI TF_CreateInputProcessorProfiles(ITfInputProcessorProfiles **ppipr)
Definition: msctf.c:668
UINT_PTR HKL
Definition: msctf.idl:143
unsigned int UINT
Definition: ndis.h:50
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
Definition: scsiwmi.h:51
int32_t INT
Definition: typedefs.h:58
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 E_NOINTERFACE
Definition: winerror.h:2364
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
__wchar_t WCHAR
Definition: xmlstorage.h:180