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.

74 lines
1.3 KiB

  1. //
  2. // editsess.h
  3. //
  4. // CEditSessionBase declaration.
  5. //
  6. #ifndef EDITSESS_H
  7. #define EDITSESS_H
  8. class CEditSessionBase : public ITfEditSession
  9. {
  10. public:
  11. CEditSessionBase(ITfContext *pContext)
  12. {
  13. _cRef = 1;
  14. _pContext = pContext;
  15. _pContext->AddRef();
  16. }
  17. virtual ~CEditSessionBase()
  18. {
  19. _pContext->Release();
  20. }
  21. // IUnknown
  22. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj)
  23. {
  24. if (ppvObj == NULL)
  25. return E_INVALIDARG;
  26. *ppvObj = NULL;
  27. if (IsEqualIID(riid, IID_IUnknown) ||
  28. IsEqualIID(riid, IID_ITfEditSession))
  29. {
  30. *ppvObj = (ITfLangBarItemButton *)this;
  31. }
  32. if (*ppvObj)
  33. {
  34. AddRef();
  35. return S_OK;
  36. }
  37. return E_NOINTERFACE;
  38. }
  39. STDMETHODIMP_(ULONG) AddRef(void)
  40. {
  41. return ++_cRef;
  42. }
  43. STDMETHODIMP_(ULONG) Release(void)
  44. {
  45. LONG cr = --_cRef;
  46. assert(_cRef >= 0);
  47. if (_cRef == 0)
  48. {
  49. delete this;
  50. }
  51. return cr;
  52. }
  53. // ITfEditSession
  54. virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0;
  55. protected:
  56. ITfContext *_pContext;
  57. private:
  58. LONG _cRef; // COM ref count
  59. };
  60. #endif // EDITSESS_H