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.

196 lines
5.6 KiB

  1. /*
  2. * DATAOBJ.H
  3. * Data Object Chapter 6
  4. *
  5. * Classes that implement the Data Object independent of whether
  6. * we live in a DLL or EXE.
  7. *
  8. * Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved
  9. *
  10. * Kraig Brockschmidt, Software Design Engineer
  11. * Microsoft Systems Developer Relations
  12. *
  13. * Internet : kraigb@microsoft.com
  14. * Compuserve: >INTERNET:kraigb@microsoft.com
  15. */
  16. #ifndef _DATAOBJ_H_
  17. #define _DATAOBJ_H_
  18. #define INC_OLE2
  19. #include <windows.h>
  20. #include <ole2.h>
  21. #include "../my3216.h"
  22. #include "../bookpart.h"
  23. //Type for an object-destroyed callback
  24. typedef void (PASCAL *PFNDESTROYED)(void);
  25. /*
  26. * The DataObject object is implemented in its own class with its
  27. * own IUnknown to support aggregation. It contains one
  28. * CImpIDataObject object that we use to implement the externally
  29. * exposed interfaces.
  30. */
  31. //DATAOBJ.CPP
  32. #ifdef NOT_SIMPLE
  33. LRESULT APIENTRY
  34. AdvisorWndProc(HWND, UINT, WPARAM, LPARAM);
  35. #endif /* NOT_SIMPLE */
  36. class CImpIDataObject;
  37. typedef class CImpIDataObject *PIMPIDATAOBJECT;
  38. class CDataObject : public IUnknown
  39. {
  40. friend class CImpIDataObject;
  41. #ifdef NOT_SIMPLE
  42. friend LRESULT APIENTRY AdvisorWndProc(HWND, UINT
  43. , WPARAM, LPARAM);
  44. #endif /* NOT_SIMPLE */
  45. protected:
  46. ULONG m_cRef;
  47. LPUNKNOWN m_pUnkOuter;
  48. PFNDESTROYED m_pfnDestroy;
  49. HWND m_hWndAdvise; //Popup with Advise menu
  50. DWORD m_dwAdvFlags; //Notification flags
  51. //Contained interface implemetation
  52. PIMPIDATAOBJECT m_pIDataObject;
  53. //Other interfaces used, implemented elsewhere
  54. LPDATAADVISEHOLDER m_pIDataAdviseHolder;
  55. //Arrays for IDataObject::EnumFormatEtc
  56. #define CFORMATETCGET 1
  57. ULONG m_cfeGet;
  58. FORMATETC m_rgfeGet[CFORMATETCGET];
  59. LPSTR m_dataText;
  60. ULONG m_cDataSize;
  61. protected:
  62. //Functions for use from IDataObject::GetData
  63. #define FL_MAKE_ITEM 0x01 // StgMedium item must be created.
  64. #define FL_USE_ITEM 0x00 // StgMedium item is allocated, use that.
  65. #define FL_PASS_PUNK 0x02 // put a pUnk in the StgMedium.
  66. HRESULT RenderText(LPSTGMEDIUM, LPTSTR, DWORD flags);
  67. HRESULT RenderBitmap(LPSTGMEDIUM);
  68. HRESULT RenderMetafilePict(LPSTGMEDIUM);
  69. public:
  70. CDataObject(LPUNKNOWN, PFNDESTROYED);
  71. ~CDataObject(void);
  72. BOOL FInit(void);
  73. //Non-delegating object IUnknown
  74. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  75. STDMETHODIMP_(ULONG) AddRef(void);
  76. STDMETHODIMP_(ULONG) Release(void);
  77. };
  78. typedef CDataObject *PCDataObject;
  79. /*
  80. * Interface implementations for the CDataObject object.
  81. */
  82. class CImpIDataObject : public IDataObject
  83. {
  84. private:
  85. ULONG m_cRef;
  86. PCDataObject m_pObj;
  87. LPUNKNOWN m_pUnkOuter;
  88. public:
  89. CImpIDataObject(PCDataObject, LPUNKNOWN);
  90. ~CImpIDataObject(void);
  91. //IUnknown members that delegate to m_pUnkOuter.
  92. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  93. STDMETHODIMP_(ULONG) AddRef(void);
  94. STDMETHODIMP_(ULONG) Release(void);
  95. //IDataObject members
  96. STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
  97. STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
  98. STDMETHODIMP QueryGetData(LPFORMATETC);
  99. STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC,LPFORMATETC);
  100. STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
  101. STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
  102. STDMETHODIMP DAdvise(LPFORMATETC, DWORD, LPADVISESINK
  103. , DWORD *);
  104. STDMETHODIMP DUnadvise(DWORD);
  105. STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *);
  106. };
  107. /*
  108. * IEnumFORMATETC object that is created from
  109. * IDataObject::EnumFormatEtc. This object lives on its own.
  110. */
  111. class CEnumFormatEtc : public IEnumFORMATETC
  112. {
  113. private:
  114. ULONG m_cRef; //Object reference count
  115. LPUNKNOWN m_pUnkRef; //For reference counting
  116. ULONG m_iCur; //Current element.
  117. ULONG m_cfe; //Number of FORMATETCs in us
  118. LPFORMATETC m_prgfe; //Source of FORMATETCs
  119. public:
  120. CEnumFormatEtc(LPUNKNOWN, ULONG, LPFORMATETC);
  121. ~CEnumFormatEtc(void);
  122. //IUnknown members that delegate to m_pUnkRef.
  123. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  124. STDMETHODIMP_(ULONG) AddRef(void);
  125. STDMETHODIMP_(ULONG) Release(void);
  126. //IEnumFORMATETC members
  127. STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG *);
  128. STDMETHODIMP Skip(ULONG);
  129. STDMETHODIMP Reset(void);
  130. STDMETHODIMP Clone(IEnumFORMATETC **);
  131. };
  132. typedef CEnumFormatEtc *PCEnumFormatEtc;
  133. //////////////////////////////////////////////////////////////////////////////
  134. // Storage Medium IUnknown interface for pUnkForRelease.
  135. //
  136. class CStgMedIf: public IUnknown {
  137. private:
  138. ULONG m_cRef;
  139. LPSTGMEDIUM m_pSTM;
  140. public:
  141. CStgMedIf(LPSTGMEDIUM);
  142. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  143. STDMETHODIMP_(ULONG) AddRef(void);
  144. STDMETHODIMP_(ULONG) Release(void);
  145. };
  146. //////////////////////////
  147. // API for getting a pUnkForRelease.
  148. //
  149. HRESULT
  150. GetStgMedpUnkForRelease(LPSTGMEDIUM pSTM, IUnknown **pp_unk);
  151. #endif //_DATAOBJ_H_
  152.