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));
        }
Example #2
0
        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));
        }
Example #3
0
        public void InsertFootnote_WithRangeSelectionInBt()
        {
            CheckDisposed();

            IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus");

            m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus");
            m_btDraftView.BookFilter.Insert(0, book.Hvo);
            IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "The first section",
                                                           ScrStyleNames.SectionHead);

            // Construct a parent paragraph in the vernacular.
            StTxtPara parentPara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                    ScrStyleNames.NormalParagraph);

            AddVerse(parentPara, 1, 1, "uno");
            AddVerse(parentPara, 0, 2, "dos");
            StFootnote footnote1 = m_scrInMemoryCache.AddFootnote(book, parentPara, 5);

            m_scrInMemoryCache.AddParaToMockedText(footnote1.Hvo, ScrStyleNames.NormalFootnoteParagraph);
            StFootnote footnote2 = m_scrInMemoryCache.AddFootnote(book, parentPara, 10);

            m_scrInMemoryCache.AddParaToMockedText(footnote2.Hvo, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(2, book.FootnotesOS.Count);
            section.AdjustReferences();

            // Construct the initial back translation
            int            wsBt  = m_inMemoryCache.Cache.DefaultAnalWs;
            ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(parentPara, wsBt);

            m_inMemoryCache.AddRunToMockedTrans(trans, wsBt, "one two", null);
            ITsStrBldr btTssBldr = trans.Translation.GetAlternative(wsBt).UnderlyingTsString.GetBldr();

            trans.Translation.SetAlternative(btTssBldr.GetString(), wsBt);

            m_btDraftView.SelectRangeOfChars(0, 0, 0, 0, 3);             // select the word "one"
            int iBtFootnote1;

            m_btDraftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote1);

            m_btDraftView.SelectRangeOfChars(0, 0, 0, 8, 5);             // select the word "two" -- end before anchor
            int iBtFootnote2;

            m_btDraftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote2);

            // Confirm that the footnote callers were inserted in the correct locations.
            Assert.AreEqual("one" + StringUtils.kchObject + " two" + StringUtils.kchObject,
                            trans.Translation.GetAlternative(wsBt).UnderlyingTsString.Text);
            StTxtParaTests.VerifyBtFootnote(footnote1, parentPara, wsBt, 3);
            StTxtParaTests.VerifyBtFootnote(footnote2, parentPara, wsBt, 8);

            // Confirm that the footnote back translations contain the text that was selected
            // when they were inserted.
            ICmTranslation transFootnote1 = ((StTxtPara)footnote1.ParagraphsOS[0]).GetBT();

            Assert.IsNotNull(transFootnote1);
            AssertEx.AreTsStringsEqual(DraftViewTests.GetReferencedTextFootnoteStr("one", Cache.DefaultAnalWs),
                                       transFootnote1.Translation.GetAlternative(wsBt).UnderlyingTsString);
            ICmTranslation transFootnote2 = ((StTxtPara)footnote2.ParagraphsOS[0]).GetBT();

            Assert.IsNotNull(transFootnote2);
            AssertEx.AreTsStringsEqual(DraftViewTests.GetReferencedTextFootnoteStr("two", Cache.DefaultAnalWs),
                                       transFootnote2.Translation.GetAlternative(wsBt).UnderlyingTsString);
        }