HRESULT COVTSF::_HandleCompositionFinalize(TfEditCookie ec, _In_ ITfContext *pContext, BOOL isCandidateList) { HRESULT hr = S_OK; if (isCandidateList && _pCandidateListUIPresenter) { // Finalize selected candidate string from CCandidateListUIPresenter DWORD_PTR candidateLen = 0; const WCHAR *pCandidateString = nullptr; candidateLen = _pCandidateListUIPresenter->_GetSelectedCandidateString(&pCandidateString); CStringRange candidateString; candidateString.Set(pCandidateString, candidateLen); if (candidateLen) { // Finalize character hr = _AddCharAndFinalize(ec, pContext, &candidateString); if (FAILED(hr)) { return hr; } } } else { // Finalize current text store strings if (_IsComposing()) { ULONG fetched = 0; TF_SELECTION tfSelection; if (FAILED(pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &fetched)) || fetched != 1) { return S_FALSE; } ITfRange* pRangeComposition = nullptr; if (SUCCEEDED(_pComposition->GetRange(&pRangeComposition))) { if (_IsRangeCovered(ec, tfSelection.range, pRangeComposition)) { _EndComposition(pContext); } pRangeComposition->Release(); } tfSelection.range->Release(); } } _HandleCancel(ec, pContext); return S_OK; }
HRESULT COVTSF::_HandleCompositionDoubleSingleByte(TfEditCookie ec, _In_ ITfContext *pContext, WCHAR wch) { HRESULT hr = S_OK; WCHAR fullWidth = Global::FullWidthCharTable[wch - 0x20]; CStringRange fullWidthString; fullWidthString.Set(&fullWidth, 1); // Finalize character hr = _AddCharAndFinalize(ec, pContext, &fullWidthString); if (FAILED(hr)) { return hr; } _HandleCancel(ec, pContext); return S_OK; }
HRESULT COVTSF::_HandleCompositionPunctuation(TfEditCookie ec, _In_ ITfContext *pContext, WCHAR wch) { HRESULT hr = S_OK; if (_candidateMode != CANDIDATE_NONE && _pCandidateListUIPresenter) { DWORD_PTR candidateLen = 0; const WCHAR* pCandidateString = nullptr; candidateLen = _pCandidateListUIPresenter->_GetSelectedCandidateString(&pCandidateString); CStringRange candidateString; candidateString.Set(pCandidateString, candidateLen); if (candidateLen) { _AddComposingAndChar(ec, pContext, &candidateString); } } // // Get punctuation char from composition processor engine // CCompositionProcessorEngine* pCompositionProcessorEngine = nullptr; pCompositionProcessorEngine = _pCompositionProcessorEngine; WCHAR punctuation = pCompositionProcessorEngine->GetPunctuation(wch); CStringRange punctuationString; punctuationString.Set(&punctuation, 1); // Finalize character hr = _AddCharAndFinalize(ec, pContext, &punctuationString); if (FAILED(hr)) { return hr; } _HandleCancel(ec, pContext); return S_OK; }
HRESULT CSampleIME::_HandlePhraseFinalize(TfEditCookie ec, _In_ ITfContext *pContext) { HRESULT hr = S_OK; DWORD phraseLen = 0; const WCHAR* pPhraseString = nullptr; phraseLen = (DWORD)_pCandidateListUIPresenter->_GetSelectedCandidateString(&pPhraseString); CStringRange phraseString; phraseString.Set(pPhraseString, phraseLen); if (phraseLen) { if ((hr = _AddCharAndFinalize(ec, pContext, &phraseString)) != S_OK) { return hr; } } _HandleComplete(ec, pContext); return S_OK; }