/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="startRef">The start reference at the position where the footnote ORC is /// in the vernacular text</param> /// <param name="endRef">The end reference at the position where the footnote ORC is in /// the vernacular text (can be different from start ref because of verse bridges). /// </param> /// <param name="hvo">The ID of the paragraph containing the ORC for the footnote. This /// could also be the last paragraph where it was found if it is in the process of /// being deleted (in which case ORCs may still exist in the corresponding back /// translations).</param> /// ------------------------------------------------------------------------------------ public FootnoteHashEntry(BCVRef startRef, BCVRef endRef, int hvo) { m_startRef = new BCVRef(startRef); m_endRef = new BCVRef(endRef); m_hvoPara = hvo; m_fFound = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert a new check result annotation at its correct position in the list. /// </summary> /// <param name="startRef">beginning reference note refers to</param> /// <param name="endRef">ending reference note refers to</param> /// <param name="beginObject">id of beginning object note refers to</param> /// <param name="endObject">id of ending object note refers to</param> /// <param name="checkId">The check id.</param> /// <param name="bldrQuote">Para builder to use for the cited text paragraph</param> /// <param name="bldrDiscussion">Para builder to use to build the Discussion /// paragraph</param> /// <returns>note inserted into annotation list</returns> /// ------------------------------------------------------------------------------------ public IScrScriptureNote InsertErrorAnnotation(BCVRef startRef, BCVRef endRef, ICmObject beginObject, ICmObject endObject, Guid checkId, StTxtParaBldr bldrQuote, StTxtParaBldr bldrDiscussion) { return InsertNote(startRef, endRef, beginObject, endObject, checkId, -1, 0, 0, bldrQuote, bldrDiscussion, null, null, GetInsertIndexForRef(startRef)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Notify all Santa Fe windows that a Scripture Reference focus change has occured. /// </summary> /// <param name="sRef">The string representation of the reference (e.g. MAT 1:1)</param> /// ------------------------------------------------------------------------------------ public static void SendFocusMessage(string sRef) { BCVRef bcvRef = new BCVRef(sRef); if (!bcvRef.Valid) return; s_SantaFeRefKey.SetValue(null, sRef); PostMessage(new IntPtr(-1), s_FocusMsg, (uint)FocusTypes.ScriptureReferenceFocus, 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the first annotation in the list that covers the specified reference. /// </summary> /// <param name="reference">Scripture reference to seek</param> /// <returns>The first note for the specified reference, if any; otherwise null</returns> /// ------------------------------------------------------------------------------------ public IScrScriptureNote GetFirstNoteForReference(BCVRef reference) { foreach (IScrScriptureNote note in NotesOS) { if (note.BeginRef <= reference && note.EndRef >= reference) return note; } return null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:SegmentInfo"/> class. /// </summary> /// <param name="sMarker">The segment marker.</param> /// <param name="sText">The segment text.</param> /// <param name="domain">The import domain.</param> /// <param name="reference">The current Scripture reference.</param> /// <param name="ws">The writing system (-1 to indicate the default WS).</param> /// ------------------------------------------------------------------------------------ internal SegmentInfo(string sMarker, string sText, ImportDomain domain, BCVRef reference, int ws) { m_sMarker = sMarker; m_sText = sText; m_domain = domain; m_ref = reference; m_ws = ws; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="ws"></param> /// <param name="bldr"></param> /// <param name="styleId"></param> /// <param name="ichOffset"></param> /// <param name="reference"></param> /// ------------------------------------------------------------------------------------ public BtFootnoteBldrInfo(int ws, ITsStrBldr bldr, string styleId, int ichOffset, BCVRef reference) { this.ws = ws; this.bldr = bldr; this.styleId = styleId; this.ichOffset = ichOffset; this.reference = new BCVRef(reference); }
/// <summary>overload for same end ref</summary> public static void VerifyParaDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { VerifyParaDiff(diff, startAndEnd, startAndEnd, type, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichMinRev, ichLimRev); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="SCTextSegment"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public SCTextSegment(string text, string marker, string literalVerse, BCVRef firstRef, BCVRef lastRef, string filename, int lineNumber) { m_marker = marker; m_text = text; m_firstRef = new BCVRef(firstRef); m_lastRef = new BCVRef(lastRef); m_filename = filename; m_lineNumber = lineNumber; m_literalVerse = literalVerse; }
public DummyPictureCheckingToken(ICmObject obj, int ws, string icuLocale) { m_startRef = m_endRef = new BCVRef(1, 3, 34); m_fNoteStart = false; m_fParagraphStart = false; m_icuLocale = icuLocale; m_object = obj; m_sText = "La biblioteque in Monroe"; m_paraStyleName = ScrStyleNames.Figure; m_textType = TextType.Other; Ws = ws; m_flid = CmPictureTags.kflidCaption; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the insert index where a new annotation is inserted when the annotation's /// reference is that specified. The index will be at the end of those for the /// specified reference. /// </summary> /// ------------------------------------------------------------------------------------ private int GetInsertIndexForRef(BCVRef startRef) { IFdoOwningSequence<IScrScriptureNote> notes = NotesOS; for (int i = notes.Count - 1; i >= 0; i--) { IScrScriptureNote note = notes[i]; if (note.BeginRef <= startRef) return i + 1; } return 0; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyParaCheckingToken"/> class. /// </summary> /// <param name="obj">The obj.</param> /// <param name="ws">The writing system</param> /// <param name="paraOffset">The para offset.</param> /// <param name="startRef">The start reference.</param> /// <param name="endRef">The end reference.</param> /// ------------------------------------------------------------------------------------ public DummyParaCheckingToken(ICmObject obj, int ws, int paraOffset, BCVRef startRef, BCVRef endRef) { m_startRef = startRef; m_endRef = endRef; m_fNoteStart = false; m_fParagraphStart = false; m_icuLocale = null; m_object = obj; m_sText = "This is lousy text and it is bad, it is"; m_paraStyleName = ScrStyleNames.NormalParagraph; m_textType = TextType.Verse; Ws = ws; m_flid = (int)StTxtPara.StTxtParaTags.kflidContents; m_paraOffset = paraOffset; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a text segment enumerator for importing a project /// </summary> /// <param name="firstRef">start reference for importing</param> /// <param name="lastRef">end reference for importing</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public ISCTextEnum TextEnum(BCVRef firstRef, BCVRef lastRef) { try { if (m_encConverters == null) m_encConverters = new EncConverters(); } catch (DirectoryNotFoundException ex) { string message = string.Format(ScriptureUtilsException.GetResourceString( "kstidEncConverterInitError"), ex.Message); throw new EncodingConverterException(message, "/Beginning_Tasks/Import_Standard_Format/Unable_to_Import/Encoding_converter_not_found.htm"); } // get the enumerator that will return text segments return new SCTextEnum(m_settings, m_domain, firstRef, lastRef, m_encConverters); }
public override void Initialize() { base.Initialize(); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); InitWsInfo(); DummyTeImporter.s_translatorNoteDefn = m_scrInMemoryCache.m_translatorNoteDefn; DummyTeImporter.s_consultantNoteDefn = m_scrInMemoryCache.m_consultantNoteDefn; m_titus = new BCVRef(56001001); m_settings = new DummyScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Other; m_settings.StartRef = m_titus; m_settings.EndRef = m_titus; m_settings.ImportTranslation = true; InitializeImportSettings(); m_importer = new DummyTeImporter(m_settings, Cache, m_styleSheet, m_scrInMemoryCache); m_importer.Initialize(); }
public void ValidBCVRefs() { BCVRef bcvRef = new BCVRef(1, 2, 3, 0); Assert.IsTrue(bcvRef.Valid); Assert.AreEqual(1002003, (int)bcvRef); Assert.AreEqual(1, bcvRef.Book); Assert.AreEqual(2, bcvRef.Chapter); Assert.AreEqual(3, bcvRef.Verse); bcvRef = new BCVRef(4005006); Assert.IsTrue(bcvRef.Valid); Assert.AreEqual(4005006, (int)bcvRef); Assert.AreEqual(4, bcvRef.Book); Assert.AreEqual(5, bcvRef.Chapter); Assert.AreEqual(6, bcvRef.Verse); bcvRef = new BCVRef(); Assert.IsFalse(bcvRef.Valid); Assert.AreEqual(0, (int)bcvRef); Assert.AreEqual(0, bcvRef.Book); Assert.AreEqual(0, bcvRef.Chapter); Assert.AreEqual(0, bcvRef.Verse); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="SCTextEnum"/> class. /// </summary> /// <param name="settings">The import settings</param> /// <param name="domain">The source domain</param> /// <param name="startRef">first reference to retrieve</param> /// <param name="endRef">last reference to retrieve</param> /// <param name="encConverters">The encoding converters repository</param> /// ------------------------------------------------------------------------------------ public SCTextEnum(IScrImportSet settings, ImportDomain domain, BCVRef startRef, BCVRef endRef, IEncConverters encConverters) { m_settings = settings; m_domain = domain; m_startRef = new BCVRef(startRef); m_endRef = new BCVRef(endRef); m_mappingSet = m_settings.GetMappingSetForDomain(domain); // Gets the set of encoding converters m_encConverters = encConverters; // make a list of all of the begin and end markers for inline markers // Also build the map of encoding converters m_InlineBeginAndEndMarkers = new List<string>(); foreach (ImportMappingInfo mapping in m_settings.GetMappingListForDomain(domain)) { if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5) { m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker); if (mapping.IsInline) m_InlineBeginAndEndMarkers.Add(mapping.EndMarker); } } m_InlineBeginAndEndMarkers.Sort(new StrLengthComparer(false)); // Build a list of all of the characters that inline markers start with Set<char> tempCharList = new Set<char>(); foreach (string marker in m_InlineBeginAndEndMarkers) tempCharList.Add(marker[0]); // Set ignores duplicates. m_InlineMarkerStartChars = tempCharList.ToArray(); // Get the import file source that will provide the files to import. m_importSource = settings.GetImportFiles(domain); m_importSourceEnum = m_importSource.GetEnumerator(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for any types that deal with changes in a paragraph. /// </summary> /// <remarks>char styles and subDiffs are not verified here; test code should just check /// those directly if relevant</remarks> /// <param name="diff">the given Difference.</param> /// <param name="start">The verse ref start.</param> /// <param name="end">The verse ref end.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraCurr">The Current paragraph.</param> /// <param name="ichMinCurr">The ich min in paraCurr.</param> /// <param name="ichLimCurr">The ich lim in paraCurr.</param> /// <param name="paraRev">The Revision paragraph.</param> /// <param name="ichMinRev">The ich min in paraRev.</param> /// <param name="ichLimRev">The ich lim in paraRev.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, StTxtPara paraCurr, int ichMinCurr, int ichLimCurr, StTxtPara paraRev, int ichMinRev, int ichLimRev) { // verify the basics Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); // the Current para stuff Assert.AreEqual(paraCurr.Hvo, diff.HvoCurr); Assert.AreEqual(ichMinCurr, diff.IchMinCurr); Assert.AreEqual(ichLimCurr, diff.IchLimCurr); // the Revision para stuff Assert.AreEqual(paraRev.Hvo, diff.HvoRev); Assert.AreEqual(ichMinRev, diff.IchMinRev); Assert.AreEqual(ichLimRev, diff.IchLimRev); // section stuff should be null Assert.IsNull(diff.HvosSectionsRev); Assert.IsNull(diff.HvosSectionsCurr); }
public void UndoImport_ReplaceBook() { FdoCache cache = m_firstMainWnd.Cache; Scripture scr = (Scripture)m_firstMainWnd.ScriptureObj; Set<int> origDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); // Create a settings object and set it to be a Paratext import of Philemon. ScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\it", @"\it*", false, MappingTargetType.TEStyle, MarkerDomain.Default, "Emphasis", null)); cache.Save(); // Setup the reference to import. BCVRef scrRef = new BCVRef(57001001); // Do the import. settings.ImportTranslation = true; settings.ImportBookIntros = true; settings.StartRef = scrRef; settings.EndRef = scrRef; m_firstMainWnd.Import(settings); IScrDraft importedDraft = GetImportedVersion(cache, origDrafts, 2); IScrBook importedPhm = importedDraft.FindBook(57); Assert.IsNotNull(importedPhm); Assert.IsTrue(cache.ActionHandlerAccessor.CanUndo()); Assert.AreEqual(UndoResult.kuresRefresh, cache.ActionHandlerAccessor.Undo()); IScrBook restoredPhm = scr.FindBook(57); Assert.IsNotNull(restoredPhm); Assert.AreNotEqual(restoredPhm.Hvo, importedPhm.Hvo); Set<int> finalDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); Assert.AreEqual(origDrafts.Count, finalDrafts.Count); }
public void UndoImport_NewBook() { FdoCache cache = m_firstMainWnd.Cache; Scripture scr = (Scripture)m_firstMainWnd.ScriptureObj; Set<int> origDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); // Create a settings object and set it to be a Paratext import of Titus. ScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\it", @"\it*", false, MappingTargetType.TEStyle, MarkerDomain.Default, "Emphasis", null)); cache.Save(); // Setup the reference to import. BCVRef scrRef = new BCVRef(56001001); // Do the import. settings.ImportTranslation = true; settings.ImportBookIntros = true; settings.StartRef = scrRef; settings.EndRef = scrRef; m_firstMainWnd.Import(settings); IScrDraft importedDrafts = GetImportedVersion(cache, origDrafts, 1); Assert.IsNotNull(importedDrafts.FindBook(56)); Assert.IsTrue(cache.ActionHandlerAccessor.CanUndo()); Assert.AreEqual(UndoResult.kuresRefresh, cache.ActionHandlerAccessor.Undo()); Assert.IsNull(scr.FindBook(56)); // JohnT: no longer happens, and I can't think why it should, since Undo does not // change Scripture. Set<int> finalDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); Assert.AreEqual(origDrafts.Count, finalDrafts.Count); }
public void VerifyStylesComboBoxAfterImport() { Unpacker.UnpackTEVTitusWithUnmappedStyle(); try { // Move selection to a place in the text where the styles combo contents // are not restricted to exclude general paragraphs (Jud 1:10 will do). m_firstDraftView.GotoVerse(65001010); // Make sure the style combo box doesn't have the UnknownTEStyle in it. Assert.IsTrue(m_firstMainWnd.ParaStylesComboBox.FindString(@"\xx") < 0, @"'\xx' was found!"); // Create a settings object and set it to be a Paratext import of the // TEV scripture project (containing Titus with an unmapped marker). IScripture scr = (Scripture)m_firstMainWnd.ScriptureObj; IScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); scr.DefaultImportSettings = settings; settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; // Setup the reference to import. BCVRef scrRef = new BCVRef(56001001); // Do the import. settings.ImportTranslation = true; (settings as ScrImportSet).StartRef = scrRef; (settings as ScrImportSet).EndRef = scrRef; m_firstMainWnd.Import(settings); m_firstMainWnd.InitStyleComboBox(); // Move selection back to Jud 1:10 because the selection seems to get messed // up in this test. m_firstDraftView.GotoVerse(65001010); // Make sure the styles combo now contains a new style for the unmapped marker // found in our test TEV style sheet and in the test Titus scripture data // (the style file and scripture data file contain the unmapped marker '\xx'). Assert.IsTrue(m_firstMainWnd.ParaStylesComboBox.FindString(@"\xx") >= 0, @"'\xx' was not found!"); } finally { Unpacker.UnPackParatextTestProjects(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Convert a Scripture reference to a string (perhaps like this: 16:3, depending on the /// chapterVerseSeparator). It will also handle script digits if necessary. /// </summary> /// <param name="reference">A ScrReference that holds the chapter and verse to format</param> /// <param name="hvoWs">The HVO of the writing system in which we are displaying this /// reference (used to determine whether to use script digits and whether to include /// right-to-left marks)</param> /// <returns>A formatted chapter/verse reference</returns> /// <remarks>See TeHeaderFooterVc for an example of how to format the full reference, /// including book name. The method BookName in that class could be moved somewhere /// more appropriate if it's ever needed.</remarks> /// ------------------------------------------------------------------------------------ public string ChapterVerseRefAsString(BCVRef reference, int hvoWs) { bool fUseScriptDigits = (UseScriptDigits && hvoWs == Cache.DefaultVernWs); string sVerseRef = (reference.Verse > 0) ? ConvertToString(reference.Verse, fUseScriptDigits) : String.Empty; if (reference.Chapter > 0 && reference.Verse > 0) { return ConvertToString(reference.Chapter, fUseScriptDigits) + ChapterVerseSeparatorForWs(hvoWs) + sVerseRef; } return sVerseRef; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Convert a Scripture reference to a string (like this: 16:3). It will also /// handle script digits if necessary. /// </summary> /// <param name="reference">A ScrReference that holds the chapter and verse to format</param> /// <returns>A formatted chapter/verse reference</returns> /// <remarks>See TeHeaderFooterVc for an example of how to format the full reference, /// including book name. The method BookName in that class could be moved somewhere /// more appropriate if it's ever needed.</remarks> /// ------------------------------------------------------------------------------------ public string ChapterVerseRefAsString(BCVRef reference) { return ChapterVerseRefAsString(reference, m_cache.DefaultVernWs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Parses a picture location range string. /// </summary> /// <param name="s">The string representation of a picture location range.</param> /// <param name="anchorLocation">The anchor location.</param> /// <param name="locType">The type of the location range. The incoming value tells us /// the assumed type for parsing. The out value can be set to a different type if we /// discover that the actual value is another type.</param> /// <param name="locationMin">The location min.</param> /// <param name="locationMax">The location max.</param> /// <remarks>This is implemented on Scripture because CmPicture's implementation does /// not handle Scripture reference ranges.</remarks> /// ------------------------------------------------------------------------------------ public void ParsePictureLoc(string s, int anchorLocation, ref PictureLocationRangeType locType, out int locationMin, out int locationMax) { locationMin = locationMax = 0; if (BCVRef.GetChapterFromBcv(anchorLocation) == 1 && BCVRef.GetVerseFromBcv(anchorLocation) == 0) { string[] pieces = s.Split(new char[] { '-' }, 2, StringSplitOptions.RemoveEmptyEntries); if (pieces.Length == 2 && Int32.TryParse(pieces[0], out locationMin) && Int32.TryParse(pieces[1], out locationMax)) { locType = PictureLocationRangeType.ParagraphRange; return; } locType = PictureLocationRangeType.AfterAnchor; return; } BCVRef startRef = new BCVRef(anchorLocation); BCVRef endRef = new BCVRef(anchorLocation); if (ScrReference.ParseRefRange(s, ref startRef, ref endRef, Versification) && startRef <= anchorLocation && endRef >= anchorLocation) { locationMin = startRef.BBCCCVVV; locationMax = endRef.BBCCCVVV; locType = PictureLocationRangeType.ReferenceRange; } else locType = PictureLocationRangeType.AfterAnchor; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Convert two Scripture references to a string (perhaps like this: 16:3-6), depending /// on the chapter/verse separator. It will also handle script digits if necessary. /// </summary> /// <param name="start">A BCVRef that holds the chapter and beginning verse to format</param> /// <param name="end">A BCVRef that holds the ending reference (if book and chapter /// don't match book and chapter of start ref, an argument exception is hurled</param> /// <param name="hvoWs">HVO of the writing system for which we are formatting this /// reference.</param> /// <returns>A formatted chapter/verse reference</returns> /// ------------------------------------------------------------------------------------ public string ChapterVerseBridgeAsString(BCVRef start, BCVRef end, int hvoWs) { if (start.Book != end.Book) throw new ArgumentException("Books are different"); if (start.Chapter != end.Chapter) throw new ArgumentException("Chapters are different"); string sResult = ChapterVerseRefAsString(start, hvoWs); if (start.Verse != end.Verse) { bool fUseScriptDigits = (UseScriptDigits && hvoWs == Cache.DefaultVernWs); sResult = MakeBridgeAsString(sResult, ConvertToString(end.Verse, fUseScriptDigits), hvoWs); } return sResult; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attempts to scroll to the first annotation whose beginning reference's book is /// the same as the specified book. /// </summary> /// ------------------------------------------------------------------------------------ private bool ScrollToNonScrAnnotationByBook(int book, string selectedText) { int bookHvo = m_scr.BookAnnotationsOS[book - 1].Hvo; int[] annHvos = ((ISilDataAccessManaged)m_rootb.DataAccess).VecProp(bookHvo, kCurrentNotesTag); if (annHvos.Length == 0) return false; int ihvo = 0; IScrScriptureNote ann; BCVRef bcvRef; // Go through the annotations for the book and find the one whose // cited text is the same as the specified selected text. for (int i = 0; i < annHvos.Length; i++) { ann = Cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(annHvos[i]); bcvRef = new BCVRef(ann.BeginRef); if (ann.CitedText == selectedText && bcvRef.Chapter == 0) { ihvo = i; break; } } ann = Cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(annHvos[ihvo]); bcvRef = new BCVRef(ann.BeginRef); if (bcvRef.Chapter > 0) return false; NotesEditingHelper.MakeSelectionInNote(m_vc, book - 1, ihvo, this, m_vc.IsExpanded(ann.Hvo)); return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets the start ref to first book available for import. /// </summary> /// ------------------------------------------------------------------------------------ private void SetStartRefToFirstImportableBook() { StartRef = new BCVRef(FirstImportableBook, 1, 1); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Clears the starting and ending references in this dialog. /// </summary> /// ------------------------------------------------------------------------------------ public static void ClearDialogReferences() { s_StartRef = null; s_EndRef = null; }
///------------------------------------------------------------------------------- /// <summary> /// If the user didn't choose cancel, save the controls' values. /// </summary> /// <param name="e"></param> ///------------------------------------------------------------------------------- protected override void OnClosing(CancelEventArgs e) { // If the scripture range is selected, then make sure both scripture references are // valid. Focus the incorrect one. if (this.DialogResult == DialogResult.OK && radImportRange.Checked) { if (!scrPsgFrom.Valid) { scrPsgFrom.Focus(); e.Cancel = true; return; } if (!scrPsgTo.Valid) { scrPsgTo.Focus(); e.Cancel = true; return; } } else if (DialogResult == DialogResult.OK && radImportEntire.Checked) { m_importSettings.StartRef = StartRef; m_importSettings.EndRef = EndRef; NonUndoableUnitOfWorkHelper.Do(ActionHandler, () => m_importSettings.SaveSettings()); } base.OnClosing(e); if (this.DialogResult == DialogResult.OK) { ImportEntire = radImportEntire.Checked; ImportTranslation = chkTranslation.Checked; ImportBackTranslation = chkBackTranslation.Checked; ImportBookIntros = chkBookIntros.Checked; ImportAnnotations = chkOther.Checked; s_StartRef = scrPsgFrom.ScReference; s_EndRef = scrPsgTo.ScReference; if (m_importSettings != null) { m_importSettings.StartRef = StartRef; m_importSettings.EndRef = EndRef; m_importSettings.ImportTranslation = chkTranslation.Checked; m_importSettings.ImportBackTranslation = chkBackTranslation.Checked; m_importSettings.ImportBookIntros = chkBookIntros.Checked; m_importSettings.ImportAnnotations = chkOther.Checked; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Find a paragraph with the specified style id, containing the specified verse number, /// if specified, and having the correct sequence number. /// </summary> /// <param name="targetStyle">style of paragraph to find</param> /// <param name="targetRef">Reference to seek</param> /// <param name="iPara">0-based index of paragraph</param> /// <param name="iVernSection">0-based index of the section the corresponding /// vernacular paragraph is in. This will be 0 if no corresponding paragraph can be /// found.</param> /// <returns>The corresponding StTxtPara, or null if no matching para is found</returns> /// ------------------------------------------------------------------------------------ public IScrTxtPara FindPara(IStStyle targetStyle, BCVRef targetRef, int iPara, ref int iVernSection) { // REVIEW: In production code, iPara is always passed as 0. Can we eliminate this parameter? // Do tests really need to be able to pass 1? Why are we testing something that can never happen in real life? Debug.Assert(targetRef.BookIsValid, "Invalid book number"); IScrBook book = FindBook(targetRef.Book); if (book == null) return null; return book.FindPara(targetStyle, targetRef, iPara, ref iVernSection); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets the end ref to last book available for import. /// </summary> /// ------------------------------------------------------------------------------------ private void SetEndRefToLastImportableBook() { EndRef = new BCVRef(LastImportableBook, 1, 1); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the Scripture reference of the specified annotation as string. /// </summary> /// <param name="ann">The specified annotation.</param> /// ------------------------------------------------------------------------------------ private string GetRefAsString(IScrScriptureNote ann) { BCVRef startRef = new BCVRef(ann.BeginRef); IScrBook book = m_scr.FindBook(startRef.Book); string bookName; // Book for note may not be in the project. if (book != null) bookName = book.BestUIName; else { IScrBookRef bookRef = Cache.ServiceLocator.GetInstance<IScrRefSystemRepository>().Singleton.BooksOS[startRef.Book - 1]; ITsString tsName = bookRef.BookName.get_String(Cache.DefaultUserWs); if (tsName.Length == 0) tsName = bookRef.BookName.BestAnalysisAlternative; bookName = tsName.Text; } string titleText = ResourceHelper.GetResourceString("kstidScriptureTitle"); string introText = ResourceHelper.GetResourceString("kstidScriptureIntro"); return BCVRef.MakeReferenceString(bookName, startRef, new BCVRef(ann.EndRef), m_scr.ChapterVerseSepr, m_scr.Bridge, titleText, introText); }