/// <summary> /// Reads all HHC files and checks which one has the global object tag. /// This hhc file will be returned as master hhc /// </summary> /// <param name="hhcTopics">list of topics containing the extension hhc</param> /// <param name="TopicItemArrayList">true if the arraylist contains topic items</param> /// <returns>the filename of the found master toc</returns> private string GetMasterHHC(ArrayList hhcTopics, bool TopicItemArrayList) { string sRet = ""; if ((hhcTopics != null) && (hhcTopics.Count > 0)) { if (TopicItemArrayList) { if (hhcTopics.Count == 1) { sRet = ((TopicEntry)hhcTopics[0]).Locale; } else { foreach (TopicEntry curEntry in hhcTopics) { CHMStream.CHMStream iw = null; MemoryStream fileObject = null; if (_associatedFile.CurrentStorageWrapper == null) { iw = new CHMStream.CHMStream(); iw.OpenCHM(_associatedFile.ChmFilePath); } else { iw = _associatedFile.CurrentStorageWrapper; } fileObject = iw.OpenStream(curEntry.Locale); if (fileObject != null) { string fileString = _associatedFile.TextEncoding.GetString(fileObject.ToArray(), 0, (int)fileObject.Length); fileObject.Close(); if (HHCParser.HasGlobalObjectTag(fileString, _associatedFile)) { sRet = curEntry.Locale; break; } } } } } else { if (hhcTopics.Count == 1) { sRet = ((string)hhcTopics[0]); } else { foreach (string curEntry in hhcTopics) { CHMStream.CHMStream iw = null; MemoryStream fileObject = null; if (_associatedFile.CurrentStorageWrapper == null) { iw = new CHMStream.CHMStream(); iw.OpenCHM(_associatedFile.ChmFilePath); } else { iw = _associatedFile.CurrentStorageWrapper; } fileObject = iw.OpenStream(curEntry); if (fileObject != null) { string fileString = _associatedFile.TextEncoding.GetString(fileObject.ToArray(), 0, (int)fileObject.Length); fileObject.Close(); if (HHCParser.HasGlobalObjectTag(fileString, _associatedFile)) { sRet = curEntry; break; } } } } } } return(sRet); }
/// <summary> /// Reads all HHC files and checks which one has the global object tag. /// This hhc file will be returned as master hhc /// </summary> /// <param name="hhcTopics">list of topics containing the extension hhc</param> /// <param name="TopicItemArrayList">true if the arraylist contains topic items</param> /// <returns>the filename of the found master toc</returns> private string GetMasterHHC(ArrayList hhcTopics, bool TopicItemArrayList) { string sRet = ""; if ((hhcTopics != null) && (hhcTopics.Count > 0)) { if (TopicItemArrayList) { if (hhcTopics.Count == 1) { sRet = ((TopicEntry)hhcTopics[0]).Locale; } else { foreach (TopicEntry curEntry in hhcTopics) { ITStorageWrapper iw = null; // Open the internal chm system files and parse their content FileObject fileObject = null; if (_associatedFile.CurrentStorageWrapper == null) { iw = new ITStorageWrapper(_associatedFile.ChmFilePath, false); } else { iw = _associatedFile.CurrentStorageWrapper; } fileObject = iw.OpenUCOMStream(null, curEntry.Locale); if (fileObject != null) { string fileString = fileObject.ReadFromFile(_associatedFile.TextEncoding); fileObject.Close(); if (HHCParser.HasGlobalObjectTag(fileString, _associatedFile)) { sRet = curEntry.Locale; break; } } } } } else { if (hhcTopics.Count == 1) { sRet = ((string)hhcTopics[0]); } else { foreach (string curEntry in hhcTopics) { ITStorageWrapper iw = null; // Open the internal chm system files and parse their content FileObject fileObject = null; if (_associatedFile.CurrentStorageWrapper == null) { iw = new ITStorageWrapper(_associatedFile.ChmFilePath, false); } else { iw = _associatedFile.CurrentStorageWrapper; } fileObject = iw.OpenUCOMStream(null, curEntry); if (fileObject != null) { string fileString = fileObject.ReadFromFile(_associatedFile.TextEncoding); fileObject.Close(); if (HHCParser.HasGlobalObjectTag(fileString, _associatedFile)) { sRet = curEntry; break; } } } } } } return(sRet); }