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.

76 lines
1.4 KiB

  1. //
  2. // editcb.cpp
  3. //
  4. // CEditSession
  5. //
  6. #include "private.h"
  7. #include "editcb.h"
  8. //+---------------------------------------------------------------------------
  9. //
  10. // ctor
  11. //
  12. //----------------------------------------------------------------------------
  13. CEditSession::CEditSession(ESCALLBACK pfnCallback)
  14. {
  15. _pfnCallback = pfnCallback;
  16. _cRef = 1;
  17. }
  18. //+---------------------------------------------------------------------------
  19. //
  20. // IUnknown
  21. //
  22. //----------------------------------------------------------------------------
  23. STDAPI CEditSession::QueryInterface(REFIID riid, void **ppvObj)
  24. {
  25. *ppvObj = NULL;
  26. if (IsEqualIID(riid, IID_IUnknown) ||
  27. IsEqualIID(riid, IID_ITfEditSession))
  28. {
  29. *ppvObj = SAFECAST(this, CEditSession *);
  30. }
  31. if (*ppvObj)
  32. {
  33. AddRef();
  34. return S_OK;
  35. }
  36. return E_NOINTERFACE;
  37. }
  38. STDAPI_(ULONG) CEditSession::AddRef()
  39. {
  40. return ++_cRef;
  41. }
  42. STDAPI_(ULONG) CEditSession::Release()
  43. {
  44. long cr;
  45. cr = --_cRef;
  46. Assert(cr >= 0);
  47. if (cr == 0)
  48. {
  49. delete this;
  50. }
  51. return cr;
  52. }
  53. //+---------------------------------------------------------------------------
  54. //
  55. // DoEditSession
  56. //
  57. //----------------------------------------------------------------------------
  58. STDAPI CEditSession::DoEditSession(TfEditCookie ec)
  59. {
  60. return _pfnCallback(ec, this);
  61. }