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.

951 lines
31 KiB

  1. VERSION 1.0 CLASS
  2. BEGIN
  3. MultiUse = -1 'True
  4. Persistable = 0 'NotPersistable
  5. DataBindingBehavior = 0 'vbNone
  6. DataSourceBehavior = 0 'vbNone
  7. MTSTransactionMode = 0 'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "HHT"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"No"
  16. Option Explicit
  17. Private WithEvents p_clsTaxonomy As Taxonomy
  18. Attribute p_clsTaxonomy.VB_VarHelpID = -1
  19. Private p_clsKeywords As Keywords
  20. Private p_clsStopSigns As StopSigns
  21. Private p_clsStopWords As StopWords
  22. Private Const LCID_ENGLISH As Long = 1033
  23. Private Const PACKAGE_DESCRIPTION As String = "package_description.xml"
  24. Private Const CHQ_C As String = ".chq"
  25. Private Const CHM_C As String = ".chm"
  26. Private Const HHK_C As String = ".hhk"
  27. Public Event ReportStatus(ByVal strStatus As String, ByRef blnCancel As Boolean)
  28. Private Sub Class_Initialize()
  29. Set p_clsTaxonomy = New Taxonomy
  30. Set p_clsKeywords = New Keywords
  31. Set p_clsStopSigns = New StopSigns
  32. Set p_clsStopWords = New StopWords
  33. End Sub
  34. Private Sub Class_Terminate()
  35. Set p_clsTaxonomy = Nothing
  36. Set p_clsKeywords = Nothing
  37. Set p_clsStopSigns = Nothing
  38. Set p_clsStopWords = Nothing
  39. End Sub
  40. Public Sub GenerateCAB( _
  41. ByVal i_strFileName As String, _
  42. ByVal i_intSKU As Long _
  43. )
  44. Dim FSO As Scripting.FileSystemObject
  45. Dim WS As IWshShell
  46. Dim TSPackage As Scripting.TextStream
  47. Dim strTempDir As String
  48. Dim strHHTFileName As String
  49. Dim strPackage As String
  50. Dim strCmd As String
  51. Dim enumSKU As SKU_E
  52. Set FSO = New Scripting.FileSystemObject
  53. Set WS = CreateObject("Wscript.Shell")
  54. strTempDir = Environ$("TEMP") & "\__HSCCAB"
  55. If (FSO.FolderExists(strTempDir)) Then
  56. FSO.DeleteFolder strTempDir, Force:=True
  57. End If
  58. FSO.CreateFolder strTempDir
  59. strHHTFileName = XmlSKU(i_intSKU) & ".hht"
  60. GenerateHHT strTempDir & "\" & strHHTFileName, i_intSKU
  61. strPackage = strTempDir & "\" & PACKAGE_DESCRIPTION
  62. Set TSPackage = FSO.CreateTextFile(strPackage, Overwrite:=True, Unicode:=True)
  63. enumSKU = i_intSKU
  64. p_GeneratePackageDescription TSPackage, enumSKU, strHHTFileName
  65. Set TSPackage = Nothing ' Required for cabarc to work
  66. p_RaiseEventAndLookForCancel "CAB'ing the files."
  67. strCmd = "cabarc -r -s 6144 n """ & i_strFileName & """ " & strTempDir & "\*"
  68. WS.Run strCmd, , True
  69. End Sub
  70. Public Sub GenerateHHT( _
  71. ByVal i_strFileName As String, _
  72. ByVal i_intSKU As Long _
  73. )
  74. Dim FSO As Scripting.FileSystemObject
  75. Dim TS As Scripting.TextStream
  76. Dim colKeywords As Collection
  77. Dim intAG As Long
  78. Dim enumSKU As SKU_E
  79. Dim DOMNode As MSXML2.IXMLDOMNode
  80. Dim DOMNodeEntries As MSXML2.IXMLDOMNode
  81. Dim DOMNodeRoot As MSXML2.IXMLDOMNode
  82. Set FSO = New Scripting.FileSystemObject
  83. Set TS = FSO.CreateTextFile(i_strFileName, Unicode:=True)
  84. Set colKeywords = New Collection
  85. enumSKU = i_intSKU
  86. p_OutputHHTProlog TS, enumSKU
  87. intAG = g_clsParameters.AuthoringGroup
  88. If (intAG > AG_CORE_MAX_C) Then
  89. Set DOMNode = GenerateHHTForAuthoringGroup(i_intSKU)
  90. Set DOMNode = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRIES_C)
  91. p_RemoveUnnecessaryAttributes DOMNode
  92. TS.WriteLine DOMNode.XML
  93. Else
  94. p_clsKeywords.GetAllKeywordsColl colKeywords
  95. Set DOMNode = p_clsTaxonomy.GetTaxonomyInXml
  96. Set DOMNodeEntries = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRIES_C)
  97. Set DOMNodeRoot = XMLFindFirstNode(DOMNodeEntries, HHT_TAXONOMY_ENTRY_C)
  98. p_clsTaxonomy.TransformHHTTov10 DOMNodeRoot, colKeywords, "", _
  99. ALL_SKUS_C, DOMNodeEntries, i_intSKU, False
  100. p_RemoveUnnecessaryAttributes DOMNodeEntries
  101. TS.WriteLine DOMNodeEntries.XML
  102. End If
  103. TS.WriteLine g_clsParameters.DomFragmentHHT(i_intSKU)
  104. If (intAG <= AG_CORE_MAX_C) Then
  105. If (i_intSKU <> SKU_WINDOWS_MILLENNIUM_E) Then
  106. p_OutputStopSigns TS
  107. p_OutputStopWords TS
  108. p_OutputSynonyms TS
  109. End If
  110. p_OutputOperators TS
  111. End If
  112. p_PrintWithIndentation TS, 0, "</METADATA>"
  113. End Sub
  114. Private Sub p_RemoveUnnecessaryAttributes( _
  115. ByRef u_DOMNode As MSXML2.IXMLDOMNode _
  116. )
  117. Dim Element As MSXML2.IXMLDOMElement
  118. For Each Element In u_DOMNode.childNodes
  119. If (XMLGetAttribute(Element, HHT_URI_C) = "") Then
  120. Element.removeAttribute HHT_URI_C
  121. End If
  122. If (XMLGetAttribute(Element, HHT_ICONURI_C) = "") Then
  123. Element.removeAttribute HHT_ICONURI_C
  124. End If
  125. If (XMLGetAttribute(Element, HHT_DESCRIPTION_C) = "") Then
  126. Element.removeAttribute HHT_DESCRIPTION_C
  127. End If
  128. If (XMLGetAttribute(Element, HHT_VISIBLE_C) = "True") Then
  129. Element.removeAttribute HHT_VISIBLE_C
  130. End If
  131. If (XMLGetAttribute(Element, HHT_SUBSITE_C) = "False") Then
  132. Element.removeAttribute HHT_SUBSITE_C
  133. End If
  134. If (XMLGetAttribute(Element, HHT_NAVIGATIONMODEL_C) = "Default") Then
  135. Element.removeAttribute HHT_NAVIGATIONMODEL_C
  136. End If
  137. Next
  138. End Sub
  139. Private Function p_GetAllowedSKUs( _
  140. ByRef i_DOMNode As MSXML2.IXMLDOMNode _
  141. ) As SKU_E
  142. Dim DOMNode As MSXML2.IXMLDOMNode
  143. Dim DOMNodeParent As MSXML2.IXMLDOMNode
  144. Dim intTID As Long
  145. Dim enumParentAllowedSKUs As SKU_E
  146. Dim enumParentSKUs As SKU_E
  147. p_GetAllowedSKUs = ALL_SKUS_C
  148. If (i_DOMNode.nodeName <> HHT_TAXONOMY_ENTRY_C) Then
  149. Exit Function
  150. End If
  151. intTID = XMLGetAttribute(i_DOMNode, HHT_tid_C)
  152. If (intTID = ROOT_TID_C) Then
  153. Exit Function
  154. End If
  155. Set DOMNodeParent = i_DOMNode.parentNode
  156. If (DOMNodeParent Is Nothing) Then
  157. Exit Function
  158. End If
  159. enumParentAllowedSKUs = p_GetAllowedSKUs(DOMNodeParent)
  160. enumParentSKUs = XMLGetAttribute(DOMNodeParent, HHT_skus_C)
  161. p_GetAllowedSKUs = enumParentAllowedSKUs And enumParentSKUs
  162. End Function
  163. Private Sub p_AddDBParameters( _
  164. ByRef i_DOMDoc As MSXML2.DOMDocument, _
  165. ByRef u_DOMNode As MSXML2.IXMLDOMNode _
  166. )
  167. Dim Element As MSXML2.IXMLDOMElement
  168. Dim DOMNodeParameters As MSXML2.IXMLDOMNode
  169. Dim DOMNodeParameter As MSXML2.IXMLDOMNode
  170. Dim arrNames() As String
  171. Dim strName As String
  172. Dim vntValue As Variant
  173. Dim intIndex As Long
  174. Set Element = i_DOMDoc.createElement(HHT_dbparameters_C)
  175. Set DOMNodeParameters = u_DOMNode.appendChild(Element)
  176. ReDim arrNames(55)
  177. arrNames(0) = MINIMUM_KEYWORD_VALIDATION_C
  178. arrNames(1) = VENDOR_STRING_C
  179. arrNames(2) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_STANDARD_E)
  180. arrNames(3) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_PROFESSIONAL_E)
  181. arrNames(4) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_SERVER_E)
  182. arrNames(5) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_ADVANCED_SERVER_E)
  183. arrNames(6) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_DATA_CENTER_SERVER_E)
  184. arrNames(7) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_PROFESSIONAL_64_E)
  185. arrNames(8) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_ADVANCED_SERVER_64_E)
  186. arrNames(9) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  187. arrNames(10) = BROKEN_LINK_WORKING_DIR_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  188. arrNames(11) = PRODUCT_ID_C & Hex(SKU_STANDARD_E)
  189. arrNames(12) = PRODUCT_ID_C & Hex(SKU_PROFESSIONAL_E)
  190. arrNames(13) = PRODUCT_ID_C & Hex(SKU_SERVER_E)
  191. arrNames(14) = PRODUCT_ID_C & Hex(SKU_ADVANCED_SERVER_E)
  192. arrNames(15) = PRODUCT_ID_C & Hex(SKU_DATA_CENTER_SERVER_E)
  193. arrNames(16) = PRODUCT_ID_C & Hex(SKU_PROFESSIONAL_64_E)
  194. arrNames(17) = PRODUCT_ID_C & Hex(SKU_ADVANCED_SERVER_64_E)
  195. arrNames(18) = PRODUCT_ID_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  196. arrNames(19) = PRODUCT_ID_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  197. arrNames(20) = PRODUCT_VERSION_C & Hex(SKU_STANDARD_E)
  198. arrNames(21) = PRODUCT_VERSION_C & Hex(SKU_PROFESSIONAL_E)
  199. arrNames(22) = PRODUCT_VERSION_C & Hex(SKU_SERVER_E)
  200. arrNames(23) = PRODUCT_VERSION_C & Hex(SKU_ADVANCED_SERVER_E)
  201. arrNames(24) = PRODUCT_VERSION_C & Hex(SKU_DATA_CENTER_SERVER_E)
  202. arrNames(25) = PRODUCT_VERSION_C & Hex(SKU_PROFESSIONAL_64_E)
  203. arrNames(26) = PRODUCT_VERSION_C & Hex(SKU_ADVANCED_SERVER_64_E)
  204. arrNames(27) = PRODUCT_VERSION_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  205. arrNames(28) = PRODUCT_VERSION_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  206. arrNames(29) = DISPLAY_NAME_C & Hex(SKU_STANDARD_E)
  207. arrNames(30) = DISPLAY_NAME_C & Hex(SKU_PROFESSIONAL_E)
  208. arrNames(31) = DISPLAY_NAME_C & Hex(SKU_SERVER_E)
  209. arrNames(32) = DISPLAY_NAME_C & Hex(SKU_ADVANCED_SERVER_E)
  210. arrNames(33) = DISPLAY_NAME_C & Hex(SKU_DATA_CENTER_SERVER_E)
  211. arrNames(34) = DISPLAY_NAME_C & Hex(SKU_PROFESSIONAL_64_E)
  212. arrNames(35) = DISPLAY_NAME_C & Hex(SKU_ADVANCED_SERVER_64_E)
  213. arrNames(36) = DISPLAY_NAME_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  214. arrNames(37) = DISPLAY_NAME_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  215. arrNames(38) = DOM_FRAGMENT_PKG_C & Hex(SKU_STANDARD_E)
  216. arrNames(39) = DOM_FRAGMENT_PKG_C & Hex(SKU_PROFESSIONAL_E)
  217. arrNames(40) = DOM_FRAGMENT_PKG_C & Hex(SKU_SERVER_E)
  218. arrNames(41) = DOM_FRAGMENT_PKG_C & Hex(SKU_ADVANCED_SERVER_E)
  219. arrNames(42) = DOM_FRAGMENT_PKG_C & Hex(SKU_DATA_CENTER_SERVER_E)
  220. arrNames(43) = DOM_FRAGMENT_PKG_C & Hex(SKU_PROFESSIONAL_64_E)
  221. arrNames(44) = DOM_FRAGMENT_PKG_C & Hex(SKU_ADVANCED_SERVER_64_E)
  222. arrNames(45) = DOM_FRAGMENT_PKG_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  223. arrNames(46) = DOM_FRAGMENT_PKG_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  224. arrNames(47) = DOM_FRAGMENT_HHT_C & Hex(SKU_STANDARD_E)
  225. arrNames(48) = DOM_FRAGMENT_HHT_C & Hex(SKU_PROFESSIONAL_E)
  226. arrNames(49) = DOM_FRAGMENT_HHT_C & Hex(SKU_SERVER_E)
  227. arrNames(50) = DOM_FRAGMENT_HHT_C & Hex(SKU_ADVANCED_SERVER_E)
  228. arrNames(51) = DOM_FRAGMENT_HHT_C & Hex(SKU_DATA_CENTER_SERVER_E)
  229. arrNames(52) = DOM_FRAGMENT_HHT_C & Hex(SKU_PROFESSIONAL_64_E)
  230. arrNames(53) = DOM_FRAGMENT_HHT_C & Hex(SKU_ADVANCED_SERVER_64_E)
  231. arrNames(54) = DOM_FRAGMENT_HHT_C & Hex(SKU_DATA_CENTER_SERVER_64_E)
  232. arrNames(55) = DOM_FRAGMENT_HHT_C & Hex(SKU_WINDOWS_MILLENNIUM_E)
  233. For intIndex = LBound(arrNames) To UBound(arrNames)
  234. strName = arrNames(intIndex)
  235. vntValue = g_clsParameters.Value(strName)
  236. If (Not IsNull(vntValue)) Then
  237. Set Element = i_DOMDoc.createElement(HHT_dbparameter_C)
  238. Set DOMNodeParameter = DOMNodeParameters.appendChild(Element)
  239. XMLSetAttribute DOMNodeParameter, HHT_name_C, strName
  240. XMLSetAttribute DOMNodeParameter, HHT_value_C, XMLEscape(vntValue)
  241. End If
  242. Next
  243. End Sub
  244. Private Function p_GetHHTForAuthoringGroup( _
  245. ByRef i_DOMNode As MSXML2.IXMLDOMNode, _
  246. ByRef i_colKeywords As Collection, _
  247. ByVal i_intAuthoringGroup As Long, _
  248. ByVal i_intAllowedSKUs As Long _
  249. ) As MSXML2.IXMLDOMNode
  250. Dim DOMDoc As MSXML2.DOMDocument
  251. Dim DOMNode As MSXML2.IXMLDOMNode
  252. Dim DOMNodeParent As MSXML2.IXMLDOMNode
  253. Dim DOMElement As MSXML2.IXMLDOMElement
  254. Dim strCategory As String
  255. Dim intAllowedSKUs As Long
  256. Dim intAuthoringGroup As Long
  257. Set DOMDoc = New MSXML2.DOMDocument
  258. Set DOMNode = HhtPreamble(DOMDoc, True)
  259. XMLCopyDOMTree i_DOMNode, DOMNode
  260. p_RaiseEventAndLookForCancel "Saving database parameters..."
  261. Set DOMNode = DOMNode.parentNode
  262. p_AddDBParameters DOMDoc, DOMNode
  263. Set DOMNode = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRY_C)
  264. Set DOMNodeParent = DOMNode.parentNode
  265. strCategory = p_clsTaxonomy.GetCategory(i_DOMNode)
  266. intAllowedSKUs = p_GetAllowedSKUs(i_DOMNode)
  267. p_RaiseEventAndLookForCancel "Flattening HHT..."
  268. p_clsTaxonomy.TransformHHTTov10 DOMNode, i_colKeywords, strCategory, _
  269. intAllowedSKUs, DOMNodeParent, i_intAllowedSKUs, True
  270. For Each DOMNode In DOMNodeParent.childNodes
  271. p_RaiseEventAndLookForCancel "Processing title: " & _
  272. XMLGetAttribute(DOMNode, HHT_TITLE_C)
  273. intAuthoringGroup = XMLGetAttribute(DOMNode, HHT_authoringgroup_C)
  274. If (intAuthoringGroup <> i_intAuthoringGroup) Then
  275. DOMNodeParent.removeChild DOMNode
  276. Else
  277. Set DOMElement = DOMNode
  278. DOMElement.removeAttribute HHT_authoringgroup_C
  279. If (i_intAllowedSKUs = SKU_WINDOWS_MILLENNIUM_E) Then
  280. DOMElement.removeAttribute HHT_ICONURI_C
  281. DOMElement.removeAttribute HHT_VISIBLE_C
  282. DOMElement.removeAttribute HHT_INSERTMODE_C
  283. DOMElement.removeAttribute HHT_INSERTLOCATION_C
  284. DOMElement.removeAttribute HHT_SUBSITE_C
  285. DOMElement.removeAttribute HHT_NAVIGATIONMODEL_C
  286. End If
  287. End If
  288. Next
  289. Set p_GetHHTForAuthoringGroup = DOMDoc
  290. End Function
  291. Public Sub ExportHHT( _
  292. ByVal i_strFileName As String, _
  293. Optional ByVal i_intAuthoringGroup As Long = INVALID_ID_C _
  294. )
  295. Dim DOMNode As MSXML2.IXMLDOMNode
  296. Dim colKeywords As Collection
  297. Dim intAG As Long
  298. Set DOMNode = p_clsTaxonomy.GetTaxonomyInXml
  299. p_RaiseEventAndLookForCancel "Reading keywords..."
  300. Set colKeywords = New Collection
  301. p_clsKeywords.GetAllKeywordsColl colKeywords
  302. If (i_intAuthoringGroup = INVALID_ID_C) Then
  303. intAG = g_clsParameters.AuthoringGroup
  304. Else
  305. intAG = i_intAuthoringGroup
  306. End If
  307. Set DOMNode = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRY_C)
  308. Set DOMNode = p_GetHHTForAuthoringGroup(DOMNode, colKeywords, intAG, ALL_SKUS_C)
  309. FileWrite i_strFileName, DOMNode.XML, False, True
  310. End Sub
  311. Public Function GenerateHHTForAuthoringGroup( _
  312. ByVal i_intSKU As Long _
  313. ) As MSXML2.IXMLDOMNode
  314. Dim DOMNode As MSXML2.IXMLDOMNode
  315. Dim DOMNodeEntries As MSXML2.IXMLDOMNode
  316. Dim DOMNodeChild As MSXML2.IXMLDOMNode
  317. Dim DOMElement As MSXML2.IXMLDOMElement
  318. Dim colKeywords As Collection
  319. Dim intAG As Long
  320. Set DOMNode = p_clsTaxonomy.GetTaxonomyInXml
  321. Set colKeywords = New Collection
  322. p_clsKeywords.GetAllKeywordsColl colKeywords
  323. intAG = g_clsParameters.AuthoringGroup
  324. Set DOMNode = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRY_C)
  325. Set DOMNode = p_GetHHTForAuthoringGroup(DOMNode, colKeywords, intAG, i_intSKU)
  326. Set DOMNodeEntries = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRIES_C)
  327. For Each DOMNodeChild In DOMNodeEntries.childNodes
  328. Set DOMElement = DOMNodeChild
  329. DOMElement.removeAttribute HHT_skus_C
  330. Next
  331. Set GenerateHHTForAuthoringGroup = DOMNode
  332. End Function
  333. Private Function p_GetOrphanedNodesTopics( _
  334. ByRef u_DOMNodeMain As MSXML2.IXMLDOMNode, _
  335. ByVal i_intAuthoringGroup As Long _
  336. ) As MSXML2.IXMLDOMNode
  337. Dim DOMNode As MSXML2.IXMLDOMNode
  338. Dim DOMDoc As MSXML2.DOMDocument
  339. Dim DOMNodeNew As MSXML2.IXMLDOMNode
  340. Dim strTitle As String
  341. Dim blnLeaf As Boolean
  342. For Each DOMNode In u_DOMNodeMain.childNodes
  343. strTitle = XMLGetAttribute(DOMNode, HHT_TITLE_C)
  344. blnLeaf = XMLGetAttribute(DOMNode, HHT_leaf_C)
  345. If ((strTitle = NODE_FOR_ORPHANS_C) And (Not blnLeaf)) Then
  346. Set p_GetOrphanedNodesTopics = DOMNode
  347. Exit Function
  348. End If
  349. Next
  350. Set DOMDoc = u_DOMNodeMain.ownerDocument
  351. p_clsTaxonomy.CreateFast NODE_FOR_ORPHANS_C, "", 0, NAVMODEL_DEFAULT_NUM_C, _
  352. "", "", ALL_SKUS_C, False, _
  353. ROOT_TID_C, LOC_INCLUDE_ALL_C, False, False, "", "", "", "", _
  354. DOMDoc, DOMNodeNew, i_intAuthoringGroup
  355. u_DOMNodeMain.appendChild DOMNodeNew
  356. Set p_GetOrphanedNodesTopics = DOMNodeNew
  357. End Function
  358. Private Function p_GetCategoryNode( _
  359. ByRef u_DOMNodeMain As MSXML2.IXMLDOMNode, _
  360. ByRef i_strCategory As String, _
  361. ByVal i_enumSKUs As SKU_E, _
  362. ByRef u_DOMNodeOrphans As MSXML2.IXMLDOMNode, _
  363. ByVal i_intAuthoringGroup As Long _
  364. ) As MSXML2.IXMLDOMNode
  365. Dim DOMDoc As MSXML2.DOMDocument
  366. Dim DOMNodeList As MSXML2.IXMLDOMNodeList
  367. Dim DOMNode As MSXML2.IXMLDOMNode
  368. Dim DOMNodeNew As MSXML2.IXMLDOMNode
  369. Dim intIndex As Long
  370. Dim strQuery As String
  371. Dim enumSKUs As SKU_E
  372. Dim intTIDOrphans As Long
  373. strQuery = "descendant::TAXONOMY_ENTRY["
  374. strQuery = strQuery & "attribute::" & HHT_category2_C & "=""" & i_strCategory & """]"
  375. Set DOMDoc = u_DOMNodeMain.ownerDocument
  376. DOMDoc.setProperty "SelectionLanguage", "XPath"
  377. Set DOMNodeList = u_DOMNodeMain.selectNodes(strQuery)
  378. For intIndex = 0 To DOMNodeList.length - 1
  379. Set DOMNode = DOMNodeList(intIndex)
  380. enumSKUs = XMLGetAttribute(DOMNode, HHT_skus_C)
  381. If ((enumSKUs And i_enumSKUs) <> 0) Then
  382. Set p_GetCategoryNode = DOMNode
  383. Exit Function
  384. End If
  385. Next
  386. If (u_DOMNodeOrphans Is Nothing) Then
  387. Set u_DOMNodeOrphans = p_GetOrphanedNodesTopics(u_DOMNodeMain, i_intAuthoringGroup)
  388. End If
  389. intTIDOrphans = XMLGetAttribute(u_DOMNodeOrphans, HHT_tid_C)
  390. p_clsTaxonomy.CreateFast i_strCategory, "", 0, NAVMODEL_DEFAULT_NUM_C, _
  391. "", "", i_enumSKUs, False, _
  392. intTIDOrphans, LOC_INCLUDE_ALL_C, True, False, "", "", "", "", _
  393. DOMDoc, DOMNodeNew, i_intAuthoringGroup
  394. XMLSetAttribute DOMNodeNew, HHT_category2_C, i_strCategory
  395. u_DOMNodeOrphans.appendChild DOMNodeNew
  396. Set p_GetCategoryNode = DOMNodeNew
  397. End Function
  398. Private Sub p_GetBeforeAndAfterNodes( _
  399. ByRef i_DOMNodeCategory As MSXML2.IXMLDOMNode, _
  400. ByRef i_strInsertMode As String, _
  401. ByRef i_strInsertLocation As String, _
  402. ByRef o_DOMNodeBefore As MSXML2.IXMLDOMNode, _
  403. ByRef o_DOMNodeAfter As MSXML2.IXMLDOMNode _
  404. )
  405. Dim DOMNode As MSXML2.IXMLDOMNode
  406. Dim strAttribute As String
  407. Dim str As String
  408. Select Case i_strInsertMode
  409. Case HHTVAL_TOP_C
  410. Set o_DOMNodeBefore = Nothing
  411. Set o_DOMNodeAfter = i_DOMNodeCategory.firstChild
  412. Case HHTVAL_AFTER_NODE_C, HHTVAL_AFTER_TOPIC_C
  413. If (i_strInsertMode = HHTVAL_AFTER_NODE_C) Then
  414. strAttribute = HHT_ENTRY_C
  415. Else
  416. strAttribute = HHT_URI_C
  417. End If
  418. For Each DOMNode In i_DOMNodeCategory.childNodes
  419. str = XMLGetAttribute(DOMNode, strAttribute)
  420. If (str = i_strInsertLocation) Then
  421. Set o_DOMNodeBefore = DOMNode
  422. Set o_DOMNodeAfter = DOMNode.nextSibling
  423. End If
  424. Next
  425. Case Else
  426. Set o_DOMNodeBefore = Nothing
  427. Set o_DOMNodeAfter = Nothing
  428. End Select
  429. End Sub
  430. Private Function p_CreateKeyword( _
  431. ByRef i_strKeyword As String _
  432. ) As Long
  433. On Error GoTo LErrorHandler
  434. p_CreateKeyword = p_clsKeywords.Create(i_strKeyword)
  435. Exit Function
  436. LErrorHandler:
  437. p_CreateKeyword = INVALID_ID_C
  438. End Function
  439. Private Function p_GetKID( _
  440. ByRef i_strKeyword As String, _
  441. ByRef u_dictKeywords As Scripting.Dictionary _
  442. ) As String
  443. Dim intKID As Long
  444. If (u_dictKeywords.Exists(i_strKeyword)) Then
  445. p_GetKID = u_dictKeywords(i_strKeyword)
  446. Else
  447. intKID = p_CreateKeyword(i_strKeyword)
  448. If (intKID <> INVALID_ID_C) Then
  449. u_dictKeywords.Add i_strKeyword, intKID
  450. p_GetKID = intKID
  451. End If
  452. End If
  453. End Function
  454. Private Function p_GetKeywords( _
  455. ByRef i_DOMNodeHHT As MSXML2.IXMLDOMNode, _
  456. ByRef u_dictKeywords As Scripting.Dictionary _
  457. ) As String
  458. Dim DOMNode As MSXML2.IXMLDOMNode
  459. If (Not i_DOMNodeHHT.firstChild Is Nothing) Then
  460. For Each DOMNode In i_DOMNodeHHT.childNodes
  461. p_GetKeywords = p_GetKeywords & p_GetKID(DOMNode.Text, u_dictKeywords) & " "
  462. Next
  463. p_GetKeywords = FormatKeywordsForTaxonomy(p_GetKeywords)
  464. End If
  465. End Function
  466. Private Sub p_CreateTaxonomyEntry( _
  467. ByRef i_DOMNodeHHT As MSXML2.IXMLDOMNode, _
  468. ByRef u_DOMNodeMain As MSXML2.IXMLDOMNode, _
  469. ByRef u_dictKeywords As Scripting.Dictionary, _
  470. ByRef u_DOMNodeOrphans As MSXML2.IXMLDOMNode, _
  471. ByVal i_intAuthoringGroup As Long _
  472. )
  473. Dim strCategory As String
  474. Dim enumSKUs As SKU_E
  475. Dim DOMNodeCategory As MSXML2.IXMLDOMNode
  476. Dim DOMDoc As MSXML2.DOMDocument
  477. Dim DOMNodeNew As MSXML2.IXMLDOMNode
  478. Dim DOMNodeBefore As MSXML2.IXMLDOMNode
  479. Dim DOMNodeAfter As MSXML2.IXMLDOMNode
  480. Dim strTitle As String
  481. Dim strURI As String
  482. Dim strIconURI As String
  483. Dim strDescription As String
  484. Dim intType As Long
  485. Dim intNavModel As Long
  486. Dim blnVisible As Boolean
  487. Dim blnSubSite As Boolean
  488. Dim strEntry As String
  489. Dim blnLeaf As Boolean
  490. Dim intParentTID As Long
  491. Dim strInsertMode As String
  492. Dim strInsertLocation As String
  493. Dim intTID As Long
  494. Dim intRefTID As Long
  495. Dim intOrderUnderParent As Long
  496. Dim strKeywords As String
  497. strCategory = XMLGetAttribute(i_DOMNodeHHT, HHT_CATEGORY_C)
  498. enumSKUs = XMLGetAttribute(i_DOMNodeHHT, HHT_skus_C)
  499. If (Len(strCategory) = 0) Then
  500. Set DOMNodeCategory = u_DOMNodeMain
  501. Else
  502. Set DOMNodeCategory = p_GetCategoryNode(u_DOMNodeMain, strCategory, _
  503. enumSKUs, u_DOMNodeOrphans, i_intAuthoringGroup)
  504. End If
  505. strTitle = XMLGetAttribute(i_DOMNodeHHT, HHT_TITLE_C)
  506. p_RaiseEventAndLookForCancel "Creating " & strTitle
  507. strURI = XMLGetAttribute(i_DOMNodeHHT, HHT_URI_C)
  508. strIconURI = XMLGetAttribute(i_DOMNodeHHT, HHT_ICONURI_C)
  509. strDescription = XMLGetAttribute(i_DOMNodeHHT, HHT_DESCRIPTION_C)
  510. intType = XMLGetAttribute(i_DOMNodeHHT, HHT_TYPE_C)
  511. intNavModel = NavModelNumber(XMLGetAttribute(i_DOMNodeHHT, HHT_NAVIGATIONMODEL_C))
  512. blnVisible = XMLGetAttribute(i_DOMNodeHHT, HHT_VISIBLE_C)
  513. blnSubSite = XMLGetAttribute(i_DOMNodeHHT, HHT_SUBSITE_C)
  514. strEntry = XMLGetAttribute(i_DOMNodeHHT, HHT_ENTRY_C)
  515. If (Len(strEntry) = 0) Then
  516. blnLeaf = True
  517. End If
  518. intParentTID = XMLGetAttribute(DOMNodeCategory, HHT_tid_C)
  519. Set DOMDoc = u_DOMNodeMain.ownerDocument
  520. strKeywords = p_GetKeywords(i_DOMNodeHHT, u_dictKeywords)
  521. p_clsTaxonomy.CreateFast strTitle, strDescription, intType, intNavModel, strURI, strIconURI, _
  522. enumSKUs, blnLeaf, intParentTID, LOC_INCLUDE_ALL_C, blnVisible, blnSubSite, _
  523. strKeywords, "", "", strEntry, DOMDoc, DOMNodeNew, i_intAuthoringGroup
  524. p_clsTaxonomy.SetCategory2AndEntry DOMNodeNew, strCategory
  525. strInsertMode = XMLGetAttribute(i_DOMNodeHHT, HHT_INSERTMODE_C)
  526. strInsertLocation = XMLGetAttribute(i_DOMNodeHHT, HHT_INSERTLOCATION_C)
  527. p_GetBeforeAndAfterNodes DOMNodeCategory, strInsertMode, strInsertLocation, _
  528. DOMNodeBefore, DOMNodeAfter
  529. intTID = XMLGetAttribute(DOMNodeNew, HHT_tid_C)
  530. If (Not DOMNodeBefore Is Nothing) Then
  531. intRefTID = XMLGetAttribute(DOMNodeBefore, HHT_tid_C)
  532. p_clsTaxonomy.Move intTID, intRefTID, False, 0, intOrderUnderParent
  533. If (DOMNodeAfter Is Nothing) Then
  534. DOMNodeCategory.appendChild DOMNodeNew
  535. Else
  536. DOMNodeCategory.insertBefore DOMNodeNew, DOMNodeAfter
  537. End If
  538. ElseIf (Not DOMNodeAfter Is Nothing) Then
  539. intRefTID = XMLGetAttribute(DOMNodeAfter, HHT_tid_C)
  540. p_clsTaxonomy.Move intTID, intRefTID, True, 0, intOrderUnderParent
  541. DOMNodeCategory.insertBefore DOMNodeNew, DOMNodeAfter
  542. Else
  543. DOMNodeCategory.appendChild DOMNodeNew
  544. End If
  545. End Sub
  546. Private Sub p_RestoreDBParameters( _
  547. ByRef i_DOMNode As MSXML2.IXMLDOMNode _
  548. )
  549. Dim DOMNode As MSXML2.IXMLDOMNode
  550. Dim strName As String
  551. Dim strValue As String
  552. If (i_DOMNode Is Nothing) Then
  553. Exit Sub
  554. End If
  555. For Each DOMNode In i_DOMNode.childNodes
  556. strName = XMLGetAttribute(DOMNode, HHT_name_C)
  557. strValue = XMLGetAttribute(DOMNode, HHT_value_C)
  558. g_clsParameters.Value(strName) = XMLUnEscape(strValue)
  559. Next
  560. End Sub
  561. Public Sub ImportHHT( _
  562. ByVal i_strFileName As String, _
  563. Optional ByVal i_intAuthoringGroup As Long = INVALID_ID_C _
  564. )
  565. Dim DOMDoc As MSXML2.DOMDocument
  566. Dim DOMNodeHHT As MSXML2.IXMLDOMNode
  567. Dim DOMNodeMain As MSXML2.IXMLDOMNode
  568. Dim DOMNodeEntries As MSXML2.IXMLDOMNode
  569. Dim DOMNode As MSXML2.IXMLDOMNode
  570. Dim dictKeywords As Scripting.Dictionary
  571. Dim DOMNodeOrphans As MSXML2.IXMLDOMNode
  572. Dim DOMNodeParameters As MSXML2.IXMLDOMNode
  573. Set DOMDoc = New MSXML2.DOMDocument
  574. DOMDoc.Load i_strFileName
  575. Set DOMNodeHHT = DOMDoc
  576. Set DOMNodeMain = p_clsTaxonomy.GetTaxonomyInXml
  577. Set DOMNodeMain = XMLFindFirstNode(DOMNodeMain, HHT_TAXONOMY_ENTRY_C)
  578. Set dictKeywords = New Scripting.Dictionary
  579. p_clsKeywords.GetAllKeywordsDict dictKeywords
  580. p_clsTaxonomy.SetCategory2AndEntry DOMNodeMain, ""
  581. Set DOMNodeEntries = XMLFindFirstNode(DOMNodeHHT, HHT_TAXONOMY_ENTRIES_C)
  582. If (DOMNodeEntries Is Nothing) Then
  583. Exit Sub
  584. End If
  585. For Each DOMNode In DOMNodeEntries.childNodes
  586. p_CreateTaxonomyEntry DOMNode, DOMNodeMain, dictKeywords, DOMNodeOrphans, _
  587. i_intAuthoringGroup
  588. Next
  589. p_RaiseEventAndLookForCancel "Restoring database parameters..."
  590. Set DOMNodeParameters = XMLFindFirstNode(DOMNodeHHT, HHT_dbparameters_C)
  591. p_RestoreDBParameters DOMNodeParameters
  592. End Sub
  593. Private Sub p_OutputStopSigns( _
  594. ByVal i_TS As Scripting.TextStream _
  595. )
  596. Dim dictStopSigns As Scripting.Dictionary
  597. Dim intSSID As Variant
  598. Dim strContext As String
  599. Set dictStopSigns = New Scripting.Dictionary
  600. p_clsStopSigns.GetAllStopSignsDict dictStopSigns
  601. p_PrintWithIndentation i_TS, 1, "<STOPSIGN_ENTRIES>"
  602. p_RaiseEventAndLookForCancel "Adding new Stop Signs"
  603. For Each intSSID In dictStopSigns.Keys
  604. If (dictStopSigns(intSSID)(1) = CONTEXT_ANYWHERE_E) Then
  605. strContext = "ANYWHERE"
  606. Else
  607. strContext = "ENDOFWORD"
  608. End If
  609. p_PrintWithIndentation i_TS, 2, _
  610. "<STOPSIGN ACTION=""ADD"" CONTEXT=""" & strContext & _
  611. """ STOPSIGN=""" & XmlText(dictStopSigns(intSSID)(0)) & """ />"
  612. Next
  613. p_PrintWithIndentation i_TS, 1, "</STOPSIGN_ENTRIES>"
  614. End Sub
  615. Private Sub p_OutputStopWords( _
  616. ByVal i_TS As Scripting.TextStream _
  617. )
  618. Dim dictStopWords As Scripting.Dictionary
  619. Dim intSWID As Variant
  620. Set dictStopWords = New Scripting.Dictionary
  621. p_clsStopWords.GetAllStopWordsDict dictStopWords
  622. p_PrintWithIndentation i_TS, 1, "<STOPWORD_ENTRIES>"
  623. p_RaiseEventAndLookForCancel "Adding new Stop Words"
  624. For Each intSWID In dictStopWords.Keys
  625. p_PrintWithIndentation i_TS, 2, _
  626. "<STOPWORD ACTION=""ADD""" & _
  627. " STOPWORD=""" & XmlText(dictStopWords(intSWID)) & """ />"
  628. Next
  629. p_PrintWithIndentation i_TS, 1, "</STOPWORD_ENTRIES>"
  630. End Sub
  631. Private Sub p_OutputSynonyms( _
  632. ByVal i_TS As Scripting.TextStream _
  633. )
  634. Dim clsSynonymSets As SynonymSets
  635. Dim rs As ADODB.Recordset
  636. Dim intLastEID As Long
  637. Dim intEID As Long
  638. Set clsSynonymSets = New SynonymSets
  639. Set rs = New ADODB.Recordset
  640. clsSynonymSets.GetSynonymsRs rs
  641. p_PrintWithIndentation i_TS, 1, "<SYNTABLE>"
  642. Do While (Not rs.EOF)
  643. intEID = rs("EID")
  644. If (intEID <> intLastEID) Then
  645. If (intLastEID <> 0) Then
  646. p_PrintWithIndentation i_TS, 2, "</SYNSET>"
  647. End If
  648. intLastEID = intEID
  649. p_PrintWithIndentation i_TS, 2, "<SYNSET ID=""" & intEID & """>"
  650. End If
  651. p_PrintWithIndentation i_TS, 3, "<SYNONYM ACTION=""ADD"">" & XMLEscape(rs("Keyword")) & "</SYNONYM>"
  652. rs.MoveNext
  653. Loop
  654. If (rs.RecordCount <> 0) Then
  655. p_PrintWithIndentation i_TS, 2, "</SYNSET>"
  656. End If
  657. p_PrintWithIndentation i_TS, 1, "</SYNTABLE>"
  658. End Sub
  659. Private Sub p_OutputOperators( _
  660. ByVal i_TS As Scripting.TextStream _
  661. )
  662. p_PrintWithIndentation i_TS, 1, "<OPERATOR_ENTRIES>"
  663. p_PrintWithIndentation i_TS, 2, _
  664. "<OPERATOR ACTION=""ADD"" OPERATION=""AND"" OPERATOR=""and"" />"
  665. p_PrintWithIndentation i_TS, 2, _
  666. "<OPERATOR ACTION=""ADD"" OPERATION=""OR"" OPERATOR=""or"" />"
  667. p_PrintWithIndentation i_TS, 2, _
  668. "<OPERATOR ACTION=""ADD"" OPERATION=""NOT"" OPERATOR=""not"" />"
  669. p_PrintWithIndentation i_TS, 1, "</OPERATOR_ENTRIES>"
  670. End Sub
  671. Private Sub p_GeneratePackageDescription( _
  672. ByVal i_TS As Scripting.TextStream, _
  673. ByVal i_enumSKU As SKU_E, _
  674. ByVal i_strHHT As String _
  675. )
  676. p_RaiseEventAndLookForCancel "Generating " & PACKAGE_DESCRIPTION
  677. p_PrintWithIndentation i_TS, 0, "<?xml version=""1.0"" ?>"
  678. p_PrintWithIndentation i_TS, 0, "<HELPCENTERPACKAGE>"
  679. p_PrintWithIndentation i_TS, 1, "<VERSION VALUE=""" & _
  680. g_clsParameters.ProductVersion(i_enumSKU) & """ />"
  681. p_PrintWithIndentation i_TS, 1, "<PRODUCT ID=""" & _
  682. g_clsParameters.ProductId(i_enumSKU) & """ />"
  683. If (i_enumSKU <> SKU_WINDOWS_MILLENNIUM_E) Then
  684. p_PrintWithIndentation i_TS, 1, "<SKU VALUE='" & XmlSKU(i_enumSKU) & "' " & _
  685. "DISPLAYNAME='" & g_clsParameters.DisplayName(i_enumSKU) & "'/>"
  686. p_PrintWithIndentation i_TS, 1, "<LANGUAGE VALUE='" & LCID_ENGLISH & "'/>"
  687. End If
  688. p_PrintWithIndentation i_TS, 1, "<METADATA>"
  689. p_PrintWithIndentation i_TS, 2, "<HHT FILE=""" & i_strHHT & """ />"
  690. p_PrintWithIndentation i_TS, 1, "</METADATA>"
  691. i_TS.WriteLine g_clsParameters.DomFragmentPackageDesc(i_enumSKU)
  692. p_PrintWithIndentation i_TS, 0, "</HELPCENTERPACKAGE>"
  693. End Sub
  694. Private Sub p_OutputHHTProlog( _
  695. ByVal i_TS As Scripting.TextStream, _
  696. ByVal i_enumSKU As SKU_E _
  697. )
  698. Dim strDateTime As String
  699. strDateTime = FormatDateTime(Now, vbLongDate) & " " & FormatDateTime(Now, vbLongTime)
  700. p_PrintWithIndentation i_TS, 0, "<?xml version=""1.0"" encoding=""UTF-16"" ?>"
  701. p_PrintWithIndentation i_TS, 0, "<!--"
  702. p_PrintWithIndentation i_TS, 0, "This file was automatically created on " & strDateTime
  703. p_PrintWithIndentation i_TS, 0, "Do not modify, as it may be overwritten."
  704. p_PrintWithIndentation i_TS, 0, "SKU: " & DisplayNameForSKU(i_enumSKU)
  705. p_PrintWithIndentation i_TS, 0, "-->"
  706. p_PrintWithIndentation i_TS, 0, "<METADATA>"
  707. End Sub
  708. Private Sub p_PrintWithIndentation( _
  709. ByVal i_TS As Scripting.TextStream, _
  710. ByVal i_intNumIndents As Long, _
  711. ByVal i_strText As String _
  712. )
  713. i_TS.Write Space(i_intNumIndents * 4)
  714. i_TS.WriteLine i_strText
  715. End Sub
  716. Private Sub p_RaiseEventAndLookForCancel( _
  717. ByVal strStatus As String _
  718. )
  719. Dim blnCancel As Boolean
  720. blnCancel = False
  721. RaiseEvent ReportStatus(strStatus, blnCancel)
  722. If (blnCancel) Then
  723. Err.Raise errCancel
  724. End If
  725. End Sub
  726. Private Sub p_clsTaxonomy_ReportStatus(ByVal strStatus As String, blnCancel As Boolean)
  727. p_RaiseEventAndLookForCancel strStatus
  728. End Sub