https://git.reactos.org/?p=reactos.git;a=commitdiff;h=88107adc9249bcc7eb691…
commit 88107adc9249bcc7eb691a8b3f97a797bb58d5ab
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Jan 1 16:36:49 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Jan 1 16:36:49 2024 +0900
[MSCTFIME][SDK] Implement CFunctionProvider (#6269)
Supporting TIPs...
JIRA issue: CORE-19360
Define CFunctionProviderBase class.
Define CFunctionProvider class.
Strengthen <cicero/cictf.h>.
---
dll/ime/msctfime/msctfime.cpp | 233 +++++++++++++++++++++++++++++++++++--
sdk/include/reactos/cicero/cictf.h | 13 +++
2 files changed, 235 insertions(+), 11 deletions(-)
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index c5bfab1abdb..28a1c55d4df 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -6,6 +6,7 @@
*/
#include "msctfime.h"
+#include <ndk/ldrfuncs.h> /* for RtlDllShutdownInProgress */
WINE_DEFAULT_DEBUG_CHANNEL(msctfime);
@@ -1071,24 +1072,132 @@ HRESULT CThreadMgrEventSink::_Unadvise()
return hr;
}
-/* FIXME */
-class CFunctionProvider : public IUnknown
+class CFunctionProviderBase : public ITfFunctionProvider
{
+protected:
+ TfClientId m_clientId;
+ GUID m_guid;
+ BSTR m_bstr;
+ LONG m_cRefs;
+
public:
- CFunctionProvider(_In_ TfClientId clientId)
- {
- }
+ CFunctionProviderBase(_In_ TfClientId clientId);
+ virtual ~CFunctionProviderBase();
// IUnknown interface
- STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override;
+ STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override;
STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release() override;
+
+ // ITfFunctionProvider interface
+ STDMETHODIMP GetType(_Out_ GUID *guid) override;
+ STDMETHODIMP GetDescription(_Out_ BSTR *desc) override;
+ //STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown
**func) = 0;
+
+ BOOL Init(_In_ REFGUID rguid, _In_ LPCWSTR psz);
};
+/**
+ * @implemented
+ */
+CFunctionProviderBase::CFunctionProviderBase(_In_ TfClientId clientId)
+{
+ m_clientId = clientId;
+ m_guid = GUID_NULL;
+ m_bstr = NULL;
+ m_cRefs = 1;
+}
+
+/**
+ * @implemented
+ */
+CFunctionProviderBase::~CFunctionProviderBase()
+{
+ if (!RtlDllShutdownInProgress())
+ ::SysFreeString(m_bstr);
+}
+
+/**
+ * @implemented
+ */
+BOOL
+CFunctionProviderBase::Init(
+ _In_ REFGUID rguid,
+ _In_ LPCWSTR psz)
+{
+ m_bstr = ::SysAllocString(psz);
+ m_guid = rguid;
+ return (m_bstr != NULL);
+}
+
+class CFnDocFeed : public IAImmFnDocFeed
+{
+ LONG m_cRefs;
+
+public:
+ CFnDocFeed();
+ virtual ~CFnDocFeed();
+
+ // IUnknown interface
+ STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override;
+ STDMETHODIMP_(ULONG) AddRef() override;
+ STDMETHODIMP_(ULONG) Release() override;
+
+ // IAImmFnDocFeed interface
+ STDMETHODIMP DocFeed() override;
+ STDMETHODIMP ClearDocFeedBuffer() override;
+ STDMETHODIMP StartReconvert() override;
+ STDMETHODIMP StartUndoCompositionString() override;
+};
+
+CFnDocFeed::CFnDocFeed()
+{
+ m_cRefs = 1;
+}
+
+CFnDocFeed::~CFnDocFeed()
+{
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP CFnDocFeed::QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj)
+{
+ if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IAImmFnDocFeed))
+ {
+ *ppvObj = this;
+ AddRef();
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP_(ULONG) CFnDocFeed::AddRef()
+{
+ return ::InterlockedIncrement(&m_cRefs);
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP_(ULONG) CFnDocFeed::Release()
+{
+ if (::InterlockedDecrement(&m_cRefs) == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_cRefs;
+}
+
/**
* @unimplemented
*/
-STDMETHODIMP CFunctionProvider::QueryInterface(REFIID riid, LPVOID* ppvObj)
+STDMETHODIMP CFnDocFeed::DocFeed()
{
return E_NOTIMPL;
}
@@ -1096,17 +1205,119 @@ STDMETHODIMP CFunctionProvider::QueryInterface(REFIID riid,
LPVOID* ppvObj)
/**
* @unimplemented
*/
-STDMETHODIMP_(ULONG) CFunctionProvider::AddRef()
+STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer()
{
- return 1;
+ return E_NOTIMPL;
}
/**
* @unimplemented
*/
-STDMETHODIMP_(ULONG) CFunctionProvider::Release()
+STDMETHODIMP CFnDocFeed::StartReconvert()
{
- return 0;
+ return E_NOTIMPL;
+}
+
+/**
+ * @unimplemented
+ */
+STDMETHODIMP CFnDocFeed::StartUndoCompositionString()
+{
+ return E_NOTIMPL;
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP
+CFunctionProviderBase::QueryInterface(
+ _In_ REFIID riid,
+ _Out_ LPVOID* ppvObj)
+{
+ if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfFunctionProvider))
+ {
+ *ppvObj = this;
+ AddRef();
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP_(ULONG) CFunctionProviderBase::AddRef()
+{
+ return ::InterlockedIncrement(&m_cRefs);
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP_(ULONG) CFunctionProviderBase::Release()
+{
+ if (::InterlockedDecrement(&m_cRefs) == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_cRefs;
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP CFunctionProviderBase::GetType(_Out_ GUID *guid)
+{
+ *guid = m_guid;
+ return S_OK;
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP CFunctionProviderBase::GetDescription(_Out_ BSTR *desc)
+{
+ *desc = ::SysAllocString(m_bstr);
+ return (*desc ? S_OK : E_OUTOFMEMORY);
+}
+
+class CFunctionProvider : public CFunctionProviderBase
+{
+public:
+ CFunctionProvider(_In_ TfClientId clientId);
+
+ STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func)
override;
+};
+
+/**
+ * @implemented
+ */
+CFunctionProvider::CFunctionProvider(_In_ TfClientId clientId) :
CFunctionProviderBase(clientId)
+{
+ Init(CLSID_CAImmLayer, L"MSCTFIME::Function Provider");
+}
+
+/**
+ * @implemented
+ */
+STDMETHODIMP
+CFunctionProvider::GetFunction(
+ _In_ REFGUID guid,
+ _In_ REFIID riid,
+ _Out_ IUnknown **func)
+{
+ *func = NULL;
+
+ if (IsEqualGUID(guid, GUID_NULL) &&
+ IsEqualIID(riid, IID_IAImmFnDocFeed))
+ {
+ *func = new CFnDocFeed();
+ if (*func)
+ return S_OK;
+ }
+
+ return E_NOINTERFACE;
}
/* FIXME */
diff --git a/sdk/include/reactos/cicero/cictf.h b/sdk/include/reactos/cicero/cictf.h
index e11cebc3154..afc96cdfc14 100644
--- a/sdk/include/reactos/cicero/cictf.h
+++ b/sdk/include/reactos/cicero/cictf.h
@@ -29,3 +29,16 @@ struct ITfThreadMgr_P : ITfThreadMgr
};
DEFINE_GUID(IID_ITfKeystrokeMgr_P, 0x53FA1BEC, 0x5BE1, 0x458E, 0xAE, 0x70, 0xA9, 0xF1,
0xDC, 0x84, 0x3E, 0x81);
+
+// FIXME: ITfKeystrokeMgr_P
+
+DEFINE_GUID(IID_IAImmFnDocFeed, 0x6E098993, 0x9577, 0x499A, 0xA8, 0x30, 0x52, 0x34, 0x4F,
0x3E, 0x20, 0x0D);
+DEFINE_GUID(CLSID_CAImmLayer, 0xB676DB87, 0x64DC, 0x4651, 0x99, 0xEC, 0x91, 0x07, 0x0E,
0xA4, 0x87, 0x90);
+
+struct IAImmFnDocFeed : IUnknown
+{
+ STDMETHOD(DocFeed)() = 0;
+ STDMETHOD(ClearDocFeedBuffer)() = 0;
+ STDMETHOD(StartReconvert)() = 0;
+ STDMETHOD(StartUndoCompositionString)() = 0;
+};