/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the texts for each Scripture book title, section, footnote, etc. /// </summary> /// ------------------------------------------------------------------------------------ public void LoadScriptureTexts(FdoCache cache, IBookImporter bookImporter) { m_bookImporter = bookImporter; m_associatedPtText = bookImporter != null?ParatextHelper.GetAssociatedProject(cache.ProjectId) : null; m_scr = cache.LanguageProject.TranslatedScriptureOA; if (m_scr == null) { return; } List <TreeNode> otBooks = new List <TreeNode>(); List <TreeNode> ntBooks = new List <TreeNode>(); for (int bookNum = 1; bookNum <= BCVRef.LastBook; bookNum++) { var bookName = cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS[bookNum - 1].UIBookName; object book = m_scr.FindBook(bookNum); if (book == null) { if (m_associatedPtText != null && m_associatedPtText.BookPresent(bookNum)) { book = bookNum; } else { continue; } } TreeNode node = new TreeNode(bookName); node.Tag = book; node.Name = "Book"; // help us query for books. if (bookNum < ScriptureTags.kiNtMin) { otBooks.Add(node); } else { ntBooks.Add(node); } } TreeNode bibleNode = new TreeNode(FwControls.kstidBibleNode); bibleNode.Name = "Bible"; if (otBooks.Count > 0) { TreeNode testamentNode = new TreeNode(FwControls.kstidOtNode, otBooks.ToArray()); testamentNode.Name = "Testament"; // help us query for Testaments bibleNode.Nodes.Add(testamentNode); } if (ntBooks.Count > 0) { TreeNode testamentNode = new TreeNode(FwControls.kstidNtNode, ntBooks.ToArray()); testamentNode.Name = "Testament"; // help us query for Testaments bibleNode.Nodes.Add(testamentNode); } Nodes.Add(bibleNode); }
/// <summary> /// This class creates text, it must delete it here when UNDO is commanded /// so it can update InterestingTexts. /// </summary> /* public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel) * { * if (cvDel != 1) * return; * SaveOnChangeRecord(); * SuppressSaveOnChangeRecord = true; * try * { * m_list.DeleteCurrentObject(); * } * finally * { * SuppressSaveOnChangeRecord = false; * } * GetInterestingTextList().UpdateInterestingTexts(); * } */ #region IBookImporter Members /// ------------------------------------------------------------------------------------ /// <summary> /// Imports the specified book. /// </summary> /// <param name="bookNum">The canonical book number.</param> /// <param name="owningForm">Form that can be used as the owner of progress dialogs and /// message boxes.</param> /// <param name="importBt">True to import only the back translation, false to import /// only the main translation</param> /// <returns> /// The ScrBook created to hold the imported data /// </returns> /// ------------------------------------------------------------------------------------ public IScrBook Import(int bookNum, Form owningForm, bool importBt) { IScripture scr = Cache.LangProject.TranslatedScriptureOA; bool haveSomethingToImport = NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => { IScrImportSet importSettings = scr.FindOrCreateDefaultImportSettings(TypeOfImport.Paratext6); importSettings.StyleSheet = ScriptureStylesheet; IScrText paratextProj = ParatextHelper.GetAssociatedProject(Cache.ProjectId); importSettings.ParatextScrProj = paratextProj.Name; importSettings.StartRef = new BCVRef(bookNum, 0, 0); int chapter = paratextProj.Versification.LastChapter(bookNum); importSettings.EndRef = new BCVRef(bookNum, chapter, paratextProj.Versification.LastVerse(bookNum, chapter)); if (!importBt) { importSettings.ImportTranslation = true; importSettings.ImportBackTranslation = false; } else { List <IScrText> btProjects = ParatextHelper.GetBtsForProject(paratextProj).ToList(); if (btProjects.Count > 0 && (string.IsNullOrEmpty(importSettings.ParatextBTProj) || !btProjects.Any(st => st.Name == importSettings.ParatextBTProj))) { importSettings.ParatextBTProj = btProjects[0].Name; } if (string.IsNullOrEmpty(importSettings.ParatextBTProj)) { return(false); } importSettings.ImportTranslation = false; importSettings.ImportBackTranslation = true; } ParatextHelper.LoadProjectMappings(importSettings); ScrMappingList importMap = importSettings.GetMappingListForDomain(ImportDomain.Main); ImportMappingInfo figureInfo = importMap[@"\fig"]; if (figureInfo != null) { figureInfo.IsExcluded = true; } importSettings.SaveSettings(); return(true); }); if (haveSomethingToImport && ReflectionHelper.GetBoolResult(ReflectionHelper.GetType("TeImportExport.dll", "SIL.FieldWorks.TE.TeImportManager"), "ImportParatext", owningForm, ScriptureStylesheet, (FwApp)m_mediator.PropertyTable.GetValue("App"))) { return(scr.FindBook(bookNum)); } return(null); }
/// <summary> /// This class creates text, it must delete it here when UNDO is commanded /// so it can update InterestingTexts. /// </summary> /* public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel) * { * if (cvDel != 1) * return; * SaveOnChangeRecord(); * SuppressSaveOnChangeRecord = true; * try * { * m_list.DeleteCurrentObject(); * } * finally * { * SuppressSaveOnChangeRecord = false; * } * GetInterestingTextList().UpdateInterestingTexts(); * } */ #region IBookImporter Members /// ------------------------------------------------------------------------------------ /// <summary> /// Imports the specified book. /// </summary> /// <param name="bookNum">The canonical book number.</param> /// <param name="owningForm">Form that can be used as the owner of progress dialogs and /// message boxes.</param> /// <param name="importBt">True to import only the back translation, false to import /// only the main translation</param> /// <returns> /// The ScrBook created to hold the imported data /// </returns> /// ------------------------------------------------------------------------------------ public IScrBook Import(int bookNum, Form owningForm, bool importBt) { IScripture scr = Cache.LangProject.TranslatedScriptureOA; bool haveSomethingToImport = NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => { IScrImportSet importSettings = scr.FindOrCreateDefaultImportSettings(TypeOfImport.Paratext6); ScrText paratextProj = ParatextHelper.GetAssociatedProject(Cache.ProjectId); importSettings.ParatextScrProj = paratextProj.Name; importSettings.IncludeBooks(bookNum, bookNum, paratextProj.Versification); if (!importBt) { importSettings.ImportTranslation = true; importSettings.ImportBackTranslation = false; } else { List <ScrText> btProjects = ParatextHelper.GetBtsForProject(paratextProj).ToList(); if (btProjects.Count > 0 && (string.IsNullOrEmpty(importSettings.ParatextBTProj) || !btProjects.Any(st => st.Name == importSettings.ParatextBTProj))) { importSettings.ParatextBTProj = btProjects[0].Name; } if (string.IsNullOrEmpty(importSettings.ParatextBTProj)) { return(false); } importSettings.ImportTranslation = false; importSettings.ImportBackTranslation = true; } return(true); }); if (haveSomethingToImport && ReflectionHelper.GetBoolResult(ReflectionHelper.GetType("TeImportExport.dll", "SIL.FieldWorks.TE.TeImportManager"), "ImportParatext", owningForm, ScriptureStylesheet, (FwApp)m_mediator.PropertyTable.GetValue("App"))) { return(scr.FindBook(bookNum)); } return(null); }