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.

157 lines
3.5 KiB

  1. //
  2. // pkes.cpp
  3. //
  4. #include "private.h"
  5. #include "reconvcb.h"
  6. #include "a_context.h"
  7. #include "helpers.h"
  8. //////////////////////////////////////////////////////////////////////////////
  9. //
  10. // CStartReconversionNotifySink
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13. //+---------------------------------------------------------------------------
  14. //
  15. // IUnknown
  16. //
  17. //----------------------------------------------------------------------------
  18. STDAPI CStartReconversionNotifySink::QueryInterface(REFIID riid, void **ppvObj)
  19. {
  20. *ppvObj = NULL;
  21. if (IsEqualIID(riid, IID_IUnknown) ||
  22. IsEqualIID(riid, IID_ITfStartReconversionNotifySink))
  23. {
  24. *ppvObj = SAFECAST(this, CStartReconversionNotifySink *);
  25. }
  26. if (*ppvObj)
  27. {
  28. AddRef();
  29. return S_OK;
  30. }
  31. return E_NOINTERFACE;
  32. }
  33. STDAPI_(ULONG) CStartReconversionNotifySink::AddRef()
  34. {
  35. return ++_cRef;
  36. }
  37. STDAPI_(ULONG) CStartReconversionNotifySink::Release()
  38. {
  39. long cr;
  40. cr = --_cRef;
  41. Assert(cr >= 0);
  42. if (cr == 0)
  43. {
  44. delete this;
  45. }
  46. return cr;
  47. }
  48. //+---------------------------------------------------------------------------
  49. //
  50. // ctor
  51. //
  52. //----------------------------------------------------------------------------
  53. CStartReconversionNotifySink::CStartReconversionNotifySink(CAImeContext *pAImeContext)
  54. {
  55. Dbg_MemSetThisName(TEXT("CStartReconversionNotifySink"));
  56. _cRef = 1;
  57. _pAImeContext = pAImeContext;
  58. }
  59. //+---------------------------------------------------------------------------
  60. //
  61. // CStartReconversionNotifySink::Advise
  62. //
  63. //----------------------------------------------------------------------------
  64. HRESULT CStartReconversionNotifySink::_Advise(ITfContext *pic)
  65. {
  66. HRESULT hr;
  67. ITfSource *source = NULL;
  68. _pic = NULL;
  69. hr = E_FAIL;
  70. if (FAILED(pic->QueryInterface(IID_ITfSource, (void **)&source)))
  71. goto Exit;
  72. if (FAILED(source->AdviseSink(IID_ITfStartReconversionNotifySink, this, &_dwCookie)))
  73. goto Exit;
  74. _pic = pic;
  75. _pic->AddRef();
  76. hr = S_OK;
  77. Exit:
  78. SafeRelease(source);
  79. return hr;
  80. }
  81. //+---------------------------------------------------------------------------
  82. //
  83. // CStartReconversionNotifySink::Unadvise
  84. //
  85. //----------------------------------------------------------------------------
  86. HRESULT CStartReconversionNotifySink::_Unadvise()
  87. {
  88. HRESULT hr;
  89. ITfSource *source = NULL;
  90. hr = E_FAIL;
  91. if (_pic == NULL)
  92. goto Exit;
  93. if (FAILED(_pic->QueryInterface(IID_ITfSource, (void **)&source)))
  94. goto Exit;
  95. if (FAILED(source->UnadviseSink(_dwCookie)))
  96. goto Exit;
  97. hr = S_OK;
  98. Exit:
  99. SafeRelease(source);
  100. SafeReleaseClear(_pic);
  101. return hr;
  102. }
  103. //+---------------------------------------------------------------------------
  104. //
  105. // StartReconversionNotifySink::StartReconversion
  106. //
  107. //----------------------------------------------------------------------------
  108. STDAPI CStartReconversionNotifySink::StartReconversion()
  109. {
  110. _pAImeContext->SetupReconvertString();
  111. return S_OK;
  112. }
  113. //+---------------------------------------------------------------------------
  114. //
  115. // StartReconversionNotifySink::EndReconversion
  116. //
  117. //----------------------------------------------------------------------------
  118. STDAPI CStartReconversionNotifySink::EndReconversion()
  119. {
  120. _pAImeContext->EndReconvertString();
  121. return S_OK;
  122. }