[IMM32] Implement ImmGetGuideLineA/W (#3877)

Implement ImmGetGuideLineA and ImmGetGuideLineW functions. CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2021-08-05 21:43:21 +09:00 committed by GitHub
parent acf28dbc1e
commit 29b09d8935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2758,17 +2758,184 @@ UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
return (UINT)cch; return (UINT)cch;
} }
static DWORD APIENTRY
ImmGetGuideLineAW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen, BOOL bAnsi)
{
PCLIENTIMC pClientImc;
LPINPUTCONTEXT pIC;
LPGUIDELINE pGuideLine;
DWORD cb, ret = 0;
LPVOID pvStr, pvPrivate;
BOOL bUsedDefault;
pClientImc = ImmLockClientImc(hIMC);
if (!pClientImc)
return 0;
pIC = ImmLockIMC(hIMC);
if (!pIC)
{
ImmUnlockClientImc(pClientImc);
return 0;
}
pGuideLine = ImmLockIMCC(pIC->hGuideLine);
if (!pGuideLine)
{
ImmUnlockIMC(hIMC);
ImmUnlockClientImc(pClientImc);
return 0;
}
if (dwIndex == GGL_LEVEL)
{
ret = pGuideLine->dwLevel;
goto Quit;
}
if (dwIndex == GGL_INDEX)
{
ret = pGuideLine->dwIndex;
goto Quit;
}
if (dwIndex == GGL_STRING)
{
pvStr = (LPBYTE)pGuideLine + pGuideLine->dwStrOffset;
/* get size */
if (bAnsi)
{
if (pClientImc->dwFlags & CLIENTIMC_WIDE)
{
cb = WideCharToMultiByte(CP_ACP, 0, pvStr, pGuideLine->dwStrLen,
NULL, 0, NULL, &bUsedDefault);
}
else
{
cb = pGuideLine->dwStrLen * sizeof(CHAR);
}
}
else
{
if (pClientImc->dwFlags & CLIENTIMC_WIDE)
{
cb = pGuideLine->dwStrLen * sizeof(WCHAR);
}
else
{
cb = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pvStr, pGuideLine->dwStrLen,
NULL, 0) * sizeof(WCHAR);
}
}
if (dwBufLen == 0 || cb == 0 || lpBuf == NULL || dwBufLen < cb)
{
ret = cb;
goto Quit;
}
/* store to buffer */
if (bAnsi)
{
if (pClientImc->dwFlags & CLIENTIMC_WIDE)
{
ret = WideCharToMultiByte(CP_ACP, 0, pvStr, pGuideLine->dwStrLen,
lpBuf, dwBufLen, NULL, &bUsedDefault);
goto Quit;
}
}
else
{
if (!(pClientImc->dwFlags & CLIENTIMC_WIDE))
{
ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pvStr, pGuideLine->dwStrLen,
lpBuf, dwBufLen) * sizeof(WCHAR);
goto Quit;
}
}
RtlCopyMemory(lpBuf, pvStr, cb);
ret = cb;
goto Quit;
}
if (dwIndex == GGL_PRIVATE)
{
pvPrivate = (LPBYTE)pGuideLine + pGuideLine->dwPrivateOffset;
/* get size */
if (bAnsi)
{
if ((pClientImc->dwFlags & CLIENTIMC_WIDE) &&
pGuideLine->dwIndex == GL_ID_REVERSECONVERSION)
{
cb = CandidateListWideToAnsi(pvPrivate, NULL, 0, CP_ACP);
}
else
{
cb = pGuideLine->dwPrivateSize;
}
}
else
{
if (!(pClientImc->dwFlags & CLIENTIMC_WIDE) &&
pGuideLine->dwIndex == GL_ID_REVERSECONVERSION)
{
cb = CandidateListAnsiToWide(pvPrivate, NULL, 0, CP_ACP);
}
else
{
cb = pGuideLine->dwPrivateSize;
}
}
if (dwBufLen == 0 || cb == 0 || lpBuf == NULL || dwBufLen < cb)
{
ret = cb;
goto Quit;
}
/* store to buffer */
if (bAnsi)
{
if ((pClientImc->dwFlags & CLIENTIMC_WIDE) &&
pGuideLine->dwIndex == GL_ID_REVERSECONVERSION)
{
ret = CandidateListWideToAnsi(pvPrivate, lpBuf, cb, CP_ACP);
goto Quit;
}
}
else
{
if (!(pClientImc->dwFlags & CLIENTIMC_WIDE) &&
pGuideLine->dwIndex == GL_ID_REVERSECONVERSION)
{
ret = CandidateListAnsiToWide(pvPrivate, lpBuf, cb, CP_ACP);
goto Quit;
}
}
RtlCopyMemory(lpBuf, pvPrivate, cb);
ret = cb;
goto Quit;
}
Quit:
ImmUnlockIMCC(pIC->hGuideLine);
ImmUnlockIMC(hIMC);
ImmUnlockClientImc(pClientImc);
return ret;
}
/*********************************************************************** /***********************************************************************
* ImmGetGuideLineA (IMM32.@) * ImmGetGuideLineA (IMM32.@)
*/ */
DWORD WINAPI ImmGetGuideLineA( DWORD WINAPI ImmGetGuideLineA(
HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen) HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen)
{ {
FIXME("(%p, %d, %s, %d): stub\n", TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
hIMC, dwIndex, debugstr_a(lpBuf), dwBufLen return ImmGetGuideLineAW(hIMC, dwIndex, lpBuf, dwBufLen, TRUE);
);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
} }
/*********************************************************************** /***********************************************************************
@ -2776,11 +2943,8 @@ DWORD WINAPI ImmGetGuideLineA(
*/ */
DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen) DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen)
{ {
FIXME("(%p, %d, %s, %d): stub\n", TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
hIMC, dwIndex, debugstr_w(lpBuf), dwBufLen return ImmGetGuideLineAW(hIMC, dwIndex, lpBuf, dwBufLen, FALSE);
);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
} }
/*********************************************************************** /***********************************************************************