https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1ead16de95b5c11267588…
commit 1ead16de95b5c11267588622d27ee08e770eabb1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Aug 12 12:30:13 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Aug 12 12:30:13 2021 +0900
[IMM32] Rewrite ImmUnregisterWordA (#3893)
Implementing Japanese input... CORE-11700
---
dll/win32/imm32/imm.c | 66 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 47 insertions(+), 19 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index f7ec97bcc42..a64f38246f7 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -4105,28 +4105,56 @@ BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
BOOL WINAPI ImmUnregisterWordA(
HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister)
{
- ImmHkl *immHkl = IMM_GetImmHkl(hKL);
- TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle,
- debugstr_a(lpszUnregister));
- if (immHkl->hIME && immHkl->pImeUnregisterWord)
+ BOOL ret = FALSE;
+ PIMEDPI pImeDpi;
+ LPWSTR pszReadingW = NULL, pszUnregisterW = NULL;
+ INT cch;
+
+ TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
+ debugstr_a(lpszUnregister));
+
+ pImeDpi = ImmLockOrLoadImeDpi(hKL);
+ if (pImeDpi == NULL)
+ return FALSE;
+
+ if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE))
{
- if (!is_kbd_ime_unicode(immHkl))
- return immHkl->pImeUnregisterWord((LPCWSTR)lpszReading,dwStyle,
- (LPCWSTR)lpszUnregister);
- else
- {
- LPWSTR lpszwReading = strdupAtoW(lpszReading);
- LPWSTR lpszwUnregister = strdupAtoW(lpszUnregister);
- BOOL rc;
+ ret = pImeDpi->ImeUnregisterWord(lpszReading, dwStyle, lpszUnregister);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+ }
- rc = immHkl->pImeUnregisterWord(lpszwReading,dwStyle,lpszwUnregister);
- HeapFree(GetProcessHeap(),0,lpszwReading);
- HeapFree(GetProcessHeap(),0,lpszwUnregister);
- return rc;
- }
+ if (lpszReading)
+ {
+ cch = lstrlenA(lpszReading);
+ pszReadingW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
+ if (pszReadingW == NULL)
+ goto Quit;
+ cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszReading, cch,
+ pszReadingW, cch + 1);
+ pszReadingW[cch] = 0;
}
- else
- return FALSE;
+
+ if (lpszUnregister)
+ {
+ cch = lstrlenA(lpszUnregister);
+ pszUnregisterW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
+ if (pszUnregisterW == NULL)
+ goto Quit;
+ cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszUnregister, cch,
+ pszUnregisterW, cch + 1);
+ pszUnregisterW[cch] = 0;
+ }
+
+ ret = pImeDpi->ImeUnregisterWord(pszReadingW, dwStyle, pszUnregisterW);
+
+Quit:
+ if (pszReadingW)
+ HeapFree(g_hImm32Heap, 0, pszReadingW);
+ if (pszUnregisterW)
+ HeapFree(g_hImm32Heap, 0, pszUnregisterW);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
}
/***********************************************************************