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.

172 lines
5.5 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #ifndef _DATAOBJ_H
  9. #define _DATAOBJ_H
  10. const GUID* FolderTypeToNodeGUID(DATA_OBJECT_TYPES type, CFolder* pFolder);
  11. class CDataObject :
  12. public IDataObject,
  13. public CComObjectRoot
  14. {
  15. // ATL Maps
  16. DECLARE_NOT_AGGREGATABLE(CDataObject)
  17. BEGIN_COM_MAP(CDataObject)
  18. COM_INTERFACE_ENTRY(IDataObject)
  19. END_COM_MAP()
  20. // Construction/Destruction
  21. CDataObject();
  22. virtual ~CDataObject()
  23. {
  24. if (m_pComponentData)
  25. {
  26. m_pComponentData->Release();
  27. m_pComponentData = NULL;
  28. }
  29. };
  30. // Clipboard formats that are required by the console
  31. public:
  32. static unsigned int m_cfNodeType; // Required by the console
  33. static unsigned int m_cfNodeID; // per-node column identifiers
  34. static unsigned int m_cfNodeTypeString; // Required by the console
  35. static unsigned int m_cfDisplayName; // Required by the console
  36. static unsigned int m_cfCoClass; // Required by the console
  37. static unsigned int m_cfIsMultiSel; // Required by the console
  38. static unsigned int m_cfObjInMultiSel; // Required by the console
  39. static unsigned int m_cfPreloads; // Required by the console
  40. static unsigned int m_cfInternal; //
  41. static unsigned int m_cfSelectedCA_InstallType; // published information
  42. static unsigned int m_cfSelectedCA_CommonName; // Published information
  43. static unsigned int m_cfSelectedCA_MachineName; // Published information
  44. static unsigned int m_cfSelectedCA_SanitizedName; // Published information
  45. // Standard IDataObject methods
  46. public:
  47. // Implemented
  48. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc);
  49. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium);
  50. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  51. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
  52. // Not Implemented
  53. private:
  54. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  55. { return E_NOTIMPL; };
  56. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  57. { return E_NOTIMPL; };
  58. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  59. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  60. { return E_NOTIMPL; };
  61. STDMETHOD(DUnadvise)(DWORD dwConnection)
  62. { return E_NOTIMPL; };
  63. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  64. { return E_NOTIMPL; };
  65. // Implementation
  66. // This is used only as a diagnostic in debug builds to track if
  67. // anyone is hanging on to any data objects that's have been handed out
  68. // Snapins should view context data objects as ephemeral.
  69. public:
  70. void SetComponentData(CComponentDataImpl* pCCD)
  71. {
  72. if (NULL != pCCD)
  73. {
  74. ASSERT(m_pComponentData == NULL);
  75. m_pComponentData = pCCD;
  76. m_pComponentData->AddRef();
  77. }
  78. }
  79. private:
  80. CComponentDataImpl* m_pComponentData;
  81. public:
  82. void SetViewID(DWORD dwView) { /* m_dwViewID = dwView; */}
  83. void SetType(DATA_OBJECT_TYPES type) { ASSERT(m_internal.m_type == CCT_UNINITIALIZED); m_internal.m_type = type; }
  84. void SetCookie(MMC_COOKIE cookie) { m_internal.m_cookie = cookie; }
  85. void SetString(LPTSTR lpString) { m_internal.m_string = lpString; }
  86. void SetClsid(const CLSID& clsid) { m_internal.m_clsid = clsid; }
  87. void SetMultiSelData(SMMCObjectTypes *psGuidObjTypes, UINT cbMultiSelData)
  88. {
  89. // make sure [1] still good enough
  90. ASSERT(cbMultiSelData == sizeof(m_sGuidObjTypes));
  91. if (cbMultiSelData == sizeof(m_sGuidObjTypes))
  92. {
  93. m_cbMultiSelData = cbMultiSelData;
  94. CopyMemory(&m_sGuidObjTypes, psGuidObjTypes, cbMultiSelData);
  95. }
  96. }
  97. void SetMultiSelDobj()
  98. {
  99. m_bMultiSelDobj = TRUE;
  100. }
  101. #ifdef _DEBUG
  102. UINT dbg_refCount;
  103. void AddRefMultiSelDobj()
  104. {
  105. ASSERT(m_bMultiSelDobj == TRUE);
  106. ++dbg_refCount;
  107. }
  108. void ReleaseMultiSelDobj()
  109. {
  110. ASSERT(m_bMultiSelDobj == TRUE);
  111. --dbg_refCount;
  112. }
  113. #endif
  114. private:
  115. HRESULT CreateObjInMultiSel(LPSTGMEDIUM lpMedium);
  116. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  117. HRESULT CreateNodeIDData(LPSTGMEDIUM lpMedium);
  118. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  119. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  120. HRESULT CreateInternal(LPSTGMEDIUM lpMedium);
  121. HRESULT CreateWorkstationName(LPSTGMEDIUM lpMedium);
  122. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  123. HRESULT CreatePreloadsData(LPSTGMEDIUM lpMedium);
  124. HRESULT CreateSelectedCA_InstallType(LPSTGMEDIUM lpMedium);
  125. HRESULT CreateSelectedCA_CommonName(LPSTGMEDIUM lpMedium);
  126. HRESULT CreateSelectedCA_MachineName(LPSTGMEDIUM lpMedium);
  127. HRESULT CreateSelectedCA_SanitizedName(LPSTGMEDIUM lpMedium);
  128. HRESULT Create(const void* pBuffer, int len, LPSTGMEDIUM lpMedium);
  129. HRESULT CreateVariableLen(const void* pBuffer, int len, LPSTGMEDIUM lpMedium);
  130. private:
  131. INTERNAL m_internal;
  132. SMMCObjectTypes m_sGuidObjTypes; // length[1] good enough for now
  133. UINT m_cbMultiSelData;
  134. BOOL m_bMultiSelDobj;
  135. DWORD m_dwViewID;
  136. };
  137. #endif