Source code of Windows XP (NT5)
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.

181 lines
4.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: gendata.h
  7. //
  8. // Contents: Declaration of a generic data object.
  9. //
  10. // Classes: CGenDataObject
  11. //
  12. // Functions:
  13. //
  14. // History: dd-mmm-yy Author Comment
  15. // 24-Mar-94 alexgo author
  16. //
  17. //--------------------------------------------------------------------------
  18. #ifndef _GENDATA_H
  19. #define _GENDATA_H
  20. // flags used by OLE1 compatibilty mode
  21. typedef enum
  22. {
  23. OLE1_OFFER_OWNERLINK = 1,
  24. OLE1_OFFER_OBJECTLINK = 2,
  25. OLE1_OFFER_NATIVE = 4,
  26. OLE1_OWNERLINK_PRECEDES_NATIVE = 8
  27. } Ole1TestFlags;
  28. // more flags used to control what formats are offered
  29. typedef enum
  30. {
  31. OFFER_TESTSTORAGE = 1,
  32. OFFER_EMBEDDEDOBJECT = 2
  33. } DataFlags;
  34. //+-------------------------------------------------------------------------
  35. //
  36. // Class: CGenDataObject
  37. //
  38. // Purpose: generic data object (for clipboard data transfers, etc)
  39. //
  40. // Interface: IDataObject
  41. //
  42. // History: dd-mmm-yy Author Comment
  43. // 24-Mar-94 alexgo author
  44. //
  45. // Notes:
  46. //
  47. //--------------------------------------------------------------------------
  48. class CGenDataObject : public IDataObject
  49. {
  50. public:
  51. // IUnknown methods
  52. STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppvObj);
  53. STDMETHOD_(ULONG,AddRef)(void);
  54. STDMETHOD_(ULONG,Release)(void);
  55. // IDataObject methods
  56. STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
  57. STDMETHOD(GetDataHere)(THIS_ LPFORMATETC pformatetc,
  58. LPSTGMEDIUM pmedium);
  59. STDMETHOD(QueryGetData)(THIS_ LPFORMATETC pformatetc);
  60. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatetc,
  61. LPFORMATETC pformatetcOut);
  62. STDMETHOD(SetData)(LPFORMATETC pformatetc,
  63. STGMEDIUM FAR* pmedium, BOOL fRelease);
  64. STDMETHOD(EnumFormatEtc)(DWORD dwDirection,
  65. LPENUMFORMATETC FAR* ppenumFormatEtc);
  66. STDMETHOD(DAdvise)(FORMATETC FAR* pFormatetc, DWORD advf,
  67. IAdviseSink FAR* pAdvSink, DWORD FAR* pdwConnection);
  68. STDMETHOD(DUnadvise)(DWORD dwConnection);
  69. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
  70. // constructor
  71. CGenDataObject();
  72. // test functions
  73. BOOL VerifyFormatAndMedium(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  74. // OLE1 compatibility test functions
  75. void SetupOle1Mode( Ole1TestFlags fFlags );
  76. HRESULT SetOle1ToClipboard( void );
  77. // Used by various tests, controls what formats are offered by
  78. // the data object
  79. void SetDataFormats( DataFlags fFlags );
  80. // Indicates whether or not QueryInterface was called. Used by
  81. // OleQueryXXX tests.
  82. BOOL HasQIBeenCalled();
  83. // test clipboard formats
  84. UINT m_cfTestStorage;
  85. UINT m_cfEmbeddedObject;
  86. UINT m_cfEmbedSource;
  87. UINT m_cfObjectDescriptor;
  88. UINT m_cfLinkSource;
  89. UINT m_cfLinkSrcDescriptor;
  90. UINT m_cfOwnerLink;
  91. UINT m_cfObjectLink;
  92. UINT m_cfNative;
  93. private:
  94. IStorage * GetTestStorage(void);
  95. BOOL VerifyTestStorage(FORMATETC *pformatetc,
  96. STGMEDIUM *pmedium);
  97. ULONG m_refs; // reference count
  98. DWORD m_cFormats; // number of formats supported
  99. FORMATETC * m_rgFormats; // the formats
  100. // OLE1 support functions and data
  101. HGLOBAL GetOwnerOrObjectLink(void);
  102. HGLOBAL GetNativeData(void);
  103. BOOL VerifyOwnerOrObjectLink( FORMATETC *pformatec,
  104. STGMEDIUM *pmedium);
  105. BOOL VerifyNativeData( FORMATETC *pformatetc,
  106. STGMEDIUM *pmedium);
  107. Ole1TestFlags m_fOle1; // OLE1 configuration flags
  108. BOOL m_fQICalled;
  109. };
  110. //+-------------------------------------------------------------------------
  111. //
  112. // Class: CGenEnumFormatEtc
  113. //
  114. // Purpose: Enumerator for the formats available on the generic data
  115. // object
  116. //
  117. // Interface: IEnumFORMATETC
  118. //
  119. // History: dd-mmm-yy Author Comment
  120. // 15-Apr-94 alexgo author
  121. //
  122. // Notes:
  123. //
  124. //--------------------------------------------------------------------------
  125. class CGenEnumFormatEtc :public IEnumFORMATETC
  126. {
  127. public:
  128. STDMETHOD(QueryInterface)(REFIID riid, void **ppvObj);
  129. STDMETHOD_(ULONG,AddRef)(void);
  130. STDMETHOD_(ULONG,Release)(void);
  131. STDMETHOD(Next) (ULONG celt, FORMATETC *rgelt,
  132. ULONG *pceltFetched);
  133. STDMETHOD(Skip) (ULONG celt);
  134. STDMETHOD(Reset) (void);
  135. STDMETHOD(Clone) (IEnumFORMATETC **ppenum);
  136. static HRESULT Create(IEnumFORMATETC **ppIEnum, FORMATETC *prgFormats,
  137. DWORD cFormats);
  138. private:
  139. CGenEnumFormatEtc(); // constructor
  140. ~CGenEnumFormatEtc(); // destructor
  141. ULONG m_refs; // reference count
  142. ULONG m_iCurrent; // current clipboard format
  143. ULONG m_cTotal; // total number of formats
  144. FORMATETC * m_rgFormats; // array of available formats
  145. };
  146. #endif // !_GENDATA_H
  147.