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.

626 lines
21 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000
  6. //
  7. // File: ResultViewInfo.h
  8. //
  9. // History: Jan-18-2000 VivekJ Added
  10. //--------------------------------------------------------------------------
  11. #ifndef _RESULTVIEW_H
  12. #define _RESULTVIEW_H
  13. /*+-------------------------------------------------------------------------*
  14. * class CResultViewType
  15. *
  16. *
  17. * PURPOSE: Provides a wrapper for the RESULT_VIEW_TYPE_INFO structure, and
  18. * is used for communication between conui and nodemgr.
  19. *
  20. *+-------------------------------------------------------------------------*/
  21. class CResultViewType : public CXMLObject
  22. {
  23. typedef std::wstring wstring; // only wide strings are needed here.
  24. protected:
  25. virtual void Persist(CPersistor &persistor);
  26. DEFINE_XML_TYPE(XML_TAG_RESULTVIEWTYPE);
  27. public:
  28. CResultViewType();
  29. CResultViewType & operator =(RESULT_VIEW_TYPE_INFO &rvti); // conversion from a RESULT_VIEW_TYPE_INFO structure
  30. bool operator != (const CResultViewType& rvt) const;
  31. // the default copy constructor and assignment operators are sufficient
  32. MMC_VIEW_TYPE GetType() const {return m_viewType;}
  33. DWORD GetListOptions() const {return m_dwListOptions;}
  34. DWORD GetHTMLOptions() const {return m_dwHTMLOptions;}
  35. DWORD GetOCXOptions() const {return m_dwOCXOptions;}
  36. DWORD GetMiscOptions() const {return m_dwMiscOptions;}
  37. BOOL HasList() const {return (m_viewType==MMC_VIEW_TYPE_LIST);}
  38. BOOL HasWebBrowser() const {return (m_viewType==MMC_VIEW_TYPE_HTML);}
  39. BOOL HasOCX() const {return (m_viewType==MMC_VIEW_TYPE_OCX);}
  40. LPCOLESTR GetURL() const {return m_strURL.data();}
  41. LPCOLESTR GetOCX() const {return m_strOCX.data();}
  42. LPUNKNOWN GetOCXUnknown() const {return m_spUnkControl;} // returns the IUnknown of the OCX.
  43. bool IsPersistableViewDescriptionValid() const {return m_bPersistableViewDescriptionValid;}
  44. bool IsMMC12LegacyData() const {return !IsPersistableViewDescriptionValid();}
  45. SC ScInitialize(LPOLESTR & pszView, long lMiscOptions); // the legacy case.
  46. SC ScGetOldTypeViewOptions(long* plViewOptions) const;
  47. SC ScReset();
  48. // functions specific to nodemgr. Do NOT add any member variables in this section.
  49. #ifdef _NODEMGR_DLL_
  50. SC ScInitialize(RESULT_VIEW_TYPE_INFO &rvti);
  51. SC ScGetResultViewTypeInfo(RESULT_VIEW_TYPE_INFO& rvti) const;
  52. #endif _NODEMGR_DLL_
  53. private:
  54. bool m_bPersistableViewDescriptionValid;
  55. bool m_bInitialized;
  56. MMC_VIEW_TYPE m_viewType;
  57. wstring m_strURL;
  58. wstring m_strOCX; // for snapins that implement IComponent only.
  59. wstring m_strPersistableViewDescription;
  60. DWORD m_dwMiscOptions;
  61. DWORD m_dwListOptions;
  62. DWORD m_dwHTMLOptions;
  63. DWORD m_dwOCXOptions;
  64. CComPtr<IUnknown> m_spUnkControl; // a smart pointer for the control created by the snapin.
  65. };
  66. inline CResultViewType::CResultViewType()
  67. :
  68. m_viewType(MMC_VIEW_TYPE_LIST), // the default view type
  69. m_dwMiscOptions(0),
  70. m_dwListOptions(0),
  71. m_dwHTMLOptions(0),
  72. m_dwOCXOptions(0),
  73. m_bPersistableViewDescriptionValid(false),
  74. m_bInitialized(false)
  75. {
  76. }
  77. //+-------------------------------------------------------------------
  78. //
  79. // Member: CResultViewType::ScReset
  80. //
  81. // Synopsis:
  82. //
  83. // Arguments:
  84. //
  85. // Returns: SC
  86. //
  87. //--------------------------------------------------------------------
  88. inline SC CResultViewType::ScReset ()
  89. {
  90. DECLARE_SC(sc, _T("CResultViewType::ScReset"));
  91. m_viewType = MMC_VIEW_TYPE_LIST; // the default view type
  92. m_dwMiscOptions = 0;
  93. m_dwListOptions = 0;
  94. m_dwHTMLOptions = 0;
  95. m_dwOCXOptions = 0;
  96. m_bPersistableViewDescriptionValid = false;
  97. m_bInitialized = false;
  98. return (sc);
  99. }
  100. /*+-------------------------------------------------------------------------*
  101. *
  102. * CResultViewType::operator!=
  103. *
  104. * PURPOSE: Operator != (Used by CViewSettings which is used by CMemento).
  105. *
  106. * NOTE: For MMC2 compare only persistable view desc for MMC1.2 compare all
  107. * parameters.
  108. *
  109. *+-------------------------------------------------------------------------*/
  110. inline
  111. bool CResultViewType::operator != (const CResultViewType& rvt) const
  112. {
  113. if (m_bInitialized != rvt.m_bInitialized)
  114. return true;
  115. if (m_bPersistableViewDescriptionValid)
  116. {
  117. if (m_strPersistableViewDescription != rvt.m_strPersistableViewDescription)
  118. return true;
  119. return false;
  120. }
  121. // Legacy case MMC1.2, should compare other parameters.
  122. switch(m_viewType)
  123. {
  124. default:
  125. ASSERT(FALSE && _T("Unknown view type"));
  126. break;
  127. case MMC_VIEW_TYPE_LIST:
  128. if ( (m_viewType != rvt.m_viewType) ||
  129. (m_dwMiscOptions != rvt.m_dwMiscOptions) ||
  130. (m_dwListOptions != rvt.m_dwListOptions) )
  131. {
  132. return true;
  133. }
  134. break;
  135. case MMC_VIEW_TYPE_HTML:
  136. if ( (m_viewType != rvt.m_viewType) ||
  137. (m_dwMiscOptions != rvt.m_dwMiscOptions) ||
  138. (m_dwHTMLOptions != rvt.m_dwHTMLOptions) ||
  139. (m_strURL != rvt.m_strURL) )
  140. {
  141. return true;
  142. }
  143. break;
  144. case MMC_VIEW_TYPE_OCX:
  145. if ( (m_viewType != rvt.m_viewType) ||
  146. (m_dwMiscOptions != rvt.m_dwMiscOptions) ||
  147. (m_dwOCXOptions != rvt.m_dwOCXOptions) ||
  148. (m_strOCX != rvt.m_strOCX) )
  149. {
  150. return true;
  151. }
  152. break;
  153. }
  154. return false;
  155. }
  156. /*+-------------------------------------------------------------------------*
  157. *
  158. * CResultViewType::ScInitialize
  159. *
  160. * PURPOSE: Initializes the class from parameters returned by IComponent::
  161. * GetResultViewType
  162. *
  163. * PARAMETERS:
  164. * LPOLESTR ppViewType :
  165. * long lViewOptions :
  166. *
  167. * RETURNS:
  168. * SC
  169. *
  170. * NOTE: This is for MMC1.2 compatible GetResultViewType.
  171. *
  172. *+-------------------------------------------------------------------------*/
  173. inline
  174. SC CResultViewType::ScInitialize(LPOLESTR & pszView, long lViewOptions)
  175. {
  176. DECLARE_SC(sc, TEXT("CResultViewType::ScInitialize"));
  177. m_bInitialized = true;
  178. m_bPersistableViewDescriptionValid = false; // the legacy case - we don't have a persistable view description.
  179. // MMC_VIEW_OPTIONS_NOLISTVIEWS is a special case - it goes to the dwMiscOptions
  180. if(lViewOptions & MMC_VIEW_OPTIONS_NOLISTVIEWS)
  181. m_dwMiscOptions |= RVTI_MISC_OPTIONS_NOLISTVIEWS;
  182. // check whether the type of view is a web page or OCX.
  183. if ( (NULL == pszView) || (_T('\0') == pszView[0]) )
  184. {
  185. // the result pane is a standard list
  186. m_viewType = MMC_VIEW_TYPE_LIST;
  187. m_dwListOptions = 0;
  188. // convert the view options from the old bits to the new ones
  189. if(lViewOptions & MMC_VIEW_OPTIONS_OWNERDATALIST) m_dwListOptions |= RVTI_LIST_OPTIONS_OWNERDATALIST;
  190. if(lViewOptions & MMC_VIEW_OPTIONS_MULTISELECT) m_dwListOptions |= RVTI_LIST_OPTIONS_MULTISELECT;
  191. if(lViewOptions & MMC_VIEW_OPTIONS_FILTERED) m_dwListOptions |= RVTI_LIST_OPTIONS_FILTERED;
  192. if(lViewOptions & MMC_VIEW_OPTIONS_USEFONTLINKING) m_dwListOptions |= RVTI_LIST_OPTIONS_USEFONTLINKING;
  193. if(lViewOptions & MMC_VIEW_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST) m_dwListOptions |= RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST;
  194. if(lViewOptions & MMC_VIEW_OPTIONS_LEXICAL_SORT) m_dwListOptions |= RVTI_LIST_OPTIONS_LEXICAL_SORT;
  195. }
  196. else
  197. {
  198. // the result pane is a web page or an OCX.
  199. if (L'{' == pszView[0]) // the hacky way of ensuring that the result view is an OCX
  200. {
  201. m_viewType = MMC_VIEW_TYPE_OCX;
  202. m_strOCX = pszView;
  203. // If the snapin says "create new" then do not "cache the ocx"
  204. if(!(lViewOptions & MMC_VIEW_OPTIONS_CREATENEW)) m_dwOCXOptions |= RVTI_OCX_OPTIONS_CACHE_OCX;
  205. if(lViewOptions & MMC_VIEW_OPTIONS_NOLISTVIEWS) m_dwOCXOptions |= RVTI_OCX_OPTIONS_NOLISTVIEW;
  206. }
  207. else
  208. {
  209. m_viewType = MMC_VIEW_TYPE_HTML;
  210. m_strURL = pszView;
  211. if(lViewOptions & MMC_VIEW_OPTIONS_NOLISTVIEWS) m_dwHTMLOptions |= RVTI_HTML_OPTIONS_NOLISTVIEW;
  212. }
  213. }
  214. // make sure we free the allocated memory.
  215. if(pszView != NULL)
  216. {
  217. ::CoTaskMemFree(pszView);
  218. pszView = NULL; // NOTE: pszView is a reference, so this changes the in parameter.
  219. }
  220. return sc;
  221. }
  222. //+-------------------------------------------------------------------
  223. //
  224. // Member: CResultViewType::Persist
  225. //
  226. // Synopsis: persist to / from XML document.
  227. //
  228. // Arguments: [persistor] - target or source.
  229. //
  230. //--------------------------------------------------------------------
  231. inline
  232. void CResultViewType::Persist(CPersistor& persistor)
  233. {
  234. if ( (! m_bInitialized) &&
  235. (persistor.IsStoring()) )
  236. {
  237. SC sc;
  238. (sc = E_UNEXPECTED).Throw();
  239. }
  240. else
  241. m_bInitialized = true;
  242. if (persistor.IsLoading())
  243. m_bPersistableViewDescriptionValid = persistor.HasElement(XML_TAG_RESULTVIEW_DESCRIPTION, NULL);
  244. if (m_bPersistableViewDescriptionValid)
  245. {
  246. CPersistor persistorDesc(persistor, XML_TAG_RESULTVIEW_DESCRIPTION);
  247. persistorDesc.PersistContents(m_strPersistableViewDescription);
  248. return;
  249. }
  250. // Legacy code for MMC1.2
  251. {
  252. int &viewType = (int&) m_viewType;
  253. // define the table to map enumeration values to strings
  254. static const EnumLiteral mappedViewTypes[] =
  255. {
  256. { MMC_VIEW_TYPE_LIST, XML_ENUM_MMC_VIEW_TYPE_LIST },
  257. { MMC_VIEW_TYPE_HTML, XML_ENUM_MMC_VIEW_TYPE_HTML },
  258. { MMC_VIEW_TYPE_OCX, XML_ENUM_MMC_VIEW_TYPE_OCX },
  259. };
  260. const size_t countof_types = sizeof(mappedViewTypes)/sizeof(mappedViewTypes[0]);
  261. // create wrapper to persist flag values as strings
  262. CXMLEnumeration viewTypePersistor(viewType, mappedViewTypes, countof_types );
  263. // persist the wrapper
  264. persistor.PersistAttribute(XML_ATTR_VIEW_SETTINGS_TYPE, viewTypePersistor);
  265. switch(m_viewType)
  266. {
  267. case MMC_VIEW_TYPE_LIST:
  268. {
  269. // define the table to map enumeration flags to strings
  270. static const EnumLiteral mappedLVOptions[] =
  271. {
  272. { RVTI_LIST_OPTIONS_OWNERDATALIST, XML_BITFLAG_LIST_OPTIONS_OWNERDATALIST },
  273. { RVTI_LIST_OPTIONS_MULTISELECT, XML_BITFLAG_LIST_OPTIONS_MULTISELECT },
  274. { RVTI_LIST_OPTIONS_FILTERED, XML_BITFLAG_LIST_OPTIONS_FILTERED },
  275. { RVTI_LIST_OPTIONS_USEFONTLINKING, XML_BITFLAG_LIST_OPTIONS_USEFONTLINKING },
  276. { RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST, XML_BITFLAG_LIST_OPTIONS_NO_SCOPE_ITEMS },
  277. { RVTI_LIST_OPTIONS_LEXICAL_SORT, XML_BITFLAG_LIST_OPTIONS_LEXICAL_SORT },
  278. };
  279. const size_t countof_options = sizeof(mappedLVOptions)/sizeof(mappedLVOptions[0]);
  280. // create wrapper to persist flag values as strings
  281. CXMLBitFlags optPersistor(m_dwListOptions, mappedLVOptions, countof_options);
  282. persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_OPTIONS, optPersistor);
  283. }
  284. break;
  285. case MMC_VIEW_TYPE_HTML:
  286. {
  287. // NOT USED - persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_OPTIONS, m_dwHTMLOptions);
  288. m_dwHTMLOptions = 0;
  289. persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_URL_STRING, m_strURL);
  290. }
  291. break;
  292. case MMC_VIEW_TYPE_OCX:
  293. {
  294. // define the table to map enumeration flags to strings
  295. static const EnumLiteral mappedOCXOptions[] =
  296. {
  297. { RVTI_OCX_OPTIONS_CACHE_OCX, XML_BITFLAG_OCX_OPTIONS_CACHE_OCX },
  298. };
  299. const size_t countof_options = sizeof(mappedOCXOptions)/sizeof(mappedOCXOptions[0]);
  300. // create wrapper to persist flag values as strings
  301. CXMLBitFlags optPersistor(m_dwOCXOptions, mappedOCXOptions, countof_options);
  302. // persist the wrapper
  303. persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_OPTIONS, optPersistor);
  304. persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_OCX_STRING, m_strOCX);
  305. }
  306. break;
  307. default:
  308. ASSERT(FALSE && _T("Unknown MMC_VIEW_TYPE"));
  309. break;
  310. }
  311. // define the table to map enumeration flags to strings
  312. static const EnumLiteral mappedMiscOptions[] =
  313. {
  314. { RVTI_MISC_OPTIONS_NOLISTVIEWS, _T("Misc_NoListViews") },
  315. };
  316. const size_t countof_miscoptions = sizeof(mappedMiscOptions)/sizeof(mappedMiscOptions[0]);
  317. // create wrapper to persist flag values as strings
  318. CXMLBitFlags miscPersistor(m_dwMiscOptions, mappedMiscOptions, countof_miscoptions);
  319. // persist the wrapper
  320. persistor.PersistAttribute(XML_ATTR_RESULTVIEWTYPE_MISC_OPTIONS, miscPersistor);
  321. }
  322. }
  323. /*+-------------------------------------------------------------------------*
  324. *
  325. * CResultViewType::ScGetOldTypeViewOptions
  326. *
  327. * PURPOSE: This method is for compatibility with MMC1.2. It makes MMC1.2 compatible
  328. * view option for MMCN_RESTORE_VIEW.
  329. *
  330. * PARAMETERS:
  331. * [out] long* plViewOptions :
  332. *
  333. * RETURNS:
  334. * SC
  335. *
  336. *+-------------------------------------------------------------------------*/
  337. inline SC
  338. CResultViewType::ScGetOldTypeViewOptions(long* plViewOptions) const
  339. {
  340. DECLARE_SC(sc, TEXT("CResultViewType::ScInitialize"));
  341. sc = ScCheckPointers(plViewOptions);
  342. if (sc)
  343. return sc;
  344. *plViewOptions = 0;
  345. if(! m_bInitialized)
  346. return (sc = E_UNEXPECTED); // should be initialized.
  347. if (m_bPersistableViewDescriptionValid)
  348. return (sc = E_UNEXPECTED); // Not MMC1.2 type data.
  349. if (HasWebBrowser())
  350. {
  351. if (m_dwMiscOptions & RVTI_MISC_OPTIONS_NOLISTVIEWS)
  352. *plViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  353. return sc;
  354. }
  355. if (HasList())
  356. {
  357. if(m_dwListOptions & RVTI_LIST_OPTIONS_OWNERDATALIST) *plViewOptions |= MMC_VIEW_OPTIONS_OWNERDATALIST;
  358. if(m_dwListOptions & RVTI_LIST_OPTIONS_MULTISELECT) *plViewOptions |= MMC_VIEW_OPTIONS_MULTISELECT;
  359. if(m_dwListOptions & RVTI_LIST_OPTIONS_FILTERED) *plViewOptions |= MMC_VIEW_OPTIONS_FILTERED;
  360. if(m_dwListOptions & RVTI_LIST_OPTIONS_USEFONTLINKING) *plViewOptions |= MMC_VIEW_OPTIONS_USEFONTLINKING;
  361. if(m_dwListOptions & RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST) *plViewOptions |= MMC_VIEW_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST;
  362. if(m_dwListOptions & RVTI_LIST_OPTIONS_LEXICAL_SORT) *plViewOptions |= MMC_VIEW_OPTIONS_LEXICAL_SORT;
  363. return sc;
  364. }
  365. else if(HasOCX())
  366. {
  367. // NOTE: The CREATENEW flag has the opposite sense of the CACHE_OCX flag.
  368. if(!(m_dwOCXOptions & RVTI_OCX_OPTIONS_CACHE_OCX)) *plViewOptions |= MMC_VIEW_OPTIONS_CREATENEW;
  369. if (m_dwMiscOptions & RVTI_MISC_OPTIONS_NOLISTVIEWS) *plViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  370. return sc;
  371. }
  372. return (sc = E_UNEXPECTED);
  373. }
  374. #ifdef _NODEMGR_DLL_
  375. /*+-------------------------------------------------------------------------*
  376. *
  377. * CResultViewType::ScInitialize
  378. *
  379. * PURPOSE: Initializes the class from a RESULT_VIEW_TYPE_INFO structure.
  380. *
  381. * PARAMETERS:
  382. * RESULT_VIEW_TYPE_INFO & rvti :
  383. *
  384. * RETURNS:
  385. * SC
  386. *
  387. *+-------------------------------------------------------------------------*/
  388. inline SC
  389. CResultViewType::ScInitialize(RESULT_VIEW_TYPE_INFO &rvti)
  390. {
  391. DECLARE_SC(sc, TEXT("CResultViewType::ScInitialize"));
  392. if(m_bInitialized)
  393. return (sc = E_UNEXPECTED); // should not try to initialize twice
  394. m_bInitialized = true;
  395. // make sure we have a persistable view description.
  396. if(!rvti.pstrPersistableViewDescription)
  397. {
  398. sc = E_INVALIDARG;
  399. TraceSnapinError(TEXT("Parameter 'pstrPersistableViewDescription' in structure 'RESULT_VIEW_TYPE_INFO' is NULL"), sc);
  400. return sc;
  401. }
  402. // copy the description
  403. m_strPersistableViewDescription = rvti.pstrPersistableViewDescription;
  404. ::CoTaskMemFree(rvti.pstrPersistableViewDescription);
  405. rvti.pstrPersistableViewDescription = NULL; // just to make sure we don't try to use it
  406. m_bPersistableViewDescriptionValid = true;
  407. // validate the view type
  408. m_viewType = rvti.eViewType;
  409. if( (m_viewType != MMC_VIEW_TYPE_LIST) &&
  410. (m_viewType != MMC_VIEW_TYPE_OCX) &&
  411. (m_viewType != MMC_VIEW_TYPE_HTML) )
  412. {
  413. sc = E_INVALIDARG;
  414. TraceSnapinError(TEXT("Parameter 'eViewType' in structure 'RESULT_VIEW_TYPE_INFO' is invalid"), sc);
  415. return sc;
  416. }
  417. // validate the various view options
  418. switch(m_viewType)
  419. {
  420. default:
  421. ASSERT(0 && "Should not come here");
  422. return (sc = E_INVALIDARG);
  423. break;
  424. case MMC_VIEW_TYPE_LIST:
  425. if(rvti.dwListOptions & ~( RVTI_LIST_OPTIONS_NONE |
  426. RVTI_LIST_OPTIONS_OWNERDATALIST | RVTI_LIST_OPTIONS_MULTISELECT |
  427. RVTI_LIST_OPTIONS_FILTERED | RVTI_LIST_OPTIONS_USEFONTLINKING |
  428. RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST | RVTI_LIST_OPTIONS_LEXICAL_SORT |
  429. RVTI_LIST_OPTIONS_ALLOWPASTE )
  430. )
  431. {
  432. sc = E_INVALIDARG;
  433. TraceSnapinError(TEXT("Parameter 'dwListOptions' in structure 'RESULT_VIEW_TYPE_INFO' is invalid"), sc);
  434. return sc;
  435. }
  436. m_dwListOptions = rvti.dwListOptions;
  437. break;
  438. case MMC_VIEW_TYPE_HTML:
  439. // if the view type is HTML, make sure that no flags are set. If snapins wrongly set this flag, it could break our well
  440. // intentioned effort to add future expansion
  441. if(rvti.dwHTMLOptions & ~( RVTI_HTML_OPTIONS_NONE |
  442. RVTI_HTML_OPTIONS_NOLISTVIEW) )
  443. {
  444. sc = E_INVALIDARG;
  445. TraceSnapinError(TEXT("Parameter 'dwHTMLOptions' in structure 'RESULT_VIEW_TYPE_INFO' must be zero"), sc);
  446. return sc;
  447. }
  448. // make sure we have a valid URL
  449. if(NULL == rvti.pstrURL)
  450. {
  451. sc = E_INVALIDARG;
  452. TraceSnapinError(TEXT("Parameter 'pstrURL' in structure 'RESULT_VIEW_TYPE_INFO' cannot be NULL"), sc);
  453. return sc;
  454. }
  455. m_dwHTMLOptions = 0;
  456. // copy the URL
  457. m_strURL = rvti.pstrURL;
  458. ::CoTaskMemFree(rvti.pstrURL);
  459. rvti.pstrURL = NULL; // just to make sure we don't try to use it
  460. break;
  461. case MMC_VIEW_TYPE_OCX:
  462. if(rvti.dwOCXOptions & ~( RVTI_OCX_OPTIONS_NONE |
  463. RVTI_OCX_OPTIONS_NOLISTVIEW |
  464. RVTI_OCX_OPTIONS_CACHE_OCX) )
  465. {
  466. sc = E_INVALIDARG;
  467. TraceSnapinError(TEXT("Parameter 'dwOCXOptions' in structure 'RESULT_VIEW_TYPE_INFO' is invalid"), sc);
  468. return sc;
  469. }
  470. // if an OCX was specified, must have a valid OCX control IUnknown
  471. if(rvti.pUnkControl == NULL)
  472. {
  473. sc = E_INVALIDARG;
  474. TraceSnapinError(TEXT("No OCX specified in parameter 'pUnkControl' of structure 'RESULT_VIEW_TYPE_INFO'"), sc);
  475. return sc;
  476. }
  477. m_dwOCXOptions = rvti.dwOCXOptions;
  478. m_spUnkControl = rvti.pUnkControl; // does an addref, but rvti.ppUnkControl already had an addref set by the snapin. So need to release it once.
  479. rvti.pUnkControl->Release();
  480. break;
  481. }
  482. return sc;
  483. }
  484. //+-------------------------------------------------------------------
  485. //
  486. // Member: CResultViewType::ScGetResultViewTypeInfo
  487. //
  488. // Synopsis: Fill the RESULT_VIEW_TYPE_INFO struct and return.
  489. //
  490. // Arguments: [rvti] - Fill the struct and return.
  491. //
  492. // Returns: SC
  493. //
  494. //--------------------------------------------------------------------
  495. inline SC
  496. CResultViewType::ScGetResultViewTypeInfo (RESULT_VIEW_TYPE_INFO& rvti) const
  497. {
  498. DECLARE_SC(sc, _T("CResultViewType::ScGetResultViewTypeInfo"));
  499. if(! m_bInitialized)
  500. return (sc = E_UNEXPECTED);
  501. ZeroMemory(&rvti, sizeof(rvti));
  502. rvti.pstrPersistableViewDescription = NULL;
  503. // must have a persistable description
  504. if (!IsPersistableViewDescriptionValid())
  505. return (sc = E_UNEXPECTED);
  506. rvti.pstrPersistableViewDescription = (LPOLESTR)
  507. CoTaskMemAlloc( (1 + wcslen(m_strPersistableViewDescription.data())) * sizeof(OLECHAR));
  508. sc = ScCheckPointers(rvti.pstrPersistableViewDescription, E_OUTOFMEMORY);
  509. if (sc)
  510. return sc;
  511. // copy over the description string.
  512. wcscpy(rvti.pstrPersistableViewDescription, m_strPersistableViewDescription.data());
  513. return (sc);
  514. }
  515. #endif _NODEMGR_DLL_
  516. #endif //_RESULTVIEW_H