/// ------------------------------------------------------------------------------------ /// <summary> /// If the Scripture/BackTrans radio button is changed, update the OK button (enabling /// it only if at least one domain selected for export). Also update the BT writing /// systems control enabled state and which writing systems are checked. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> /// ------------------------------------------------------------------------------------ protected void rdoScripture_CheckedChanged(object sender, EventArgs e) { if (rdoScripture.Checked) { // Save current settings for back translation domain m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; m_fBTModifiedSuffix = fileNameSchemeCtrl.UserModifiedSuffix; fileNameSchemeCtrl.FileNameFormat = m_fileNameScheme; fileNameSchemeCtrl.UserModifiedSuffix = m_fModifiedSuffix; cboShortName.Text = m_shortName; } else { // Save current settings for Scripture domain m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; m_fModifiedSuffix = fileNameSchemeCtrl.UserModifiedSuffix; fileNameSchemeCtrl.FileNameFormat = m_BTfileNameScheme; fileNameSchemeCtrl.UserModifiedSuffix = m_fBTModifiedSuffix; cboShortName.Text = m_BTshortName; } chklbWritingSystems.Enabled = rdoBackTranslation.Checked && chklbWritingSystems.Items.Count > 1; WhatToExportChanged(sender, e); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the Paratext ssf file. /// </summary> /// <param name="ssfFileName">Name of the SSF file.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// <returns>Name of the Language whose LDS file should be updated</returns> /// ------------------------------------------------------------------------------------ public string UpdateSsfFile(string ssfFileName, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { XmlDocument ssfContents; using (StreamReader sr = new StreamReader(ssfFileName)) { ssfContents = UpdateSsfFile(sr, format, sShortName, styleSheetFile, projPath, ws); } // Set settings so that XmlWriter produces the XML file in the pseudo-XML format // that Paratext expects (no whitespace except line breaks, no XML declaration) XmlWriterSettings settings = new XmlWriterSettings(); settings.CheckCharacters = false; settings.Encoding = new UTF8Encoding(false); settings.Indent = true; settings.IndentChars = string.Empty; settings.OmitXmlDeclaration = true; using (XmlWriter writer = XmlWriter.Create(ssfFileName, settings)) { ssfContents.Save(writer); } return(ssfContents.SelectSingleNode("ScriptureText/Language").InnerText); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the method to update a Paratext ssf file. /// </summary> /// <param name="ssf">Stream for Paratext SSF that already exists.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// ------------------------------------------------------------------------------------ public XmlDocument UpdateSsfFile(TextReader ssf, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { CheckDisposed(); return(m_ParatextSsfFileAccessor.UpdateSsfFile(ssf, format, sShortName, styleSheetFile, projPath, ws)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the combobox for the file naming schemes. /// </summary> /// <remarks>Public so that we can intialize from tests without showing the dialog.</remarks> /// ------------------------------------------------------------------------------------ public void InitSchemeComboBx() { CheckDisposed(); cboScheme.Items.Clear(); cboScheme.Items.Add(FileNameFormat.GetUiSchemeFormat(m_markupType, FileNameFormat.SchemeFormat.NNBBB)); cboScheme.Items.Add(FileNameFormat.GetUiSchemeFormat(m_markupType, FileNameFormat.SchemeFormat.BBB)); cboScheme.Items.Add(FileNameFormat.GetUiSchemeFormat(m_markupType, FileNameFormat.SchemeFormat.NN)); UpdateFileNameExample(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Computes the settings. /// </summary> /// <param name="format">The format.</param> /// <param name="projPath">The proj path.</param> /// <param name="ws">The ws.</param> /// ------------------------------------------------------------------------------------ private void ComputeSettings(FileNameFormat format, string projPath, int ws) { m_projPath = projPath.Trim(); IWritingSystem wsObj = m_cache.ServiceLocator.WritingSystemManager.Get(ws); m_wsName = wsObj.DisplayLabel; m_fileScheme = format.ParatextFileScheme; m_sPostPart = format.m_fileSuffix + "." + format.m_fileExtension; m_sPrePart = format.m_filePrefix; m_LtoR = (wsObj.RightToLeftScript ? "F" : "T"); m_versification = ((int)m_cache.LangProject.TranslatedScriptureOA.Versification).ToString(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Computes the settings. /// </summary> /// <param name="format">The format.</param> /// <param name="projPath">The proj path.</param> /// <param name="ws">The ws.</param> /// ------------------------------------------------------------------------------------ private void ComputeSettings(FileNameFormat format, string projPath, int ws) { m_projPath = projPath.Trim(); LgWritingSystem lgws = new LgWritingSystem(m_cache, ws); m_wsName = lgws.Name.UserDefaultWritingSystem; m_fileScheme = format.ParatextFileScheme; m_sPostPart = format.m_fileSuffix + "." + format.m_fileExtension; m_sPrePart = format.m_filePrefix; m_LtoR = (lgws.RightToLeft ? "F" : "T"); m_versification = ((int)m_cache.LangProject.TranslatedScriptureOA.Versification).ToString(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Saves the ssf file. /// </summary> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="writer">The file writer.</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// ------------------------------------------------------------------------------------ public void SaveSsfFile(FileNameFormat format, string sShortName, string styleSheetFile, string projPath, FileWriter writer, int ws) { ComputeSettings(format, projPath, ws); writer.WriteLine("<ScriptureText>"); writer.WriteLine("<BooksPresent>" + BooksPresent + "</BooksPresent>"); writer.WriteLine("<Copyright></Copyright>"); writer.WriteLine("<Directory>" + m_projPath + "</Directory>"); writer.WriteLine("<Editable>T</Editable>"); writer.WriteLine("<Encoding>" + kUnicodeEncoding + "</Encoding>"); writer.WriteLine("<FileNameForm>" + m_fileScheme + "</FileNameForm>"); writer.WriteLine("<FileNamePostPart>" + m_sPostPart + "</FileNamePostPart>"); writer.WriteLine("<FileNamePrePart>" + m_sPrePart + "</FileNamePrePart>"); writer.WriteLine("<FullName>" + m_cache.ProjectId.Name + "</FullName>"); writer.WriteLine("<Language>" + m_wsName + "</Language>"); writer.WriteLine("<LeftToRight>" + m_LtoR + "</LeftToRight>"); writer.WriteLine("<Name>" + sShortName + "</Name>"); writer.WriteLine("<StyleSheet>" + styleSheetFile + "</StyleSheet>"); writer.WriteLine("<Versification>" + m_versification + "</Versification>"); writer.WriteLine(NamingNode); writer.WriteLine("</ScriptureText>"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the SelectedIndexChanged event of the cboShortName control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> /// ------------------------------------------------------------------------------------ protected void cboShortName_SelectedIndexChanged(object sender, System.EventArgs e) { if (!m_fUserModifiedFolder && cboShortName.SelectedIndex >= 0) { try { using (ScrText paraTextSO = new ScrText(ShortName)) { string folder = paraTextSO.Directory; m_fAppendShortNameToFolder = (folder.EndsWith(Path.DirectorySeparatorChar + ShortName)); BaseOutputFolder = folder; m_fUserModifiedFolder = false; CalculateDisplayOutputFolder(); FileNameFormat currentFileNameScheme = ExportScriptureDomain ? m_fileNameScheme : m_BTfileNameScheme; currentFileNameScheme.m_filePrefix = paraTextSO.FileNamePrePart; currentFileNameScheme.m_schemeFormat = FileNameFormat.GetSchemeFormatFromParatextForm(paraTextSO.FileNameForm); m_fileNameScheme.m_fileSuffix = Path.GetFileNameWithoutExtension(paraTextSO.FileNamePostPart); //if (ExportScriptureDomain) // m_BTfileNameScheme.m_fileSuffix = m_fileNameScheme.m_fileSuffix.Substring(0, 3) + "BT"; currentFileNameScheme.m_fileExtension = Path.GetExtension(paraTextSO.FileNamePostPart); // set file name scheme control with properties that check the export domain. fileNameSchemeCtrl.ClearUserModifiedNameScheme(); fileNameSchemeCtrl.Prefix = FileNamePrefix; fileNameSchemeCtrl.Scheme = FileNameScheme; fileNameSchemeCtrl.Suffix = FileNameSuffix; fileNameSchemeCtrl.Extension = FileNameExtension; } } catch { // Ignore Paratext Load errors. Project will be overwritten. } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the Paratext ssf file. /// </summary> /// <param name="ssfFileName">Name of the SSF file.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// <returns>Name of the Language whose LDS file should be updated</returns> /// ------------------------------------------------------------------------------------ public string UpdateSsfFile(string ssfFileName, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { XmlDocument ssfContents; using (StreamReader sr = new StreamReader(ssfFileName)) { ssfContents = UpdateSsfFile(sr, format, sShortName, styleSheetFile, projPath, ws); } // Set settings so that XmlWriter produces the XML file in the pseudo-XML format // that Paratext expects (no whitespace except line breaks, no XML declaration) XmlWriterSettings settings = new XmlWriterSettings(); settings.CheckCharacters = false; settings.Encoding = new UTF8Encoding(false); settings.Indent = true; settings.IndentChars = string.Empty; settings.OmitXmlDeclaration = true; using (XmlWriter writer = XmlWriter.Create(ssfFileName, settings)) { ssfContents.Save(writer); } return ssfContents.SelectSingleNode("ScriptureText/Language").InnerText; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the method to update a Paratext ssf file. /// </summary> /// <param name="ssf">Stream for Paratext SSF that already exists.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// ------------------------------------------------------------------------------------ public XmlDocument UpdateSsfFile(TextReader ssf, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { CheckDisposed(); return m_ParatextSsfFileAccessor.UpdateSsfFile(ssf, format, sShortName, styleSheetFile, projPath, ws); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Calculates new contents for an existing ssf file. /// </summary> /// <param name="ssf">Stream for Paratext SSF that already exists.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// <returns>An XML document containing the settings for the Paratext project</returns> /// ------------------------------------------------------------------------------------ public XmlDocument UpdateSsfFile(TextReader ssf, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { ComputeSettings(format, projPath, ws); XmlDocument project = new XmlDocument(); project.InnerXml = ssf.ReadToEnd(); XmlNode scriptureTextNode = project.SelectSingleNode("ScriptureText"); XmlNode styleSheetNode = scriptureTextNode.SelectSingleNode("StyleSheet"); if (styleSheetNode == null) scriptureTextNode.InnerXml += "<StyleSheet>" + styleSheetFile + "</StyleSheet>"; XmlNode booksPresent, directory, encoding, fileNameForm, fileNamePostPart, fileNamePrePart, namingNode; bool fRequiredElementsMissing = false; fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "BooksPresent", out booksPresent); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "Directory", out directory); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "Encoding", out encoding); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNameForm", out fileNameForm); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNamePostPart", out fileNamePostPart); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNamePrePart", out fileNamePrePart); namingNode = scriptureTextNode.SelectSingleNode("Naming"); if (namingNode != null && namingNode.OuterXml != NamingNode) { scriptureTextNode.RemoveChild(namingNode); namingNode = null; } if (namingNode == null) { fRequiredElementsMissing = true; scriptureTextNode.InnerXml += NamingNode; } // If the project is the same... if (!fRequiredElementsMissing && directory.InnerText == m_projPath && encoding.InnerText == kUnicodeEncoding && fileNameForm.InnerText == m_fileScheme && fileNamePostPart.InnerText == m_sPostPart && fileNamePrePart.InnerText == m_sPrePart) { // Need to add the books being exported to the existing list of books in the project. booksPresent.InnerText = MergeBooksPresent(booksPresent.InnerText); } else { // If any required elements were missing, we need to re-get all the nodes since the // ones we got before refer to the old XML. if (fRequiredElementsMissing) { booksPresent = scriptureTextNode.SelectSingleNode("BooksPresent"); directory = scriptureTextNode.SelectSingleNode("Directory"); encoding = scriptureTextNode.SelectSingleNode("Encoding"); fileNameForm = scriptureTextNode.SelectSingleNode("FileNameForm"); fileNamePostPart = scriptureTextNode.SelectSingleNode("FileNamePostPart"); fileNamePrePart = scriptureTextNode.SelectSingleNode("FileNamePrePart"); namingNode = scriptureTextNode.SelectSingleNode("Naming"); } // set up the default values. booksPresent.InnerText = BooksPresent; directory.InnerText = m_projPath; encoding.InnerText = kUnicodeEncoding; fileNameForm.InnerText = m_fileScheme; fileNamePostPart.InnerText = m_sPostPart; fileNamePrePart.InnerText = m_sPrePart; namingNode.Attributes.GetNamedItem("PostPart").Value = m_sPostPart; namingNode.Attributes.GetNamedItem("BookNameForm").Value = m_fileScheme; } XmlNode languageNode = scriptureTextNode.SelectSingleNode("Language"); if (languageNode == null) scriptureTextNode.InnerXml += "<Language>" + m_wsName + "</Language>"; else languageNode.InnerText = m_wsName; XmlNode leftToRight = scriptureTextNode.SelectSingleNode("LeftToRight"); if (leftToRight != null) leftToRight.InnerText = m_LtoR; // Technically, the Versification node isn't required. We only want to write // the versification if it doesn't already exist in the project file. XmlNode versification = scriptureTextNode.SelectSingleNode("Versification"); if (versification == null) { scriptureTextNode.InnerXml += "<Versification>" + m_versification + "</Versification>"; } return project; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Load event of the ExportPtxDialog control. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event /// data.</param> /// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { // set up default short name m_shortName = m_regGroup.GetStringValue(base.RegistrySettingType + "ShortName", null); m_BTshortName = m_regGroup.GetStringValue(base.RegistrySettingType + "BT" + "ShortName", null); if (string.IsNullOrEmpty(m_shortName) || string.IsNullOrEmpty(m_BTshortName)) { foreach (IScrImportSet importSet in m_cache.LangProject.TranslatedScriptureOA.ImportSettingsOC) { if (!string.IsNullOrEmpty(importSet.ParatextScrProj)) { if (string.IsNullOrEmpty(m_shortName)) { m_shortName = importSet.ParatextScrProj; } if (string.IsNullOrEmpty(m_BTshortName)) { m_BTshortName = importSet.ParatextBTProj; } if (importSet.Name.UserDefaultWritingSystem.Text == ScriptureTags.kDefaultImportSettingsName) { break; } } } } if (m_shortName == null) { IWritingSystem wsVern = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem; string abbr = wsVern.Abbreviation; if (abbr != null && !abbr.Contains("***")) { m_shortName = abbr.Trim(); } else { m_shortName = wsVern.Abbreviation.Trim(); } } else { m_shortName = m_shortName.Trim(); } // Paratext 6 requires short name to be between 3 and 5 characters in length. if (m_shortName.Length < 3) { m_shortName = m_shortName.PadRight(3, '_'); } if (m_shortName.Length > 5) { m_shortName = m_shortName.Substring(0, 5); } if (string.IsNullOrEmpty(m_BTshortName)) { m_BTshortName = m_shortName.Substring(0, 3) + "BT"; } // Set values for what to export for one domain export (Paratext). switch (m_regGroup.GetIntValue("ParatextOneDomainExportWhat", 0)) { case 0: default: // Temporarily load the BT settings, so when we "switch" to Scripture, // the BT settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType + "BT", m_BTshortName); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoScripture.Select(); base.OnLoad(e); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; case 1: // Temporarily load the regular (vern) settings, so when we "switch" to // back translation, the vern settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType, m_shortName); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoBackTranslation.Select(); base.OnLoad(e); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; } // Get the output file or folder specification. try { m_paratextProjFolder = ScrTextCollection.SettingsDirectory; } catch { // Ignore: Paratext not installed } if (m_paratextProjFolder != null) { m_paratextProjFolder = m_paratextProjFolder.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); cboShortName.Items.AddRange(ParatextHelper.WritableShortNames.ToArray()); // The following is an attempt to keep us from looking like idiots by making // the default project name a non-editable project. int i = 1; while (!ParatextHelper.IsProjectWritable(m_shortName) && i < 1000) { m_shortName = "MP" + i++; } i = 1; while (!ParatextHelper.IsProjectWritable(m_BTshortName) && i < 1000) { m_BTshortName = "BT" + i++; } } else { // Paratext is not installed or Paratext directory does not exist. // We default the output path to "C:\My Paratext Projects". However, this directory // might not exist and/or we might have no permissions to write there. We attempt to // create this folder now. If we fail, then we disable the Short Name control and // won't bother writing the Paratext settings files. // REVIEW: this comment seems to be out of date. We might crash if we have an // invalid directory (see FWNX-828). m_paratextProjFolder = ParatextHelper.ProjectsDirectory; } cboShortName.Text = ShortName; m_OutputFolder = m_regGroup.GetStringValue("ParatextOutputSpec", m_paratextProjFolder); m_BTOutputFolder = m_regGroup.GetStringValue("ParatextBTOutputSpec", m_paratextProjFolder); UpdateDisplay(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Load event of the ExportPtxDialog control. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event /// data.</param> /// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { // set up default short name m_shortName = m_regGroup.GetStringValue(base.RegistrySettingType + "ShortName", null); m_BTshortName = m_regGroup.GetStringValue(base.RegistrySettingType + "BT" + "ShortName", null); if (string.IsNullOrEmpty(m_shortName) || string.IsNullOrEmpty(m_BTshortName)) { foreach (IScrImportSet importSet in m_cache.LangProject.TranslatedScriptureOA.ImportSettingsOC) { if (!string.IsNullOrEmpty(importSet.ParatextScrProj)) { if (string.IsNullOrEmpty(m_shortName)) m_shortName = importSet.ParatextScrProj; if (string.IsNullOrEmpty(m_BTshortName)) m_BTshortName = importSet.ParatextBTProj; if (importSet.Name.UserDefaultWritingSystem.Text == ScriptureTags.kDefaultImportSettingsName) break; } } } if (m_shortName == null) { IWritingSystem wsVern = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem; string abbr = wsVern.Abbreviation; if (abbr != null && !abbr.Contains("***")) m_shortName = abbr.Trim(); else m_shortName = wsVern.Abbreviation.Trim(); } else m_shortName = m_shortName.Trim(); // Paratext 6 requires short name to be between 3 and 5 characters in length. if (m_shortName.Length < 3) m_shortName = m_shortName.PadRight(3, '_'); if (m_shortName.Length > 5) m_shortName = m_shortName.Substring(0, 5); if (string.IsNullOrEmpty(m_BTshortName)) m_BTshortName = m_shortName.Substring(0, 3) + "BT"; // Set values for what to export for one domain export (Paratext). switch (m_regGroup.GetIntValue("ParatextOneDomainExportWhat", 0)) { case 0: default: // Temporarily load the BT settings, so when we "switch" to Scripture, // the BT settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType + "BT", m_BTshortName); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoScripture.Select(); base.OnLoad(e); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; case 1: // Temporarily load the regular (vern) settings, so when we "switch" to // back translation, the vern settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType, m_shortName); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoBackTranslation.Select(); base.OnLoad(e); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; } // Get the output file or folder specification. try { m_paratextProjFolder = ScrTextCollection.SettingsDirectory; } catch { // Ignore: Paratext not installed } if (m_paratextProjFolder != null) { m_paratextProjFolder = m_paratextProjFolder.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); cboShortName.Items.AddRange(ParatextHelper.WritableShortNames.ToArray()); // The following is an attempt to keep us from looking like idiots by making // the default project name a non-editable project. int i = 1; while (!ParatextHelper.IsProjectWritable(m_shortName) && i < 1000) m_shortName = "MP" + i++; i = 1; while (!ParatextHelper.IsProjectWritable(m_BTshortName) && i < 1000) m_BTshortName = "BT" + i++; } else { // Paratext is not installed or Paratext directory does not exist. // We default the output path to "C:\My Paratext Projects". However, this directory // might not exist and/or we might have no permissions to write there. We attempt to // create this folder now. If we fail, then we disable the Short Name control and // won't bother writing the Paratext settings files. // REVIEW: this comment seems to be out of date. We might crash if we have an // invalid directory (see FWNX-828). m_paratextProjFolder = ParatextHelper.ProjectsDirectory; } cboShortName.Text = ShortName; m_OutputFolder = m_regGroup.GetStringValue("ParatextOutputSpec", m_paratextProjFolder); m_BTOutputFolder = m_regGroup.GetStringValue("ParatextBTOutputSpec", m_paratextProjFolder); UpdateDisplay(); }
public void UpdateParatextSsfFile_SameFolderAndSpec() { int wsHvo = Cache.DefaultVernWs; m_scr.Versification = 0; // Should default to English LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); // The existing file has Exodus and Matthew. string existingSsf = @"<ScriptureText>" + Environment.NewLine + @"<Book_EXO>Exodus</Book_EXO>" + Environment.NewLine + @"<Book_MAT>Matthew</Book_MAT>" + Environment.NewLine + @"<BooksPresent>010000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000</BooksPresent>" + Environment.NewLine + @"<ChapterMarker>c</ChapterMarker>" + Environment.NewLine + @"<Copyright></Copyright>" + Environment.NewLine + @"<Directory>C:\My Paratext Projects\dummy</Directory>" + Environment.NewLine + @"<DotAll>No</DotAll>" + Environment.NewLine + @"<Editable>T</Editable>" + Environment.NewLine + @"<Encoding>65001</Encoding>" + Environment.NewLine + @"<FileNameChapterNumberForm></FileNameChapterNumberForm>" + Environment.NewLine + @"<FileNameForm>41MAT</FileNameForm>" + Environment.NewLine + @"<FileNamePostPart>suf.ext</FileNamePostPart>" + Environment.NewLine + @"<FileNamePrePart>pre</FileNamePrePart>" + Environment.NewLine + @"<FullName>My project Name</FullName>" + Environment.NewLine + @"<Language>Gumbasian</Language>" + Environment.NewLine + @"<LeftToRight>" + (vernWs.RightToLeft ? "F" : "T") + "</LeftToRight>" + Environment.NewLine + @"<MatchCase>No</MatchCase>" + Environment.NewLine + @"<Name>dummy</Name>" + Environment.NewLine + @"<ResourceText>F</ResourceText>" + Environment.NewLine + @"<RunFromCD>F</RunFromCD>" + Environment.NewLine + @"<ShowReferences>No</ShowReferences>" + Environment.NewLine + @"<StyleSheet>dontOverWriteMe.sty</StyleSheet>" + Environment.NewLine + @"<VerseMarker>v</VerseMarker>" + Environment.NewLine + @"<Versification>2</Versification>" + Environment.NewLine + "<Naming PrePart=\"pre\" PostPart=\"suf.ext\" BookNameForm=\"41MAT\"></Naming>" + Environment.NewLine + @"</ScriptureText>"; FileNameFormat fileNameFormat = new FileNameFormat("pre", FileNameFormat.SchemeFormat.NNBBB, "suf", "ext"); XmlDocument resultSSF; m_filter.Add(m_book.Hvo); using (StringReader sr = new StringReader(existingSsf)) { resultSSF = m_exporter.ParatextSsfFileAccessor.UpdateSsfFile(sr, fileNameFormat, "dummy", "styFile.sty", @"C:\My Paratext Projects\dummy", wsHvo); } // Verify the .ssf contents Dictionary<string, string> expectedSsfEntries = new Dictionary<string, string>(); expectedSsfEntries["Book_EXO"] = "Exodus"; expectedSsfEntries["Book_MAT"] = "Matthew"; expectedSsfEntries["BooksPresent"] = "110000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000"; expectedSsfEntries["ChapterMarker"] = "c"; expectedSsfEntries["Copyright"] = string.Empty; expectedSsfEntries["Directory"] = @"C:\My Paratext Projects\dummy"; expectedSsfEntries["DotAll"] = "No"; expectedSsfEntries["Editable"] = "T"; expectedSsfEntries["Encoding"] = "65001"; expectedSsfEntries["FileNameChapterNumberForm"] = string.Empty; expectedSsfEntries["FileNameForm"] = "41MAT"; expectedSsfEntries["FileNamePostPart"] = "suf.ext"; expectedSsfEntries["FileNamePrePart"] = "pre"; expectedSsfEntries["FullName"] = "My project Name"; expectedSsfEntries["Language"] = "francés"; expectedSsfEntries["LeftToRight"] = (vernWs.RightToLeft ? "F" : "T"); expectedSsfEntries["MatchCase"] = "No"; expectedSsfEntries["Name"] = "dummy"; expectedSsfEntries["ResourceText"] = "F"; expectedSsfEntries["RunFromCD"] = "F"; expectedSsfEntries["ShowReferences"] = "No"; expectedSsfEntries["StyleSheet"] = "dontOverWriteMe.sty"; // Don't overwrite the .sty expectedSsfEntries["VerseMarker"] = "v"; expectedSsfEntries["Versification"] = "2"; // Don't overwrite the versification. expectedSsfEntries["Naming"] = string.Empty; Assert.AreEqual(1, resultSSF.ChildNodes.Count, "Only node in document should be ScriptureText"); XmlNode contents = resultSSF.SelectSingleNode("ScriptureText"); Assert.AreEqual(expectedSsfEntries.Count, contents.ChildNodes.Count); foreach (string expectedElement in expectedSsfEntries.Keys) { XmlNode node = contents.SelectSingleNode(expectedElement); Assert.IsNotNull(node); Assert.AreEqual(expectedSsfEntries[expectedElement], node.InnerText); } // Check the Naiming node (only node that uses attributes) XmlNode namingNode = contents.SelectSingleNode("Naming"); Assert.IsNotNull(namingNode); Assert.AreEqual("pre", namingNode.Attributes.GetNamedItem("PrePart").Value); Assert.AreEqual("suf.ext", namingNode.Attributes.GetNamedItem("PostPart").Value); Assert.AreEqual("41MAT", namingNode.Attributes.GetNamedItem("BookNameForm").Value); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Load event of the ExportPtxDialog control. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event /// data.</param> /// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { // set up default short name ScrImportSet importSet = (ScrImportSet)m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings; m_shortName = (importSet != null) ? importSet.ParatextScrProj : null; if (m_shortName == null) { LgWritingSystem wsVern = ((LgWritingSystem)m_cache.LangProject.CurVernWssRS[0]); string abbr = wsVern.Abbr.UserDefaultWritingSystem; if (abbr != null) m_shortName = abbr.Trim(); else m_shortName = wsVern.Abbreviation.Trim(); } else m_shortName = m_shortName.Trim(); // Paratext 6 requires short name to be between 3 and 5 characters in length. if (m_shortName.Length < 3) m_shortName = m_shortName.PadRight(3, '_'); if (m_shortName.Length > 5) m_shortName = m_shortName.Substring(0, 5); m_BTshortName = (importSet != null && !string.IsNullOrEmpty(importSet.ParatextBTProj)) ? importSet.ParatextBTProj : (m_shortName.Substring(0, 3) + "BT"); // Set values for what to export for one domain export (Paratext). switch (m_regGroup.GetIntValue("ParatextOneDomainExportWhat", 0)) { case 0: default: // Temporarily load the BT settings, so when we "switch" to Scripture, // the BT settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType + "BT", m_BTshortName); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoScripture.Select(); base.OnLoad(e); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; case 1: // Temporarily load the regular (vern) settings, so when we "switch" to // back translation, the vern settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType, m_shortName); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoBackTranslation.Select(); base.OnLoad(e); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; } // Get the output file or folder specification. SCRIPTUREOBJECTSLib.ISCScriptureText3 paraTextSO = null; try { paraTextSO = new SCRIPTUREOBJECTSLib.SCScriptureTextClass(); } catch { // Ignore: Paratext not installed } if (paraTextSO != null) { m_paratextProjFolder = paraTextSO.SettingsDirectory; if (m_paratextProjFolder != null) { m_paratextProjFolder = m_paratextProjFolder.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } string[] shortNames = ParatextHelper.GetParatextShortNames(paraTextSO); if (shortNames != null) { foreach (string shortName in shortNames) { bool fIsEditable = true; try { paraTextSO.Load(shortName); fIsEditable = (paraTextSO.Editable != 0); } catch { // Paratext settings file is probably bogus, so we regard it as editable (i.e., we can overwrite it). } if (fIsEditable) cboShortName.Items.Add(shortName); else m_nonEditableP6Projects.Add(shortName); } } // The following is an attempt to keep us from looking like idiots by making // the default project name a non-editable project. int i = 1; while (m_nonEditableP6Projects.Contains(m_shortName) && i < 1000) m_shortName = "MP" + i++; i = 1; while (m_nonEditableP6Projects.Contains(m_BTshortName) && i < 1000) m_BTshortName = "BT" + i++; } else { // Paratext is not installed or Paratext directory does not exist. // We default the output path to "C:\My Paratext Projects". However, this directory // might not exist and/or we might have no permissions to write there. We attempt to // create this folder now. If we fail, then we disable the Short Name control and // won't bother writing the Paratext settings files. m_paratextProjFolder = kDefaultParatextPath; } cboShortName.Text = ShortName; m_OutputFolder = m_regGroup.GetStringValue("ParatextOutputSpec", m_paratextProjFolder); m_BTOutputFolder = m_regGroup.GetStringValue("ParatextBTOutputSpec", m_paratextProjFolder); UpdateDisplay(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Load event of the ExportPtxDialog control. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event /// data.</param> /// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { // set up default short name ScrImportSet importSet = (ScrImportSet)m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings; m_shortName = (importSet != null) ? importSet.ParatextScrProj : null; if (m_shortName == null) { LgWritingSystem wsVern = ((LgWritingSystem)m_cache.LangProject.CurVernWssRS[0]); string abbr = wsVern.Abbr.UserDefaultWritingSystem; if (abbr != null) { m_shortName = abbr.Trim(); } else { m_shortName = wsVern.Abbreviation.Trim(); } } else { m_shortName = m_shortName.Trim(); } // Paratext 6 requires short name to be between 3 and 5 characters in length. if (m_shortName.Length < 3) { m_shortName = m_shortName.PadRight(3, '_'); } if (m_shortName.Length > 5) { m_shortName = m_shortName.Substring(0, 5); } m_BTshortName = (importSet != null && !string.IsNullOrEmpty(importSet.ParatextBTProj)) ? importSet.ParatextBTProj : (m_shortName.Substring(0, 3) + "BT"); // Set values for what to export for one domain export (Paratext). switch (m_regGroup.GetIntValue("ParatextOneDomainExportWhat", 0)) { case 0: default: // Temporarily load the BT settings, so when we "switch" to Scripture, // the BT settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType + "BT", m_BTshortName); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoScripture.Select(); base.OnLoad(e); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; case 1: // Temporarily load the regular (vern) settings, so when we "switch" to // back translation, the vern settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType, m_shortName); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoBackTranslation.Select(); base.OnLoad(e); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; } // Get the output file or folder specification. SCRIPTUREOBJECTSLib.ISCScriptureText3 paraTextSO = null; try { paraTextSO = new SCRIPTUREOBJECTSLib.SCScriptureTextClass(); } catch { // Ignore: Paratext not installed } if (paraTextSO != null) { m_paratextProjFolder = paraTextSO.SettingsDirectory; if (m_paratextProjFolder != null) { m_paratextProjFolder = m_paratextProjFolder.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } string[] shortNames = ParatextHelper.GetParatextShortNames(paraTextSO); if (shortNames != null) { foreach (string shortName in shortNames) { bool fIsEditable = true; try { paraTextSO.Load(shortName); fIsEditable = (paraTextSO.Editable != 0); } catch { // Paratext settings file is probably bogus, so we regard it as editable (i.e., we can overwrite it). } if (fIsEditable) { cboShortName.Items.Add(shortName); } else { m_nonEditableP6Projects.Add(shortName); } } } // The following is an attempt to keep us from looking like idiots by making // the default project name a non-editable project. int i = 1; while (m_nonEditableP6Projects.Contains(m_shortName) && i < 1000) { m_shortName = "MP" + i++; } i = 1; while (m_nonEditableP6Projects.Contains(m_BTshortName) && i < 1000) { m_BTshortName = "BT" + i++; } } else { // Paratext is not installed or Paratext directory does not exist. // We default the output path to "C:\My Paratext Projects". However, this directory // might not exist and/or we might have no permissions to write there. We attempt to // create this folder now. If we fail, then we disable the Short Name control and // won't bother writing the Paratext settings files. m_paratextProjFolder = kDefaultParatextPath; } cboShortName.Text = ShortName; m_OutputFolder = m_regGroup.GetStringValue("ParatextOutputSpec", m_paratextProjFolder); m_BTOutputFolder = m_regGroup.GetStringValue("ParatextBTOutputSpec", m_paratextProjFolder); UpdateDisplay(); }
public void WriteParatextSsfFile_SeptuagintVersification() { int wsHvo = Cache.DefaultVernWs; m_scr.Versification = Paratext.ScrVers.Septuagint; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyFileWriter writer = new DummyFileWriter(); FileNameFormat fileNameFormat = new FileNameFormat("pre", FileNameFormat.SchemeFormat.NNBBB, "suf", "ext"); m_exporter.ParatextSsfFileAccessor.SaveSsfFile(fileNameFormat, "dummy", "styFile.sty", @"C:\My Paratext Projects\dummy", writer, Cache.DefaultVernWs); // Verify the .ssf file string[] expectedSsf = new string[] { @"<ScriptureText>", @"<BooksPresent>100000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000</BooksPresent>", @"<Copyright></Copyright>", @"<Directory>C:\My Paratext Projects\dummy</Directory>", @"<Editable>T</Editable>", @"<Encoding>65001</Encoding>", @"<FileNameForm>41MAT</FileNameForm>", @"<FileNamePostPart>suf.ext</FileNamePostPart>", @"<FileNamePrePart>pre</FileNamePrePart>", @"<FullName>" + Cache.LangProject.Name.UserDefaultWritingSystem + "</FullName>", @"<Language>French</Language>", @"<LeftToRight>" + (vernWs.RightToLeft ? "F" : "T") + "</LeftToRight>", @"<Name>dummy</Name>", @"<StyleSheet>styFile.sty</StyleSheet>", @"<Versification>2</Versification>", // Septuagint "<Naming PrePart=\"pre\" PostPart=\"suf.ext\" BookNameForm=\"41MAT\"></Naming>", @"</ScriptureText>" }; writer.VerifyOutput(expectedSsf); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Calculates new contents for an existing ssf file. /// </summary> /// <param name="ssf">Stream for Paratext SSF that already exists.</param> /// <param name="format">the prefix, scheme, suffix, extension</param> /// <param name="sShortName">The short name of the Paratext project</param> /// <param name="styleSheetFile">The style sheet file.</param> /// <param name="projPath">The path where the project is located</param> /// <param name="ws">The HVO of the writing system for the current export.</param> /// <returns>An XML document containing the settings for the Paratext project</returns> /// ------------------------------------------------------------------------------------ public XmlDocument UpdateSsfFile(TextReader ssf, FileNameFormat format, string sShortName, string styleSheetFile, string projPath, int ws) { ComputeSettings(format, projPath, ws); XmlDocument project = new XmlDocument(); project.InnerXml = ssf.ReadToEnd(); XmlNode scriptureTextNode = project.SelectSingleNode("ScriptureText"); XmlNode styleSheetNode = scriptureTextNode.SelectSingleNode("StyleSheet"); if (styleSheetNode == null) { scriptureTextNode.InnerXml += "<StyleSheet>" + styleSheetFile + "</StyleSheet>"; } XmlNode booksPresent, directory, encoding, fileNameForm, fileNamePostPart, fileNamePrePart, namingNode; bool fRequiredElementsMissing = false; fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "BooksPresent", out booksPresent); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "Directory", out directory); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "Encoding", out encoding); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNameForm", out fileNameForm); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNamePostPart", out fileNamePostPart); fRequiredElementsMissing |= !CheckNode(scriptureTextNode, "FileNamePrePart", out fileNamePrePart); namingNode = scriptureTextNode.SelectSingleNode("Naming"); if (namingNode != null && namingNode.OuterXml != NamingNode) { scriptureTextNode.RemoveChild(namingNode); namingNode = null; } if (namingNode == null) { fRequiredElementsMissing = true; scriptureTextNode.InnerXml += NamingNode; } // If the project is the same... if (!fRequiredElementsMissing && directory.InnerText == m_projPath && encoding.InnerText == kUnicodeEncoding && fileNameForm.InnerText == m_fileScheme && fileNamePostPart.InnerText == m_sPostPart && fileNamePrePart.InnerText == m_sPrePart) { // Need to add the books being exported to the existing list of books in the project. booksPresent.InnerText = MergeBooksPresent(booksPresent.InnerText); } else { // If any required elements were missing, we need to re-get all the nodes since the // ones we got before refer to the old XML. if (fRequiredElementsMissing) { booksPresent = scriptureTextNode.SelectSingleNode("BooksPresent"); directory = scriptureTextNode.SelectSingleNode("Directory"); encoding = scriptureTextNode.SelectSingleNode("Encoding"); fileNameForm = scriptureTextNode.SelectSingleNode("FileNameForm"); fileNamePostPart = scriptureTextNode.SelectSingleNode("FileNamePostPart"); fileNamePrePart = scriptureTextNode.SelectSingleNode("FileNamePrePart"); namingNode = scriptureTextNode.SelectSingleNode("Naming"); } // set up the default values. booksPresent.InnerText = BooksPresent; directory.InnerText = m_projPath; encoding.InnerText = kUnicodeEncoding; fileNameForm.InnerText = m_fileScheme; fileNamePostPart.InnerText = m_sPostPart; fileNamePrePart.InnerText = m_sPrePart; namingNode.Attributes.GetNamedItem("PostPart").Value = m_sPostPart; namingNode.Attributes.GetNamedItem("BookNameForm").Value = m_fileScheme; } XmlNode languageNode = scriptureTextNode.SelectSingleNode("Language"); if (languageNode == null) { scriptureTextNode.InnerXml += "<Language>" + m_wsName + "</Language>"; } else { languageNode.InnerText = m_wsName; } XmlNode leftToRight = scriptureTextNode.SelectSingleNode("LeftToRight"); if (leftToRight != null) { leftToRight.InnerText = m_LtoR; } // Technically, the Versification node isn't required. We only want to write // the versification if it doesn't already exist in the project file. XmlNode versification = scriptureTextNode.SelectSingleNode("Versification"); if (versification == null) { scriptureTextNode.InnerXml += "<Versification>" + m_versification + "</Versification>"; } return(project); }
public void UpdateParatextSsfFile_DifferentFolderSameSpec() { int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); // The existing file has a lot of books. string existingSsf = @"<ScriptureText>" + Environment.NewLine + @"<BooksPresent>111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000</BooksPresent>" + Environment.NewLine + @"<Copyright></Copyright>" + Environment.NewLine + @"<Directory>C:\My Documents\dummy</Directory>" + Environment.NewLine + @"<Editable>T</Editable>" + Environment.NewLine + @"<Encoding>65001</Encoding>" + Environment.NewLine + @"<FileNameForm>41MAT</FileNameForm>" + Environment.NewLine + @"<FileNamePostPart>suf.ext</FileNamePostPart>" + Environment.NewLine + @"<FileNamePrePart>pre</FileNamePrePart>" + Environment.NewLine + @"<FullName>My project Name</FullName>" + Environment.NewLine + @"<Language>Gumbasian</Language>" + Environment.NewLine + @"<LeftToRight>" + (vernWs.RightToLeft ? "F" : "T") + "</LeftToRight>" + Environment.NewLine + @"<Name>dummy</Name>" + Environment.NewLine + @"<StyleSheet>styFile.sty</StyleSheet>" + Environment.NewLine + @"<Versification>4</Versification>" + Environment.NewLine + "<Naming PrePart=\"pre\" PostPart=\"suf.ext\" BookNameForm=\"41MAT\"></Naming>" + Environment.NewLine + @"</ScriptureText>"; FileNameFormat fileNameFormat = new FileNameFormat("pre", FileNameFormat.SchemeFormat.NNBBB, "suf", "ext"); XmlDocument resultSSF; m_filter.Add(m_book.Hvo); using (StringReader sr = new StringReader(existingSsf)) { resultSSF = m_exporter.ParatextSsfFileAccessor.UpdateSsfFile(sr, fileNameFormat, "dummy", "styFile.sty", @"C:\My Paratext Projects\dummy", wsHvo); } // Verify the .ssf contents Dictionary<string, string> expectedSsfEntries = new Dictionary<string, string>(); expectedSsfEntries["BooksPresent"] = "100000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000"; expectedSsfEntries["Copyright"] = string.Empty; expectedSsfEntries["Directory"] = @"C:\My Paratext Projects\dummy"; expectedSsfEntries["Editable"] = "T"; expectedSsfEntries["Encoding"] = "65001"; expectedSsfEntries["FileNameForm"] = "41MAT"; expectedSsfEntries["FileNamePostPart"] = "suf.ext"; expectedSsfEntries["FileNamePrePart"] = "pre"; expectedSsfEntries["FullName"] = "My project Name"; expectedSsfEntries["Language"] = "francés"; expectedSsfEntries["LeftToRight"] = (vernWs.RightToLeft ? "F" : "T"); expectedSsfEntries["Name"] = "dummy"; expectedSsfEntries["StyleSheet"] = "styFile.sty"; expectedSsfEntries["Versification"] = "4"; // Preserve the versification of their original project expectedSsfEntries["Naming"] = string.Empty; Assert.AreEqual(1, resultSSF.ChildNodes.Count, "Only node in document should be ScriptureText"); XmlNode contents = resultSSF.SelectSingleNode("ScriptureText"); Assert.AreEqual(expectedSsfEntries.Count, contents.ChildNodes.Count); foreach (string expectedElement in expectedSsfEntries.Keys) { XmlNode node = contents.SelectSingleNode(expectedElement); Assert.IsNotNull(node); Assert.AreEqual(expectedSsfEntries[expectedElement], node.InnerText); } // Check the Naiming node (only node that uses attributes) XmlNode namingNode = contents.SelectSingleNode("Naming"); Assert.IsNotNull(namingNode); Assert.AreEqual("pre", namingNode.Attributes.GetNamedItem("PrePart").Value); Assert.AreEqual("suf.ext", namingNode.Attributes.GetNamedItem("PostPart").Value); Assert.AreEqual("41MAT", namingNode.Attributes.GetNamedItem("BookNameForm").Value); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ExportUsfm"/> class. /// </summary> /// <param name="cache">FDO cache to use for export</param> /// <param name="filter">book filter to determine which books to export</param> /// <param name="outputFolder">Folder name to export to</param> /// <param name="app">The application.</param> /// <param name="fileNameFormat">The file name format.</param> /// ------------------------------------------------------------------------------------ public ExportUsfm(FdoCache cache, FilteredScrBooks filter, string outputFolder, IApp app, FileNameFormat fileNameFormat) : this(cache, filter, outputFolder, app) { m_splitByBook = true; m_fileNameFormat = fileNameFormat; }