ReactOS 0.4.15-dev-8241-g63935f8
CCompartmentEventSink Class Reference

#include <sinks.h>

Inheritance diagram for CCompartmentEventSink:
Collaboration diagram for CCompartmentEventSink:

Public Member Functions

 CCompartmentEventSink (FN_EVENTSINK fnEventSink, LPVOID pUserData)
 @implemented
 
virtual ~CCompartmentEventSink ()
 @implemented
 
HRESULT _Advise (IUnknown *pUnknown, REFGUID rguid, BOOL bThread)
 @implemented
 
HRESULT _Unadvise ()
 @implemented
 
STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObj) override
 @implemented
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP OnChange (REFGUID rguid) override
 @implemented
 
HRESULT OnChange ([in] REFGUID rguid)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Attributes

CicArray< CESMAPm_array
 
LONG m_cRefs
 
FN_EVENTSINK m_fnEventSink
 
LPVOID m_pUserData
 

Additional Inherited Members

- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 

Detailed Description

Definition at line 20 of file sinks.h.

Constructor & Destructor Documentation

◆ CCompartmentEventSink()

CCompartmentEventSink::CCompartmentEventSink ( FN_EVENTSINK  fnEventSink,
LPVOID  pUserData 
)

@implemented

Definition at line 13 of file sinks.cpp.

14 : m_array()
15 , m_cRefs(1)
16 , m_fnEventSink(fnEventSink)
17 , m_pUserData(pUserData)
18{
19}
LPVOID m_pUserData
Definition: sinks.h:25
FN_EVENTSINK m_fnEventSink
Definition: sinks.h:24
CicArray< CESMAP > m_array
Definition: sinks.h:22

◆ ~CCompartmentEventSink()

CCompartmentEventSink::~CCompartmentEventSink ( )
virtual

@implemented

Definition at line 22 of file sinks.cpp.

23{
24}

Member Function Documentation

◆ _Advise()

HRESULT CCompartmentEventSink::_Advise ( IUnknown pUnknown,
REFGUID  rguid,
BOOL  bThread 
)

@implemented

Definition at line 62 of file sinks.cpp.

63{
64 CESMAP *pCesMap = m_array.Append(1);
65 if (!pCesMap)
66 return E_OUTOFMEMORY;
67
68 ITfSource *pSource = NULL;
69
70 HRESULT hr = GetCompartment(pUnknown, rguid, &pCesMap->m_pComp, bThread);
71 if (FAILED(hr))
72 {
73 hr = pCesMap->m_pComp->QueryInterface(IID_ITfSource, (void **)&pSource);
74 if (FAILED(hr))
75 {
76 hr = pSource->AdviseSink(IID_ITfCompartmentEventSink, this, &pCesMap->m_dwCookie);
77 if (FAILED(hr))
78 {
79 if (pCesMap->m_pComp)
80 {
81 pCesMap->m_pComp->Release();
82 pCesMap->m_pComp = NULL;
83 }
84 m_array.Remove(m_array.size() - 1, 1);
85 }
86 else
87 {
88 hr = S_OK;
89 }
90 }
91 }
92
93 if (pSource)
94 pSource->Release();
95
96 return hr;
97}
void Remove(size_t iItem, size_t cRemove=1)
Definition: cicarray.cpp:57
size_t size() const
Definition: cicarray.h:34
T_ITEM * Append(size_t cGrow)
Definition: cicarray.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
HRESULT GetCompartment(IUnknown *pUnknown, REFGUID rguid, ITfCompartment **ppComp, BOOL bThread)
@implemented
Definition: misc.cpp:219
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
Definition: sinks.h:13
DWORD m_dwCookie
Definition: sinks.h:15
ITfCompartment * m_pComp
Definition: sinks.h:14

◆ _Unadvise()

HRESULT CCompartmentEventSink::_Unadvise ( )

@implemented

Definition at line 100 of file sinks.cpp.

101{
102 CESMAP *pCesMap = m_array.data();
103 size_t cItems = m_array.size();
104 if (!cItems)
105 return S_OK;
106
107 do
108 {
109 ITfSource *pSource = NULL;
110 HRESULT hr = pCesMap->m_pComp->QueryInterface(IID_ITfSource, (void **)&pSource);
111 if (SUCCEEDED(hr))
112 pSource->UnadviseSink(pCesMap->m_dwCookie);
113
114 if (pCesMap->m_pComp)
115 {
116 pCesMap->m_pComp->Release();
117 pCesMap->m_pComp = NULL;
118 }
119
120 if (pSource)
121 pSource->Release();
122
123 ++pCesMap;
124 --cItems;
125 } while (cItems);
126
127 return S_OK;
128}
T_ITEM * data() const
Definition: cicarray.h:33
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by CicInputContext::DestroyInputContext().

◆ OnChange()

STDMETHODIMP CCompartmentEventSink::OnChange ( REFGUID  rguid)
override

@implemented

Implements ITfCompartmentEventSink.

Definition at line 55 of file sinks.cpp.

56{
57 return m_fnEventSink(m_pUserData, rguid);
58}

◆ QueryInterface()

STDMETHODIMP CCompartmentEventSink::QueryInterface ( REFIID  riid,
LPVOID ppvObj 
)
override

@implemented

Definition at line 27 of file sinks.cpp.

28{
29 static const QITAB c_tab[] =
30 {
32 { NULL }
33 };
34 return ::QISearch(this, c_tab, riid, ppvObj);
35}
REFIID riid
Definition: atlbase.h:39
#define QITABENT(Cthis, Ifoo)
Definition: shlwapi.h:2094

◆ STDMETHODIMP_() [1/2]

CCompartmentEventSink::STDMETHODIMP_ ( ULONG  )
override

◆ STDMETHODIMP_() [2/2]

CCompartmentEventSink::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_array

CicArray<CESMAP> CCompartmentEventSink::m_array
private

Definition at line 22 of file sinks.h.

Referenced by _Advise(), and _Unadvise().

◆ m_cRefs

LONG CCompartmentEventSink::m_cRefs
private

Definition at line 23 of file sinks.h.

Referenced by STDMETHODIMP_().

◆ m_fnEventSink

FN_EVENTSINK CCompartmentEventSink::m_fnEventSink
private

Definition at line 24 of file sinks.h.

Referenced by OnChange().

◆ m_pUserData

LPVOID CCompartmentEventSink::m_pUserData
private

Definition at line 25 of file sinks.h.

Referenced by OnChange().


The documentation for this class was generated from the following files: