Leaked source code of windows server 2003
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//
// editsink.cpp
//
// ITfTextEditSink implementation.
//
#include "globals.h"
#include "case.h"
#include "snoop.h"
//+---------------------------------------------------------------------------
//
// OnEndEdit
//
// Called by the system whenever anyone releases a write-access document lock.
//----------------------------------------------------------------------------
STDAPI CCaseTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) { BOOL fSelectionChanged; IEnumTfRanges *pEnumTextChanges; ITfRange *pRange;
// we'll use the endedit notification to update the snoop window
// did the selection change?
if (pEditRecord->GetSelectionStatus(&fSelectionChanged) == S_OK && fSelectionChanged) { _pSnoopWnd->_UpdateText(ecReadOnly, pContext, NULL); return S_OK; }
// text modification?
if (pEditRecord->GetTextAndPropertyUpdates(TF_GTP_INCL_TEXT, NULL, 0, &pEnumTextChanges) == S_OK) { if (pEnumTextChanges->Next(1, &pRange, NULL) == S_OK) { // arbitrary update the snoop window with the first change
// there may be more than one in the enumerator, but we don't care here
_pSnoopWnd->_UpdateText(ecReadOnly, pContext, pRange); pRange->Release(); }
pEnumTextChanges->Release(); }
// if we get here, only property values changed
return S_OK; }
//+---------------------------------------------------------------------------
//
// _InitTextEditSink
//
// Init a text edit sink on the topmost context of the document.
// Always release any previous sink.
//----------------------------------------------------------------------------
BOOL CCaseTextService::_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; }
|