ReactOS 0.4.16-dev-1602-gd4d52e1
CDocumentMgr Class Reference

#include <documentmgr.h>

Inheritance diagram for CDocumentMgr:
Collaboration diagram for CDocumentMgr:

Public Member Functions

 CDocumentMgr (ITfThreadMgrEventSink *threadMgrSink)
 
virtual ~CDocumentMgr ()
 
STDMETHODIMP QueryInterface (REFIID iid, LPVOID *ppvObject) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP CreateContext (TfClientId tidOwner, DWORD dwFlags, IUnknown *punk, ITfContext **ppic, TfEditCookie *pecTextStore) override
 
STDMETHODIMP Push (ITfContext *pic) override
 
STDMETHODIMP Pop (DWORD dwFlags) override
 
STDMETHODIMP GetTop (ITfContext **ppic) override
 
STDMETHODIMP GetBase (ITfContext **ppic) override
 
STDMETHODIMP EnumContexts (IEnumTfContexts **ppEnum) override
 
STDMETHODIMP AdviseSink (REFIID riid, IUnknown *punk, DWORD *pdwCookie) override
 
STDMETHODIMP UnadviseSink (DWORD pdwCookie) override
 
HRESULT CreateContext ([in] TfClientId tidOwner, [in] DWORD dwFlags, [in, unique] IUnknown *punk, [out] ITfContext **ppic, [out] TfEditCookie *pecTextStore)
 
HRESULT Push ([in] ITfContext *pic)
 
HRESULT Pop ([in] DWORD dwFlags)
 
HRESULT GetTop ([out] ITfContext **ppic)
 
HRESULT GetBase ([out] ITfContext **ppic)
 
HRESULT EnumContexts ([out] IEnumTfContexts **ppEnum)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
HRESULT AdviseSink ([in] REFIID riid, [in, iid_is(riid)] IUnknown *punk, [out] DWORD *pdwCookie)
 
HRESULT UnadviseSink ([in] DWORD dwCookie)
 

Static Public Member Functions

static HRESULT CreateInstance (_In_ ITfThreadMgrEventSink *pThreadMgrSink, _Out_ ITfDocumentMgr **ppOut)
 

Protected Attributes

LONG m_cRefs
 
ITfCompartmentMgrm_pCompartmentMgr
 
ITfContextm_initialContext
 
ITfContextm_contextStack [2]
 
ITfThreadMgrEventSinkm_pThreadMgrSink
 
struct list m_transitoryExtensionSink
 

Friends

class CEnumTfContext
 

Additional Inherited Members

- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Attributes inherited from ITfDocumentMgr
const DWORD TF_POPF_ALL = 0x0001
 

Detailed Description

Definition at line 14 of file documentmgr.h.

Constructor & Destructor Documentation

◆ CDocumentMgr()

CDocumentMgr::CDocumentMgr ( ITfThreadMgrEventSink threadMgrSink)

Definition at line 17 of file documentmgr.cpp.

18 : m_cRefs(1)
21 , m_pThreadMgrSink(threadMgrSink)
22{
24
26
27 ITfDocumentMgr *pDocMgr = static_cast<ITfDocumentMgr *>(this);
28 ITfCompartmentMgr **ppCompMgr = static_cast<ITfCompartmentMgr **>(&m_pCompartmentMgr);
29 CompartmentMgr_Constructor(pDocMgr, IID_IUnknown, reinterpret_cast<IUnknown **>(ppCompMgr));
30
33}
static void list_init(struct list_entry *head)
Definition: list.h:51
const GUID IID_IUnknown
struct list m_transitoryExtensionSink
Definition: documentmgr.h:57
ITfContext * m_initialContext
Definition: documentmgr.h:54
ITfThreadMgrEventSink * m_pThreadMgrSink
Definition: documentmgr.h:56
ITfCompartmentMgr * m_pCompartmentMgr
Definition: documentmgr.h:53
ITfContext * m_contextStack[2]
Definition: documentmgr.h:55
EXTERN_C HRESULT CompartmentMgr_Constructor(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppOut)
EXTERN_C HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfDocumentMgr *mgr, ITfContext **ppOut, TfEditCookie *pecTextStore)
Definition: context.cpp:967
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
TfClientId g_processId
Definition: msctf.cpp:44
Definition: cookie.c:34

◆ ~CDocumentMgr()

CDocumentMgr::~CDocumentMgr ( )
virtual

Definition at line 35 of file documentmgr.cpp.

36{
37 TRACE("destroying %p\n", this);
38
41 if (tm)
42 {
44 tm->Release();
45 }
46
49 if (m_contextStack[0])
51 if (m_contextStack[1])
53
55
57 {
60 }
61}
void ThreadMgr_OnDocumentMgrDestruction(ITfThreadMgr *tm, ITfDocumentMgr *mgr)
Definition: threadmgr.cpp:1394
ULONG Release()
HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim)
Definition: msctf.cpp:611
EXTERN_C void free_sinks(struct list *sink_list)
Definition: msctf.cpp:297
#define TRACE(s)
Definition: solgame.cpp:4
Definition: time.h:68

Member Function Documentation

◆ AdviseSink()

STDMETHODIMP CDocumentMgr::AdviseSink ( REFIID  riid,
IUnknown punk,
DWORD pdwCookie 
)
override

Implements ITfSource.

Definition at line 281 of file documentmgr.cpp.

282{
283 TRACE("%p -> (%s, %p, %p)\n", this, wine_dbgstr_guid(&riid), punk, pdwCookie);
284
285 if (cicIsNullPtr(&riid) || !punk || !pdwCookie)
286 return E_INVALIDARG;
287
288 if (riid == IID_ITfTransitoryExtensionSink)
289 {
290 WARN("semi-stub for ITfTransitoryExtensionSink: callback won't be used.\n");
291 return advise_sink(&m_transitoryExtensionSink, IID_ITfTransitoryExtensionSink,
292 COOKIE_MAGIC_DMSINK, punk, pdwCookie);
293 }
294
295 FIXME("(%p) Unhandled Sink: %s\n", this, debugstr_guid(&riid));
296 return E_NOTIMPL;
297}
#define COOKIE_MAGIC_DMSINK
Definition: precomp.h:39
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
static bool cicIsNullPtr(LPCVOID ptr)
Definition: cicbase.h:40
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
EXTERN_C HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie)
Definition: msctf.cpp:259
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

◆ CreateContext()

STDMETHODIMP CDocumentMgr::CreateContext ( TfClientId  tidOwner,
DWORD  dwFlags,
IUnknown punk,
ITfContext **  ppic,
TfEditCookie pecTextStore 
)
override

Implements ITfDocumentMgr.

Definition at line 132 of file documentmgr.cpp.

138{
139 TRACE("%p -> (%d, 0x%lX, %p, %p, %p)\n", this, tidOwner, dwFlags, punk, ppic, pecTextStore);
140 return Context_Constructor(tidOwner, punk, this, ppic, pecTextStore);
141}
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37

◆ CreateInstance()

HRESULT CDocumentMgr::CreateInstance ( _In_ ITfThreadMgrEventSink pThreadMgrSink,
_Out_ ITfDocumentMgr **  ppOut 
)
static

Definition at line 64 of file documentmgr.cpp.

67{
68 if (!ppOut)
69 {
70 ERR("!ppOut\n");
71 return E_POINTER;
72 }
73
74 if (!pThreadMgrSink)
75 {
76 ERR("!pThreadMgrSink\n");
77 return E_INVALIDARG;
78 }
79
80 CDocumentMgr *This = new(cicNoThrow) CDocumentMgr(pThreadMgrSink);
81 if (!This)
82 {
83 ERR("E_OUTOFMEMORY\n");
84 return E_OUTOFMEMORY;
85 }
86
87 *ppOut = static_cast<ITfDocumentMgr *>(This);
88 TRACE("returning %p\n", *ppOut);
89 return S_OK;
90}
#define ERR(fmt,...)
Definition: precomp.h:57
#define cicNoThrow
Definition: cicbase.h:46
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:52
#define E_POINTER
Definition: winerror.h:3480

Referenced by DocumentMgr_Constructor().

◆ EnumContexts()

STDMETHODIMP CDocumentMgr::EnumContexts ( IEnumTfContexts **  ppEnum)
override

Implements ITfDocumentMgr.

Definition at line 275 of file documentmgr.cpp.

276{
277 TRACE("%p -> (%p)\n", this, ppEnum);
278 return EnumTfContext_Constructor(this, ppEnum);
279}
EXTERN_C HRESULT EnumTfContext_Constructor(CDocumentMgr *mgr, IEnumTfContexts **ppOut)

◆ GetBase()

STDMETHODIMP CDocumentMgr::GetBase ( ITfContext **  ppic)
override

Implements ITfDocumentMgr.

Definition at line 250 of file documentmgr.cpp.

251{
252 TRACE("%p -> (%p)\n", this, ppic);
253
254 if (!ppic)
255 {
256 ERR("!ppic\n");
257 return E_INVALIDARG;
258 }
259
261 if (m_contextStack[1])
263 else if (m_contextStack[0])
265 else
267
268 if (target)
269 target->AddRef();
270
271 *ppic = target;
272 return S_OK;
273}
GLenum target
Definition: glext.h:7315
ULONG AddRef()

◆ GetTop()

STDMETHODIMP CDocumentMgr::GetTop ( ITfContext **  ppic)
override

Implements ITfDocumentMgr.

Definition at line 227 of file documentmgr.cpp.

228{
229 TRACE("%p -> (%p)\n", this, ppic);
230
231 if (!ppic)
232 {
233 ERR("!ppic\n");
234 return E_INVALIDARG;
235 }
236
238 if (m_contextStack[0])
240 else
242
243 if (target)
244 target->AddRef();
245
246 *ppic = target;
247 return S_OK;
248}

◆ Pop()

STDMETHODIMP CDocumentMgr::Pop ( DWORD  dwFlags)
override

Implements ITfDocumentMgr.

Definition at line 179 of file documentmgr.cpp.

180{
181 TRACE("%p -> (0x%lX)\n", this, dwFlags);
182
183 if (dwFlags == TF_POPF_ALL)
184 {
185 for (SIZE_T i = 0; i < _countof(m_contextStack); i++)
186 {
187 if (!m_contextStack[i])
188 continue;
189
194 }
195
197 return S_OK;
198 }
199
200 if (dwFlags)
201 {
202 ERR("E_INVALIDARG: 0x%lX\n", dwFlags);
203 return E_INVALIDARG;
204 }
205
206 if (!m_contextStack[1]) // Cannot pop last context
207 {
208 ERR("!m_contextStack[1]\n");
209 return E_FAIL;
210 }
211
214
215 if (m_contextStack[0])
217
219 m_contextStack[1] = NULL;
220
221 if (!m_contextStack[0])
223
224 return S_OK;
225}
EXTERN_C HRESULT Context_Uninitialize(ITfContext *iface)
Definition: context.cpp:985
#define E_FAIL
Definition: ddrawi.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const DWORD TF_POPF_ALL
Definition: msctf.idl:281
HRESULT OnUninitDocumentMgr([in] ITfDocumentMgr *pdim)
HRESULT OnPopContext([in] ITfContext *pic)
#define _countof(array)
Definition: sndvol32.h:70
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ Push()

STDMETHODIMP CDocumentMgr::Push ( ITfContext pic)
override

Implements ITfDocumentMgr.

Definition at line 143 of file documentmgr.cpp.

144{
145 TRACE("%p -> (%p)\n", this, pic);
146
147 if (m_contextStack[1]) /* Full */
148 {
149 ERR("TF_E_STACKFULL\n");
150 return TF_E_STACKFULL;
151 }
152
153 if (!pic)
154 {
155 ERR("!pic\n");
156 return E_INVALIDARG;
157 }
158
160 HRESULT hr = pic->QueryInterface(IID_ITfContext, reinterpret_cast<LPVOID *>(&check));
161 if (FAILED(hr))
162 {
163 ERR("hr: 0x%lX\n", hr);
164 return E_INVALIDARG;
165 }
166
167 if (!m_contextStack[0])
169
172
175
176 return S_OK;
177}
EXTERN_C HRESULT Context_Initialize(ITfContext *iface, ITfDocumentMgr *manager)
Definition: context.cpp:978
#define check(expected, result)
Definition: dplayx.c:32
HRESULT OnInitDocumentMgr([in] ITfDocumentMgr *pdim)
HRESULT OnPushContext([in] ITfContext *pic)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183

◆ QueryInterface()

STDMETHODIMP CDocumentMgr::QueryInterface ( REFIID  iid,
LPVOID ppvObject 
)
override

Definition at line 92 of file documentmgr.cpp.

93{
94 TRACE("%p -> (%s, %p)\n", this, wine_dbgstr_guid(&iid), ppvObject);
95 *ppvObject = NULL;
96
98 if (iid == IID_IUnknown || iid == IID_ITfDocumentMgr)
99 pUnk = static_cast<ITfDocumentMgr *>(this);
100 else if (iid == IID_ITfSource)
101 pUnk = static_cast<ITfSource *>(this);
102 else if (iid == IID_ITfCompartmentMgr)
104
105 if (pUnk)
106 {
107 pUnk->AddRef();
108 *ppvObject = pUnk;
109 return S_OK;
110 }
111
112 WARN("unsupported interface: %s\n", debugstr_guid(&iid));
113 return E_NOINTERFACE;
114}
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
nsrefcnt AddRef()
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ STDMETHODIMP_() [1/2]

CDocumentMgr::STDMETHODIMP_ ( ULONG  )
override

◆ STDMETHODIMP_() [2/2]

CDocumentMgr::STDMETHODIMP_ ( ULONG  )
override

◆ UnadviseSink()

STDMETHODIMP CDocumentMgr::UnadviseSink ( DWORD  pdwCookie)
override

Implements ITfSource.

Definition at line 299 of file documentmgr.cpp.

300{
301 TRACE("%p -> (%p)\n", this, pdwCookie);
302
303 if (get_Cookie_magic(pdwCookie) != COOKIE_MAGIC_DMSINK)
304 return E_INVALIDARG;
305
306 return unadvise_sink(pdwCookie);
307}
EXTERN_C DWORD get_Cookie_magic(DWORD id)
Definition: msctf.cpp:203
EXTERN_C HRESULT unadvise_sink(DWORD cookie)
Definition: msctf.cpp:286

Friends And Related Function Documentation

◆ CEnumTfContext

friend class CEnumTfContext
friend

Definition at line 49 of file documentmgr.h.

Member Data Documentation

◆ m_contextStack

ITfContext* CDocumentMgr::m_contextStack[2]
protected

Definition at line 55 of file documentmgr.h.

Referenced by CDocumentMgr(), GetBase(), GetTop(), CEnumTfContext::Next(), Pop(), Push(), and ~CDocumentMgr().

◆ m_cRefs

LONG CDocumentMgr::m_cRefs
protected

Definition at line 52 of file documentmgr.h.

Referenced by STDMETHODIMP_().

◆ m_initialContext

ITfContext* CDocumentMgr::m_initialContext
protected

Definition at line 54 of file documentmgr.h.

Referenced by CDocumentMgr(), GetBase(), GetTop(), and ~CDocumentMgr().

◆ m_pCompartmentMgr

ITfCompartmentMgr* CDocumentMgr::m_pCompartmentMgr
protected

Definition at line 53 of file documentmgr.h.

Referenced by CDocumentMgr(), QueryInterface(), and ~CDocumentMgr().

◆ m_pThreadMgrSink

ITfThreadMgrEventSink* CDocumentMgr::m_pThreadMgrSink
protected

Definition at line 56 of file documentmgr.h.

Referenced by Pop(), and Push().

◆ m_transitoryExtensionSink

struct list CDocumentMgr::m_transitoryExtensionSink
protected

Definition at line 57 of file documentmgr.h.

Referenced by AdviseSink(), CDocumentMgr(), and ~CDocumentMgr().


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