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.

188 lines
6.6 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. XMLConfig.cpp
  5. Abstract:
  6. This file contains the implementation of the HelpHost::XMLConfig class.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 12/03/2000
  9. created
  10. ******************************************************************************/
  11. #include "stdafx.h"
  12. ////////////////////////////////////////////////////////////////////////////////
  13. CFG_BEGIN_FIELDS_MAP(HelpHost::XMLConfig::Context)
  14. CFG_ATTRIBUTE( L"ID" , BSTR, m_bstrID ),
  15. CFG_ELEMENT ( L"TaxonomyPath" , BSTR, m_bstrTaxonomyPath ),
  16. CFG_ELEMENT ( L"NodeToHighlight" , BSTR, m_bstrNodeToHighlight ),
  17. CFG_ELEMENT ( L"TopicToHighlight", BSTR, m_bstrTopicToHighlight),
  18. CFG_ELEMENT ( L"Query" , BSTR, m_bstrQuery ),
  19. CFG_END_FIELDS_MAP()
  20. CFG_BEGIN_CHILD_MAP(HelpHost::XMLConfig::Context)
  21. CFG_END_CHILD_MAP()
  22. DEFINE_CFG_OBJECT(HelpHost::XMLConfig::Context,L"Context")
  23. DEFINE_CONFIG_METHODS__NOCHILD(HelpHost::XMLConfig::Context)
  24. ////////////////////
  25. CFG_BEGIN_FIELDS_MAP(HelpHost::XMLConfig::WindowSettings)
  26. CFG_ATTRIBUTE__TRISTATE( L"NoResize" , bool, m_fNoResize , m_fPresence_NoResize ),
  27. CFG_ATTRIBUTE__TRISTATE( L"Maximized", bool, m_fMaximized, m_fPresence_Maximized ),
  28. CFG_ELEMENT__TRISTATE ( L"Title" , BSTR, m_bstrTitle , m_fPresence_Title ),
  29. CFG_ELEMENT__TRISTATE ( L"Left" , BSTR, m_bstrLeft , m_fPresence_Left ),
  30. CFG_ELEMENT__TRISTATE ( L"Top" , BSTR, m_bstrTop , m_fPresence_Top ),
  31. CFG_ELEMENT__TRISTATE ( L"Width" , BSTR, m_bstrWidth , m_fPresence_Width ),
  32. CFG_ELEMENT__TRISTATE ( L"Height" , BSTR, m_bstrHeight, m_fPresence_Height ),
  33. CFG_ELEMENT ( L"Layout" , BSTR, m_bstrLayout ),
  34. CFG_END_FIELDS_MAP()
  35. CFG_BEGIN_CHILD_MAP(HelpHost::XMLConfig::WindowSettings)
  36. CFG_END_CHILD_MAP()
  37. DEFINE_CFG_OBJECT(HelpHost::XMLConfig::WindowSettings,L"WindowSettings")
  38. DEFINE_CONFIG_METHODS__NOCHILD(HelpHost::XMLConfig::WindowSettings)
  39. ////////////////////
  40. CFG_BEGIN_FIELDS_MAP(HelpHost::XMLConfig::ApplyTo)
  41. CFG_ATTRIBUTE( L"SKU" , BSTR, m_bstrSKU ),
  42. CFG_ATTRIBUTE( L"Language" , BSTR, m_bstrLanguage ),
  43. CFG_ELEMENT ( L"TopicToDisplay", BSTR, m_bstrTopicToDisplay),
  44. CFG_ELEMENT ( L"Application" , BSTR, m_bstrApplication ),
  45. CFG_END_FIELDS_MAP()
  46. CFG_BEGIN_CHILD_MAP(HelpHost::XMLConfig::ApplyTo)
  47. CFG_CHILD(HelpHost::XMLConfig::WindowSettings)
  48. CFG_CHILD(HelpHost::XMLConfig::Context)
  49. CFG_END_CHILD_MAP()
  50. DEFINE_CFG_OBJECT(HelpHost::XMLConfig::ApplyTo,L"ApplyTo")
  51. DEFINE_CONFIG_METHODS_CREATEINSTANCE_SECTION(HelpHost::XMLConfig::ApplyTo,tag,defSubType)
  52. if(tag == _cfg_table_tags[0])
  53. {
  54. delete m_WindowSettings;
  55. m_WindowSettings = new WindowSettings; if(!m_WindowSettings) return E_OUTOFMEMORY;
  56. defSubType = m_WindowSettings;
  57. return S_OK;
  58. }
  59. if(tag == _cfg_table_tags[1])
  60. {
  61. delete m_Context;
  62. m_Context = new Context; if(!m_Context) return E_OUTOFMEMORY;
  63. defSubType = m_Context;
  64. return S_OK;
  65. }
  66. DEFINE_CONFIG_METHODS_SAVENODE_SECTION(HelpHost::XMLConfig::ApplyTo,xdn)
  67. if(m_WindowSettings)
  68. {
  69. if(FAILED(hr = MPC::Config::SaveSubNode( m_WindowSettings, xdn ))) return hr;
  70. }
  71. if(m_Context)
  72. {
  73. if(FAILED(hr = MPC::Config::SaveSubNode( m_Context, xdn ))) return hr;
  74. }
  75. DEFINE_CONFIG_METHODS_END(HelpHost::XMLConfig::ApplyTo)
  76. ////////////////////
  77. CFG_BEGIN_FIELDS_MAP(HelpHost::XMLConfig)
  78. CFG_END_FIELDS_MAP()
  79. CFG_BEGIN_CHILD_MAP(HelpHost::XMLConfig)
  80. CFG_CHILD(HelpHost::XMLConfig::ApplyTo)
  81. CFG_END_CHILD_MAP()
  82. DEFINE_CFG_OBJECT(HelpHost::XMLConfig,L"HelpSession")
  83. DEFINE_CONFIG_METHODS_CREATEINSTANCE_SECTION(HelpHost::XMLConfig,tag,defSubType)
  84. if(tag == _cfg_table_tags[0])
  85. {
  86. defSubType = &(*(m_lstSessions.insert( m_lstSessions.end() )));
  87. return S_OK;
  88. }
  89. DEFINE_CONFIG_METHODS_SAVENODE_SECTION(HelpHost::XMLConfig,xdn)
  90. hr = MPC::Config::SaveList( m_lstSessions, xdn );
  91. DEFINE_CONFIG_METHODS_END(HelpHost::XMLConfig)
  92. ////////////////////////////////////////////////////////////////////////////////
  93. HelpHost::XMLConfig::Context::Context()
  94. {
  95. // CComBSTR m_bstrID;
  96. //
  97. // CComBSTR m_bstrTaxonomyPath;
  98. // CComBSTR m_bstrNodeToHighlight;
  99. // CComBSTR m_bstrTopicToHighlight;
  100. // CComBSTR m_bstrQuery;
  101. }
  102. ////////////////////////////////////////////////////////////////////////////////
  103. HelpHost::XMLConfig::WindowSettings::WindowSettings()
  104. {
  105. // CComBSTR m_bstrLayout;
  106. m_fNoResize = false; m_fPresence_NoResize = false; // bool m_fNoResize ; bool m_fPresence_NoResize;
  107. m_fMaximized = false; m_fPresence_Maximized = false; // bool m_fMaximized; bool m_fPresence_Maximized;
  108. m_fPresence_Title = false; // CComBSTR m_bstrTitle ; bool m_fPresence_Title;
  109. m_fPresence_Left = false; // CComBSTR m_bstrLeft ; bool m_fPresence_Left;
  110. m_fPresence_Top = false; // CComBSTR m_bstrTop ; bool m_fPresence_Top;
  111. m_fPresence_Width = false; // CComBSTR m_bstrWidth ; bool m_fPresence_Width;
  112. m_fPresence_Height = false; // CComBSTR m_bstrHeight; bool m_fPresence_Height;
  113. }
  114. ////////////////////////////////////////////////////////////////////////////////
  115. HelpHost::XMLConfig::ApplyTo::ApplyTo()
  116. {
  117. // CComBSTR m_bstrSKU;
  118. // CComBSTR m_bstrLanguage;
  119. //
  120. // CComBSTR m_bstrTopicToDisplay;
  121. // CComBSTR m_bstrApplication;
  122. m_WindowSettings = NULL; // WindowSettings* m_WindowSettings;
  123. m_Context = NULL; // Context* m_Context;
  124. }
  125. HelpHost::XMLConfig::ApplyTo::~ApplyTo()
  126. {
  127. delete m_WindowSettings;
  128. delete m_Context;
  129. }
  130. bool HelpHost::XMLConfig::ApplyTo::MatchSystem( /*[in]*/ CPCHHelpCenterExternal* external ,
  131. /*[out]*/ Taxonomy::HelpSet& ths )
  132. {
  133. if(OfflineCache::Root::s_GLOBAL->IsReady())
  134. {
  135. if(SUCCEEDED(OfflineCache::Root::s_GLOBAL->FindMatch( m_bstrSKU, m_bstrLanguage, ths )))
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. ////////////////////////////////////////////////////////////////////////////////