Example #1
0
        public void FindPrevBackTrans_SecondBookTitleToFirstBook()
        {
            CheckDisposed();

            // add new book with a BT
            IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(3, "Leviticus");
            StText   text = m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Title for Leviticus");

            m_scrInMemoryCache.AddBtToMockedParagraph((StTxtPara)text.ParagraphsOS[0],
                                                      Cache.DefaultAnalWs);

            // add BT for last para of first book
            ScrTxtPara para = new ScrTxtPara(Cache, m_book.SectionsOS[2].ContentOA.ParagraphsOS.HvoArray[0]);

            m_inMemoryCache.AddBtToMockedParagraph(para, Cache.DefaultAnalWs);
            m_btDraftView.RefreshDisplay();

            m_btDraftView.SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 1, 0);

            m_btDraftView.CallPrevUnfinishedBackTrans();
            SelectionHelper helper = m_btDraftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_btDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(2, m_btDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_btDraftView.ParagraphIndex);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidContent,
                            m_btDraftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsFalse(m_btDraftView.TeEditingHelper.InBookTitle);
        }
        public void ApplyStyle_CharStyleNotAppliedToBorderingWhiteSpace()
        {
            CheckDisposed();
            m_draftView.RefreshDisplay();

            // Select a word in the book intro with white space around it: " text. "
            m_draftView.SetInsertionPoint(0, 0, 0, 5, false);
            IVwSelection sel0 = m_draftView.RootBox.Selection;

            Assert.IsNotNull(sel0);
            m_draftView.SetInsertionPoint(0, 0, 0, 12, true);
            IVwSelection sel1 = m_draftView.RootBox.Selection;

            Assert.IsNotNull(sel1);
            IVwSelection rangeSel = m_draftView.RootBox.MakeRangeSelection(sel0, sel1, true);
            ITsString    tssSelected;

            rangeSel.GetSelectionString(out tssSelected, "*");
            Assert.AreEqual(" text. ", tssSelected.Text);

            // Apply a character style to the selected text.
            m_draftView.ApplyStyle("Emphasis");

            // The selection should be updated to omit bordering white space in the original selection.
            m_draftView.RootBox.Selection.GetSelectionString(out tssSelected, "*");
            Assert.AreEqual("text.", tssSelected.Text);

            // Confirm that the character styles are applied correctly: Emphasis style applied only to "text."
            ScrSection introSection = (ScrSection)m_exodus.SectionsOS[0];
            ITsString  paraContents = ((StTxtPara)introSection.ContentOA.ParagraphsOS[0]).Contents.UnderlyingTsString;

            Assert.AreEqual(3, paraContents.RunCount);
            Assert.AreEqual(7, paraContents.get_MinOfRun(1));
            Assert.AreEqual(11, paraContents.get_LimOfRun(1));
            ITsTextProps ttp = paraContents.get_Properties(0);

            Assert.IsNull(ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle),
                          "First run should be 'Default Paragraph Characters'");
            ttp = paraContents.get_Properties(1);
            Assert.AreEqual("Emphasis", ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle));
            ttp = paraContents.get_Properties(2);
            Assert.IsNull(ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle),
                          "Third run should be 'Default Paragraph Characters'");
        }