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.

352 lines
9.1 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 00
  5. *
  6. * File: node.inl
  7. *
  8. * Contents: Inline functions for node.h
  9. *
  10. * History: 9-Mar-2000 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #pragma once
  14. //_____________________________________________________________________________
  15. //
  16. // Inlines for class: CComponent
  17. //_____________________________________________________________________________
  18. //
  19. inline CComponent::CComponent(CSnapIn * pSnapIn)
  20. {
  21. Construct(pSnapIn, NULL);
  22. }
  23. inline HRESULT CComponent::Initialize(LPCONSOLE lpConsole)
  24. {
  25. ASSERT(m_spIComponent != NULL);
  26. if (m_spIComponent == NULL)
  27. return E_FAIL;
  28. return m_spIComponent->Initialize(lpConsole);
  29. }
  30. inline HRESULT CComponent::Destroy(MMC_COOKIE cookie)
  31. {
  32. ASSERT(m_spIComponent != NULL);
  33. if (m_spIComponent == NULL)
  34. return E_FAIL;
  35. return m_spIComponent->Destroy(cookie);
  36. }
  37. inline HRESULT CComponent::QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type,
  38. LPDATAOBJECT* ppDataObject)
  39. {
  40. ASSERT(m_spIComponent != NULL);
  41. if (m_spIComponent == NULL)
  42. return E_FAIL;
  43. ASSERT(type == CCT_RESULT || type == CCT_UNINITIALIZED);
  44. return m_spIComponent->QueryDataObject(cookie, type, ppDataObject);
  45. }
  46. inline HRESULT CComponent::GetResultViewType(MMC_COOKIE cookie, LPOLESTR* ppszViewType, long* pViewOptions)
  47. {
  48. ASSERT(m_spIComponent != NULL);
  49. if (m_spIComponent == NULL)
  50. return E_FAIL;
  51. return m_spIComponent->GetResultViewType(cookie, ppszViewType, pViewOptions);
  52. }
  53. inline HRESULT CComponent::GetDisplayInfo(RESULTDATAITEM* pResultDataItem)
  54. {
  55. ASSERT(m_spIComponent != NULL);
  56. if (m_spIComponent == NULL)
  57. return E_FAIL;
  58. return m_spIComponent->GetDisplayInfo(pResultDataItem);
  59. }
  60. //_____________________________________________________________________________
  61. //
  62. // Inlines for class: COCX
  63. //_____________________________________________________________________________
  64. //
  65. inline COCX::COCX(void)
  66. : m_clsid(CLSID_NULL)
  67. {
  68. DEBUG_INCREMENT_INSTANCE_COUNTER(COCX);
  69. }
  70. inline COCX::~COCX(void)
  71. {
  72. DEBUG_DECREMENT_INSTANCE_COUNTER(COCX);
  73. }
  74. inline void COCX::SetControl(CLSID& clsid, IUnknown* pUnknown)
  75. {
  76. m_clsid = clsid;
  77. m_spOCXWrapperUnknown = pUnknown;
  78. }
  79. inline void COCX::SetControl(LPUNKNOWN pUnkOCX, LPUNKNOWN pUnkOCXWrapper)
  80. {
  81. m_spOCXUnknown = pUnkOCX;
  82. m_spOCXWrapperUnknown = pUnkOCXWrapper;
  83. }
  84. //____________________________________________________________________________
  85. //
  86. // Inlines for class: CNode
  87. //____________________________________________________________________________
  88. //
  89. /*+-------------------------------------------------------------------------*
  90. * CNode::ToHandle
  91. * CNode::FromHandle
  92. *
  93. * Converts between HNODE's and CNode*'s. Currently this is a direct mapping
  94. * via casting, but enventually there will be an indirect mapping that will
  95. * allow detection of stale HNODEs.
  96. *--------------------------------------------------------------------------*/
  97. inline CNode* CNode::FromHandle (HNODE hNode)
  98. {
  99. return (reinterpret_cast<CNode*>(hNode));
  100. }
  101. inline HNODE CNode::ToHandle (const CNode* pNode)
  102. {
  103. return (reinterpret_cast<HNODE>(const_cast<CNode*>(pNode)));
  104. }
  105. inline void CNode::ResetFlags(void)
  106. {
  107. //m_dwFlags &= ~flag_expanded_at_least_once;
  108. m_dwFlags = 0;
  109. }
  110. inline void CNode::SetExpandedAtLeastOnce(void)
  111. {
  112. m_dwFlags |= flag_expanded_at_least_once;
  113. }
  114. inline BOOL CNode::WasExpandedAtLeastOnce(void)
  115. {
  116. return (m_dwFlags & flag_expanded_at_least_once) ? TRUE : FALSE;
  117. }
  118. inline void CNode::SetExpandedVisually(bool bExpanded)
  119. {
  120. if (bExpanded)
  121. m_dwFlags |= flag_expanded_visually;
  122. else
  123. m_dwFlags &= ~flag_expanded_visually;
  124. }
  125. inline bool CNode::WasExpandedVisually(void)
  126. {
  127. return (m_dwFlags & flag_expanded_visually) ? true : false;
  128. }
  129. inline const CLSID& CNode::GetPrimarySnapInCLSID(void)
  130. {
  131. CSnapIn* const pSnapIn = GetPrimarySnapIn();
  132. if (pSnapIn == NULL)
  133. return (GUID_NULL);
  134. return pSnapIn->GetSnapInCLSID();
  135. }
  136. inline CComponent* CNode::GetPrimaryComponent(void)
  137. {
  138. ASSERT ((m_pPrimaryComponent != NULL) && m_pPrimaryComponent->IsInitialized());
  139. return m_pPrimaryComponent;
  140. }
  141. inline LPARAM CNode::GetUserParam(void)
  142. {
  143. DECLARE_SC (sc, _T("CNode::GetUserParam"));
  144. CMTNode* pMTNode = GetMTNode();
  145. sc = ScCheckPointers (pMTNode, E_UNEXPECTED);
  146. if (sc)
  147. return (0);
  148. return (pMTNode->GetUserParam());
  149. }
  150. inline HRESULT CNode::GetNodeType(GUID* pGuid)
  151. {
  152. DECLARE_SC (sc, _T("CNode::GetNodeType"));
  153. sc = ScCheckPointers (pGuid);
  154. if (sc)
  155. return (sc.ToHr());
  156. CMTNode* pMTNode = GetMTNode();
  157. sc = ScCheckPointers (pMTNode, E_UNEXPECTED);
  158. if (sc)
  159. return (sc.ToHr());
  160. return pMTNode->GetNodeType(pGuid);
  161. }
  162. inline HRESULT CNode::QueryDataObject(DATA_OBJECT_TYPES type,
  163. LPDATAOBJECT* ppdtobj)
  164. {
  165. DECLARE_SC (sc, _T("CNode::QueryDataObject"));
  166. sc = ScCheckPointers (ppdtobj);
  167. if (sc)
  168. return (sc.ToHr());
  169. CMTNode* pMTNode = GetMTNode();
  170. sc = ScCheckPointers (pMTNode, E_UNEXPECTED);
  171. if (sc)
  172. return (sc.ToHr());
  173. return pMTNode->QueryDataObject(type, ppdtobj);
  174. }
  175. /*--------------------------------------------------------------------------*
  176. * CNode::ExtractColumnConfigID
  177. *
  178. *
  179. *--------------------------------------------------------------------------*/
  180. inline HRESULT CNode::ExtractColumnConfigID(IDataObject* pDataObj, HGLOBAL& hGlobal)
  181. {
  182. ASSERT(pDataObj != NULL);
  183. // Get the data
  184. return (DataObject_GetHGLOBALData (pDataObj, GetColumnConfigIDCF(),&hGlobal));
  185. }
  186. /*--------------------------------------------------------------------------*
  187. * CNode::GetColumnConfigIDCF
  188. *
  189. *
  190. *--------------------------------------------------------------------------*/
  191. inline CLIPFORMAT CNode::GetColumnConfigIDCF()
  192. {
  193. static CLIPFORMAT cfColumnConfigID = 0;
  194. if (cfColumnConfigID == 0)
  195. {
  196. USES_CONVERSION;
  197. cfColumnConfigID = (CLIPFORMAT) RegisterClipboardFormat (W2T (CCF_COLUMN_SET_ID));
  198. ASSERT (cfColumnConfigID != 0);
  199. }
  200. return (cfColumnConfigID);
  201. }
  202. inline CSnapInNode* CNode::GetStaticParent(void)
  203. {
  204. CMTSnapInNode* pMTSINode = GetMTNode()->GetStaticParent();
  205. CNodeList& nodeList = pMTSINode->GetNodeList();
  206. POSITION pos = nodeList.GetHeadPosition();
  207. CNode* pNode = NULL;
  208. while (pos)
  209. {
  210. pNode = nodeList.GetNext(pos);
  211. if (pNode->GetViewID() == GetViewID())
  212. break;
  213. }
  214. ASSERT(pNode != NULL);
  215. return dynamic_cast<CSnapInNode*>(pNode);
  216. }
  217. inline CComponent* CNode::GetComponent(COMPONENTID nID)
  218. {
  219. CMTSnapInNode* pMTSnapInNode = GetMTNode()->GetStaticParent();
  220. CComponent* pCC = pMTSnapInNode->GetComponent(GetViewID(), nID,
  221. GetPrimarySnapIn());
  222. ASSERT(pCC != NULL);
  223. return pCC;
  224. }
  225. inline LPUNKNOWN CNode::GetControl(CLSID& clsid)
  226. {
  227. DECLARE_SC(sc, TEXT("CNode::GetControl"));
  228. CSnapInNode* pSINode = GetStaticParent();
  229. sc = ScCheckPointers(pSINode, E_UNEXPECTED);
  230. if (sc)
  231. return NULL;
  232. return pSINode->GetControl(clsid);
  233. }
  234. inline void CNode::SetControl(CLSID& clsid, IUnknown* pUnknown)
  235. {
  236. DECLARE_SC(sc, TEXT("CNode::SetControl"));
  237. CSnapInNode* pSINode = GetStaticParent();
  238. sc = ScCheckPointers(pSINode, E_UNEXPECTED);
  239. if (sc)
  240. return;
  241. pSINode->SetControl(clsid, pUnknown);
  242. }
  243. inline LPUNKNOWN CNode::GetControl(LPUNKNOWN pUnkOCX)
  244. {
  245. DECLARE_SC(sc, TEXT("CNode::GetControl"));
  246. CSnapInNode* pSINode = GetStaticParent();
  247. sc = ScCheckPointers(pSINode, E_UNEXPECTED);
  248. if (sc)
  249. return NULL;
  250. return pSINode->GetControl(pUnkOCX);
  251. }
  252. inline void CNode::SetControl(LPUNKNOWN pUnkOCX, IUnknown* pUnknown)
  253. {
  254. DECLARE_SC(sc, TEXT("CNode::SetControl"));
  255. CSnapInNode* pSINode = GetStaticParent();
  256. sc = ScCheckPointers(pSINode, E_UNEXPECTED);
  257. if (sc)
  258. return;
  259. pSINode->SetControl(pUnkOCX, pUnknown);
  260. }
  261. //_____________________________________________________________________________
  262. //
  263. // Inlines for class: CSnapInNode
  264. //_____________________________________________________________________________
  265. //
  266. inline CComponent* CSnapInNode::GetComponent(const CLSID& clsid)
  267. {
  268. for (int i=0; i < GetComponentArray().size(); i++)
  269. {
  270. if (GetComponentArray()[i] != NULL &&
  271. IsEqualCLSID(clsid, GetComponentArray()[i]->GetCLSID()) == TRUE)
  272. return GetComponentArray()[i];
  273. }
  274. return NULL;
  275. }
  276. inline CComponent* CSnapInNode::GetComponent(COMPONENTID nID)
  277. {
  278. if (nID < GetComponentArray().size())
  279. return GetComponentArray()[nID];
  280. return NULL;
  281. }