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.

309 lines
9.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: clipdata.h
  7. //
  8. // Contents: Declaration of the clipboard data object.
  9. //
  10. // Classes: CClipDataObject
  11. //
  12. // Functions:
  13. //
  14. // History: dd-mmm-yy Author Comment
  15. // 01-Feb-95 t-ScottH added Dump methods to CClipDataObject
  16. // and CClipEnumFormatEtc
  17. // 31-Mar-94 alexgo author
  18. //
  19. //--------------------------------------------------------------------------
  20. #ifdef _DEBUG
  21. #include <dbgexts.h>
  22. #endif // _DEBUG
  23. #ifndef _CLIPDATA_H
  24. #define _CLIPDATA_H
  25. typedef enum
  26. {
  27. RESET_AND_FREE = 1,
  28. JUST_RESET = 2
  29. } FreeResourcesFlags;
  30. typedef enum
  31. {
  32. FORMAT_NOTFOUND = 1,
  33. FORMAT_BADMATCH = 2,
  34. FORMAT_GOODMATCH = 4
  35. } FormatMatchFlag;
  36. // format for an array for FormatEtcs in memory.
  37. struct FORMATETCDATA
  38. {
  39. FORMATETC _FormatEtc;
  40. BOOL fSaveOnFlush; // set to true in Clipboard case if format is valid after OleFlushClipboard.
  41. DWORD dwReserved1;
  42. DWORD dwReserved2;
  43. };
  44. #define FETC_OFFER_OLE1 1
  45. #define FETC_OFFER_OBJLINK 2
  46. #define FETC_PERSIST_DATAOBJ_ON_FLUSH 4
  47. struct FORMATETCDATAARRAY
  48. {
  49. DWORD _dwSig; // must be zero.
  50. DWORD _dwSize; // total size of structure.
  51. ULONG _cRefs; // Number of references held on Data.
  52. DWORD _cFormats; // number of formats in the enumerator.
  53. DWORD _dwMiscArrayFlags;
  54. BOOL _fIs64BitArray;
  55. FORMATETCDATA _FormatEtcData[1];
  56. };
  57. //
  58. // Methods and types used for 32/64 bit FORMATETC interop
  59. //
  60. #ifdef _WIN64
  61. #define IS_WIN64 TRUE
  62. #else
  63. #define IS_WIN64 FALSE
  64. #endif
  65. void GetCopiedFormatEtcDataArraySize (
  66. FORMATETCDATAARRAY* pClipFormatEtcDataArray,
  67. size_t* pstSize
  68. );
  69. void CopyFormatEtcDataArray (
  70. FORMATETCDATAARRAY* pClipFormatEtcDataArray,
  71. FORMATETCDATAARRAY* pFormatEtcDataArray,
  72. size_t stSize,
  73. BOOL bCheckAvailable
  74. );
  75. typedef struct FARSTRUCT tagFORMATETC32
  76. {
  77. CLIPFORMAT cfFormat;
  78. ULONG ptd;
  79. DWORD dwAspect;
  80. LONG lindex;
  81. DWORD tymed;
  82. } FORMATETC32, FAR* LPFORMATETC32;
  83. typedef struct FARSTRUCT tagFORMATETC64
  84. {
  85. CLIPFORMAT cfFormat;
  86. ULONG64 ptd;
  87. DWORD dwAspect;
  88. LONG lindex;
  89. DWORD tymed;
  90. } FORMATETC64, FAR* LPFORMATETC64;
  91. struct FORMATETCDATA32
  92. {
  93. FORMATETC32 _FormatEtc;
  94. BOOL fSaveOnFlush; // set to true in Clipboard case if format is valid after OleFlushClipboard.
  95. DWORD dwReserved1;
  96. DWORD dwReserved2;
  97. };
  98. struct FORMATETCDATA64
  99. {
  100. FORMATETC64 _FormatEtc;
  101. BOOL fSaveOnFlush; // set to true in Clipboard case if format is valid after OleFlushClipboard.
  102. DWORD dwReserved1;
  103. DWORD dwReserved2;
  104. };
  105. struct FORMATETCDATAARRAY32
  106. {
  107. DWORD _dwSig; // must be zero.
  108. DWORD _dwSize; // total size of structure.
  109. ULONG _cRefs; // Number of references held on Data.
  110. DWORD _cFormats; // number of formats in the enumerator.
  111. DWORD _dwMiscArrayFlags;
  112. BOOL _fIs64BitArray;
  113. FORMATETCDATA32 _FormatEtcData[1];
  114. };
  115. struct FORMATETCDATAARRAY64
  116. {
  117. DWORD _dwSig; // must be zero.
  118. DWORD _dwSize; // total size of structure.
  119. ULONG _cRefs; // Number of references held on Data.
  120. DWORD _cFormats; // number of formats in the enumerator.
  121. DWORD _dwMiscArrayFlags;
  122. BOOL _fIs64BitArray;
  123. FORMATETCDATA64 _FormatEtcData[1];
  124. };
  125. //+-------------------------------------------------------------------------
  126. //
  127. // Class: CClipDataObject
  128. //
  129. // Purpose: clipboard data object
  130. //
  131. // Interface: IDataObject
  132. //
  133. // History: dd-mmm-yy Author Comment
  134. // 01-Feb-95 t-ScottH added Dump method (_DEBUG only)
  135. // 04-Jun-94 alexgo added OLE1 support
  136. // 31-Mar-94 alexgo author
  137. //
  138. // Notes: See clipdata.cpp for a description of OLE1 support
  139. //
  140. //--------------------------------------------------------------------------
  141. class CClipDataObject : public IDataObject, public CPrivAlloc,
  142. public CThreadCheck
  143. {
  144. friend void ClipboardUninitialize(void);
  145. friend void SetClipDataObjectInTLS(IDataObject *pDataObj,
  146. DWORD dwClipSeqNum, BOOL fIsClipWrapper);
  147. friend void GetClipDataObjectFromTLS(IDataObject **ppDataObj);
  148. // HACK ALERT!!!
  149. // MFC was being slimy, so we have to special case testing against clipboard data
  150. // objects in OleQueryCreateFromData. See create.cpp,
  151. // wQueryEmbedFormats for more details.
  152. friend WORD wQueryEmbedFormats( LPDATAOBJECT lpSrcDataObj,CLIPFORMAT FAR* lpcfFormat);
  153. public:
  154. // IUnknown methods
  155. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  156. STDMETHOD_(ULONG,AddRef) (void);
  157. STDMETHOD_(ULONG,Release) (void);
  158. // IDataObject methods
  159. STDMETHOD(GetData) (LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
  160. STDMETHOD(GetDataHere) (LPFORMATETC pformatetc,
  161. LPSTGMEDIUM pmedium);
  162. STDMETHOD(QueryGetData) (LPFORMATETC pformatetc);
  163. STDMETHOD(GetCanonicalFormatEtc) (LPFORMATETC pformatetc,
  164. LPFORMATETC pformatetcOut);
  165. STDMETHOD(SetData) (LPFORMATETC pformatetc,
  166. STGMEDIUM FAR* pmedium, BOOL fRelease);
  167. STDMETHOD(EnumFormatEtc) (DWORD dwDirection,
  168. LPENUMFORMATETC FAR* ppenumFormatEtc);
  169. STDMETHOD(DAdvise) (FORMATETC FAR* pFormatetc, DWORD advf,
  170. IAdviseSink FAR* pAdvSink, DWORD FAR* pdwConnection);
  171. STDMETHOD(DUnadvise) (DWORD dwConnection);
  172. STDMETHOD(EnumDAdvise) (LPENUMSTATDATA FAR* ppenumAdvise);
  173. static HRESULT CClipDataObject::Create(IDataObject **ppDataObj,
  174. FORMATETCDATAARRAY *pClipFormatEtcDataArray);
  175. #ifdef _DEBUG
  176. HRESULT Dump(char **ppszDump, ULONG ulFlag, int nIndentLevel);
  177. // need to be able to access CClipDataObject private data members in the
  178. // following debugger extension APIs
  179. // this allows the debugger extension APIs to copy memory from the
  180. // debuggee process memory to the debugger's process memory
  181. // this is required since the Dump method follows pointers to other
  182. // structures and classes
  183. friend DEBUG_EXTENSION_API(dump_clipdataobject);
  184. #endif // _DEBUG
  185. private:
  186. CClipDataObject(); // constructor
  187. ~CClipDataObject(); // destructor
  188. ULONG InternalAddRef(); // ensure object stays around as long as OLE thinks it should.
  189. ULONG InternalRelease();
  190. IDataObject * GetRealDataObjPtr(); // Get real data object for clipboard
  191. HRESULT GetFormatEtcDataArray(); //checks is have a FormatEtcDataArray, if not creates one from the Native Clipboard.
  192. FormatMatchFlag MatchFormatetc( FORMATETC *pformatetc,BOOL fNativeOnly, TYMED *ptymed );
  193. // checks the given formatetc against
  194. // the formatetc we know about.
  195. // the following methods and data items are used for OLE1
  196. // support
  197. void FreeResources( FreeResourcesFlags fFlags );
  198. HRESULT GetAndTranslateOle1( UINT cf, LPOLESTR *ppszClass,
  199. LPOLESTR *ppszFile, LPOLESTR *ppszItem,
  200. LPSTR *ppszItemA );
  201. HRESULT GetEmbeddedObjectFromOle1( STGMEDIUM *pmedium );
  202. HRESULT GetEmbedSourceFromOle1( STGMEDIUM *pmedium );
  203. HRESULT GetLinkSourceFromOle1( STGMEDIUM *pmedium );
  204. HRESULT GetObjectDescriptorFromOle1( UINT cf,
  205. STGMEDIUM *pmedium );
  206. HRESULT GetOle2FromOle1( UINT cf, STGMEDIUM *pmedium );
  207. HRESULT OleGetClipboardData( UINT cf, HANDLE *pHandle );
  208. BOOL OleIsClipboardFormatAvailable( UINT cf );
  209. HGLOBAL m_hOle1; // hGlobal to OLE2 data constructed
  210. // from OLE1 data
  211. IUnknown * m_pUnkOle1; // IUnknown to either a storage or
  212. // a stream of OLE1 data
  213. // end of OLE1 support
  214. ULONG m_refs; // reference count
  215. ULONG m_Internalrefs; // Internal Reference Count
  216. FORMATETCDATAARRAY *m_pFormatEtcDataArray; // Enumerator Data.
  217. IDataObject * m_pDataObject; // Actual data object for data.
  218. BOOL m_fTriedToGetDataObject;
  219. // indicates whether or not we've
  220. // tried to get the real IDataObject
  221. // from the clipboard source
  222. // (see GetDataObjectForClip)
  223. };
  224. //+-------------------------------------------------------------------------
  225. //
  226. // Class: CEnumFormatEtcDataArray
  227. //
  228. // Purpose: Enumerator for the formats available on the clipboard
  229. // and in DragDrop.
  230. //
  231. // Interface: IEnumFORMATETC
  232. //
  233. // History: dd-mmm-yy Author Comment
  234. // 30-Sep-96 rogerg created base on CClipEnumFormatEtc
  235. //
  236. // Notes:
  237. //
  238. //--------------------------------------------------------------------------
  239. class CEnumFormatEtcDataArray :public IEnumFORMATETC, public CPrivAlloc,
  240. public CThreadCheck
  241. {
  242. public:
  243. STDMETHOD(QueryInterface)(REFIID riid, LPLPVOID ppvObj);
  244. STDMETHOD_(ULONG,AddRef)(void);
  245. STDMETHOD_(ULONG,Release)(void);
  246. STDMETHOD(Next) (ULONG celt, FORMATETC *rgelt,
  247. ULONG *pceltFetched);
  248. STDMETHOD(Skip) (ULONG celt);
  249. STDMETHOD(Reset) (void);
  250. STDMETHOD(Clone) (IEnumFORMATETC **ppenum);
  251. CEnumFormatEtcDataArray(FORMATETCDATAARRAY *pFormatEtcDataArray,DWORD cOffset);
  252. private:
  253. ~CEnumFormatEtcDataArray(); // destructor
  254. ULONG m_refs; // reference count
  255. ULONG m_cOffset; // current clipboard format
  256. FORMATETCDATAARRAY * m_pFormatEtcDataArray;
  257. };
  258. #endif // !_CLIPDATA_H