BOOL CSampleIME::_InitTextEditSink(_In_ ITfDocumentMgr *pDocMgr) { ITfSource* pSource = nullptr; BOOL ret = TRUE; // clear out any previous sink first if (_textEditSinkCookie != TF_INVALID_COOKIE) { if (SUCCEEDED(_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource))) { pSource->UnadviseSink(_textEditSinkCookie); pSource->Release(); } _pTextEditSinkContext->Release(); _pTextEditSinkContext = nullptr; _textEditSinkCookie = TF_INVALID_COOKIE; } if (pDocMgr == nullptr) { return TRUE; // caller just wanted to clear the previous sink } if (FAILED(pDocMgr->GetTop(&_pTextEditSinkContext))) { return FALSE; } if (_pTextEditSinkContext == nullptr) { return TRUE; // empty document, no sink possible } ret = FALSE; if (SUCCEEDED(_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource))) { if (SUCCEEDED(pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_textEditSinkCookie))) { ret = TRUE; } else { _textEditSinkCookie = TF_INVALID_COOKIE; } pSource->Release(); } if (ret == FALSE) { _pTextEditSinkContext->Release(); _pTextEditSinkContext = nullptr; } return ret; }
BOOL CTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) { ITfSource *pSource; BOOL fRet; // clear out any previous sink first if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) { if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(_dwTextEditSinkCookie); pSource->Release(); } _pTextEditSinkContext->Release(); _pTextEditSinkContext = NULL; _dwTextEditSinkCookie = TF_INVALID_COOKIE; } if (pDocMgr == NULL) return TRUE; // caller just wanted to clear the previous sink // setup a new sink advised to the topmost context of the document if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) return FALSE; if (_pTextEditSinkContext == NULL) return TRUE; // empty document, no sink possible fRet = FALSE; if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) { fRet = TRUE; } else { _dwTextEditSinkCookie = TF_INVALID_COOKIE; } pSource->Release(); } if (fRet == FALSE) { _pTextEditSinkContext->Release(); _pTextEditSinkContext = NULL; } return fRet; }
BOOL WeaselTSF::_InitThreadMgrEventSink() { ITfSource *pSource; if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **) &pSource) != S_OK) return FALSE; if (pSource->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *) this, &_dwThreadMgrEventSinkCookie) != S_OK) { _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE; pSource->Release(); return FALSE; } pSource->Release(); return TRUE; }
HRESULT CTextEditSink::_Unadvise() { HRESULT hr; ITfSource *source = NULL; hr = E_FAIL; if (_pic == NULL) goto Exit; if (FAILED(_pic->QueryInterface(IID_ITfSource, (void **)&source))) goto Exit; if (FAILED(source->UnadviseSink(_dwEditCookie))) goto Exit; hr = S_OK; Exit: if (source) source->Release(); if (_pic) { _pic->Release(); _pic = NULL; } return hr; }
HRESULT CCompartmentMonitor::Uninitialize(void) { HRESULT hr = S_OK; if(m_pCompartment) { ITfSource *pSource; hr = m_pCompartment->QueryInterface(IID_ITfSource, (void **)&pSource); if(SUCCEEDED(hr)) { hr = pSource->UnadviseSink(m_dwCookie); pSource->Release(); } m_pCompartment->Release(); m_pCompartment = NULL; } m_guidCompartment = GUID_NULL; return hr; }
HRESULT CCompartmentEventSink::_Advise(_In_ IUnknown *punk, _In_ REFGUID guidCompartment) { HRESULT hr = S_OK; ITfCompartmentMgr* pCompartmentMgr = nullptr; ITfSource* pSource = nullptr; hr = punk->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompartmentMgr); if (FAILED(hr)) { return hr; } hr = pCompartmentMgr->GetCompartment(guidCompartment, &_pCompartment); if (SUCCEEDED(hr)) { hr = _pCompartment->QueryInterface(IID_ITfSource, (void **)&pSource); if (SUCCEEDED(hr)) { hr = pSource->AdviseSink(IID_ITfCompartmentEventSink, this, &_dwCookie); pSource->Release(); } } pCompartmentMgr->Release(); return hr; }
void CIME::_UninitThreadFocusSink() { ITfSource* pSource = nullptr; if (FAILED(_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource))) { return; } if (FAILED(pSource->UnadviseSink(_dwThreadFocusSinkCookie))) { pSource->Release(); return; } pSource->Release(); }
void CExtentMonitorTextService::_UninitThreadFocusSink() { ITfSource *pSource; if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(_dwThreadFocusCookie); pSource->Release(); } }
BOOL CIME::_InitThreadFocusSink() { ITfSource* pSource = nullptr; if (FAILED(_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource))) { return FALSE; } if (FAILED(pSource->AdviseSink(IID_ITfThreadFocusSink, (ITfThreadFocusSink *)this, &_dwThreadFocusSinkCookie))) { pSource->Release(); return FALSE; } pSource->Release(); return TRUE; }
void WeaselTSF::_UninitThreadMgrEventSink() { ITfSource *pSource; if (_dwThreadMgrEventSinkCookie == TF_INVALID_COOKIE) return; if (SUCCEEDED(_pThreadMgr->QueryInterface(IID_ITfSource, (void **) &pSource))) { pSource->UnadviseSink(_dwThreadMgrEventSinkCookie); pSource->Release(); } _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE; }
BOOL CExtentMonitorTextService::_InitThreadFocusSink() { ITfSource *pSource; if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->AdviseSink(IID_ITfThreadFocusSink, (ITfThreadFocusSink *)this, &_dwThreadFocusCookie); pSource->Release(); } return TRUE; }
void CCaseTextService::_UninitThreadMgrSink() { ITfSource *pSource; if (_dwThreadMgrEventSinkCookie == TF_INVALID_COOKIE) return; // never Advised if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(_dwThreadMgrEventSinkCookie); pSource->Release(); } _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE; }
void UnadviseSink(IUnknown *pSourceIn, DWORD *pdwCookie) { ITfSource *pSource; if (*pdwCookie == TF_INVALID_COOKIE) return; // never Advised if (pSourceIn->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(*pdwCookie); pSource->Release(); } *pdwCookie = TF_INVALID_COOKIE; }
void COVTSF::_UninitActiveLanguageProfileNotifySink() { ITfSource* pSource = nullptr; if (_activeLanguageProfileNotifySinkCookie == TF_INVALID_COOKIE) { return; // never Advised } if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(_activeLanguageProfileNotifySinkCookie); pSource->Release(); } _activeLanguageProfileNotifySinkCookie = TF_INVALID_COOKIE; }
void CSampleIME::_UninitThreadMgrEventSink() { ITfSource* pSource = nullptr; if (_threadMgrEventSinkCookie == TF_INVALID_COOKIE) { return; } if (SUCCEEDED(_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource))) { pSource->UnadviseSink(_threadMgrEventSinkCookie); pSource->Release(); } _threadMgrEventSinkCookie = TF_INVALID_COOKIE; }
HRESULT CCompartmentEventSink::_Unadvise() { HRESULT hr = S_OK; ITfSource* pSource = nullptr; hr = _pCompartment->QueryInterface(IID_ITfSource, (void **)&pSource); if (SUCCEEDED(hr)) { hr = pSource->UnadviseSink(_dwCookie); pSource->Release(); } _pCompartment->Release(); _pCompartment = nullptr; _dwCookie = 0; return hr; }
HRESULT CCandidateList::_AdviseContextKeyEventSink(){ HRESULT hr; ITfSource *pSource = NULL; hr = E_FAIL; if (FAILED(_pContextCandidateWindow->QueryInterface(IID_ITfSource, (void **)&pSource))) goto Exit; if (FAILED(pSource->AdviseSink(IID_ITfContextKeyEventSink, (ITfContextKeyEventSink *)this, &_dwCookieContextKeyEventSink))) goto Exit; hr = S_OK; Exit: if (pSource != NULL) pSource->Release(); return hr; }
BOOL AdviseSink(IUnknown *pSourceIn, IUnknown *pSink, REFIID riid, DWORD *pdwCookie) { ITfSource *pSource; HRESULT hr; if (pSourceIn->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK) return FALSE; hr = pSource->AdviseSink(riid, pSink, pdwCookie); pSource->Release(); if (hr != S_OK) { // make sure we don't try to Unadvise pdwCookie later *pdwCookie = TF_INVALID_COOKIE; return FALSE; } return TRUE; }
BOOL COVTSF::_InitActiveLanguageProfileNotifySink() { ITfSource* pSource = nullptr; BOOL ret = FALSE; if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK) { return ret; } if (pSource->AdviseSink(IID_ITfActiveLanguageProfileNotifySink, (ITfActiveLanguageProfileNotifySink *)this, &_activeLanguageProfileNotifySinkCookie) != S_OK) { _activeLanguageProfileNotifySinkCookie = TF_INVALID_COOKIE; goto Exit; } ret = TRUE; Exit: pSource->Release(); return ret; }
BOOL CSampleIME::_InitThreadMgrEventSink() { ITfSource* pSource = nullptr; BOOL ret = FALSE; if (FAILED(_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource))) { return ret; } if (FAILED(pSource->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *)this, &_threadMgrEventSinkCookie))) { _threadMgrEventSinkCookie = TF_INVALID_COOKIE; goto Exit; } ret = TRUE; Exit: pSource->Release(); return ret; }
BOOL CCaseTextService::_InitThreadMgrSink() { ITfSource *pSource; BOOL fRet; if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) != S_OK) return FALSE; fRet = FALSE; if (pSource->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *)this, &_dwThreadMgrEventSinkCookie) != S_OK) { // make sure we don't try to Unadvise _dwThreadMgrEventSinkCookie later _dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE; goto Exit; } fRet = TRUE; Exit: pSource->Release(); return fRet; }
HRESULT CCandidateList::_UnadviseTextLayoutSink() { HRESULT hr; ITfSource *pSource = NULL; hr = E_FAIL; if (_pContextDocument == NULL) goto Exit; if (FAILED(_pContextDocument->QueryInterface(IID_ITfSource, (void **)&pSource))) goto Exit; if (FAILED(pSource->UnadviseSink(_dwCookieTextLayoutSink))) goto Exit; hr = S_OK; Exit: if (pSource != NULL) pSource->Release(); return hr; }
HRESULT CTextEditSink::_Advise(ITfContext *pic) { HRESULT hr; ITfSource *source = NULL; _pic = NULL; hr = E_FAIL; if (FAILED(pic->QueryInterface(IID_ITfSource, (void **)&source))) goto Exit; if (FAILED(source->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwEditCookie))) goto Exit; _pic = pic; _pic->AddRef(); hr = S_OK; Exit: if (source) source->Release(); return hr; }