[MSCTFIME] Implement CicBridge::Notify (#6586)

Supporting TIPs...
JIRA issue: CORE-19360
- Implement CicBridge::Notify
  method.
- Implement CicBridge::
  SetCompositionString method.
- Add some CicInputContext
  methods (stub).
This commit is contained in:
Katayama Hirofumi MZ 2024-03-09 12:57:50 +09:00 committed by GitHub
parent 1ee014525c
commit efa86fff9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 182 additions and 5 deletions

View file

@ -679,15 +679,111 @@ CicBridge::SetActiveContextAlways(TLS *pTLS, HIMC hIMC, BOOL fActive, HWND hWnd,
}
/// @unimplemented
BOOL
CicBridge::DoOpenCandidateHanja(
ITfThreadMgr_P *pThreadMgr,
CicIMCLock& imcLock,
CicInputContext *pCicIC)
{
return FALSE;
}
/// @unimplemented
HRESULT
CicBridge::OnSetConversionSentenceMode(
ITfThreadMgr_P *pThreadMgr,
CicIMCLock& imcLock,
CicInputContext *pCicIC,
DWORD dwValue,
LANGID LangID)
{
return E_NOTIMPL;
}
/// @implemented
HRESULT CicBridge::Notify(
TLS *pTLS,
ITfThreadMgr *pThreadMgr,
ITfThreadMgr_P *pThreadMgr,
HIMC hIMC,
DWORD dwAction,
DWORD dwIndex,
DWORD_PTR dwValue)
{
return E_NOTIMPL; // FIXME
CicIMCLock imcLock(hIMC);
if (FAILED(imcLock.m_hr))
return imcLock.m_hr;
CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
if (FAILED(imeContext.m_hr))
return imeContext.m_hr;
CicInputContext *pCicIC = imeContext.get().m_pCicIC;
if (!pCicIC)
return E_OUTOFMEMORY;
CicProfile *pProfile = pTLS->m_pProfile;
if (!pProfile)
return E_OUTOFMEMORY;
LANGID LangID;
pProfile->GetLangId(&LangID);
switch (dwAction)
{
case NI_OPENCANDIDATE:
if (PRIMARYLANGID(LangID) == LANG_KOREAN)
{
if (DoOpenCandidateHanja(pThreadMgr, imcLock, pCicIC))
return S_OK;
return E_FAIL;
}
return E_NOTIMPL;
case NI_COMPOSITIONSTR:
switch (dwIndex)
{
case CPS_COMPLETE:
pCicIC->EscbCompComplete(imcLock);
break;
case CPS_CONVERT:
case CPS_REVERT:
return E_NOTIMPL;
case CPS_CANCEL:
pCicIC->EscbCompCancel(imcLock);
break;
default:
return E_FAIL;
}
return S_OK;
case NI_CONTEXTUPDATED:
switch (dwValue)
{
case IMC_SETCONVERSIONMODE:
case IMC_SETSENTENCEMODE:
return OnSetConversionSentenceMode(pThreadMgr, imcLock, pCicIC, dwValue, LangID);
case IMC_SETOPENSTATUS:
return OnSetOpenStatus(pTLS, pThreadMgr, imcLock, pCicIC);
case IMC_SETCANDIDATEPOS:
return pCicIC->OnSetCandidatePos(pTLS, imcLock);
case IMC_SETCOMPOSITIONFONT:
case IMC_SETCOMPOSITIONWINDOW:
return E_NOTIMPL;
default:
return E_FAIL;
}
break;
default:
return E_NOTIMPL;
}
}
/// @unimplemented
@ -719,7 +815,7 @@ CicBridge::ToAsciiEx(
return E_NOTIMPL; // FIXME
}
/// @unimplemented
/// @implemented
BOOL
CicBridge::SetCompositionString(
TLS *pTLS,
@ -731,7 +827,41 @@ CicBridge::SetCompositionString(
LPCVOID lpRead,
DWORD dwReadLen)
{
return FALSE; // FIXME
CicIMCLock imcLock(hIMC);
if (FAILED(imcLock.m_hr))
return FALSE;
CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
if (FAILED(imeContext.m_hr))
return FALSE;
CicInputContext *pCicIC = imeContext.get().m_pCicIC;
auto pProfile = pTLS->m_pProfile;
if (!pCicIC || !pProfile)
return FALSE;
UINT uCodePage;
pProfile->GetCodePageA(&uCodePage);
LANGID LangID;
if (dwIndex != SCS_SETSTR ||
!lpComp || *(WORD*)lpComp ||
!dwCompLen ||
FAILED(pProfile->GetLangId(&LangID)) ||
PRIMARYLANGID(LangID) != LANG_KOREAN)
{
return pCicIC->SetCompositionString(imcLock, pThreadMgr, dwIndex,
lpComp, dwCompLen, lpRead, dwReadLen,
uCodePage);
}
if (imcLock.get().fdwConversion & IME_CMODE_NATIVE)
{
::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
return TRUE;
}
return FALSE;
}
/// @unimplemented

View file

@ -91,7 +91,7 @@ public:
HRESULT Notify(
TLS *pTLS,
ITfThreadMgr *pThreadMgr,
ITfThreadMgr_P *pThreadMgr,
HIMC hIMC,
DWORD dwAction,
DWORD dwIndex,
@ -134,4 +134,18 @@ public:
LPVOID lpData);
static BOOL IsOwnDim(ITfDocumentMgr *pDocMgr);
BOOL
DoOpenCandidateHanja(
ITfThreadMgr_P *pThreadMgr,
CicIMCLock& imcLock,
CicInputContext *pCicIC);
HRESULT
OnSetConversionSentenceMode(
ITfThreadMgr_P *pThreadMgr,
CicIMCLock& imcLock,
CicInputContext *pCicIC,
DWORD dwValue,
LANGID LangID);
};

View file

@ -449,6 +449,18 @@ HRESULT CicInputContext::EscbCompComplete(CicIMCLock& imcLock)
return E_NOTIMPL;
}
/// @unimplemented
HRESULT CicInputContext::EscbCompCancel(CicIMCLock& imcLock)
{
return E_NOTIMPL;
}
/// @unimplemented
HRESULT CicInputContext::OnSetCandidatePos(TLS *pTLS, CicIMCLock& imcLock)
{
return E_NOTIMPL;
}
/// @unimplemented
HRESULT CicInputContext::DelayedReconvertFuncCall(CicIMCLock& imcLock)
{
@ -492,3 +504,17 @@ HRESULT CicInputContext::EndReconvertString(CicIMCLock& imcLock)
{
return E_NOTIMPL;
}
/// @unimplemented
BOOL CicInputContext::SetCompositionString(
CicIMCLock& imcLock,
ITfThreadMgr_P *pThreadMgr,
DWORD dwIndex,
LPCVOID lpComp,
DWORD dwCompLen,
LPCVOID lpRead,
DWORD dwReadLen,
UINT uCodePage)
{
return FALSE;
}

View file

@ -141,9 +141,14 @@ public:
HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock& imcLock);
HRESULT DestroyInputContext();
BOOL SetCompositionString(CicIMCLock& imcLock, ITfThreadMgr_P *pThreadMgr, DWORD dwIndex,
LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen,
UINT uCodePage);
HRESULT SetupDocFeedString(CicIMCLock& imcLock, UINT uCodePage);
HRESULT EscbClearDocFeedBuffer(CicIMCLock& imcLock, BOOL bFlag);
HRESULT EscbCompComplete(CicIMCLock& imcLock);
HRESULT EscbCompCancel(CicIMCLock& imcLock);
HRESULT SetupReconvertString(
CicIMCLock& imcLock,
ITfThreadMgr_P *pThreadMgr,
@ -159,4 +164,6 @@ public:
HRESULT EndReconvertString(CicIMCLock& imcLock);
HRESULT DelayedReconvertFuncCall(CicIMCLock& imcLock);
void ClearPrevCandidatePos();
HRESULT OnSetCandidatePos(TLS *pTLS, CicIMCLock& imcLock);
};