/// <summary>overload for same end ref</summary> public static void VerifyParaDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara paraRev, int ichMinRev, int ichLimRev) { VerifyParaDiff(diff, startAndEnd, startAndEnd, type, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichMinRev, ichLimRev); }
private void FixtureSetupInternal() { //IWritingSystem wsEn = Cache.WritingSystemFactory.get_Engine("en"); // Setup default analysis ws //m_wsEn = Cache.ServiceLocator.GetInstance<ILgWritingSystemRepository>().GetObject(wsEn.WritingSystem); m_wsVern = Cache.DefaultVernWs; m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create(); //Cache.LangProject.TextsOC.Add(m_text); m_stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create(); m_text.ContentsOA = m_stText; m_para = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(m_stText, ScrStyleNames.NormalParagraph); }
public void DeleteFootnoteInRangeSelectionAcrossMultipleBooks() { SetupSelectionForRangeAcrossBooks(); IScripture scr = Cache.LangProject.TranslatedScriptureOA; IScrFootnote[] footnotes = new IScrFootnote[4]; Guid[] guidFootnotes = new Guid[4]; IScrTxtPara[] paras = new IScrTxtPara[4]; // First get the footnotes we're deleting from JAMES. IScrBook book = scr.ScriptureBooksOS[1]; footnotes[0] = book.FootnotesOS[31]; footnotes[1] = book.FootnotesOS[32]; // First get the footnotes we're deleting from JUDE. book = (IScrBook)scr.ScriptureBooksOS[2]; footnotes[2] = book.FootnotesOS[0]; footnotes[3] = book.FootnotesOS[1]; for (int i = 0; i < 4; i++) { guidFootnotes[i] = footnotes[i].Guid; paras[i] = footnotes[i].ContainingParagraph; } m_footnoteView.DeleteFootnote(); foreach (IScrFootnote footnote in footnotes) Assert.IsFalse(footnote.IsValidObject); // now make sure that we don't find the footnote markers for (int i = 0; i < 4; i++) { Assert.IsFalse(IsFootnoteMarkerInText(paras[i], guidFootnotes[i]), "Footnote marker didn't get deleted from text"); } }
/// ------------------------------------------------------------------------------------ /// <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, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara 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, diff.ParaCurr); Assert.AreEqual(ichMinCurr, diff.IchMinCurr); Assert.AreEqual(ichLimCurr, diff.IchLimCurr); // the Revision para stuff Assert.AreEqual(paraRev, diff.ParaRev); Assert.AreEqual(ichMinRev, diff.IchMinRev); Assert.AreEqual(ichLimRev, diff.IchLimRev); // section stuff should be null Assert.IsNull(diff.SectionsRev); Assert.IsNull(diff.SectionsCurr); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference and checks that the 0th subdiff /// provides only reference points (i.e. IPs). /// Intended only for rootdiff types: ParagraphStructureChange, ParagraphSplitInCurrent, /// ParagraphMergedInCurrent. /// </summary> /// <param name="rootDiff">The root diff.</param> /// <param name="paraCurr">The para curr.</param> /// <param name="ichCurr">The ich curr.</param> /// <param name="paraRev">The para rev.</param> /// <param name="ichRev">The ich rev.</param> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffParaReferencePoints(Difference rootDiff, IScrTxtPara paraCurr, int ichCurr, IScrTxtPara paraRev, int ichRev) { Assert.IsTrue((rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0); Difference subDiff = rootDiff.SubDiffsForParas[0]; Assert.AreEqual(DifferenceType.NoDifference, subDiff.DiffType); Assert.AreEqual(paraCurr, subDiff.ParaCurr); Assert.AreEqual(ichCurr, subDiff.IchMinCurr); Assert.AreEqual(ichCurr, subDiff.IchLimCurr); Assert.AreEqual(paraRev, subDiff.ParaRev); Assert.AreEqual(ichRev, subDiff.IchMinRev); Assert.AreEqual(ichRev, subDiff.IchLimRev); Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.StyleNameCurr); Assert.IsNull(subDiff.StyleNameRev); Assert.IsNull(subDiff.SubDiffsForORCs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. /// </summary> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ //TODO: this is used only for VerseMoved subdiffs. rename it as VerifySubDiffVerseMoved. // provide logic appropriate for VerseMoved, and don't rely on VerifySubDiffTextCompared // Maybe just revert to the 2006 logic when VerseMoved was implemented. public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff, BCVRef start, BCVRef end, DifferenceType subDiffType, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara paraRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; // verify the Scripture references Assert.AreEqual(start, subDiff.RefStart); Assert.AreEqual(end, subDiff.RefEnd); // verify everything else VerifySubDiffTextCompared(rootDiff, iSubDiff, subDiffType, paraCurr, ichMinCurr, ichLimCurr, paraRev, ichMinRev, ichLimRev); }
public void InsertFootnote_OutOfOrder() { IScrBook book = AddBookToMockedScripture(1, "Genesis"); AddTitleToMockedBook(book, "Genesis"); m_draftView.BookFilter.Add(book); IScrSection section = AddSectionToMockedBook(book); // Construct a paragraph in the vernacular. IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); // Footnotes go here: a b c d e AddVerse(para, 1, 1, "Asi me dijo mi mama."); IScrFootnote footnote1 = AddFootnote(book, para, 4); AddParaToMockedText(footnote1, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote2 = AddFootnote(book, para, 8); AddParaToMockedText(footnote2, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote3 = AddFootnote(book, para, 14); AddParaToMockedText(footnote3, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote4 = AddFootnote(book, para, 18); AddParaToMockedText(footnote4, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote5 = AddFootnote(book, para, 25); AddParaToMockedText(footnote5, ScrStyleNames.NormalFootnoteParagraph); Assert.AreEqual(5, book.FootnotesOS.Count); // Construct the initial back translation // Footnotes go here: d e c b a AddSegmentFt(para, 1, "My mom told me so.", Cache.DefaultAnalWs); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 17, 17, true, false, true, VwScrollSelOpts.kssoDefault); //set the IP after the word "so" int iBtFootnote1; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote1); Assert.AreEqual(0, iBtFootnote1); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 18); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 14, 14, true, false, true, VwScrollSelOpts.kssoDefault); //set the IP after the word "me" int iBtFootnote2; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote2); Assert.AreEqual(1, iBtFootnote2); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 15); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 11, 11, true, false, true, VwScrollSelOpts.kssoDefault); //set the IP after the word "told" int iBtFootnote3; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote3); Assert.AreEqual(2, iBtFootnote3); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 12); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 2, 2, true, false, true, VwScrollSelOpts.kssoDefault); //set the IP after the word "My" int iBtFootnote4; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote4); Assert.AreEqual(3, iBtFootnote4); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 3); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 7, 7, true, false, true, VwScrollSelOpts.kssoDefault); //set the IP after the word "mom" int iBtFootnote5; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote5); Assert.AreEqual(4, iBtFootnote5); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 8); m_draftView.RefreshDisplay(); // Confirm that the footnote callers were inserted in the correct locations. VerifySegment(para, 1, "My" + StringUtils.kChObject + " mom" + StringUtils.kChObject + " told" + StringUtils.kChObject + " me" + StringUtils.kChObject + " so" + StringUtils.kChObject + ".", Cache.DefaultAnalWs); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote1, para, 1, Cache.DefaultAnalWs, 21); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote2, para, 1, Cache.DefaultAnalWs, 17); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote3, para, 1, Cache.DefaultAnalWs, 13); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote4, para, 1, Cache.DefaultAnalWs, 2); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote5, para, 1, Cache.DefaultAnalWs, 7); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the segment translations with notes and analyses. /// </summary> /// <param name="para">The para.</param> /// <param name="ichMin">The beginning character offset.</param> /// <param name="freeTrans">The free translation.</param> /// ------------------------------------------------------------------------------------ private void AddSegmentTranslations(IScrTxtPara para, int ichMin, string freeTrans) { // In the new FDO we can't really add arbitrary segments anymore. FDO now keeps // track of the paragraph content changes and creates segments for them on the // fly. The best we can do anymore is to find a segment that matches what we // think we want (a segment that starts at ichMin) and set the free translation // of that segment. ISegment foundSegment = para.SegmentsOS.FirstOrDefault(segment => segment.BeginOffset == ichMin); Assert.IsNotNull(foundSegment, "Failed to find a segment at " + ichMin + " for paragraph with contents: " + para.Contents.Text); INote note = null; if (!string.IsNullOrEmpty(freeTrans)) { // Add notes. note = Cache.ServiceLocator.GetInstance<INoteFactory>().Create(); foundSegment.NotesOS.Add(note); } if (freeTrans != null) { // Add literal and free translations and note contents foreach (IWritingSystem ws in Cache.LanguageProject.AnalysisWritingSystems) { string trans = freeTrans; if (ws.Handle != Cache.DefaultAnalWs) trans = trans.Replace("Trans", "Trans " + ws.IcuLocale); foundSegment.FreeTranslation.set_String(ws.Handle, trans); foundSegment.LiteralTranslation.set_String(ws.Handle, trans.Replace("Trans", "Literal")); if (note != null) { ITsString tss = TsStrFactoryClass.Create().MakeString("Note" + ws.IcuLocale, ws.Handle); note.Content.set_String(ws.Handle, tss); } } } // Add analyses FdoTestHelper.CreateAnalyses(foundSegment, para.Contents, foundSegment.BeginOffset, foundSegment.EndOffset); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for a point. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para, int ich) : this(para, ich, ich) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for the end of /// a paragraph. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para) : this(para, para.Contents.Length) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Helper method for verifying a ScrVerse. /// </summary> /// ------------------------------------------------------------------------------------ public static void VerifyScrVerse(ScrVerse scrVerse, IScrTxtPara para, int startRef, int endRef, string verseText, int iVerseStart, bool fIsChapter, bool fIsHeading, int iSection) { Assert.AreEqual(para, scrVerse.Para); Assert.AreEqual(startRef, scrVerse.StartRef); Assert.AreEqual(endRef, scrVerse.EndRef); Assert.AreEqual(verseText, scrVerse.Text.Text); Assert.AreEqual(iVerseStart, scrVerse.VerseStartIndex); Assert.AreEqual(fIsChapter, scrVerse.ChapterNumberRun); // check the ParaNodeMap too Assert.AreEqual(ScrBookTags.kflidSections, scrVerse.ParaNodeMap.BookFlid); Assert.AreEqual(iSection, scrVerse.ParaNodeMap.SectionIndex); Assert.AreEqual(fIsHeading ? ScrSectionTags.kflidHeading : ScrSectionTags.kflidContent, scrVerse.ParaNodeMap.SectionFlid); Assert.AreEqual(0, scrVerse.ParaNodeMap.ParaIndex); ParaNodeMap map = new ParaNodeMap(para); Assert.IsTrue(map.Equals(scrVerse.ParaNodeMap)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Calls the export paragraph method. /// </summary> /// <param name="para">The paragraph to export.</param> /// ------------------------------------------------------------------------------------ public void CallExportParagraph(IScrTxtPara para) { base.ExportParagraph(para); }
public void InsertFootnote_WithRangeSelectionInBt() { IScrBook book = AddBookToMockedScripture(1, "Genesis"); AddTitleToMockedBook(book, "Genesis"); m_draftView.BookFilter.Add(book); IScrSection section = AddSectionToMockedBook(book); AddSectionHeadParaToSection(section, "The first section", ScrStyleNames.SectionHead); // Construct a parent paragraph in the vernacular. IScrTxtPara parentPara = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(parentPara, 1, 1, "uno"); AddVerse(parentPara, 0, 2, "dos"); IScrFootnote footnote1 = AddFootnote(book, parentPara, 5); AddParaToMockedText(footnote1, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote2 = AddFootnote(book, parentPara, 10); AddParaToMockedText(footnote2, ScrStyleNames.NormalFootnoteParagraph); Assert.AreEqual(2, book.FootnotesOS.Count); // Construct the initial back translation int wsBt = Cache.DefaultAnalWs; ICmTranslation trans = AddBtToMockedParagraph(parentPara, wsBt); AddRunToMockedTrans(trans, wsBt, "one two", null); ITsStrBldr btTssBldr = trans.Translation.get_String(wsBt).GetBldr(); trans.Translation.set_String(wsBt, btTssBldr.GetString()); m_draftView.RefreshDisplay(); m_draftView.SelectRangeOfChars(0, 0, 0, 0, 3); // select the word "one" int iBtFootnote1; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote1); VerifyRequestedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 4); m_draftView.RefreshDisplay(); m_draftView.SelectRangeOfChars(0, 0, 0, 8, 5); // select the word "two" -- end before anchor int iBtFootnote2; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote2); VerifyRequestedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 9); // Confirm that the footnote callers were inserted in the correct locations. Assert.AreEqual("one" + StringUtils.kChObject + " two" + StringUtils.kChObject, trans.Translation.get_String(wsBt).Text); FdoTestHelper.VerifyBtFootnote(footnote1, parentPara, wsBt, 3); FdoTestHelper.VerifyBtFootnote(footnote2, parentPara, wsBt, 8); // Confirm that the footnote back translations contain the text that was selected // when they were inserted. ICmTranslation transFootnote1 = ((IScrTxtPara)footnote1.ParagraphsOS[0]).GetBT(); Assert.IsNotNull(transFootnote1); AssertEx.AreTsStringsEqual(DraftViewTests.GetReferencedTextFootnoteStr("one", Cache.DefaultAnalWs), transFootnote1.Translation.get_String(wsBt)); ICmTranslation transFootnote2 = ((IScrTxtPara)footnote2.ParagraphsOS[0]).GetBT(); Assert.IsNotNull(transFootnote2); AssertEx.AreTsStringsEqual(DraftViewTests.GetReferencedTextFootnoteStr("two", Cache.DefaultAnalWs), transFootnote2.Translation.get_String(wsBt)); }
public void VerseIterator() { // Create section 1 for Genesis. IScrSection section1 = CreateSection(m_genesis, "My aching head!"); // build paragraph for section 1 StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 2. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("3-4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 3-4.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara hvoS1Para = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA); // Create an iterator to test heading m_bookMerger.CreateVerseIteratorForStText(section1.HeadingOA); // Verify section 1 heading ScrVerse scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(section1.HeadingOA[0], scrVerse.Para); Assert.AreEqual(01002001, scrVerse.StartRef); Assert.AreEqual(01002001, scrVerse.EndRef); Assert.AreEqual("My aching head!", scrVerse.Text.Text); Assert.AreEqual(0, scrVerse.VerseStartIndex); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInStText(); Assert.IsNull(scrVerse); // Create an iterator to test content m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA); // Verify section 1 content scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(hvoS1Para, scrVerse.Para); Assert.AreEqual(01002001, scrVerse.StartRef); Assert.AreEqual(01002001, scrVerse.EndRef); Assert.AreEqual("2Verse 1. ", scrVerse.Text.Text); Assert.AreEqual(0, scrVerse.VerseStartIndex); Assert.AreEqual(1, scrVerse.TextStartIndex); scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(01002002, scrVerse.StartRef); Assert.AreEqual(01002002, scrVerse.EndRef); Assert.AreEqual("2Verse 2. ", scrVerse.Text.Text); Assert.AreEqual(10, scrVerse.VerseStartIndex); scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(01002003, scrVerse.StartRef); Assert.AreEqual(01002004, scrVerse.EndRef); Assert.AreEqual("3-4Verse 3-4.", scrVerse.Text.Text); Assert.AreEqual(20, scrVerse.VerseStartIndex); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInStText(); Assert.IsNull(scrVerse); }
public void VerseIterator_ForSetOfStTexts() { // Create section 1 for Genesis. IScrSection section1 = CreateSection(m_genesis, "My aching head!"); // build paragraph for section 1 StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para1 = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA); // Create section 2 for Genesis. IScrSection section2 = CreateSection(m_genesis, "My aching behind!"); // build paragraph for section 2 paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para2 = (IScrTxtPara)paraBldr.CreateParagraph(section2.ContentOA); // Create section 3 for Genesis. IScrSection section3 = CreateSection(m_genesis, ""); // build paragraph for section 3 paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; IScrTxtPara para3 = (IScrTxtPara)paraBldr.CreateParagraph(section3.ContentOA); // Create an iterator to test group of StTexts List <IStText> list = new List <IStText>(6); // this is not a typical list for TE, just a bunch of StTexts for this test list.Add(section1.HeadingOA); list.Add(section2.HeadingOA); list.Add(section3.HeadingOA); list.Add(section1.ContentOA); list.Add(section2.ContentOA); list.Add(section3.ContentOA); m_bookMerger.CreateVerseIteratorForSetOfStTexts(list); // Verify section 1 heading ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.HeadingOA[0], 01002001, 01002001, "My aching head!", 0, false, true, 0); // Verify section 2 heading scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.HeadingOA[0], 01003001, 01003001, "My aching behind!", 0, false, true, 1); // section 3 heading is empty, but returns an empty ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.HeadingOA[0], 01003001, 01003001, null, 0, false, true, 2); // Verify section 1 content scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.ContentOA[0], 01002001, 01002001, "2Verse 1. ", 0, true, false, 0); // Verify section 2 content scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.ContentOA[0], 01003001, 01003001, "3Verse 1. ", 0, true, false, 1); // Verify section 3 content--an empty ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.ContentOA[0], 01003001, 01003001, null, 0, false, false, 2); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInSet(); Assert.IsNull(scrVerse); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the test data. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { //Philemon IScrBook philemon = AddBookToMockedScripture(57, "Philemon"); AddTitleToMockedBook(philemon, "Philemon"); IScrSection introSection = AddSectionToMockedBook(philemon, true); IScrTxtPara para = AddParaToMockedSectionContent(introSection, ScrStyleNames.IntroParagraph); AddRunToMockedPara(para, "This is Philemon", null); IScrSection section = AddSectionToMockedBook(philemon); AddSectionHeadParaToSection(section, "Paul tells people", "Section Head"); para = AddParaToMockedSectionContent(section, "Paragraph"); AddRunToMockedPara(para, "1", "Chapter Number"); AddRunToMockedPara(para, "1", "Verse Number"); AddRunToMockedPara(para, "and the earth was without form and void and darkness covered the face of the deep", null); IScrSection section2 = AddSectionToMockedBook(philemon); AddSectionHeadParaToSection(section2, "Paul tells people more", "Section Head"); IScrTxtPara para2 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para2, "2", "Verse Number"); AddRunToMockedPara(para2, "paul expounds on the nature of reality", null); IScrTxtPara para3 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para3, "3", "Verse Number"); AddRunToMockedPara(para3, "the existentialists are all wrong", null); IScrBook james = AddBookToMockedScripture(59, "James"); AddTitleToMockedBook(james, "James"); // James first section section = AddSectionToMockedBook(james); AddSectionHeadParaToSection(section, "Paul tells people", "Section Head"); para = AddParaToMockedSectionContent(section, "Paragraph"); AddRunToMockedPara(para, "1", "Chapter Number"); AddRunToMockedPara(para, "1", "Verse Number"); AddRunToMockedPara(para, "and the earth was without form and void and darkness covered the face of the deep", null); // James section2 section2 = AddSectionToMockedBook(james); AddSectionHeadParaToSection(section2, "Paul tells people more", "Section Head"); para2 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para2, "2", "Chapter Number"); AddRunToMockedPara(para2, "1", "Verse Number"); AddRunToMockedPara(para2, "paul expounds on the nature of reality", null); para3 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para3, "2", "Verse Number"); AddRunToMockedPara(para3, "the existentialists are all wrong", null); // Jude IScrBook jude = AddBookToMockedScripture(65, "Jude"); AddTitleToMockedBook(jude, "Jude"); IScrSection judeSection = AddSectionToMockedBook(jude, true); AddSectionHeadParaToSection(judeSection, "Introduction", ScrStyleNames.IntroSectionHead); IScrTxtPara judePara = AddParaToMockedSectionContent(judeSection, ScrStyleNames.IntroParagraph); AddRunToMockedPara(judePara, "The Letter from Jude was written to warn against" + " false teachers who claimed to be believers. In this brief letter, which is similar in" + " content to 2 Peter the writer encourages his readers “to fight on for the faith which" + " once and for all God has given to his people.", null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for a range of /// text. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para, int ichMin, int ichLim) { Para = para; IchMin = ichMin; IchLim = ichLim; }
public void MoveNext_SpacesInVerses_ChapterNumberSeparate() { IScrSection sectionCur = AddSectionToMockedBook(m_genesis); // Create a section head for this section AddSectionHeadParaToSection(sectionCur, "My aching head!", ScrStyleNames.SectionHead); StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse One. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" Verse Two. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse Three.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para = (IScrTxtPara)paraBldr.CreateParagraph(sectionCur.ContentOA); using (ScrVerseSet verseSet = new ScrVerseSet(para)) { // Iterate through the verses in the paragraph ScrVerse verse; Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("1", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("Verse One. ", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("2 Verse Two. ", verse.Text.Text); Assert.AreEqual(01001002, verse.StartRef); Assert.AreEqual(01001002, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("3Verse Three.", verse.Text.Text); Assert.AreEqual(01001003, verse.StartRef); Assert.AreEqual(01001003, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("4 ", verse.Text.Text); Assert.AreEqual(01001004, verse.StartRef); Assert.AreEqual(01001004, verse.EndRef); Assert.IsFalse(verseSet.MoveNext()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for types: missing/added paragraphs. /// </summary> /// <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="paraAdded">The paragraph added.</param> /// <param name="paraDest">the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifyParaAddedDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, IScrTxtPara paraAdded, IScrTxtPara paraDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.ParagraphAddedToCurrent: Assert.IsNull(diff.SectionsRev); Assert.AreEqual(paraAdded, diff.ParaCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimCurr); Assert.AreEqual(paraDest, diff.ParaRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.ParagraphMissingInCurrent: Assert.IsNull(diff.SectionsRev); Assert.AreEqual(paraDest, diff.ParaCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(paraAdded, diff.ParaRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. This overload does not /// check for the starting and ending references for sub-diffs that are created without /// that information. /// </summary> /// <param name="rootDiff">The root difference.</param> /// <param name="iSubDiff">The sub difference to verify.</param> /// <param name="subDiffType">Type of the sub difference.</param> /// <param name="paraCurr">The current paragraph.</param> /// <param name="ichMinCurr">The beginning character offset of the difference in the /// current.</param> /// <param name="ichLimCurr">The ending character offset of the difference in the /// current.</param> /// <param name="paraRev">The revision paragraph.</param> /// <param name="ichMinRev">The beginning character offset of the difference in the /// revision.</param> /// <param name="ichLimRev">The ending character offset of the difference in the /// current.</param> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ //TODO: use an iSubDiff parameter instead of the subDiff itself; // use the following method as a model to verify the root diff type // make a separate method for footnote subdiffs public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara paraRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; // the Current para stuff Assert.AreEqual(paraCurr, subDiff.ParaCurr); Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr); Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr); // the Revision para stuff Assert.AreEqual(paraRev, subDiff.ParaRev); Assert.AreEqual(ichMinRev, subDiff.IchMinRev); Assert.AreEqual(ichLimRev, subDiff.IchLimRev); // section stuff should be null Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsCurr); // subDiffs may not have subDiffs, so far Assert.IsNull(subDiff.SubDiffsForORCs); Assert.IsNull(subDiff.SubDiffsForParas); Assert.AreEqual(subDiffType, subDiff.DiffType); if ((rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0) { // check the subDiff for consistency with the root diff. Assert.IsTrue((subDiff.DiffType & DifferenceType.TextDifference) != 0 || (subDiff.DiffType & DifferenceType.FootnoteAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteDifference) != 0 || (subDiff.DiffType & DifferenceType.MultipleCharStyleDifferences) != 0 || (subDiff.DiffType & DifferenceType.CharStyleDifference) != 0 || (subDiff.DiffType & DifferenceType.PictureAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureDifference) != 0 || subDiff.DiffType == DifferenceType.ParagraphStyleDifference || subDiff.DiffType == DifferenceType.NoDifference, // (structure change only) subDiff.DiffType + " is not a consistent subtype with split or merged paragraph differences."); } else { Assert.IsNotNull(paraCurr, "The current paragraph cannot be null except for para split/merge root diff"); Assert.IsNotNull(paraRev, "The revision paragraph cannot be null except for para split/merge root diff"); //check the root difference for consistency with this subDiff if (subDiff.DiffType == DifferenceType.VerseMoved) // || // subDiff.DiffType == DifferenceType.ParagraphMoved) { // this subDiff verse or paragraph was moved into an added section Assert.IsTrue(rootDiff.DiffType == DifferenceType.SectionAddedToCurrent || rootDiff.DiffType == DifferenceType.SectionMissingInCurrent, "inconsistent type of root difference"); } else if (subDiff.DiffType == DifferenceType.TextDifference) { // this subDiff text difference is within a footnote Assert.AreEqual(DifferenceType.FootnoteDifference, rootDiff.DiffType); } else { Assert.Fail("unexpected type of sub-diff"); } } }
public void InsertFootnote_WithRangeSelectionInBt() { IScrBook book = AddBookToMockedScripture(1, "Genesis"); AddTitleToMockedBook(book, "Genesis"); m_draftView.BookFilter.Add(book); IScrSection section = AddSectionToMockedBook(book); // Construct a paragraph in the vernacular. IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); // Footnote goes here: | AddVerse(para, 1, 1, "uno"); // Footnote goes here: | AddVerse(para, 0, 2, "dos"); IScrFootnote footnote1 = AddFootnote(book, para, 5); AddParaToMockedText(footnote1, ScrStyleNames.NormalFootnoteParagraph); IScrFootnote footnote2 = AddFootnote(book, para, 10); IStTxtPara footnote2Para = AddParaToMockedText(footnote2, ScrStyleNames.NormalFootnoteParagraph); // Put some text into this footnote, so there will be a segment created. footnote2Para.Contents = Cache.TsStrFactory.MakeString("fun stuff", Cache.DefaultVernWs); Assert.AreEqual(2, book.FootnotesOS.Count); // Construct the initial back translation int wsBt = Cache.DefaultAnalWs; AddSegmentFt(para, 1, "one", wsBt); AddSegmentFt(para, 3, "two", wsBt); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 1, 0, 3, true, false, true, VwScrollSelOpts.kssoDefault); // select the word "one" int iBtFootnote1; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote1); Assert.AreEqual(0, iBtFootnote1); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 1, 4); m_draftView.RefreshDisplay(); m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidContent, 0, 3, 3, 0, true, false, true, VwScrollSelOpts.kssoDefault); // select the word "two" -- end before anchor int iBtFootnote2; m_draftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote2); VerifyRequestedSegmentedBTSelection(0, 0, ScrSectionTags.kflidContent, 0, 3, 4); Assert.AreEqual(1, iBtFootnote2); // Confirm that the footnote callers were inserted in the correct locations. VerifySegment(para, 1, "one" + StringUtils.kChObject, wsBt); VerifySegment(para, 3, "two" + StringUtils.kChObject, wsBt); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote1, para, 1, wsBt, 3); FdoTestHelper.VerifyFootnoteInSegmentFt(footnote2, para, 3, wsBt, 3); // Confirm that the footnote back translations contain the text that was selected // when they were inserted. Assert.AreEqual(0, footnote1[0].SegmentsOS.Count, "Because the vernacular footnote had no text, there is no segment, so there was no place to put the selected BT text."); ISegment segFootnote2 = footnote2[0].SegmentsOS[0]; AssertEx.AreTsStringsEqual(DraftViewTests.GetReferencedTextFootnoteStr("two", wsBt), segFootnote2.FreeTranslation.get_String(wsBt)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference and checks that the 0th subdiff /// provides only reference points (i.e. IPs). /// Intended only for rootdiff types: ParagraphStructureChange, ParagraphSplitInCurrent, /// ParagraphMergedInCurrent. /// </summary> /// <param name="rootDiff">The root diff.</param> /// <param name="paraCurr">The para curr.</param> /// <param name="ichCurr">The ich curr.</param> /// <param name="paraRev">The para rev.</param> /// <param name="ichRev">The ich rev.</param> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffParaReferencePoints(Difference rootDiff, IScrTxtPara paraCurr, int ichCurr, IScrTxtPara paraRev, int ichRev) { Assert.IsTrue((rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0); Difference subDiff = rootDiff.SubDiffsForParas[0]; Assert.AreEqual(DifferenceType.NoDifference, subDiff.DiffType); Assert.AreEqual(paraCurr, subDiff.ParaCurr); Assert.AreEqual(ichCurr, subDiff.IchMinCurr); Assert.AreEqual(ichCurr, subDiff.IchLimCurr); Assert.AreEqual(paraRev, subDiff.ParaRev); Assert.AreEqual(ichRev, subDiff.IchMinRev); Assert.AreEqual(ichRev, subDiff.IchLimRev); Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.StyleNameCurr); Assert.IsNull(subDiff.StyleNameRev); Assert.IsNull(subDiff.SubDiffsForORCs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for a range of /// text. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para, int ichMin, int ichLim) { Para = para; IchMin = ichMin; IchLim = ichLim; }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for types: missing/added empty paragraphs. /// </summary> /// <param name="diff">the given Difference</param> /// <param name="startAndEnd">The starting and ending verse ref start.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraAdded">The paragraph added.</param> /// <param name="paraDest">the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifyStanzaBreakAddedDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, IScrTxtPara paraAdded, /*string strAddedParaStyle,*/ IScrTxtPara paraDest, int ichDest) { Assert.IsTrue(diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent || diff.DiffType == DifferenceType.StanzaBreakMissingInCurrent); //string addedParaStyle = (diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent) ? // diff.StyleNameCurr : diff.StyleNameRev; //Assert.AreEqual(strAddedParaStyle, addedParaStyle); VerifyParaAddedDiff(diff, startAndEnd, startAndEnd, type, paraAdded, paraDest, ichDest); }
void AddVerseSegment(IScrTxtPara para, int chapter, int verse, string verseText, string freeTrans) { int ichMin = para.Contents.Length; AddVerse(para, chapter, verse, verseText); int ichEndVerse = para.Contents.Length - verseText.Length; if (ichEndVerse > ichMin) AddSegmentTranslations(para, ichMin, null); AddSegmentTranslations(para, ichEndVerse, freeTrans); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// of type Missing/Added Section/SectionHead. /// </summary> /// <remarks>subDiffs are not verified here; test code should 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="sectionsAdded">Sections that were added (this can be single one or an /// array of them; the code will be smart enough to figure out which and act accordingly)</param> /// <param name="paraDest">The destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifySectionDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, object sectionsAdded, IScrTxtPara paraDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.SectionAddedToCurrent: case DifferenceType.SectionHeadAddedToCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsCurr.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsCurr.First()); } else if (sectionsAdded is IScrSection[]) { Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsCurr)); } else { Assert.Fail("Invalid parameter type"); } Assert.IsNull(diff.SectionsRev); Assert.AreEqual(null, diff.ParaCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(0, diff.IchLimCurr); Assert.AreEqual(paraDest, diff.ParaRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.SectionMissingInCurrent: case DifferenceType.SectionHeadMissingInCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsRev.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsRev.First()); } else if (sectionsAdded is IScrSection[]) { Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsRev)); } else { Assert.Fail("Invalid parameter type"); } Assert.IsNull(diff.SectionsCurr); Assert.AreEqual(paraDest, diff.ParaCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(null, diff.ParaRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(0, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; default: Assert.Fail("test called wrong verify method or something"); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verify that the paragraph has the expected number of segments with the expected free /// and literal translations. /// </summary> /// <param name="para">The paragraph.</param> /// <param name="translations">List of texts of the free translations.</param> /// <param name="lengths">List of lengths of the segments.</param> /// <param name="segNotes">The number of notes for each segment.</param> /// <param name="expectedWordforms">The indices of the words (relative to the paragraph) /// for which we expect wordforms instead of glosses.</param> /// <param name="label">Descriptive label to indicate what kind of test this is for.</param> /// ------------------------------------------------------------------------------------ private void VerifyTranslations(IScrTxtPara para, IList<string> translations, IList<int> lengths, IList<int> segNotes, IList<int> expectedWordforms, string label) { Assert.AreEqual(translations.Count, para.SegmentsOS.Count); foreach (IWritingSystem ws in Cache.LanguageProject.AnalysisWritingSystems) { int cumLength = 0; StringBuilder btBuilder = new StringBuilder(); for (int i = 0; i < translations.Count; i++) { ISegment seg = para.SegmentsOS[i]; Assert.AreEqual(cumLength, seg.BeginOffset, label + " - beginOffset " + i); cumLength += lengths[i]; Assert.AreEqual(cumLength, seg.EndOffset, label + " - endOffset " + i); string expectedBt = translations[i]; if (translations[i] != null && ws.Handle != Cache.DefaultAnalWs) expectedBt = expectedBt.Replace("Trans", "Trans " + ws.IcuLocale); Assert.AreEqual(expectedBt, seg.FreeTranslation.get_String(ws.Handle).Text, label + " - free translation " + i); string expectedLiteralTrans = (expectedBt == null) ? null : expectedBt.Replace("Trans", "Literal"); Assert.AreEqual(expectedLiteralTrans, seg.LiteralTranslation.get_String(ws.Handle).Text, label + " - literal translation " + i); if (!seg.IsLabel) { // Verify note added to first segment. Assert.AreEqual(segNotes[i], seg.NotesOS.Count, label + " - Wrong number of notes"); foreach (INote note in seg.NotesOS) Assert.AreEqual("Note" + ws.IcuLocale, note.Content.get_String(ws.Handle).Text); } if (expectedBt == null) btBuilder.Append(para.SegmentsOS[i].BaselineText.Text); else { btBuilder.Append(expectedBt); if (i < translations.Count - 1 && !expectedBt.EndsWith(" ")) btBuilder.Append(" "); } } Assert.AreEqual(btBuilder.ToString(), para.GetBT().Translation.get_String(ws.Handle).Text); } if (para.ParseIsCurrent) { for (int i = 0; i < translations.Count; i++) { ISegment seg = para.SegmentsOS[i]; FdoTestHelper.VerifyAnalysis(seg, i, new int[0], expectedWordforms); int numberOfWordformsInSegment = seg.AnalysesRS.Count; for (int iExp = 0; iExp < expectedWordforms.Count; iExp++) { if (expectedWordforms[iExp] > numberOfWordformsInSegment) expectedWordforms[iExp] -= numberOfWordformsInSegment; } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the reference for this footnote. /// </summary> /// <param name="owningBook">The owning book.</param> /// <param name="para">The para to search for a Scripture reference (verse or chapter). /// </param> /// <param name="startRef">The starting reference for this footnote (updated in this /// method).</param> /// <param name="endRef">The ending reference for this footnote (updated in this /// method).</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private RefResult GetReference(IScrBook owningBook, IScrTxtPara para, BCVRef startRef, BCVRef endRef) { bool foundSelf = (para != ParaContainingOrcRA); IStFootnoteRepository footnoteRepo = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>(); ITsString tssContents = para.Contents; for (int i = tssContents.RunCount - 1; i >= 0; i--) { string styleName = tssContents.get_StringProperty(i, (int)FwTextPropType.ktptNamedStyle); if (foundSelf && styleName == ScrStyleNames.VerseNumber && startRef.Verse == 0) { int nVerseStart, nVerseEnd; ScrReference.VerseToInt(tssContents.get_RunText(i), out nVerseStart, out nVerseEnd); startRef.Verse = nVerseStart; endRef.Verse = nVerseEnd; } else if (foundSelf && styleName == ScrStyleNames.ChapterNumber && startRef.Chapter == 0) { try { startRef.Chapter = endRef.Chapter = ScrReference.ChapterToInt(tssContents.get_RunText(i)); } catch (ArgumentException) { // ignore runs with invalid Chapter numbers } if (startRef.Verse == 0) { startRef.Verse = endRef.Verse = 1; } } else if (styleName == null) { IScrFootnote footnote = (IScrFootnote)footnoteRepo.GetFootnoteFromObjData(tssContents.get_StringProperty(i, (int)FwTextPropType.ktptObjData)); if (footnote != null) { if (footnote == this) { foundSelf = true; continue; } RefRange otherFootnoteLocation = ((ScrFootnote)footnote).FootnoteRefInfo_Internal; if (foundSelf && otherFootnoteLocation != RefRange.EMPTY) { // Found another footnote with a reference we can use if (startRef.Verse == 0) { startRef.Verse = otherFootnoteLocation.StartRef.Verse; endRef.Verse = otherFootnoteLocation.EndRef.Verse; } if (startRef.Chapter == 0) { startRef.Chapter = otherFootnoteLocation.StartRef.Chapter; endRef.Chapter = otherFootnoteLocation.EndRef.Chapter; } } else if (foundSelf) { // Previous footnote does not have a reference yet. We presume, for performance // reasons, that none of the previous footnotes have valid references yet, so // we set all the footnotes for the book. ((ScrBook)owningBook).RefreshFootnoteRefs(); return(RefResult.ScannedAllFootnotes); } } } if (startRef.Verse != 0 && endRef.Verse != 0 && startRef.Chapter != 0 && endRef.Chapter != 0) { return(RefResult.Found); } } return(RefResult.NotFound); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// /// This override provides special difference highlighting for a paragraph. /// </summary> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)StTextFrags.kfrPara: { // The hvo may refer to m_Differences.CurrentDifference, or to a subdiff, // so find the correct one. IScrTxtPara para = Cache.ServiceLocator.GetInstance <IScrTxtParaRepository>().GetObject(hvo); Difference diff = FindDiff(para); m_DispPropOverrides.Clear(); // If the diff represents added sections, and this paragraph belongs to it, // we must highlight the whole para bool fDisplayMissingParaPlaceholderAfter = false; if (diff != null) { bool highlightWholePara = diff.IncludesWholePara(para, m_fRev); // If the given paragraph has differences to be highlighted, // add appropriate properties if ((diff.GetPara(m_fRev) == para || highlightWholePara) && m_fNeedHighlight) { // Need to add override properties for each run in the // range to be highlighted. // Determine the range of the paragraph that we want to highlight. int paraMinHighlight = highlightWholePara ? 0 : diff.GetIchMin(m_fRev); int paraLimHighlight = highlightWholePara ? para.Contents.Length : diff.GetIchLim(m_fRev); if (paraMinHighlight == paraLimHighlight && IsParagraphAdditionOrDeletion(diff.DiffType)) { if (paraMinHighlight == 0) { InsertMissingContentPara(vwenv); } else { fDisplayMissingParaPlaceholderAfter = true; } } MakeDispPropOverrides(para, paraMinHighlight, paraLimHighlight, delegate(ref DispPropOverride prop) { prop.chrp.clrBack = kHighlightColor; }); } } // the base Display will do the actual displaying of the Para frag base.Display(vwenv, hvo, frag); if (fDisplayMissingParaPlaceholderAfter) { InsertMissingContentPara(vwenv); } break; } default: // handle all other frags base.Display(vwenv, hvo, frag); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets Scripture reference for a selection /// </summary> /// <param name="helper">The selection helper that represents the selection</param> /// <param name="fInclusive"><c>true</c> if the reference returned should include the /// reference of the text of the verse where the selection is, even if that selection /// is not at the start of the verse; <c>false</c> if the reference should be that of /// the first full verse at or following the selection</param> /// <param name="scriptureRef">returns the scripture reference found</param> /// <returns>A TsString representing the reference of the selection, or null if the /// selection represents a book title or something weird.</returns> /// ------------------------------------------------------------------------------------ private ITsString GetSelectionReference(SelectionHelper helper, bool fInclusive, out BCVRef scriptureRef) { scriptureRef = new BCVRef(); if (helper != null && m_page.Publication != null && m_page.Publication is ScripturePublication) { int iParaLevel = helper.GetLevelForTag(StTextTags.kflidParagraphs); if (iParaLevel >= 0) { int hvo = helper.LevelInfo[iParaLevel].hvo; IScrTxtPara para = m_cache.ServiceLocator.GetInstance <IScrTxtParaRepository>().GetObject(hvo); // Look through the verses of the paragraph until we pass the location // where the page break occurs. This verse reference will then be the // first one on the page. ScrVerse firstVerseOnPage = null; int ichPageBreak = helper.IchAnchor; foreach (ScrVerse verse in para) { if (!fInclusive) { firstVerseOnPage = verse; } if (verse.VerseStartIndex > ichPageBreak || (verse.VerseStartIndex == ichPageBreak && !fInclusive)) { break; } if (fInclusive) { firstVerseOnPage = verse; } } ITsString tssBookName = GetBookName(helper); if (tssBookName != null) { ITsStrBldr bldr = tssBookName.GetBldr(); int cch = bldr.Length; if (firstVerseOnPage != null) { if (firstVerseOnPage.StartRef.Verse != 0) { bldr.Replace(cch, cch, " " + m_scr.ChapterVerseRefAsString(firstVerseOnPage.StartRef), null); } scriptureRef = firstVerseOnPage.StartRef; } return(bldr.GetString()); } //else //{ // // Probably no verses were found in the paragraph // IVwSelection sel = FindNextPara(helper); // helper = SelectionHelper.Create(sel, helper.RootSite); // return GetSelectionReference(helper, fInclusive, out scriptureRef); //} } } return(null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given sub-difference /// for a two-sided subDiff representing a text comparison. This overload does not /// check for the starting and ending references for sub-diffs that are created without /// that information. /// </summary> /// <param name="rootDiff">The root difference.</param> /// <param name="iSubDiff">The sub difference to verify.</param> /// <param name="subDiffType">Type of the sub difference.</param> /// <param name="paraCurr">The current paragraph.</param> /// <param name="ichMinCurr">The beginning character offset of the difference in the /// current.</param> /// <param name="ichLimCurr">The ending character offset of the difference in the /// current.</param> /// <param name="paraRev">The revision paragraph.</param> /// <param name="ichMinRev">The beginning character offset of the difference in the /// revision.</param> /// <param name="ichLimRev">The ending character offset of the difference in the /// current.</param> /// <remarks>char styles are not verified here; test code should just check /// those directly if relevant</remarks> /// ------------------------------------------------------------------------------------ //TODO: use an iSubDiff parameter instead of the subDiff itself; // use the following method as a model to verify the root diff type // make a separate method for footnote subdiffs public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, IScrTxtPara paraCurr, int ichMinCurr, int ichLimCurr, IScrTxtPara paraRev, int ichMinRev, int ichLimRev) { Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; // the Current para stuff Assert.AreEqual(paraCurr, subDiff.ParaCurr); Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr); Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr); // the Revision para stuff Assert.AreEqual(paraRev, subDiff.ParaRev); Assert.AreEqual(ichMinRev, subDiff.IchMinRev); Assert.AreEqual(ichLimRev, subDiff.IchLimRev); // section stuff should be null Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsCurr); // subDiffs may not have subDiffs, so far Assert.IsNull(subDiff.SubDiffsForORCs); Assert.IsNull(subDiff.SubDiffsForParas); Assert.AreEqual(subDiffType, subDiff.DiffType); if ((rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0 || (rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0) { // check the subDiff for consistency with the root diff. Assert.IsTrue((subDiff.DiffType & DifferenceType.TextDifference) != 0 || (subDiff.DiffType & DifferenceType.FootnoteAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.FootnoteDifference) != 0 || (subDiff.DiffType & DifferenceType.MultipleCharStyleDifferences) != 0 || (subDiff.DiffType & DifferenceType.CharStyleDifference) != 0 || (subDiff.DiffType & DifferenceType.PictureAddedToCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureMissingInCurrent) != 0 || (subDiff.DiffType & DifferenceType.PictureDifference) != 0 || subDiff.DiffType == DifferenceType.ParagraphStyleDifference || subDiff.DiffType == DifferenceType.NoDifference, // (structure change only) subDiff.DiffType + " is not a consistent subtype with split or merged paragraph differences."); } else { Assert.IsNotNull(paraCurr, "The current paragraph cannot be null except for para split/merge root diff"); Assert.IsNotNull(paraRev, "The revision paragraph cannot be null except for para split/merge root diff"); //check the root difference for consistency with this subDiff if (subDiff.DiffType == DifferenceType.VerseMoved) // || // subDiff.DiffType == DifferenceType.ParagraphMoved) { // this subDiff verse or paragraph was moved into an added section Assert.IsTrue(rootDiff.DiffType == DifferenceType.SectionAddedToCurrent || rootDiff.DiffType == DifferenceType.SectionMissingInCurrent, "inconsistent type of root difference"); } else if (subDiff.DiffType == DifferenceType.TextDifference) { // this subDiff text difference is within a footnote Assert.AreEqual(DifferenceType.FootnoteDifference, rootDiff.DiffType); } else Assert.Fail("unexpected type of sub-diff"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Advances the enumerator to the next verse in the paragraph. /// </summary> /// <returns>True if we successfully moved to the next ScrVerse; False if we reached /// the end of the paragraph.</returns> /// ------------------------------------------------------------------------------------ public bool MoveNext() { InitializeParaContents(); if (m_ich > m_paraLength) { return(false); } m_ichVerseStart = m_ichTextStart = m_ich; TsRunInfo tsi; ITsTextProps ttpRun; string sPara = m_tssParaContents.Text; int nChapter = -1; // This is used to see if we found a chapter later. m_inVerseNum = false; m_inChapterNum = false; while (m_ich < m_paraLength) { ttpRun = m_tssParaContents.FetchRunInfoAt(m_ich, out tsi); // If this run is our verse number style if (ttpRun.Style() == ScrStyleNames.VerseNumber) { // If there is already a verse in process, a new verse number run will terminate it. if (m_ichVerseStart != m_ich) { break; } // Assume the whole run is the verse number string sVerseNum = sPara.Substring(m_ich, tsi.ichLim - tsi.ichMin); int nVerseStart, nVerseEnd; ScrReference.VerseToInt(sVerseNum, out nVerseStart, out nVerseEnd); m_startRef.Verse = nVerseStart; m_endRef.Verse = nVerseEnd; m_ichVerseStart = m_ich; //set VerseStart at beg of verse number m_ich += sVerseNum.Length; m_ichTextStart = m_ich; m_inVerseNum = true; } // If this run is our chapter number style else if (ttpRun.Style() == ScrStyleNames.ChapterNumber) { // If there is already a verse being processed, then the chapter number // run will end it if (m_ichVerseStart != m_ich) { break; } try { // Assume the whole run is the chapter number string sChapterNum = sPara.Substring(m_ich, tsi.ichLim - tsi.ichMin); nChapter = ScrReference.ChapterToInt(sChapterNum); m_startRef.Chapter = m_endRef.Chapter = nChapter; // Set the verse number to 1, since the first verse number after a // chapter is optional. If we happen to get a verse number in the // next run, this '1' will be overridden (though it will probably // still be a 1). m_startRef.Verse = m_endRef.Verse = 1; m_ichVerseStart = m_ich; //set VerseStart at beg of chapter number m_ich += sChapterNum.Length; m_ichTextStart = m_ich; m_inChapterNum = true; } catch (ArgumentException) { // ignore runs with invalid Chapter numbers m_ich += tsi.ichLim - tsi.ichMin; } } else // Process a text run. { // If it comes after a chapter number, then just return the // chapter number without adding the text. if (nChapter > 0) { break; } // skip to the next run m_ich += tsi.ichLim - tsi.ichMin; } } // determine if this verse is a complete paragraph, an empty para and/or a stanza break. m_isCompletePara = (m_ichVerseStart == 0 && m_ich == m_paraLength); if (string.IsNullOrEmpty(sPara)) { //m_isEmptyPara = true; m_isStanzaBreak = string.Equals(ScrStyleNames.StanzaBreak, m_para.StyleName); } try { return((m_ich > m_ichVerseStart) || FirstTimeAtStanzaBreak); } finally { // Update the previous paragraph for the next time (but we do the update // in a 'finally' so that we can compare the current to the previous for // the return value). m_prevPara = m_para; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference and given SubDiffForParas /// for subdiff types: missing/added paragraphs. /// </summary> /// <param name="rootDiff">The root diff.</param> /// <param name="iSubDiff">The para subdiff index.</param> /// <param name="subDiffType">diffType of the subdiff.</param> /// <param name="paraAdded">The para added.</param> /// <param name="ichLim">The ichlim for the paraAdded. Often this may be the end of the para, /// or it may indicate only the first portion (ScrVerse) of the final paragraph.</param> /// ------------------------------------------------------------------------------------ public static void VerifySubDiffParaAdded(Difference rootDiff, int iSubDiff, DifferenceType subDiffType, IScrTxtPara paraAdded, int ichLim) { Assert.IsTrue((rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0); // a ParaAdded/Missing subDiff must not be at index 0 (paragraph reference points must be in that subdiff Assert.LessOrEqual(1, iSubDiff); Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff]; Assert.AreEqual(subDiffType, subDiff.DiffType); switch (subDiffType) { case DifferenceType.ParagraphAddedToCurrent: Assert.AreEqual(paraAdded, subDiff.ParaCurr); Assert.AreEqual(0, subDiff.IchMinCurr); Assert.AreEqual(ichLim, subDiff.IchLimCurr); //subDiff may be only first portion of the final paragraph Assert.AreEqual(null, subDiff.ParaRev); Assert.AreEqual(0, subDiff.IchMinRev); Assert.AreEqual(0, subDiff.IchLimRev); break; case DifferenceType.ParagraphMissingInCurrent: Assert.AreEqual(null, subDiff.ParaCurr); Assert.AreEqual(0, subDiff.IchMinCurr); Assert.AreEqual(0, subDiff.IchLimCurr); Assert.AreEqual(paraAdded, subDiff.ParaRev); Assert.AreEqual(0, subDiff.IchMinRev); Assert.AreEqual(ichLim, subDiff.IchLimRev); //subDiff may be only first portion of the final paragraph break; default: Assert.Fail("Invalid subDiff type for a Paragraph Added/Missing subDiff"); break; } Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.SectionsRev); Assert.IsNull(subDiff.StyleNameCurr); Assert.IsNull(subDiff.StyleNameRev); Assert.IsNull(subDiff.SubDiffsForORCs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a Verse iterator from the back translation paragraph /// </summary> /// <param name="para">The paragraph with the back translation</param> /// <param name="BTWritingSystem">The writing system of the back translation</param> /// ------------------------------------------------------------------------------------ public ScrVerseSetBT(IScrTxtPara para, int BTWritingSystem) : base(para) { m_BackTranslationWS = BTWritingSystem; }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// for types: missing/added empty paragraphs. /// </summary> /// <param name="diff">the given Difference</param> /// <param name="startAndEnd">The starting and ending verse ref start.</param> /// <param name="type">Type of the diff.</param> /// <param name="paraAdded">The paragraph added.</param> /// <param name="paraDest">the destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifyStanzaBreakAddedDiff(Difference diff, BCVRef startAndEnd, DifferenceType type, IScrTxtPara paraAdded, /*string strAddedParaStyle,*/ IScrTxtPara paraDest, int ichDest) { Assert.IsTrue(diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent || diff.DiffType == DifferenceType.StanzaBreakMissingInCurrent); //string addedParaStyle = (diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent) ? // diff.StyleNameCurr : diff.StyleNameRev; //Assert.AreEqual(strAddedParaStyle, addedParaStyle); VerifyParaAddedDiff(diff, startAndEnd, startAndEnd, type, paraAdded, paraDest, ichDest); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ScrVerseSet"/> class, for the given /// paragraph. This version treats chapter numbers as separate ScrVerse tokens. /// </summary> /// <param name="para">given paragraph</param> /// ----------------------------------------------------------------------------------- public ScrVerseSet(IScrTxtPara para) : this(para, true) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// A helper method for book merger tests- /// Verifies the contents of the given difference /// of type Missing/Added Section/SectionHead. /// </summary> /// <remarks>subDiffs are not verified here; test code should 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="sectionsAdded">Sections that were added (this can be single one or an /// array of them; the code will be smart enough to figure out which and act accordingly)</param> /// <param name="paraDest">The destination paragraph</param> /// <param name="ichDest">The character index in the destination paragraph, /// where the added items could be inserted in the other book.</param> /// ------------------------------------------------------------------------------------ public static void VerifySectionDiff(Difference diff, BCVRef start, BCVRef end, DifferenceType type, object sectionsAdded, IScrTxtPara paraDest, int ichDest) { Assert.AreEqual(start, diff.RefStart); Assert.AreEqual(end, diff.RefEnd); Assert.AreEqual(type, diff.DiffType); switch (type) { case DifferenceType.SectionAddedToCurrent: case DifferenceType.SectionHeadAddedToCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsCurr.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsCurr.First()); } else if (sectionsAdded is IScrSection[]) Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsCurr)); else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.SectionsRev); Assert.AreEqual(null, diff.ParaCurr); Assert.AreEqual(0, diff.IchMinCurr); Assert.AreEqual(0, diff.IchLimCurr); Assert.AreEqual(paraDest, diff.ParaRev); Assert.AreEqual(ichDest, diff.IchMinRev); Assert.AreEqual(ichDest, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; case DifferenceType.SectionMissingInCurrent: case DifferenceType.SectionHeadMissingInCurrent: if (sectionsAdded is IScrSection) { Assert.AreEqual(1, diff.SectionsRev.Count()); Assert.AreEqual(sectionsAdded, diff.SectionsRev.First()); } else if (sectionsAdded is IScrSection[]) Assert.IsTrue(ArrayUtils.AreEqual((IScrSection[])sectionsAdded, diff.SectionsRev)); else Assert.Fail("Invalid parameter type"); Assert.IsNull(diff.SectionsCurr); Assert.AreEqual(paraDest, diff.ParaCurr); Assert.AreEqual(ichDest, diff.IchMinCurr); Assert.AreEqual(ichDest, diff.IchLimCurr); Assert.AreEqual(null, diff.ParaRev); Assert.AreEqual(0, diff.IchMinRev); Assert.AreEqual(0, diff.IchLimRev); Assert.IsNull(diff.StyleNameCurr); Assert.IsNull(diff.StyleNameRev); break; default: Assert.Fail("test called wrong verify method or something"); break; } }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ScrVerse"/> class for an empty paragraph. /// </summary> /// ----------------------------------------------------------------------------------- public ScrVerse(BCVRef start, BCVRef end, ITsString text, ParaNodeMap map, IScrTxtPara para, IStText paraOwner, bool isStanzaBreak) : this(start, end, text, map, para, paraOwner, 0, 0, false, false, true, isStanzaBreak) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates dummy paras. /// </summary> /// <returns>An array of paras</returns> /// ------------------------------------------------------------------------------------ public static IScrTxtPara[] CreateDummyParas(int count, FdoCache cache) { IText text = cache.ServiceLocator.GetInstance<ITextFactory>().Create(); //cache.LangProject.TextsOC.Add(text); IStText stText = cache.ServiceLocator.GetInstance<IStTextFactory>().Create(); text.ContentsOA = stText; IScrTxtPara[] paras = new IScrTxtPara[count]; for (int i = 0; i < paras.Length; i++) { paras[i] = cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle( stText, ScrStyleNames.NormalParagraph); } return paras; }
public void DeleteParagraph(IScrTxtPara para) { throw new NotImplementedException(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adjust the start and end section references to reflect the content of the section. /// </summary> /// <param name="paraToIgnore">The paragraph to ignore (likely because it's being deleted).</param> /// ------------------------------------------------------------------------------------ internal void AdjustReferences(IScrTxtPara paraToIgnore) { // Don't want to adjust references while cloning - direct copy is fine. if (m_cloneInProgress) return; if (SectionAdjustmentSuppressionHelper.IsSuppressionActive()) { SectionAdjustmentSuppressionHelper.RegisterSection(this); return; } // If this is not the first section then get the previous section's end reference // as a starting point for this section IScrSection prevSection = PreviousSection; ScrReference currentRefStart = new ScrReference(OwningBook.CanonicalNum, 1, 0, Cache.LangProject.TranslatedScriptureOA.Versification); if (prevSection != null) currentRefStart.BBCCCVVV = prevSection.VerseRefEnd; // If this is not an intro section then start the verse at 1 so it will not // be an intro section. if (currentRefStart.Verse == 0 && !IsIntro) currentRefStart.Verse = 1; // Default the starting reference for the case that there is no content. int newSectionStart = currentRefStart; // Scan the paragraphs of the section to get the min and max references ScrReference refMin = new ScrReference(currentRefStart); ScrReference refMax = new ScrReference(currentRefStart); ScrReference currentRefEnd = new ScrReference(currentRefStart); bool isFirstTextRun = true; if (ContentOA != null) { foreach (IStTxtPara para in ContentOA.ParagraphsOS) { if (para == paraToIgnore) continue; ITsString paraContents = para.Contents; int iLim = paraContents.RunCount; RefRunType runType = RefRunType.None; for (int iRun = 0; iRun < iLim; ) { // for very first run in StText we want to set VerseRefStart int iLimTmp = (iRun == 0 && isFirstTextRun) ? iRun + 1 : iLim; runType = Scripture.GetNextRef(iRun, iLimTmp, paraContents, true, ref currentRefStart, ref currentRefEnd, out iRun); // If a verse or chapter was found, adjust the max and min if the current // verse refs are less than min or greater than max if (runType != RefRunType.None) { // If a chapter or verse is found at the start of the section, then use that // reference instead of the one from the previous section as the min and max. if (isFirstTextRun || currentRefStart < refMin) refMin.BBCCCVVV = currentRefStart.BBCCCVVV; if (isFirstTextRun || currentRefEnd > refMax) refMax.BBCCCVVV = currentRefEnd.BBCCCVVV; } // after the first run, store the starting reference if (isFirstTextRun) { newSectionStart = currentRefStart; isFirstTextRun = false; } } } } // Store the min and max as the reference range for the section VerseRefStart = newSectionStart; VerseRefMin = refMin; VerseRefMax = refMax; // Store the last reference for the section. bool verseRefEndHasChanged = (VerseRefEnd != currentRefEnd.BBCCCVVV); bool verseRefEndChapterHasChanged = (BCVRef.GetChapterFromBcv(VerseRefEnd) != currentRefEnd.Chapter); VerseRefEnd = currentRefEnd; // If the last reference changes then the next section's references have potentially been invalidated IScrSection nextSection = NextSection; if (nextSection != null) { if ((verseRefEndChapterHasChanged && !nextSection.StartsWithChapterNumber)|| (verseRefEndHasChanged && !nextSection.StartsWithVerseOrChapterNumber)) { ((ScrSection)nextSection).AdjustReferences(); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verifys that the footnote marker was deleted /// </summary> /// <param name="hvoPara">HVO of the paragraph that contains the footnote marker</param> /// <param name="guidFootnote">GUID of the deleted footnote</param> /// ------------------------------------------------------------------------------------ private bool IsFootnoteMarkerInText(IScrTxtPara para, Guid guidFootnote) { ITsString tssContents = para.Contents; for (int i = 0; i < tssContents.RunCount; i++) { ITsTextProps tprops; TsRunInfo runInfo; tprops = tssContents.FetchRunInfo(i, out runInfo); string strGuid = tprops.GetStrPropValue((int)FwTextPropType.ktptObjData); if (strGuid != null) { Guid guid = MiscUtils.GetGuidFromObjData(strGuid.Substring(1)); if (guid == guidFootnote) return true; } } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for a point. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para, int ich) : this (para, ich, ich) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up the specified overrides (as controlled by the initializer) for the specified /// range of characters in the specified paragraph. Return true if anything changed. /// </summary> /// <param name="para">The paragraph .</param> /// <param name="ichMin">The index (in logical characters, relative to /// para.Contents) of the first character whose properties will be overridden.</param> /// <param name="ichLim">The character "limit" (in logical characters, /// relative to para.Contents) of the text whose properties will be overridden.</param> /// <param name="initializer">A delegate that modifies the display props of characters /// between ichMin and ichLim.</param> /// <param name="sourceRootBox">The source root box.</param> /// <returns><c>true</c> if the text overrides changed; <c>false</c> otherwise.</returns> /// ------------------------------------------------------------------------------------ public bool SetupOverrides(IScrTxtPara para, int ichMin, int ichLim, DispPropInitializer initializer, IVwRootBox sourceRootBox) { // ENHANCE JohnT: if more than one thing uses this at the same time, it may become necessary to // check whether we're setting up the same initializer. I don't know how to do this. Might need // another argument and variable to keep track of a type of override. if (para == m_overridePara && ichMin == m_ichMinOverride && ichLim == m_ichLimOverride) return false; if (m_overridePara != null && m_overridePara.IsValidObject) { // remove the old override. IStTxtPara oldPara = m_overridePara; m_overridePara = null; // remove it so the redraw won't show highlighting! UpdateDisplayOfPara(oldPara, sourceRootBox); } m_ichMinOverride = ichMin; m_ichLimOverride = ichLim; m_overridePara = para; m_overrideInitializer = initializer; if (m_overridePara != null && m_overridePara.IsValidObject) { // show the new override. UpdateDisplayOfPara(m_overridePara, sourceRootBox); } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a back translation from a format string, and attach it to the /// given paragraph. /// </summary> /// <param name="testBase">in-memory test base</param> /// <param name="book">book to use</param> /// <param name="para">the paragraph that will own this back translation</param> /// <param name="format">(See CreateText for the definition of the format string)</param> /// <param name="ws">writing system of the back translation</param> /// ------------------------------------------------------------------------------------ internal static void AddBackTranslation(ScrInMemoryFdoTestBase testBase, IScrBook book, IScrTxtPara para, string format, int ws) { ICmTranslation cmTrans = para.GetOrCreateBT(); // Set the translation string for the given WS cmTrans.Translation.set_String(ws, testBase.CreateFormatText(book, null, format, ws)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DiffLocation"/> class for the end of /// a paragraph. /// </summary> /// ------------------------------------------------------------------------------------ internal DiffLocation(IScrTxtPara para) : this(para, para.Contents.Length) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// privides access to the "MakeDispPropOverrides" method /// </summary> /// <param name="para">The para.</param> /// <param name="paraMinHighlight">The para min highlight.</param> /// <param name="paraLimHighlight">The para lim highlight.</param> /// <param name="initializer">The initializer.</param> /// ------------------------------------------------------------------------------------ public void CallMakeDispPropOverrides(IScrTxtPara para, int paraMinHighlight, int paraLimHighlight, DispPropInitializer initializer) { MakeDispPropOverrides(para, paraMinHighlight, paraLimHighlight, initializer); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Calls the export paragraph method. /// </summary> /// <param name="para">The paragraph to export.</param> /// ------------------------------------------------------------------------------------ public void CallExportParagraph(IScrTxtPara para) { base.ExportParagraph(para); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Make the DispPropOverrides we need to give the specified run of characters the /// display properties defined by the initializer. /// </summary> /// <param name="para">The paragraph.</param> /// <param name="paraMinHighlight">The index (in logical characters, relative to /// para.Contents) of the first character whose properties will be overridden.</param> /// <param name="paraLimHighlight">The character "limit" (in logical characters, /// relative to para.Contents) of the text whose properties will be overridden.</param> /// <param name="initializer">A delegate that modifies the display props of characters /// between ichMin and ichLim.</param> /// ------------------------------------------------------------------------------------ protected void MakeDispPropOverrides(IScrTxtPara para, int paraMinHighlight, int paraLimHighlight, DispPropInitializer initializer) { if (paraLimHighlight < paraMinHighlight) throw new ArgumentOutOfRangeException("paraLimHighlight", "ParaLimHighlight must be greater or equal to paraMinHighlight"); int offsetToStartOfParaContents = 0; if (para.Owner is IScrFootnote && para.IndexInOwner == 0) { IScrFootnote footnote = (IScrFootnote)para.Owner; string sMarker = footnote.MarkerAsString; if (sMarker != null) offsetToStartOfParaContents += sMarker.Length + OneSpaceString.Length; offsetToStartOfParaContents += footnote.RefAsString.Length; } // Add the needed properties to each run, within our range ITsString tss = para.Contents; TsRunInfo runInfo; int ichOverrideLim; int ichOverrideMin = Math.Min(Math.Max(paraMinHighlight, 0), tss.Length); int prevLim = 0; do { tss.FetchRunInfoAt(ichOverrideMin, out runInfo); ichOverrideLim = Math.Min(paraLimHighlight, runInfo.ichLim); Debug.Assert(ichOverrideLim <= tss.Length, "If we get a run it should be in the bounds of the paragraph"); // Prevent infinite loop in case of bad data in difference if (ichOverrideLim == prevLim) break; prevLim = ichOverrideLim; DispPropOverride prop = DispPropOverrideFactory.Create( ichOverrideMin + offsetToStartOfParaContents, ichOverrideLim + offsetToStartOfParaContents); initializer(ref prop); m_DispPropOverrides.Add(prop); // advance Min for next run ichOverrideMin = ichOverrideLim; } while (ichOverrideLim < paraLimHighlight); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called to make the test data for the tests /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { base.CreateTestData(); m_book = AddBookToMockedScripture(1, "Genesis"); m_section = AddSectionToMockedBook(m_book); m_para = AddParaToMockedSectionContent(m_section, ScrStyleNames.NormalParagraph); }
void AddRunAndSegmentToMockedPara(IScrTxtPara para, string runText, int ws, string freeTrans) { int ichMin = para.Contents.Length; AddRunToMockedPara(para, runText, ws); AddSegmentTranslations(para, ichMin, freeTrans); }
public override void TestTearDown() { m_styleSheet = null; m_exporter = null; m_book = null; m_section = null; m_para = null; base.TestTearDown(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verify that the paragraph has the expected number of segments with the expected free /// and literal translations. /// </summary> /// <param name="para">The paragraph.</param> /// <param name="translations">List of texts of the free translations.</param> /// <param name="lengths">List of lengths of the segments.</param> /// <param name="segNotes">The number of notes for each segment.</param> /// <param name="label">Descriptive label to indicate what kind of test this is for.</param> /// ------------------------------------------------------------------------------------ private void VerifyTranslations(IScrTxtPara para, IList<string> translations, IList<int> lengths, IList<int> segNotes, string label) { VerifyTranslations(para, translations, lengths, segNotes, new int[0], label); }
public void MultipleParas() { var paraFactory = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>(); IScrTxtPara paraPrev = paraFactory.CreateWithStyle(m_stText, 0, ScrStyleNames.NormalParagraph); IScrTxtPara paraFirst = paraFactory.CreateWithStyle(m_stText, 0, ScrStyleNames.NormalParagraph); IScrTxtPara paraNext = paraFactory.CreateWithStyle(m_stText, ScrStyleNames.NormalParagraph); IScrTxtPara paraLast = paraFactory.CreateWithStyle(m_stText, ScrStyleNames.NormalParagraph); string pc1 = "Das buch ist rot. "; string pc2 = "Das Madchen ist shon."; string verse1 = "9"; string pc3 = "Der Herr ist gross."; string pc4 = "Ich spreche nicht viel Deutsch."; string verse2 = "10"; string pc5 = "Was is das?"; string pc6 = "Wie gehts?"; ITsStrBldr bldr = TsStringUtils.MakeString(pc1 + pc2 + verse1 + pc3 + pc4 + verse2 + pc5, m_wsVern).GetBldr(); bldr.SetStrPropValue(pc1.Length + pc2.Length, pc1.Length + pc2.Length + verse1.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber); int ichEndV1 = pc1.Length + pc2.Length + verse1.Length + pc3.Length + pc4.Length; bldr.SetStrPropValue(ichEndV1, ichEndV1 + verse2.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber); var segments = GetSegments(bldr, m_para); string verse8 = "8"; bldr = TsStringUtils.MakeString(verse8 + pc3 + pc4, m_wsVern).GetBldr(); bldr.SetStrPropValue(0, verse8.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber); GetSegments(bldr, paraFirst); bldr = TsStringUtils.MakeString(pc1 + pc2, m_wsVern).GetBldr(); GetSegments(bldr, paraPrev); string verse11 = "11"; bldr = TsStringUtils.MakeString(pc3 + verse11 + pc4, m_wsVern).GetBldr(); bldr.SetStrPropValue(pc3.Length, pc3.Length + verse11.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber); GetSegments(bldr, paraNext); string verse12 = "12"; bldr = TsStringUtils.MakeString(verse12 + pc5 + pc6, m_wsVern).GetBldr(); bldr.SetStrPropValue(0, verse12.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.VerseNumber); GetSegments(bldr, paraLast); Assert.AreEqual(7, segments.Count); Assert.AreEqual("a", ScriptureServices.VerseSegLabel(paraFirst, 1)); Assert.AreEqual("b", ScriptureServices.VerseSegLabel(paraFirst, 2)); Assert.AreEqual("c", ScriptureServices.VerseSegLabel(paraPrev, 0)); Assert.AreEqual("d", ScriptureServices.VerseSegLabel(paraPrev, 1)); Assert.AreEqual("e", ScriptureServices.VerseSegLabel(m_para, 0)); Assert.AreEqual("f", ScriptureServices.VerseSegLabel(m_para, 1)); Assert.AreEqual("a", ScriptureServices.VerseSegLabel(m_para, 3)); Assert.AreEqual("b", ScriptureServices.VerseSegLabel(m_para, 4)); Assert.AreEqual("a", ScriptureServices.VerseSegLabel(m_para, 6), "should have label because seg in following para"); Assert.AreEqual("b", ScriptureServices.VerseSegLabel(paraNext, 0), "should have label due to previous para"); Assert.AreEqual("", ScriptureServices.VerseSegLabel(paraNext, 2), "should have no label because next para starts with verse"); }
private IScrFootnote AddFootnoteSegment(IScrTxtPara para1Curr, string noteText, string noteTrans) { int ichMin = para1Curr.Contents.Length; IScrFootnote footnote1Curr = AddFootnote(m_genesis, para1Curr, ichMin, noteText); AddSegmentTranslations((IScrTxtPara)footnote1Curr[0], 0, noteTrans); return footnote1Curr; }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { ITsStrFactory strfact = TsStrFactoryClass.Create(); //James IScrBook book = AddBookToMockedScripture(59, "James"); AddTitleToMockedBook(book, "James"); // James first section IScrSection section = AddSectionToMockedBook(book); AddSectionHeadParaToSection(section, "Paul tells people", "Section Head"); IStTxtPara para = AddParaToMockedSectionContent(section, "Paragraph"); AddRunToMockedPara(para, "1", "Chapter Number"); AddRunToMockedPara(para, "1", "Verse Number"); AddRunToMockedPara(para, "and the earth was without form and void and darkness covered the face of the deep", null); // James section2 IScrSection section2 = AddSectionToMockedBook(book); AddSectionHeadParaToSection(section2, "Paul tells people more", "Section Head"); IStTxtPara para2 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para2, "2", "Chapter Number"); AddRunToMockedPara(para2, "1", "Verse Number"); AddRunToMockedPara(para2, "paul expounds on the nature of reality", null); IStTxtPara para3 = AddParaToMockedSectionContent(section2, "Paragraph"); AddRunToMockedPara(para3, "2", "Verse Number"); AddRunToMockedPara(para3, "the existentialists are all wrong", null); // insert footnotes into para 2 of James ITsStrBldr jamesBldr = para2.Contents.GetBldr(); int iFootIch = 10; for (int i = 0; i < 2; i++) { IStFootnote foot = book.InsertFootnoteAt(i, jamesBldr, iFootIch); IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( foot, ScrStyleNames.NormalFootnoteParagraph); footPara.Contents = strfact.MakeString("This is footnote text for footnote " + i.ToString(), Cache.DefaultVernWs); iFootIch += 20; } para2.Contents = jamesBldr.GetString(); //Jude m_Jude = AddBookToMockedScripture(65, "Jude"); AddTitleToMockedBook(m_Jude, "Jude"); //Jude intro section IScrSection judeSection = AddSectionToMockedBook(m_Jude); AddSectionHeadParaToSection(judeSection, "Introduction", "Intro Section Head"); IStTxtPara judePara = AddParaToMockedSectionContent(judeSection, "Intro Paragraph"); AddRunToMockedPara(judePara, "The Letter from Jude was written to warn against" + " false teachers who claimed to be believers. In this brief letter, which is similar in" + " content to 2 Peter the writer encourages his readers \u201Cto fight on for the faith which" + " once and for all God has given to his people.", null); // Insert BT (in two different writing systems) of intro paragraph ICmTranslation transEn = AddBtToMockedParagraph(judePara, m_wsEn); ICmTranslation transDe = AddBtToMockedParagraph(judePara, m_wsDe); // Jude Scripture section IScrSection judeSection2 = AddSectionToMockedBook(m_Jude); AddSectionHeadParaToSection(judeSection2, "First section", "Section Head"); IStTxtPara judePara2 = AddParaToMockedSectionContent(judeSection2, "Paragraph"); AddRunToMockedPara(judePara2, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(judePara2, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(judePara2, "This is the first verse", null); AddRunToMockedPara(judePara2, "2", ScrStyleNames.VerseNumber); AddRunToMockedPara(judePara2, "This is the second verse", null); AddRunToMockedPara(judePara2, "3", ScrStyleNames.VerseNumber); AddRunToMockedPara(judePara2, "This is the third verse", null); AddRunToMockedPara(judePara2, "4", ScrStyleNames.VerseNumber); AddRunToMockedPara(judePara2, "This is the fourth verse", null); // Insert footnotes into para 1 of Jude ITsStrBldr bldr = judePara.Contents.GetBldr(); iFootIch = 10; for (int i = 0; i < 4; i++) { IStFootnote foot = m_Jude.InsertFootnoteAt(i, bldr, iFootIch); IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( foot, ScrStyleNames.NormalFootnoteParagraph); footPara.Contents = strfact.MakeString("This is text for footnote " + i.ToString(), Cache.DefaultVernWs); iFootIch += 30; // Insert ORC for footnote into BT (in both writing systems) AddBtFootnote(transEn, i, m_wsEn, foot); AddBtFootnote(transDe, i, m_wsDe, foot); } judePara.Contents = bldr.GetString(); // Insert footnotes into para 2 of Jude bldr = judePara2.Contents.GetBldr(); iFootIch = 10; for (int i = 0; i < 4; i++) { IStFootnote foot = m_Jude.InsertFootnoteAt(i + 4, bldr, iFootIch); IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( foot, ScrStyleNames.NormalFootnoteParagraph); footPara.Contents = strfact.MakeString("This is text for footnote " + (i + 4).ToString(), Cache.DefaultVernWs); iFootIch += 20; } judePara2.Contents = bldr.GetString(); }