public void GoToScrScriptureNoteRef_VerseDeleted() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; int ichStartOrig = para.Contents.Text.IndexOf("two"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("two", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001002, 2001002, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = ichStartOrig; note.EndOffset = ichStartOrig + 3; // Now we delete verse two from that paragraph. int ichStartOfVerse2 = para.Contents.Text.IndexOf("2"); ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr(); bldr.Replace(ichStartOfVerse2, para.Contents.Length, string.Empty, null); para.Contents.UnderlyingTsString = bldr.GetString(); TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the selection is at the start of the verse 3. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); Assert.AreEqual(2, ichStart, "IP should be after verse number one and chapter number one."); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }
public void GoToScrScriptureNoteRef_OrigParaEmpty() { CheckDisposed(); ScrBook exodus = (ScrBook)ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus[1].ContentOA.ParagraphsOS[1]; int ichStartExpected = para.Contents.Text.IndexOf("three"); Assert.IsTrue(ichStartExpected > 0, "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("three", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001003, 2001003, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = ichStartExpected; note.EndOffset = ichStartExpected + 5; ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr(); bldr.ReplaceRgch(0, para.Contents.Length, string.Empty, 0, null); // We want to prevent data validation so that we can set up an empty paragraph. Cache.PropChangedHandling = PropChangedHandling.SuppressChangeWatcher; para.Contents.UnderlyingTsString = bldr.GetString(); Assert.AreEqual(0, para.Contents.Length, "Contents of paragraph 3 should have been deleted."); // Initial offsets are irrelevant since the original paragraph is empty. note.BeginOffset = 7; note.EndOffset = 12; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that a selection is made close to the empty paragraph with the deleted verse. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); Assert.AreEqual(2001002, helper.CurrentStartRef.BBCCCVVV); }
public void GoToScrScriptureNoteRef_TextExistethNot() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; Assert.IsFalse(para.Contents.Text.Contains("sixty-three"), "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); // Set text to something that does not exist in the verse to simiulate subsequent deletion. bldrQuote.AppendRun("sixty-three", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001001, 2001001, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = 100; note.EndOffset = 111; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the selection is at the start of the verse. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); Assert.AreEqual(2, ichStart, "IP should be at start of verse, following chapter number and verse number."); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }
public void GoToScrScriptureNoteRef_OrigParaGone() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; int ichStartExpected = para.Contents.Text.IndexOf("one"); Assert.IsTrue(ichStartExpected > 0, "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("one", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); StTxtPara para2 = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[1]; note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001001, 2001001, para2, para2, -1, 0 ,0, bldrQuote, null, null, null); // Now delete the paragraph the note refers to. exodus.SectionsOS[1].ContentOA.ParagraphsOS.RemoveAt(1); // Initial offsets are irrelevant since the original paragraph is deleted. note.BeginOffset = 10; note.EndOffset = 13; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the text referenced in the ScrScriptureNote is selected. Assert.IsTrue(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart, ichEnd; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); helper.EditedRootBox.Selection.TextSelInfo(true, out tss, out ichEnd, out assocPrev, out hvoSel, out tag, out ws); helper.EditedRootBox.Selection.GetSelectionString(out tss, "#"); Assert.AreEqual("one", tss.Text); Assert.AreEqual(ichStartExpected, ichStart); Assert.AreEqual(ichStartExpected + 3, ichEnd); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }