4ce157356e35d04f7182d6f6b062e70a1e64132f
[reactos.git] / dll / win32 / imm32 / compstr.c
1 /*
2 * PROJECT: ReactOS IMM32
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Implementing composition strings of IMM32
5 * COPYRIGHT: Copyright 2020-2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8 #include "precomp.h"
9
10 WINE_DEFAULT_DEBUG_CHANNEL(imm);
11
12 LONG APIENTRY
13 Imm32GetCompStrA(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD dwIndex,
14 LPVOID lpBuf, DWORD dwBufLen, BOOL bAnsiClient, UINT uCodePage)
15 {
16 LONG ret = IMM_ERROR_GENERAL;
17
18 if (bAnsiClient)
19 {
20 switch (dwIndex)
21 {
22 case GCS_COMPREADSTR:
23 case GCS_COMPREADATTR:
24 case GCS_COMPREADCLAUSE:
25 case GCS_COMPSTR:
26 case GCS_COMPATTR:
27 case GCS_COMPCLAUSE:
28 case GCS_CURSORPOS:
29 case GCS_DELTASTART:
30 case GCS_RESULTREADSTR:
31 case GCS_RESULTREADCLAUSE:
32 case GCS_RESULTSTR:
33 case GCS_RESULTCLAUSE:
34 default:
35 FIXME("TODO:\n");
36 break;
37 }
38 }
39 else /* !bAnsiClient */
40 {
41 switch (dwIndex)
42 {
43 case GCS_COMPREADSTR:
44 case GCS_COMPREADATTR:
45 case GCS_COMPREADCLAUSE:
46 case GCS_COMPSTR:
47 case GCS_COMPATTR:
48 case GCS_COMPCLAUSE:
49 case GCS_CURSORPOS:
50 case GCS_DELTASTART:
51 case GCS_RESULTREADSTR:
52 case GCS_RESULTREADCLAUSE:
53 case GCS_RESULTSTR:
54 case GCS_RESULTCLAUSE:
55 default:
56 FIXME("TODO:\n");
57 break;
58 }
59 }
60
61 return ret;
62 }
63
64 LONG APIENTRY
65 Imm32GetCompStrW(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD dwIndex,
66 LPVOID lpBuf, DWORD dwBufLen, BOOL bAnsiClient, UINT uCodePage)
67 {
68 LONG ret = IMM_ERROR_GENERAL;
69
70 if (bAnsiClient)
71 {
72 switch (dwIndex)
73 {
74 case GCS_COMPREADSTR:
75 case GCS_COMPREADATTR:
76 case GCS_COMPREADCLAUSE:
77 case GCS_COMPSTR:
78 case GCS_COMPATTR:
79 case GCS_COMPCLAUSE:
80 case GCS_CURSORPOS:
81 case GCS_DELTASTART:
82 case GCS_RESULTREADSTR:
83 case GCS_RESULTREADCLAUSE:
84 case GCS_RESULTSTR:
85 case GCS_RESULTCLAUSE:
86 default:
87 FIXME("TODO:\n");
88 break;
89 }
90 }
91 else /* !bAnsiClient */
92 {
93 switch (dwIndex)
94 {
95 case GCS_COMPREADSTR:
96 case GCS_COMPREADATTR:
97 case GCS_COMPREADCLAUSE:
98 case GCS_COMPSTR:
99 case GCS_COMPATTR:
100 case GCS_COMPCLAUSE:
101 case GCS_CURSORPOS:
102 case GCS_DELTASTART:
103 case GCS_RESULTREADSTR:
104 case GCS_RESULTREADCLAUSE:
105 case GCS_RESULTSTR:
106 case GCS_RESULTCLAUSE:
107 default:
108 FIXME("TODO:\n");
109 break;
110 }
111 }
112
113 return ret;
114 }
115
116 BOOL APIENTRY
117 Imm32SetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
118 LPCVOID lpRead, DWORD dwReadLen, BOOL bAnsi)
119 {
120 FIXME("TODO:\n");
121 return FALSE;
122 }
123
124 /***********************************************************************
125 * ImmGetCompositionStringA (IMM32.@)
126 */
127 LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
128 {
129 LONG ret = 0;
130 LPINPUTCONTEXT pIC;
131 PCLIENTIMC pClientImc;
132 LPCOMPOSITIONSTRING pCS;
133 BOOL bAnsiClient;
134
135 TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
136
137 if (dwBufLen && !lpBuf)
138 return 0;
139
140 pClientImc = ImmLockClientImc(hIMC);
141 if (!pClientImc)
142 return 0;
143
144 bAnsiClient = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
145 ImmUnlockClientImc(pClientImc);
146
147 pIC = ImmLockIMC(hIMC);
148 if (!pIC)
149 return 0;
150
151 pCS = ImmLockIMCC(pIC->hCompStr);
152 if (!pCS)
153 {
154 ImmUnlockIMC(hIMC);
155 return 0;
156 }
157
158 ret = Imm32GetCompStrA(hIMC, pCS, dwIndex, lpBuf, dwBufLen, bAnsiClient, CP_ACP);
159 ImmUnlockIMCC(pIC->hCompStr);
160 ImmUnlockIMC(hIMC);
161 return ret;
162 }
163
164 /***********************************************************************
165 * ImmGetCompositionStringW (IMM32.@)
166 */
167 LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
168 {
169 LONG ret = 0;
170 LPINPUTCONTEXT pIC;
171 PCLIENTIMC pClientImc;
172 LPCOMPOSITIONSTRING pCS;
173 BOOL bAnsiClient;
174
175 TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
176
177 if (dwBufLen && !lpBuf)
178 return 0;
179
180 pClientImc = ImmLockClientImc(hIMC);
181 if (!pClientImc)
182 return 0;
183
184 bAnsiClient = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
185 ImmUnlockClientImc(pClientImc);
186
187 pIC = ImmLockIMC(hIMC);
188 if (!pIC)
189 return 0;
190
191 pCS = ImmLockIMCC(pIC->hCompStr);
192 if (!pCS)
193 {
194 ImmUnlockIMC(hIMC);
195 return 0;
196 }
197
198 ret = Imm32GetCompStrW(hIMC, pCS, dwIndex, lpBuf, dwBufLen, bAnsiClient, CP_ACP);
199 ImmUnlockIMCC(pIC->hCompStr);
200 ImmUnlockIMC(hIMC);
201 return ret;
202 }
203
204 /***********************************************************************
205 * ImmSetCompositionStringA (IMM32.@)
206 */
207 BOOL WINAPI
208 ImmSetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
209 LPCVOID lpRead, DWORD dwReadLen)
210 {
211 TRACE("(%p, %lu, %p, %lu, %p, %lu)\n",
212 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
213 return Imm32SetCompositionStringAW(hIMC, dwIndex, lpComp, dwCompLen,
214 lpRead, dwReadLen, TRUE);
215 }
216
217 /***********************************************************************
218 * ImmSetCompositionStringW (IMM32.@)
219 */
220 BOOL WINAPI
221 ImmSetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
222 LPCVOID lpRead, DWORD dwReadLen)
223 {
224 TRACE("(%p, %lu, %p, %lu, %p, %lu)\n",
225 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
226 return Imm32SetCompositionStringAW(hIMC, dwIndex, lpComp, dwCompLen,
227 lpRead, dwReadLen, FALSE);
228 }