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.

111 lines
3.9 KiB

  1. //
  2. // cleanup.cpp
  3. //
  4. // ITfCleanupContextDurationSink, ITfCleanupContextSink implementation.
  5. //
  6. #include "globals.h"
  7. #include "mark.h"
  8. //+---------------------------------------------------------------------------
  9. //
  10. // ITfCleanupContextDurationSink::OnStartCleanupContext
  11. //
  12. // TSF calls this method before it starts making OnCleanupContext callbacks.
  13. // When this happens, we know we're just about to be shut down, and this will
  14. // be our last chance to modify text in the document. So we'll set a flag so
  15. // we know not to initialize any contexts that might get created during the
  16. // shutdown.
  17. //----------------------------------------------------------------------------
  18. STDAPI CMarkTextService::OnStartCleanupContext()
  19. {
  20. _fCleaningUp = TRUE;
  21. return S_OK;
  22. }
  23. //+---------------------------------------------------------------------------
  24. //
  25. // ITfCleanupContextDurationSink::OnEndCleanupContext
  26. //
  27. // Clear the cleanup flag.
  28. //----------------------------------------------------------------------------
  29. STDAPI CMarkTextService::OnEndCleanupContext()
  30. {
  31. _fCleaningUp = FALSE;
  32. return S_OK;
  33. }
  34. //+---------------------------------------------------------------------------
  35. //
  36. // ITfCleanupContextSink::OnCleanupContext
  37. //
  38. // The system calls this method if we're about to be deactivated. It's our
  39. // last chance to modify text in the context. This is the time to abort any
  40. // ongoing compositions.
  41. //
  42. // You won't see this callback shutting down the app if the app destroys all
  43. // contexts before deactivating TSF. Another way to get here is by installing
  44. // a non-english keyboard layout or text service. If you switch languages
  45. // from english, the mark text service will be shut down before the context,
  46. // and this method will be called.
  47. //
  48. // There's intentionally no way to get an edit cookie when a context is popped.
  49. // In this case, it is assumed the context state is going to be thrown away.
  50. // It's the owner's responsibility to terminate any compositions/text services
  51. // before a Pop if they care about the contents afterwards.
  52. //----------------------------------------------------------------------------
  53. STDAPI CMarkTextService::OnCleanupContext(TfEditCookie ecWrite, ITfContext *pContext)
  54. {
  55. // this sample has nothing to do here...a real text service wouldn't bother
  56. // to advise the sink in the first place if it took no action
  57. return S_OK;
  58. }
  59. //+---------------------------------------------------------------------------
  60. //
  61. // _InitCleanupContextSink
  62. //
  63. //----------------------------------------------------------------------------
  64. BOOL CMarkTextService::_InitCleanupContextDurationSink()
  65. {
  66. return AdviseSingleSink(_tfClientId, _pThreadMgr, (ITfCleanupContextDurationSink *)this,
  67. IID_ITfCleanupContextDurationSink);
  68. }
  69. //+---------------------------------------------------------------------------
  70. //
  71. // _UninitCleanupContextSink
  72. //
  73. //----------------------------------------------------------------------------
  74. void CMarkTextService::_UninitCleanupContextDurationSink()
  75. {
  76. UnadviseSingleSink(_tfClientId, _pThreadMgr, IID_ITfCleanupContextDurationSink);
  77. }
  78. //+---------------------------------------------------------------------------
  79. //
  80. // _InitCleanupContextSink
  81. //
  82. //----------------------------------------------------------------------------
  83. BOOL CMarkTextService::_InitCleanupContextSink(ITfContext *pContext)
  84. {
  85. return AdviseSingleSink(_tfClientId, pContext, (ITfCleanupContextSink *)this,
  86. IID_ITfCleanupContextSink);
  87. }
  88. //+---------------------------------------------------------------------------
  89. //
  90. // _UninitCleanupContextSink
  91. //
  92. //----------------------------------------------------------------------------
  93. void CMarkTextService::_UninitCleanupContextSink(ITfContext *pContext)
  94. {
  95. UnadviseSingleSink(_tfClientId, pContext, IID_ITfCleanupContextSink);
  96. }