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.

159 lines
7.3 KiB

  1. /*
  2. * dataobject.hxx
  3. *
  4. *
  5. * Copyright (c) 1998-1999 Microsoft Corporation
  6. *
  7. * PURPOSE: Defines the dataobject class.
  8. *
  9. *
  10. * OWNER: ptousig
  11. */
  12. #ifndef _DATAOBJECT_HXX
  13. #define _DATAOBJECT_HXX
  14. #include <mmc.h>
  15. //
  16. // These are the clipboard format that we defined.
  17. //
  18. //
  19. // These are clipboard formats from others that we need to know about.
  20. // $REVIEW (ptousig) Don't they provide these names in some header file ?
  21. //
  22. #define CF_MMC_SNAPIN_MACHINE_NAME _T("MMC_SNAPIN_MACHINE_NAME")
  23. #define CF_EXCHANGE_ADMIN_HSCOPEITEM _T("ADMIN_HSCOPEITEM")
  24. // -----------------------------------------------------------------------------
  25. // This is a virtual class. It implements the IDataObject interface. It also
  26. // defines a set of methods that must be implemented by its descendants.
  27. //
  28. class CBaseDataObject : public IDataObject, public CComObjectRoot
  29. {
  30. public:
  31. CBaseDataObject(void)
  32. {
  33. }
  34. ~CBaseDataObject(void)
  35. {
  36. }
  37. public:
  38. //
  39. // "Sc" version of IDataObject interface
  40. //
  41. SC ScGetDataHere(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  42. SC ScGetData(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  43. SC ScQueryGetData(FORMATETC *pformatetc);
  44. SC ScEnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
  45. // Indicates if this data item is for multiselect or not (default: no)
  46. virtual BOOL FIsMultiSelectDataObject() { return FALSE;}
  47. // Returns the most derived class' name.
  48. virtual const char *SzGetSnapinItemClassName(void)
  49. {
  50. return typeid(*this).name()+6; // +6 to remove "class "
  51. }
  52. //
  53. // IDataObject interface
  54. //
  55. STDMETHOD(GetDataHere)(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  56. STDMETHOD(GetData)(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  57. STDMETHOD(QueryGetData)(FORMATETC *pformatetc);
  58. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
  59. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut) { return E_NOTIMPL;}
  60. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease) { return E_NOTIMPL;}
  61. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection) { return E_NOTIMPL;}
  62. STDMETHOD(DUnadvise)(DWORD dwConnection) { return E_NOTIMPL;}
  63. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise) { return E_NOTIMPL;}
  64. protected:
  65. // Some functions are for override only: we will not provide a default behaviour.
  66. virtual SC ScWriteAdminHscopeitem(IStream *pstream) { return E_NOTIMPL;}
  67. virtual SC ScWriteDisplayName(IStream *pstream) { return E_NOTIMPL;}
  68. virtual SC ScWriteNodeType(IStream *pstream) { return E_NOTIMPL;}
  69. virtual SC ScWriteSzNodeType(IStream *pstream) { return E_NOTIMPL;}
  70. virtual SC ScWriteClsid(IStream *pstream) { return E_NOTIMPL;}
  71. virtual SC ScWriteNodeID(IStream *pstream) { return E_NOTIMPL;}
  72. virtual SC ScWriteColumnSetId(IStream *pstream) { return E_NOTIMPL;}
  73. virtual SC ScWriteMultiSelectionItemTypes(IStream * pstream) { return E_NOTIMPL;}
  74. virtual SC ScWriteAnsiName(IStream *pStream ) { return E_NOTIMPL;}
  75. // static functions
  76. public:
  77. static SC ScGetNodeType (LPDATAOBJECT lpDataObject, CLSID *pclsid) { return ScGetGUID(s_cfNodeType, lpDataObject, pclsid);}
  78. static SC ScGetClassID (LPDATAOBJECT lpDataObject, CLSID *pclsid) { return ScGetGUID(s_cfSnapinClsid, lpDataObject, pclsid);}
  79. static SC ScGetNodeID (LPDATAOBJECT lpDataObject, SNodeID **ppsnodeid);
  80. static SC ScGetAdminHscopeitem (LPDATAOBJECT lpDataObject, HSCOPEITEM *phscopeitem) { return ScGetDword(s_cfAdminHscopeitem, lpDataObject, (DWORD *) phscopeitem);}
  81. static SC ScGetMMCSnapinMachineName (LPDATAOBJECT lpDataObject, tstring& str) { return ScGetString(s_cfMMCSnapinMachineName, lpDataObject, str);}
  82. static SC ScGetDisplayName (LPDATAOBJECT lpDataObject, tstring& str) { return ScGetString(s_cfDisplayName, lpDataObject, str);}
  83. static SC ScGetColumnSetID (LPDATAOBJECT lpDataObject, SColumnSetID ** ppColumnSetID);
  84. // For MMC only - static SC ScGetMultiSelectionItemTypes(LPDATAOBJECT lpDataObject, SMMCObjectTypes ** ppMMCObjectTypes);
  85. private:
  86. static SC ScGetString(UINT cf, LPDATAOBJECT lpDataObject, tstring& str);
  87. static SC ScGetBool(UINT cf, LPDATAOBJECT lpDataObject, BOOL *pf);
  88. static SC ScGetDword(UINT cf, LPDATAOBJECT lpDataObject, DWORD *pdw);
  89. static SC ScGetGUID(UINT cf, LPDATAOBJECT lpDataObject, GUID *pguid);
  90. private:
  91. static UINT s_cfDisplayName; // The string to display for this node
  92. static UINT s_cfNodeType; // The nodetype's GUID (in binary format)
  93. static UINT s_cfSzNodeType; // The nodetype's GUID (in string format)
  94. static UINT s_cfSnapinClsid; // The snapin's CLSID (in binary format)
  95. static UINT s_cfNodeID; // Some unique ID for this node
  96. static UINT s_cfAdminHscopeitem; // The HSCOPEITEM of this node
  97. static UINT s_cfMMCSnapinMachineName; // Format supplied by the Computer manager snapin. Passes in the name of the server.
  98. static UINT s_cfColumnSetId; // MMC column set id
  99. static UINT s_cfMultiSelectionItemTypes; // Multiselect - list of types for the selected nodes
  100. #ifdef DBG
  101. //
  102. // No retail versions of this method !!!
  103. // Should only be called from Trace functions.
  104. //
  105. static LPTSTR SzDebugNameFromFormatEtc(UINT format);
  106. #endif
  107. };
  108. #ifdef DBG
  109. class CEnumFormatEtc :
  110. public IEnumFORMATETC,
  111. public CComObjectRootEx<CComObjectThreadModel>
  112. {
  113. public:
  114. CEnumFormatEtc(void) { m_dwIndex = 0;}
  115. virtual ~CEnumFormatEtc(void) {}
  116. BEGIN_COM_MAP(CEnumFormatEtc)
  117. COM_INTERFACE_ENTRY(IEnumFORMATETC)
  118. END_COM_MAP()
  119. STDMETHOD(Next)(
  120. /* [in] */ ULONG celt,
  121. /* [length_is][size_is][out] */ FORMATETC *rgelt,
  122. /* [out] */ ULONG *pceltFetched);
  123. STDMETHOD(Skip)(
  124. /* [in] */ ULONG celt)
  125. { return S_FALSE;}
  126. STDMETHOD(Reset)( void)
  127. { m_dwIndex = 0; return S_OK;}
  128. virtual HRESULT STDMETHODCALLTYPE Clone(
  129. /* [out] */ IEnumFORMATETC **ppenum)
  130. { return QueryInterface(__uuidof(IEnumFORMATETC),(void **) ppenum );}
  131. private:
  132. DWORD m_dwIndex;
  133. };
  134. #endif // DBG
  135. #endif // _DATAOBJECT_HXX