Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jpbandroid/reactos-pulls
Browse files Browse the repository at this point in the history
…into windivs8
  • Loading branch information
errortek committed Feb 22, 2024
2 parents 1af55df + 496a4d3 commit bdf0058
Show file tree
Hide file tree
Showing 13 changed files with 582 additions and 63 deletions.
2 changes: 1 addition & 1 deletion dll/ime/msctfime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ set_module_type(msctfime win32dll UNICODE)
set_target_properties(msctfime PROPERTIES SUFFIX ".ime")
target_link_libraries(msctfime wine uuid cicero)
add_importlibs(msctfime user32 gdi32 advapi32 msvcrt kernel32 ntdll)
add_delay_importlibs(msctfime comctl32 msctf oleaut32 imm32)
add_delay_importlibs(msctfime uxtheme comctl32 msctf oleaut32 imm32)
add_cd_file(TARGET msctfime DESTINATION reactos/system32 FOR all)
13 changes: 3 additions & 10 deletions dll/ime/msctfime/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ CicBridge::CreateInputContext(
_In_ HIMC hIMC)
{
CicIMCLock imcLock(hIMC);
HRESULT hr = imcLock.m_hr;
if (!imcLock)
hr = E_FAIL;
if (FAILED(hr))
return hr;
if (FAILED(imcLock.m_hr))
return imcLock.m_hr;

if (!imcLock.get().hCtfImeContext)
{
Expand Down Expand Up @@ -126,7 +123,7 @@ CicBridge::CreateInputContext(
imeContext.get().m_pCicIC = pCicIC;
}

hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock);
HRESULT hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock);
if (FAILED(hr))
{
pCicIC->Release();
Expand All @@ -149,8 +146,6 @@ HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC)
{
CicIMCLock imcLock(hIMC);
HRESULT hr = imcLock.m_hr;
if (!imcLock)
hr = E_FAIL;
if (FAILED(hr))
return hr;

Expand Down Expand Up @@ -217,8 +212,6 @@ CicBridge::SelectEx(
return imcLock.m_hr;

CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
if (!imeContext)
imeContext.m_hr = E_FAIL;
if (FAILED(imeContext.m_hr))
return imeContext.m_hr;

Expand Down
100 changes: 93 additions & 7 deletions dll/ime/msctfime/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,112 @@ STDMETHODIMP_(ULONG) CFnDocFeed::Release()
return m_cRefs;
}

/// @unimplemented
/// @implemented
STDMETHODIMP CFnDocFeed::DocFeed()
{
return E_NOTIMPL;
TLS *pTLS = TLS::GetTLS();
if (!pTLS)
return E_OUTOFMEMORY;

HIMC hIMC = GetActiveContext();
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_FAIL;

UINT uCodePage = CP_ACP;
pTLS->m_pProfile->GetCodePageA(&uCodePage);
pCicIC->SetupDocFeedString(imcLock, uCodePage);
return S_OK;
}

/// @unimplemented
/// @implemented
STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer()
{
return E_NOTIMPL;
if (!TLS::GetTLS())
return E_OUTOFMEMORY;

HIMC hIMC = GetActiveContext();
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_FAIL;

pCicIC->EscbClearDocFeedBuffer(imcLock, TRUE);
return S_OK;
}

/// @unimplemented
STDMETHODIMP CFnDocFeed::StartReconvert()
{
return E_NOTIMPL;
TLS *pTLS = TLS::GetTLS();
if (!pTLS)
return E_OUTOFMEMORY;
auto *pThreadMgr = pTLS->m_pThreadMgr;
if (!pThreadMgr)
return E_OUTOFMEMORY;

HIMC hIMC = GetActiveContext();
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_FAIL;

UINT uCodePage = CP_ACP;
pTLS->m_pProfile->GetCodePageA(&uCodePage);

pCicIC->m_bReconverting = TRUE;
pCicIC->SetupReconvertString(imcLock, pThreadMgr, uCodePage, 0, 0);
pCicIC->EndReconvertString(imcLock);
pCicIC->m_bReconverting = FALSE;
return S_OK;
}

/// @unimplemented
/// @implemented
STDMETHODIMP CFnDocFeed::StartUndoCompositionString()
{
return E_NOTIMPL;
TLS *pTLS = TLS::GetTLS();
if (!pTLS)
return E_OUTOFMEMORY;
auto *pThreadMgr = pTLS->m_pThreadMgr;
if (!pThreadMgr)
return E_OUTOFMEMORY;

HIMC hIMC = GetActiveContext();
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_FAIL;

UINT uCodePage = CP_ACP;
pTLS->m_pProfile->GetCodePageA(&uCodePage);

pCicIC->SetupReconvertString(imcLock, pThreadMgr, uCodePage, 0, TRUE);
pCicIC->EndReconvertString(imcLock);
return S_OK;
}
41 changes: 34 additions & 7 deletions dll/ime/msctfime/inputcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CicInputContext::OnStartComposition(
ITfCompositionView *pComposition,
BOOL *pfOk)
{
if ((m_cCompLocks <= 0) || m_dwUnknown6_5)
if ((m_cCompLocks <= 0) || m_bReconverting)
{
*pfOk = TRUE;
++m_cCompLocks;
Expand Down Expand Up @@ -103,13 +103,10 @@ CicInputContext::GetGuidAtom(
_Out_opt_ LPDWORD pdwGuidAtom)
{
CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr);
HRESULT hr = imeContext.m_hr;
if (!imeContext)
hr = E_FAIL;
if (FAILED(hr))
return hr;
if (FAILED(imeContext.m_hr))
return imeContext.m_hr;

hr = E_FAIL;
HRESULT hr = E_FAIL;
if (iAtom < m_cGuidAtoms)
{
*pdwGuidAtom = m_adwGuidAtoms[iAtom];
Expand Down Expand Up @@ -251,6 +248,36 @@ CicInputContext::OnCleanupContext(
return S_OK;
}

/// @unimplemented
HRESULT CicInputContext::SetupDocFeedString(CicIMCLock& imcLock, UINT uCodePage)
{
return E_NOTIMPL;
}

/// @unimplemented
HRESULT CicInputContext::EscbClearDocFeedBuffer(CicIMCLock& imcLock, BOOL bFlag)
{
return E_NOTIMPL;
}

/// @unimplemented
HRESULT
CicInputContext::SetupReconvertString(
CicIMCLock& imcLock,
ITfThreadMgr_P *pThreadMgr,
UINT uCodePage,
DWORD dwUnknown61,
BOOL bUndo)
{
return E_NOTIMPL;
}

/// @unimplemented
HRESULT CicInputContext::EndReconvertString(CicIMCLock& imcLock)
{
return E_NOTIMPL;
}

/// Retrieves the IME information.
/// @implemented
HRESULT
Expand Down
12 changes: 11 additions & 1 deletion dll/ime/msctfime/inputcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CicInputContext
GUID m_guid;
DWORD m_dwUnknown6[11];
BOOL m_bSelecting;
DWORD m_dwUnknown6_5;
BOOL m_bReconverting;
LONG m_cCompLocks;
DWORD m_dwUnknown7[5];
WORD m_cGuidAtoms;
Expand Down Expand Up @@ -88,4 +88,14 @@ class CicInputContext

HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock& imcLock);
HRESULT DestroyInputContext();

HRESULT SetupDocFeedString(CicIMCLock& imcLock, UINT uCodePage);
HRESULT EscbClearDocFeedBuffer(CicIMCLock& imcLock, BOOL bFlag);
HRESULT SetupReconvertString(
CicIMCLock& imcLock,
ITfThreadMgr_P *pThreadMgr,
UINT uCodePage,
DWORD dwUnknown61,
BOOL bUndo);
HRESULT EndReconvertString(CicIMCLock& imcLock);
};
35 changes: 6 additions & 29 deletions dll/ime/msctfime/msctfime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
return hr;
}

HIMC GetActiveContext(VOID)
{
HWND hwndFocus = ::GetFocus();
if (!hwndFocus)
hwndFocus = ::GetActiveWindow();
return ::ImmGetContext(hwndFocus);
}

/// @implemented
HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
{
Expand Down Expand Up @@ -184,8 +176,6 @@ InternalSelectEx(
_In_ LANGID LangID)
{
CicIMCLock imcLock(hIMC);
if (!imcLock)
imcLock.m_hr = E_FAIL;
if (FAILED(imcLock.m_hr))
return imcLock.m_hr;

Expand Down Expand Up @@ -608,25 +598,17 @@ CtfImeGetGuidAtom(
TRACE("(%p, 0x%lX, %p)\n", hIMC, dwUnknown, pdwGuidAtom);

CicIMCLock imcLock(hIMC);

HRESULT hr = imcLock.m_hr;
if (!imcLock)
hr = E_FAIL;
if (FAILED(hr))
return hr;
if (FAILED(imcLock.m_hr))
return imcLock.m_hr;

CicIMCCLock<CTFIMECONTEXT> imccLock(imcLock.get().hCtfImeContext);
hr = imccLock.m_hr;
if (!imccLock)
hr = E_FAIL;
if (FAILED(hr))
return hr;
if (FAILED(imccLock.m_hr))
return imccLock.m_hr;

if (!imccLock.get().m_pCicIC)
return E_OUTOFMEMORY;

hr = imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
return hr;
return imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
}

/***********************************************************************
Expand All @@ -641,13 +623,8 @@ CtfImeIsGuidMapEnable(
TRACE("(%p)\n", hIMC);

BOOL ret = FALSE;
HRESULT hr;
CicIMCLock imcLock(hIMC);

hr = imcLock.m_hr;
if (!imcLock)
hr = E_FAIL;
if (SUCCEEDED(hr))
if (SUCCEEDED(imcLock.m_hr))
ret = !!(imcLock.get().fdwInit & INIT_GUIDMAP);

return ret;
Expand Down
9 changes: 9 additions & 0 deletions dll/ime/msctfime/msctfime.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <cicarray.h>
#include <cicimc.h>
#include <cictf.h>
#include <cicreg.h>
#include <ciccaret.h>
#include <cicuif.h>
#include <cicutb.h>
Expand All @@ -39,6 +40,14 @@ EXTERN_C BOOLEAN WINAPI DllShutdownInProgress(VOID);
HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread);
HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread);

static inline HIMC GetActiveContext(VOID)
{
HWND hwndFocus = ::GetFocus();
if (!hwndFocus)
hwndFocus = ::GetActiveWindow();
return ::ImmGetContext(hwndFocus);
}

DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95, 0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9);
DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8, 0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF);

Expand Down
Loading

0 comments on commit bdf0058

Please sign in to comment.