1*b2ec7867SKatayama Hirofumi MZ /* 2*b2ec7867SKatayama Hirofumi MZ * PROJECT: ReactOS msctfime.ime 3*b2ec7867SKatayama Hirofumi MZ * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4*b2ec7867SKatayama Hirofumi MZ * PURPOSE: The sinks of msctfime.ime 5*b2ec7867SKatayama Hirofumi MZ * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6*b2ec7867SKatayama Hirofumi MZ */ 7*b2ec7867SKatayama Hirofumi MZ 8*b2ec7867SKatayama Hirofumi MZ #pragma once 9*b2ec7867SKatayama Hirofumi MZ 10*b2ec7867SKatayama Hirofumi MZ /***********************************************************************/ 11*b2ec7867SKatayama Hirofumi MZ 12*b2ec7867SKatayama Hirofumi MZ typedef struct CESMAP 13*b2ec7867SKatayama Hirofumi MZ { 14*b2ec7867SKatayama Hirofumi MZ ITfCompartment *m_pComp; 15*b2ec7867SKatayama Hirofumi MZ DWORD m_dwCookie; 16*b2ec7867SKatayama Hirofumi MZ } CESMAP, *PCESMAP; 17*b2ec7867SKatayama Hirofumi MZ 18*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_EVENTSINK)(LPVOID, REFGUID); 19*b2ec7867SKatayama Hirofumi MZ 20*b2ec7867SKatayama Hirofumi MZ class CCompartmentEventSink : public ITfCompartmentEventSink 21*b2ec7867SKatayama Hirofumi MZ { 22*b2ec7867SKatayama Hirofumi MZ CicArray<CESMAP> m_array; 23*b2ec7867SKatayama Hirofumi MZ LONG m_cRefs; 24*b2ec7867SKatayama Hirofumi MZ FN_EVENTSINK m_fnEventSink; 25*b2ec7867SKatayama Hirofumi MZ LPVOID m_pUserData; 26*b2ec7867SKatayama Hirofumi MZ 27*b2ec7867SKatayama Hirofumi MZ public: 28*b2ec7867SKatayama Hirofumi MZ CCompartmentEventSink(FN_EVENTSINK fnEventSink, LPVOID pUserData); 29*b2ec7867SKatayama Hirofumi MZ virtual ~CCompartmentEventSink(); 30*b2ec7867SKatayama Hirofumi MZ 31*b2ec7867SKatayama Hirofumi MZ HRESULT _Advise(IUnknown *pUnknown, REFGUID rguid, BOOL bThread); 32*b2ec7867SKatayama Hirofumi MZ HRESULT _Unadvise(); 33*b2ec7867SKatayama Hirofumi MZ 34*b2ec7867SKatayama Hirofumi MZ // IUnknown interface 35*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; 36*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) AddRef() override; 37*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) Release() override; 38*b2ec7867SKatayama Hirofumi MZ 39*b2ec7867SKatayama Hirofumi MZ // ITfCompartmentEventSink interface 40*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnChange(REFGUID rguid) override; 41*b2ec7867SKatayama Hirofumi MZ }; 42*b2ec7867SKatayama Hirofumi MZ 43*b2ec7867SKatayama Hirofumi MZ /***********************************************************************/ 44*b2ec7867SKatayama Hirofumi MZ 45*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_ENDEDIT)(INT, LPVOID, LPVOID); 46*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_LAYOUTCHANGE)(UINT nType, FN_ENDEDIT fnEndEdit, ITfContextView *pView); 47*b2ec7867SKatayama Hirofumi MZ 48*b2ec7867SKatayama Hirofumi MZ class CTextEventSink : public ITfTextEditSink, ITfTextLayoutSink 49*b2ec7867SKatayama Hirofumi MZ { 50*b2ec7867SKatayama Hirofumi MZ protected: 51*b2ec7867SKatayama Hirofumi MZ LONG m_cRefs; 52*b2ec7867SKatayama Hirofumi MZ IUnknown *m_pUnknown; 53*b2ec7867SKatayama Hirofumi MZ DWORD m_dwEditSinkCookie; 54*b2ec7867SKatayama Hirofumi MZ DWORD m_dwLayoutSinkCookie; 55*b2ec7867SKatayama Hirofumi MZ union 56*b2ec7867SKatayama Hirofumi MZ { 57*b2ec7867SKatayama Hirofumi MZ UINT m_uFlags; 58*b2ec7867SKatayama Hirofumi MZ FN_LAYOUTCHANGE m_fnLayoutChange; 59*b2ec7867SKatayama Hirofumi MZ }; 60*b2ec7867SKatayama Hirofumi MZ FN_ENDEDIT m_fnEndEdit; 61*b2ec7867SKatayama Hirofumi MZ LPVOID m_pCallbackPV; 62*b2ec7867SKatayama Hirofumi MZ 63*b2ec7867SKatayama Hirofumi MZ public: 64*b2ec7867SKatayama Hirofumi MZ CTextEventSink(FN_ENDEDIT fnEndEdit, LPVOID pCallbackPV); 65*b2ec7867SKatayama Hirofumi MZ virtual ~CTextEventSink(); 66*b2ec7867SKatayama Hirofumi MZ 67*b2ec7867SKatayama Hirofumi MZ HRESULT _Advise(IUnknown *pUnknown, UINT uFlags); 68*b2ec7867SKatayama Hirofumi MZ HRESULT _Unadvise(); 69*b2ec7867SKatayama Hirofumi MZ 70*b2ec7867SKatayama Hirofumi MZ // IUnknown interface 71*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; 72*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) AddRef() override; 73*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) Release() override; 74*b2ec7867SKatayama Hirofumi MZ 75*b2ec7867SKatayama Hirofumi MZ // ITfTextEditSink interface 76*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnEndEdit( 77*b2ec7867SKatayama Hirofumi MZ ITfContext *pic, 78*b2ec7867SKatayama Hirofumi MZ TfEditCookie ecReadOnly, 79*b2ec7867SKatayama Hirofumi MZ ITfEditRecord *pEditRecord) override; 80*b2ec7867SKatayama Hirofumi MZ 81*b2ec7867SKatayama Hirofumi MZ // ITfTextLayoutSink interface 82*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP 83*b2ec7867SKatayama Hirofumi MZ OnLayoutChange( 84*b2ec7867SKatayama Hirofumi MZ ITfContext *pContext, 85*b2ec7867SKatayama Hirofumi MZ TfLayoutCode lcode, 86*b2ec7867SKatayama Hirofumi MZ ITfContextView *pContextView) override; 87*b2ec7867SKatayama Hirofumi MZ }; 88*b2ec7867SKatayama Hirofumi MZ 89*b2ec7867SKatayama Hirofumi MZ /***********************************************************************/ 90*b2ec7867SKatayama Hirofumi MZ 91*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_INITDOCMGR)(UINT, ITfDocumentMgr *, ITfDocumentMgr *, LPVOID); 92*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_PUSHPOP)(UINT, ITfContext *, LPVOID); 93*b2ec7867SKatayama Hirofumi MZ 94*b2ec7867SKatayama Hirofumi MZ class CThreadMgrEventSink : public ITfThreadMgrEventSink 95*b2ec7867SKatayama Hirofumi MZ { 96*b2ec7867SKatayama Hirofumi MZ protected: 97*b2ec7867SKatayama Hirofumi MZ ITfThreadMgr *m_pThreadMgr; 98*b2ec7867SKatayama Hirofumi MZ DWORD m_dwCookie; 99*b2ec7867SKatayama Hirofumi MZ FN_INITDOCMGR m_fnInit; 100*b2ec7867SKatayama Hirofumi MZ FN_PUSHPOP m_fnPushPop; 101*b2ec7867SKatayama Hirofumi MZ DWORD m_dw; 102*b2ec7867SKatayama Hirofumi MZ LPVOID m_pCallbackPV; 103*b2ec7867SKatayama Hirofumi MZ LONG m_cRefs; 104*b2ec7867SKatayama Hirofumi MZ 105*b2ec7867SKatayama Hirofumi MZ public: 106*b2ec7867SKatayama Hirofumi MZ CThreadMgrEventSink( 107*b2ec7867SKatayama Hirofumi MZ _In_ FN_INITDOCMGR fnInit, 108*b2ec7867SKatayama Hirofumi MZ _In_ FN_PUSHPOP fnPushPop = NULL, 109*b2ec7867SKatayama Hirofumi MZ _Inout_ LPVOID pvCallbackPV = NULL); ~CThreadMgrEventSink()110*b2ec7867SKatayama Hirofumi MZ virtual ~CThreadMgrEventSink() { } 111*b2ec7867SKatayama Hirofumi MZ 112*b2ec7867SKatayama Hirofumi MZ void SetCallbackPV(_Inout_ LPVOID pv); 113*b2ec7867SKatayama Hirofumi MZ HRESULT _Advise(ITfThreadMgr *pThreadMgr); 114*b2ec7867SKatayama Hirofumi MZ HRESULT _Unadvise(); 115*b2ec7867SKatayama Hirofumi MZ 116*b2ec7867SKatayama Hirofumi MZ // IUnknown interface 117*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; 118*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) AddRef() override; 119*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) Release() override; 120*b2ec7867SKatayama Hirofumi MZ 121*b2ec7867SKatayama Hirofumi MZ // ITfThreadMgrEventSink interface 122*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pdim) override; 123*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pdim) override; 124*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnSetFocus(ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus) override; 125*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnPushContext(ITfContext *pic) override; 126*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP OnPopContext(ITfContext *pic) override; 127*b2ec7867SKatayama Hirofumi MZ 128*b2ec7867SKatayama Hirofumi MZ static INT CALLBACK DIMCallback( 129*b2ec7867SKatayama Hirofumi MZ UINT nCode, 130*b2ec7867SKatayama Hirofumi MZ ITfDocumentMgr *pDocMgr1, 131*b2ec7867SKatayama Hirofumi MZ ITfDocumentMgr *pDocMgr2, 132*b2ec7867SKatayama Hirofumi MZ LPVOID pUserData); 133*b2ec7867SKatayama Hirofumi MZ }; 134*b2ec7867SKatayama Hirofumi MZ 135*b2ec7867SKatayama Hirofumi MZ /***********************************************************************/ 136*b2ec7867SKatayama Hirofumi MZ 137*b2ec7867SKatayama Hirofumi MZ class CActiveLanguageProfileNotifySink : public ITfActiveLanguageProfileNotifySink 138*b2ec7867SKatayama Hirofumi MZ { 139*b2ec7867SKatayama Hirofumi MZ protected: 140*b2ec7867SKatayama Hirofumi MZ typedef INT (CALLBACK *FN_COMPARE)(REFGUID rguid1, REFGUID rguid2, BOOL fActivated, 141*b2ec7867SKatayama Hirofumi MZ LPVOID pUserData); 142*b2ec7867SKatayama Hirofumi MZ LONG m_cRefs; 143*b2ec7867SKatayama Hirofumi MZ ITfThreadMgr *m_pThreadMgr; 144*b2ec7867SKatayama Hirofumi MZ DWORD m_dwConnection; 145*b2ec7867SKatayama Hirofumi MZ FN_COMPARE m_fnCompare; 146*b2ec7867SKatayama Hirofumi MZ LPVOID m_pUserData; 147*b2ec7867SKatayama Hirofumi MZ 148*b2ec7867SKatayama Hirofumi MZ public: 149*b2ec7867SKatayama Hirofumi MZ CActiveLanguageProfileNotifySink(_In_ FN_COMPARE fnCompare, _Inout_opt_ void *pUserData); 150*b2ec7867SKatayama Hirofumi MZ virtual ~CActiveLanguageProfileNotifySink(); 151*b2ec7867SKatayama Hirofumi MZ 152*b2ec7867SKatayama Hirofumi MZ HRESULT _Advise(ITfThreadMgr *pThreadMgr); 153*b2ec7867SKatayama Hirofumi MZ HRESULT _Unadvise(); 154*b2ec7867SKatayama Hirofumi MZ 155*b2ec7867SKatayama Hirofumi MZ // IUnknown interface 156*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override; 157*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) AddRef() override; 158*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP_(ULONG) Release() override; 159*b2ec7867SKatayama Hirofumi MZ 160*b2ec7867SKatayama Hirofumi MZ // ITfActiveLanguageProfileNotifySink interface 161*b2ec7867SKatayama Hirofumi MZ STDMETHODIMP 162*b2ec7867SKatayama Hirofumi MZ OnActivated( 163*b2ec7867SKatayama Hirofumi MZ REFCLSID clsid, 164*b2ec7867SKatayama Hirofumi MZ REFGUID guidProfile, 165*b2ec7867SKatayama Hirofumi MZ BOOL fActivated) override; 166*b2ec7867SKatayama Hirofumi MZ }; 167