Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Append a new section to the given book, having the specified text as the section
        /// head. The new section will have an empty content text created also.
        /// </summary>
        /// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
        /// <param name="book">The book to which the section is to be appended</param>
        /// <param name="sSectionHead">The text of the new section head. Can be a simple string
        /// or a format string. (See CreateText for the definition of the format string)</param>
        /// <param name="paraStyleName">paragraph style to apply to the section head</param>
        /// <returns>The newly created section</returns>
        /// ------------------------------------------------------------------------------------
        internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
                                                 string sSectionHead, string paraStyleName)
        {
            // Create a section
            ScrSection section = new ScrSection();

            book.SectionsOS.Append(section);

            // Create a section head for this section
            section.HeadingOA = new StText();

            if (sSectionHead.Length == 0 || sSectionHead[0] != '\\')
            {
                // create a simple section head with no character style
                StTxtParaBldr paraBldr = new StTxtParaBldr(scrInMemoryCache.Cache);
                paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(paraStyleName);
                paraBldr.AppendRun(sSectionHead,
                                   StyleUtils.CharStyleTextProps(null, scrInMemoryCache.Cache.DefaultVernWs));
                paraBldr.CreateParagraph(section.HeadingOAHvo);
            }
            else
            {
                // Create a more complex section head from the given format string
                // insert a new para in the title
                StTxtPara para = new StTxtPara();
                section.HeadingOA.ParagraphsOS.Append(para);
                // set the para's fields
                scrInMemoryCache.AddFormatTextToMockedPara(book, para, sSectionHead, scrInMemoryCache.Cache.DefaultVernWs);
                para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyleName);
            }

            section.ContentOA = new StText();
            section.AdjustReferences();
            return(section);
        }
Exemple #2
0
        public void GetSectionFromParagraph()
        {
            CheckDisposed();

            // Get the paragraph of the title and make sure the section is null
            StTxtPara paraTitle = (StTxtPara)m_philemon.TitleOA.ParagraphsOS[0];

            Assert.IsNull(ScrSection.GetSectionFromParagraph(paraTitle),
                          "Expected no section for a title para");

            // Get the paragraph for an intro content para
            StTxtPara paraIntroContent = (StTxtPara)((ScrSection)m_philemon.SectionsOS[0]).ContentOA.ParagraphsOS[0];

            Assert.AreEqual(m_philemon.SectionsOS[0], ScrSection.GetSectionFromParagraph(paraIntroContent));

            // Get the paragraph for an intro section heading para
            StTxtPara paraIntroHeading = (StTxtPara)((ScrSection)m_philemon.SectionsOS[0]).HeadingOA.ParagraphsOS[0];

            Assert.AreEqual(m_philemon.SectionsOS[0], ScrSection.GetSectionFromParagraph(paraIntroHeading));

            // Get the paragraph for a scripture content para
            StTxtPara paraScrContent = (StTxtPara)((ScrSection)m_philemon.SectionsOS[2]).ContentOA.ParagraphsOS[0];

            Assert.AreEqual(m_philemon.SectionsOS[2], ScrSection.GetSectionFromParagraph(paraScrContent));

            // Get the paragraph for a scripture section heading para
            StTxtPara paraScrHeading = (StTxtPara)((ScrSection)m_philemon.SectionsOS[2]).HeadingOA.ParagraphsOS[0];

            Assert.AreEqual(m_philemon.SectionsOS[2], ScrSection.GetSectionFromParagraph(paraScrHeading));
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert a book
        /// </summary>
        /// <returns>The new book</returns>
        /// ------------------------------------------------------------------------------------
        public IScrBook Do()
        {
            IScripture scr = m_cache.LangProject.TranslatedScriptureOA;
            int        hvoTitle;
            IScrBook   newBook = ScrBook.CreateNewScrBook(m_bookID, scr, out hvoTitle);

            m_bookHvo = newBook.Hvo;

            // Insert the new book title and set the book names
            newBook.InitTitlePara();
            newBook.Name.CopyAlternatives(newBook.BookIdRA.BookName);
            newBook.Abbrev.CopyAlternatives(newBook.BookIdRA.BookAbbrev);

            // Now insert the first section for the new book.
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                   m_cache.DefaultVernWs);

            ScrSection.CreateScrSection(newBook, 0, scr.ConvertToString(1), textProps, false);

            // Do synchronize stuff
            if (FwApp.App != null)
            {
                FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncReloadScriptureControl, 0, 0),
                                      m_cache);
            }

            // Use Redo for rest of sync'ing and updating book filter
            Redo(false);

            return(newBook);
        }
        public void DisableCompareBtn()
        {
            // Add Revelation, archive it and then remove it.
            int hvoTitle;

            Assert.IsNull(ScrBook.FindBookByID(m_cache, 66),
                          "Revelation should not be in the database. Restore the clean version of TestLangProj.");
            IScrBook        revelation = ScrBook.CreateNewScrBook(66, m_scr, out hvoTitle);
            ITsPropsFactory propFact   = TsPropsFactoryClass.Create();
            ITsTextProps    ttp        = propFact.MakeProps(ScrStyleNames.NormalParagraph, m_cache.DefaultVernWs, 0);

            ScrSection.CreateScrSection(revelation, 0, "Text for section", ttp, false);
            AddArchive("Revelation Archive", new List <int>(new int[] { revelation.Hvo }));
            m_scr.ScriptureBooksOS.Remove(m_scr.ScriptureBooksOS[3]);

            DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(m_cache);
            TreeView tree = dlg.ArchiveTree;

            // Select the archive node that was just added.
            tree.SelectedNode = tree.Nodes[0];
            dlg.SimulateSelectEvent();

            // Check to make sure the Compare to Current Version button is disabled
            Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled");

            // Select a book node.
            tree.SelectedNode = tree.Nodes[0].Nodes[0];
            dlg.SimulateSelectEvent();

            // Check to make sure the Diff button is still disabled if we select Philemon
            // after it is removed from the DB.
            Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled,
                           "The Compare to Current Version button should still");
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="para"></param>
        /// <param name="iPara"></param>
        /// <param name="section"></param>
        /// <param name="iSec"></param>
        /// <param name="book"></param>
        /// <param name="iBook"></param>
        /// <param name="setupForHeading"></param>
        /// ------------------------------------------------------------------------------------
        public void SetupSelectionInPara(StTxtPara para, int iPara, ScrSection section,
                                         int iSec, ScrBook book, int iBook, int ich, bool setupForHeading)
        {
            CheckDisposed();

            SetupRangeSelection(book, iBook, section, iSec, para, iPara, ich, setupForHeading,
                                book, iBook, section, iSec, para, iPara, ich, setupForHeading);
        }
Exemple #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adjust section refs if needed.
        /// Called by a ChangeWatcher if any paras in StText.ParagraphsOS are added, deleted,
        /// or moved.
        /// </summary>
        /// <param name="text">the StText whose Paragraphs collection was changed</param>
        /// <param name="ivMin">index of the first para inserted or deleted in the StText</param>
        /// ------------------------------------------------------------------------------------
        public static void AdjustSectionRefsForStTextParaChg(IStText text, int ivMin)
        {
            // We expect that this StText is part of ScrSection.Content
            Debug.Assert(text.Cache.GetOwningFlidOfObject(text.Hvo) ==
                         (int)ScrSection.ScrSectionTags.kflidContent);

            ScrSection section = new ScrSection(text.Cache, text.Cache.GetOwnerOfObject(text.Hvo));

            section.AdjustReferences();
        }
Exemple #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Append a new section to the given book, having the specified text as the section
        /// head. The general section head paragraph style is used.
        /// </summary>
        /// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
        /// <param name="book">The book to which the section is to be appended</param>
        /// <param name="sSectionHead">The text of the new section head</param>
        /// <returns>The newly created section</returns>
        /// ------------------------------------------------------------------------------------
        internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
                                                 string sSectionHead)
        {
            ScrSection section = CreateSection(scrInMemoryCache, book, sSectionHead, ScrStyleNames.SectionHead);
            // this should be a scripture section and not an intro section
            bool isIntro = false;

            section.VerseRefEnd = book.CanonicalNum * 1000000 + 1000 + ((isIntro) ? 0 : 1);
            section.AdjustReferences();
            return(section);
        }
Exemple #8
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Find a paragraph in a section that matches the given HVO
 /// </summary>
 /// <param name="section"></param>
 /// <param name="hvoPara"></param>
 /// <param name="iPara"></param>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 private bool FindPara(ScrSection section, int hvoPara, out int iPara)
 {
     iPara = 0;
     foreach (StPara para in section.ContentOA.ParagraphsOS)
     {
         if (para.Hvo == hvoPara)
         {
             return(true);
         }
         iPara++;
     }
     return(false);
 }
Exemple #9
0
        public void CreateScrSection_AtEndOfIntro()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 2, "New content of the new section", textProps, true);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            VerifyInsertedBookSection((ScrSection)m_philemon.SectionsOS[2], true,
                                      "New content of the new section",
                                      null, Cache.DefaultVernWs, 57001000); // intro section
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Given a Scripture section, this method returns the index of the paragraph containing
        /// the requested verse and the position of the character immediately following the
        /// verse number in that paragraph. If an exact match isn't found, the closest
        /// approximate place is found.
        /// </summary>
        /// <param name="section">The section whose paragraphs will be searched</param>
        /// <param name="targetRef">The reference being sought</param>
        /// <param name="ihvoPara"></param>
        /// <param name="ichPosition"></param>
        /// <remarks>Currently, this does NOT attempt to find a close match, but some day it
        /// should</remarks>
        /// ------------------------------------------------------------------------------------
        protected void FindVerseNumber(ScrSection section, ScrReference targetRef,
                                       out int ihvoPara, out int ichPosition)
        {
            ihvoPara    = 0;
            ichPosition = 0;

            bool fChapterFound = ((ScrReference)section.VerseRefStart).Chapter == targetRef.Chapter;

            foreach (StTxtPara para in section.ContentOA.ParagraphsOS)
            {
                TsStringAccessor contents = para.Contents;
                TsRunInfo        tsi;
                ITsTextProps     ttpRun;
                int ich = 0;
                while (ich < contents.Text.Length)
                {
                    // Get props of current run.
                    ttpRun = contents.UnderlyingTsString.FetchRunInfoAt(ich, out tsi);
                    // See if it is our verse number style.
                    if (fChapterFound)
                    {
                        if (StStyle.IsStyle(ttpRun, ScrStyleNames.VerseNumber))
                        {
                            // The whole run is the verse number. Extract it.
                            string sVerseNum = contents.Text.Substring(tsi.ichMin,
                                                                       tsi.ichLim - tsi.ichMin);
                            int startVerse, endVerse;
                            ScrReference.VerseToInt(sVerseNum, out startVerse, out endVerse);
                            if (targetRef.Verse >= startVerse && targetRef.Verse <= endVerse)
                            {
                                ihvoPara    = para.OwnOrd - 1;
                                ichPosition = tsi.ichLim;
                                return;
                            }
                            // TODO: Currently, this does NOT attempt to detect when we have
                            // a close match
                        }
                    }
                    // See if it is our chapter number style.
                    else if (StStyle.IsStyle(ttpRun, ScrStyleNames.ChapterNumber))
                    {
                        // Assume the whole run is the chapter number. Extract it.
                        string sChapterNum = contents.Text.Substring(tsi.ichMin,
                                                                     tsi.ichLim - tsi.ichMin);
                        int nChapter = ScrReference.ChapterToInt(sChapterNum);
                        fChapterFound = (nChapter == targetRef.Chapter);
                    }
                    ich = tsi.ichLim;
                }
            }
        }
Exemple #11
0
        public void CreateScrSection_AtEndOfBook()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 4, "New content of section", textProps, false);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[4];

            VerifyInsertedBookSection(section, false, "New content of section",
                                      null, Cache.DefaultVernWs, 57001007); // scripture section
        }
Exemple #12
0
        public void CreateScrSection_AtStartOfFirstScriptureSection()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 2, "New section", textProps, false);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[2];

            VerifyInsertedBookSection(section, false, "New section", null,
                                      Cache.DefaultVernWs, 57001001); // new first Scripture section
        }
Exemple #13
0
        public void CreateScrSection_AtStartOfBook()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 0, "New section", textProps, true);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[0];

            VerifyInsertedBookSection(section, true, "New section", null,
                                      Cache.DefaultVernWs, 57001000); // intro section
        }
Exemple #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adjust section refs for the edited paragraph.
        /// Called by a ChangeWatcher if any StTxtPara.Contents is modified.
        /// </summary>
        /// <param name="ivMin">Character index where text was added and/or deleted</param>
        /// <param name="cvIns">Count of characters inserted</param>
        /// <param name="cvDel">Count of characters deleted</param>
        /// ------------------------------------------------------------------------------------
        public void ProcessChapterVerseNums(int ivMin, int cvIns, int cvDel)
        {
            // We expect that our para is part of a ScrSection.Content
            Debug.Assert(m_cache.GetOwningFlidOfObject(OwnerHVO) ==
                         (int)ScrSection.ScrSectionTags.kflidContent);

            // If we join a paragraph with an empty paragraph, there's nothing for us to do.
            if (cvIns == 0 && cvDel == 0)
            {
                return;
            }

            // Now adjust our section refs if necessary
            ScrSection section = new ScrSection(m_cache, m_cache.GetOwnerOfObject(OwnerHVO));

            section.AdjustReferences();
        }
Exemple #15
0
        public void GetFootnotes_NoFootnotes()
        {
            CheckDisposed();
            ScrSection section1 = (ScrSection)m_philemon.SectionsOS[0];
            StTxtPara  para     = (StTxtPara)section1.ContentOA.ParagraphsOS[0];
            StFootnote footnote = InsertTestFootnote(m_philemon, para, 1, 0);

            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "Anything");

            ScrSection section2 = (ScrSection)m_philemon.SectionsOS[1];

            para = (StTxtPara)section2.ContentOA.ParagraphsOS[0];

            List <FootnoteInfo> footnotes = section2.GetFootnotes();

            Assert.AreEqual(0, footnotes.Count);
        }
        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'");
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks the given object agains the filter criteria
        /// </summary>
        /// <param name="hvoObj">ID of object to check against the filter criteria</param>
        /// <returns><c>true</c> if the object passes the filter criteria; otherwise
        /// <c>false</c></returns>
        /// ------------------------------------------------------------------------------------
        bool IFilter.MatchesCriteria(int hvoObj)
        {
            // Back translations don't distinguish between the sections, so return true
            // if hvoObj is a section
            if ((m_viewType & TeViewType.BackTranslation) != 0)
            {
                return(m_fdoCache.GetClassOfObject(hvoObj) == ScrSection.kClassId);
            }

            try
            {
                ScrSection section = new ScrSection(m_fdoCache, hvoObj);
                return(section.IsIntro == m_fIntroDivision);
            }
            catch
            {
                // The HVO we got isn't for a section!
                return(false);
            }
        }
Exemple #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Bring the paragraph difference into view in the diff view.
        /// </summary>
        /// <param name="hvoPara">hvo of paragraph containing the difference</param>
        /// <param name="ichMin">starting character position of the difference</param>
        /// ------------------------------------------------------------------------------------
        public void ScrollToParaDiff(int hvoPara, int ichMin)
        {
            CheckDisposed();

            StTxtPara para  = new StTxtPara(m_fdoCache, hvoPara);
            int       iPara = para.IndexInOwner;
            StText    text  = new StText(m_fdoCache, para.OwnerHVO);

            if (m_fdoCache.GetClassOfObject(text.OwnerHVO) == ScrSection.kClassId)
            {
                int tag = text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidHeading ?
                          (int)ScrSection.ScrSectionTags.kflidHeading :
                          (int)ScrSection.ScrSectionTags.kflidContent;
                ScrSection section = new ScrSection(m_fdoCache, text.OwnerHVO);
                SetInsertionPoint(tag, 0, section.IndexInBook, iPara, ichMin, false);
            }
            else
            {
                SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 0, 0, iPara, ichMin,
                                  false);
            }
        }
Exemple #19
0
        public void ChangeParagraphToSectionHead_EndOfSection()
        {
            CheckDisposed();

            IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_matthew.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "This is the heading",
                                                           ScrStyleNames.SectionHead);
            m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph);
            m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph);
            StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                              ScrStyleNames.NormalParagraph);

            m_scrInMemoryCache.AddRunToMockedPara(para, "6", ScrStyleNames.VerseNumber);
            m_scrInMemoryCache.AddRunToMockedPara(para, "Content of paragraph 2", null);
            section.AdjustReferences();

            ScrSection  secHelp    = new ScrSection(Cache, section.Hvo);
            IScrSection newSecHelp = secHelp.ChangeParagraphToSectionHead(2, 1);

            // verify that the new section has one content paragraph and one heading paragraph.
            Assert.AreEqual(1, newSecHelp.ContentOA.ParagraphsOS.Count);
            Assert.AreEqual(1, newSecHelp.HeadingOA.ParagraphsOS.Count);

            // verify that the text of the old paragraph is now in the new section head
            // and that the new section content paragraph is empty and has normal paragraph
            // style.
            StTxtPara newSecPara = (StTxtPara)newSecHelp.ContentOA.ParagraphsOS[0];

            Assert.IsTrue(StStyle.IsStyle(newSecPara.StyleRules, ScrStyleNames.NormalParagraph));
            Assert.IsFalse(StStyle.IsStyle(newSecPara.Contents.UnderlyingTsString.get_Properties(0),
                                           ScrStyleNames.NormalParagraph));

            Assert.IsNull(newSecPara.Contents.Text);
            StTxtPara newSecHeadPara = (StTxtPara)newSecHelp.HeadingOA.ParagraphsOS[0];

            Assert.AreEqual(para.Contents.Text, newSecHeadPara.Contents.Text);
        }
Exemple #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Check to see if section can be used as the starting section of the export. Must either
        /// be an intro section or a section that begins with a chapter number run.
        /// </summary>
        /// <param name="sect">section to be checked</param>
        /// <param name="prevSect">section previous to current section</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private bool ValidStartingSection(ScrSection sect, ScrSection prevSect)
        {
            if (sect.IsIntro || prevSect == null || prevSect.IsIntro)
            {
                return(true);
            }

            if (sect.ContentOA.ParagraphsOS.Count > 0)
            {
                StTxtPara para = (StTxtPara)sect.ContentOA.ParagraphsOS[0];
                ITsString tss  = para.Contents.UnderlyingTsString;
                if (tss.RunCount > 0)
                {
                    ITsTextProps ttpRun;
                    ttpRun = tss.get_Properties(0);
                    if (StStyle.IsStyle(ttpRun, ScrStyleNames.ChapterNumber))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #21
0
        public void GetFootnotes_InHeadingAndContents()
        {
            CheckDisposed();

            ScrSection section1 = (ScrSection)m_philemon.SectionsOS[0];
            StTxtPara  para     = (StTxtPara)section1.HeadingOA.ParagraphsOS[0];
            StFootnote footnote = InsertTestFootnote(m_philemon, para, 0, 0);

            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "heading footnote");

            para     = (StTxtPara)section1.ContentOA.ParagraphsOS[0];
            footnote = InsertTestFootnote(m_philemon, para, 1, 0);
            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "Anything");
            footnote = InsertTestFootnote(m_philemon, para, 2, 5);
            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "Bla");
            footnote = InsertTestFootnote(m_philemon, para, 3, 10);
            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "hing");

            ScrSection section2 = (ScrSection)m_philemon.SectionsOS[1];

            para     = (StTxtPara)section2.ContentOA.ParagraphsOS[0];
            footnote = InsertTestFootnote(m_philemon, para, 4, 0);
            m_inMemoryCache.AddParaToMockedText(footnote.Hvo, "This one shouldn't be included");

            List <FootnoteInfo> footnotes = section1.GetFootnotes();

            Assert.AreEqual(4, footnotes.Count);
            Assert.AreEqual(m_philemon.FootnotesOS[0].Hvo, ((FootnoteInfo)footnotes[0]).footnote.Hvo);
            Assert.AreEqual("heading footnote", ((FootnoteInfo)footnotes[0]).paraStylename);
            Assert.AreEqual(m_philemon.FootnotesOS[1].Hvo, ((FootnoteInfo)footnotes[1]).footnote.Hvo);
            Assert.AreEqual("Anything", ((FootnoteInfo)footnotes[1]).paraStylename);
            Assert.AreEqual(m_philemon.FootnotesOS[2].Hvo, ((FootnoteInfo)footnotes[2]).footnote.Hvo);
            Assert.AreEqual("Bla", ((FootnoteInfo)footnotes[2]).paraStylename);
            Assert.AreEqual(m_philemon.FootnotesOS[3].Hvo, ((FootnoteInfo)footnotes[3]).footnote.Hvo);
            Assert.AreEqual("hing", ((FootnoteInfo)footnotes[3]).paraStylename);
        }
Exemple #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setups the specifed SelectionHelper for the specified paragraph and StText.
        /// </summary>
        /// <param name="helper">The SelectionHelper.</param>
        /// <param name="text">The StText.</param>
        /// <param name="para">The para.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="view">The view</param>
        /// ------------------------------------------------------------------------------------
        private void SetupSelectionFor(SelectionHelper helper, StText text, StTxtPara para,
                                       SelectionHelper.SelLimitType limit, FwRootSite view)
        {
            Debug.Assert((view is DraftView && ((DraftView)view).TeEditingHelper != null) ||
                         (view is FootnoteView && ((FootnoteView)view).EditingHelper != null));
            if (view is DraftView)
            {
                DraftView draftView = (DraftView)view;

                if ((text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidContent ||
                     text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidHeading))
                {
                    // text belongs to section heading or contents
                    ScrSection section = new ScrSection(m_fdoCache, text.OwnerHVO);
                    Debug.Assert(section.OwningFlid == (int)ScrBook.ScrBookTags.kflidSections);

                    helper.SetNumberOfLevels(limit, 4);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                    info[1].ihvo = text.IndexInOwner;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = section.IndexInBook;
                    info[2].tag  = (int)ScrBook.ScrBookTags.kflidSections;
                    info[3].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(section.OwnerHVO);
                    info[3].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                    helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
                }
                else
                {
                    // text belongs to a book title
                    Debug.Assert(text.OwningFlid == (int)ScrBook.ScrBookTags.kflidTitle);
                    ScrBook book = new ScrBook(m_fdoCache, text.OwnerHVO);

                    helper.SetNumberOfLevels(limit, 3);
                    SelLevInfo[] info = helper.GetLevelInfo(limit);
                    info[0].ihvo = para.IndexInOwner;
                    info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                    info[1].ihvo = text.IndexInOwner;
                    info[1].tag  = text.OwningFlid;
                    info[2].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(book.Hvo);
                    info[2].tag  = draftView.TeEditingHelper.BookFilter.Tag;
                    helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
                }
            }
            else if (view is FootnoteView && text.OwningFlid == (int)ScrBook.ScrBookTags.kflidFootnotes)
            {
                // text belongs to a footnote
                FootnoteView footnoteView = (FootnoteView)view;
                StFootnote   footnote     = new StFootnote(m_fdoCache, para.OwnerHVO);
                ScrBook      book         = new ScrBook(m_fdoCache, text.OwnerHVO);

                helper.SetNumberOfLevels(limit, 3);
                SelLevInfo[] info = helper.GetLevelInfo(limit);
                info[0].hvo  = text.Hvo;
                info[0].tag  = (int)StText.StTextTags.kflidParagraphs;
                info[1].hvo  = footnote.Hvo;
                info[1].ihvo = footnote.IndexInOwner;
                info[1].tag  = (int)ScrBook.ScrBookTags.kflidFootnotes;
                info[2].hvo  = book.Hvo;
                info[2].ihvo = footnoteView.BookFilter.GetBookIndex(book.Hvo);
                info[2].tag  = footnoteView.BookFilter.Tag;
                info[0].ich  = info[1].ich = info[2].ich = -1;
                helper.SetLevelInfo(SelectionHelper.SelLimitType.End, info);
            }
        }
Exemple #23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Given a Scripture section, this method returns the index of the paragraph containing
        /// the requested verse and the position of the character immediately following the
        /// verse number in that paragraph. If an exact match isn't found, the closest
        /// approximate place is found.
        /// </summary>
        /// <param name="section">The section whose paragraphs will be searched</param>
        /// <param name="targetRef">The reference being sought</param>
        /// <param name="iPara">The index of the paragraph where the verse was found</param>
        /// <param name="ichPosition">The index of the character immediately following the
        /// verse number in that paragraph</param>
        /// ------------------------------------------------------------------------------------
        protected void FindVerseNumber(ScrSection section, ScrReference targetRef, out int iPara,
                                       out int ichPosition)
        {
            iPara       = 0;
            ichPosition = 0;

            bool fChapterFound = (BCVRef.GetChapterFromBcv(section.VerseRefMin) == targetRef.Chapter);

            foreach (StTxtPara para in section.ContentOA.ParagraphsOS)
            {
                TsStringAccessor contents = para.Contents;
                if (para.Contents.Text == null)
                {
                    continue;
                }
                TsRunInfo    tsi;
                ITsTextProps ttpRun;
                int          ich = 0;
                while (ich < contents.UnderlyingTsString.Length)
                {
                    // Get props of current run.
                    ttpRun = contents.UnderlyingTsString.FetchRunInfoAt(ich, out tsi);
                    // See if it is our verse number style.
                    if (fChapterFound)
                    {
                        if (StStyle.IsStyle(ttpRun, ScrStyleNames.VerseNumber))
                        {
                            // The whole run is the verse number. Extract it.
                            string sVerseNum = contents.Text.Substring(tsi.ichMin,
                                                                       tsi.ichLim - tsi.ichMin);
                            int startVerse, endVerse;
                            ScrReference.VerseToInt(sVerseNum, out startVerse, out endVerse);
                            if ((targetRef.Verse >= startVerse && targetRef.Verse <= endVerse) ||
                                targetRef.Verse < startVerse)
                            {
                                ichPosition = tsi.ichLim;
                                return;
                            }
                        }
                    }
                    // See if it is our chapter number style.
                    else if (StStyle.IsStyle(ttpRun, ScrStyleNames.ChapterNumber))
                    {
                        try
                        {
                            // Assume the whole run is the chapter number. Extract it.
                            string sChapterNum = contents.Text.Substring(tsi.ichMin,
                                                                         tsi.ichLim - tsi.ichMin);
                            fChapterFound = (ScrReference.ChapterToInt(sChapterNum) == targetRef.Chapter);
                        }
                        catch (ArgumentException)
                        {
                            // ignore runs with invalid Chapter numbers
                        }
                    }
                    ich = tsi.ichLim;
                }
                iPara++;
            }
            iPara = 0;             // Couldn't find it.
        }
Exemple #24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Load a list of sections into the beginning and ending combo boxes for export.
        /// TEMPORARY: If it is the first (i.e., starting) section to export, only include
        /// sections that begin with a chapter. See TE-7287 for story to revert this.
        /// </summary>
        /// <param name="nBook"></param>
        /// ------------------------------------------------------------------------------------
        private void LoadSectionsForBook(int nBook)
        {
            if (nBook == m_nBookForSections)
            {
                return;
            }

            m_fLoadingBookSections = true;
            using (new WaitCursor(this, true))
            {
                cboFrom.Items.Clear();
                cboTo.Items.Clear();
                cboFrom.SelectedIndex = -1;
                cboTo.SelectedIndex   = -1;

                IScrBook book = m_scr.FindBook(nBook);
                Debug.Assert(book != null);
                string sRef;
                // "{0} Intro: {1}"
                string sRefIntro = DlgResources.ResourceString("kstidOxesExportIntro");
                // "{0}: {1}"
                string    sRefPassage = DlgResources.ResourceString("kstidOxesExportRef");
                ITsString tssHeading  = null;
                // "(No text in section heading)"
                ITsString  tssEmpty = m_scr.Cache.MakeUserTss(DlgResources.ResourceString("kstidOxesExportEmptyHeading"));
                ITsStrBldr tsb      = TsStrBldrClass.Create();
                BCVRef     startRef;
                BCVRef     endRef;
                ScrSection sect;
                ScrSection prevSect     = null;
                int        iSectionFrom = 0;
                for (int iSection = 0; iSection < book.SectionsOS.Count; ++iSection, prevSect = sect)
                {
                    sect = book.SectionsOS[iSection] as ScrSection;
                    sect.GetDisplayRefs(out startRef, out endRef);

                    if (sect.HeadingOAHvo != 0)
                    {
                        // Get the first non-empty heading paragraph content.
                        for (int j = 0; j < sect.HeadingOA.ParagraphsOS.Count; ++j)
                        {
                            IStTxtPara para = sect.HeadingOA.ParagraphsOS[j] as IStTxtPara;
                            if (para != null && para.Contents.Length > 0)
                            {
                                tssHeading = para.Contents.UnderlyingTsString;
                                break;
                            }
                        }
                    }
                    if (tssHeading == null || tssHeading.Length == 0)
                    {
                        tssHeading = tssEmpty;
                    }
                    else
                    {
                        // Replace embedded line separator characters with spaces.
                        ITsStrBldr tsbFix = tssHeading.GetBldr();
                        for (int idx = tsbFix.Text.IndexOf('\x2028');
                             idx >= 0;
                             idx = tsbFix.Text.IndexOf('\x2028'))
                        {
                            tsbFix.Replace(idx, idx + 1, " ", null);
                        }
                        tssHeading = tsbFix.GetString();
                    }

                    sRef = BCVRef.MakeReferenceString(startRef, endRef, m_scr.ChapterVerseSepr, m_scr.Bridge);
                    sRef = string.Format(sect.IsIntro ? sRefIntro : sRefPassage, sRef, tssHeading.Text);

                    // Only include intro section or sections that begin with a chapter
                    // number run in the list of starting sections. This is currently
                    // required because of the way the ScrSection.AdjustReferences relies
                    // upon chapter numbers.
                    ITsString tss = m_scr.Cache.MakeUserTss(sRef);

                    if (ValidStartingSection(sect, prevSect))
                    {
                        iSectionFrom = cboFrom.Items.Add(new SectionCboItem(tss, iSection, iSection));
                    }

                    cboTo.Items.Add(new SectionCboItem(tss, iSection, iSectionFrom));
                }

                cboFrom.SelectedIndex = 0;
                cboTo.SelectedIndex   = book.SectionsOS.Count - 1;
            }

            m_fLoadingBookSections = false;
        }
Exemple #25
0
        public void HardLineBreak()
        {
            CheckDisposed();
            // Set IP in the middle of the second Scripture section head in James.
            // Then press Shift-Enter. This should put a hard line break in the middle of this
            // section head and the IP should be at the beginning of the second line.
            DummyDraftView draftView = m_draftForm.DraftView;

            draftView.RootBox.Activate(VwSelectionState.vssEnabled);
            draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4);
            KeyEventArgs e = new KeyEventArgs(Keys.Right);

            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            draftView.CallRootSiteOnKeyDown(e);
            // We should be between the 'a' and 'n' of the word "and" in the section head
            // containing "Faith and Wisdom".
            SelectionHelper selHelper = SelectionHelper.Create(draftView);

            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            int ihvoPara = selHelper.LevelInfo[0].ihvo;

            Assert.AreEqual(7, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // Now send the Shift-Enter
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter));

            // We should have split the line between the 'a' and 'n' of the word "and".
            selHelper = SelectionHelper.Create(draftView);
            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            // Make sure we're still in the same para
            Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo);
            Assert.AreEqual(8, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // To make sure we're on the next line down, send an up-arrow
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up));

            // We should be at the beginning of the section head.
            selHelper = SelectionHelper.Create(draftView);
            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            // Make sure we're still in the same para
            Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo);
            Assert.AreEqual(0, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // Finally, make sure the hard line break character is in the right place in the
            // string in the data cache.
            Scripture  scr   = new Scripture(m_draftForm.Cache, draftView.HvoScripture);
            ScrBook    james = (ScrBook)scr.ScriptureBooksOS[1];
            ScrSection modifiedScrSection =
                (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo];

            Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count);
            Assert.AreEqual(0x2028,
                            ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[7]);

            // Second test:
            // Set IP at the beginning of the second Scripture section head in James.
            // Then press Shift-Enter. This should put an empty line at the beginning of this
            // section head and the IP should be at the beginning of the second line.
            draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4);
            selHelper = SelectionHelper.Create(draftView);
            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            ihvoPara = selHelper.LevelInfo[0].ihvo;
            Assert.AreEqual(0, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // Now send the Shift-Enter
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter));
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter));

            // We should have an blank line before Faith and Wisdom.
            selHelper = SelectionHelper.Create(draftView);
            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            // Make sure we're still in the same para
            Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo);
            Assert.AreEqual(2, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // To make sure we're on the next line down, send an up-arrow
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up));
            draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up));

            // We should be at the beginning of the section head containing "Faith and Wisdom".
            selHelper = SelectionHelper.Create(draftView);
            Assert.AreEqual(4, selHelper.NumberOfLevels);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            selHelper.LevelInfo[1].tag);
            // Make sure we're still in the same para
            Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo);
            Assert.AreEqual(0, selHelper.IchAnchor);
            Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd);

            // Finally, make sure the hard line break character is in the right place in the
            // string in the data cache.
            scr   = new Scripture(m_draftForm.Cache, draftView.HvoScripture);
            james = (ScrBook)scr.ScriptureBooksOS[1];
            modifiedScrSection =
                (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo];
            Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count);
            Assert.AreEqual(0x2028,
                            ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[0]);
        }
Exemple #26
0
        /// <summary>
        /// Load data needed to display the specified objects using the specified fragment.
        /// This is called before attempting to Display an item that has been listed for lazy
        /// display using AddLazyItems. It may be used to load the necessary data into the
        /// DataAccess object.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="rghvo"></param>
        /// <param name="chvo"></param>
        /// <param name="hvoParent"></param>
        /// <param name="tag"></param>
        /// <param name="frag"></param>
        /// <param name="ihvoMin"></param>
        public override void LoadDataFor(IVwEnv vwenv, int[] rghvo, int chvo, int hvoParent, int tag,
                                         int frag, int ihvoMin)
        {
            CheckDisposed();

            // ENHANCE TomB: Implement progress bar
            bool fStartProgressBar = false;             // m_stbr && !m_stbr.IsProgressBarActive();

            switch ((ScrFrags)frag)
            {
            case ScrFrags.kfrBook:
            {
                // REVIEW EberhardB: we might want some optimizations on the loading
                // (see DraftTextVc::LoadDataFor)
                ScrBook scrBook;

                foreach (int hvo in rghvo)
                {
                    scrBook = new ScrBook(m_stvc.Cache, hvo);
                    foreach (StTxtPara stPara in scrBook.TitleOA.ParagraphsOS)
                    {
                        string text = stPara.Contents.Text;
                    }
                }

                break;
            }

            case ScrFrags.kfrSection:
            {
                // REVIEW EberhardB: optimize, especially implement reading +/- 3 paragraphs
                ScrSection sect;

                foreach (int hvo in rghvo)
                {
                    sect = new ScrSection(m_stvc.Cache, hvo);

                    foreach (StTxtPara stPara in sect.HeadingOA.ParagraphsOS)
                    {
                        string text = stPara.Contents.Text;
                    }
                    foreach (StTxtPara stPara in sect.ContentOA.ParagraphsOS)
                    {
                        string text = stPara.Contents.Text;
                    }
                }

                break;
            }

            default:
                Debug.Assert(false);
                break;
            }

            // If we had to start a progress bar, return things to normal.
            if (fStartProgressBar)
            {
                // TODO m_qstbr->EndProgressBar();
            }
        }
        public void ClearStyle_CharStyleRemovedFromAdjacentWhiteSpace()
        {
            CheckDisposed();
            m_draftView.RefreshDisplay();

            // *** Test setup ***
            // 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);

            // Build an array of string props with the style name of the only run.
            ITsTextProps[] props = new ITsTextProps[1];
            ITsPropsBldr   bldr  = TsPropsBldrClass.Create();

            // The named style is the default, so not property values are added.
            props[0] = bldr.GetTextProps();

            // Apply a character style to the selected text (including the surrounding white space)
            m_draftView.EditingHelper.RemoveCharFormatting(rangeSel, ref props, "Emphasis");

            // so that we have three runs.
            ScrSection introSection = (ScrSection)m_exodus.SectionsOS[0];
            ITsString  paraContents = ((StTxtPara)introSection.ContentOA.ParagraphsOS[0]).Contents.UnderlyingTsString;

            Assert.AreEqual(3, paraContents.RunCount);

            // *** Test ***
            // Select just the word "text." without the surrounding white space.
            m_draftView.SetInsertionPoint(0, 0, 0, 6, false);
            sel0 = m_draftView.RootBox.Selection;
            Assert.IsNotNull(sel0);
            m_draftView.SetInsertionPoint(0, 0, 0, 11, true);
            sel1 = m_draftView.RootBox.Selection;
            Assert.IsNotNull(sel1);
            rangeSel = m_draftView.RootBox.MakeRangeSelection(sel0, sel1, true);
            rangeSel.GetSelectionString(out tssSelected, "*");
            Assert.AreEqual("text.", tssSelected.Text);

            // Remove character style formatting from the selected text.
            m_draftView.EditingHelper.RemoveCharFormatting(rangeSel, ref props, string.Empty);

            // We expect that there should now only be one run in this paragraph with the style
            // "Default Paragraph Characters".
            paraContents = ((StTxtPara)introSection.ContentOA.ParagraphsOS[0]).Contents.UnderlyingTsString;
            Assert.AreEqual(1, paraContents.RunCount,
                            "Style for boundary white space characters not properly removed");
            ITsTextProps ttp = paraContents.get_Properties(0);

            Assert.IsNull(ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle),
                          "Character style of run should be 'Default Paragraph Characters'");
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="bookStart"></param>
        /// <param name="iBookStart"></param>
        /// <param name="sectionStart"></param>
        /// <param name="iSecStart"></param>
        /// <param name="paraStart"></param>
        /// <param name="iParaStart"></param>
        /// <param name="ichStart"></param>
        /// <param name="setupForHeadingStart"></param>
        /// <param name="bookEnd"></param>
        /// <param name="iBookEnd"></param>
        /// <param name="sectionEnd"></param>
        /// <param name="iSecEnd"></param>
        /// <param name="paraEnd"></param>
        /// <param name="iParaEnd"></param>
        /// <param name="ichEnd"></param>
        /// <param name="setupForHeadingEnd"></param>
        /// ------------------------------------------------------------------------------------
        public void SetupRangeSelection(ScrBook bookStart, int iBookStart, ScrSection sectionStart,
                                        int iSecStart, StTxtPara paraStart, int iParaStart, int ichStart,
                                        bool setupForHeadingStart, ScrBook bookEnd, int iBookEnd, ScrSection sectionEnd,
                                        int iSecEnd, StTxtPara paraEnd, int iParaEnd, int ichEnd, bool setupForHeadingEnd)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("NumberOfLevels", 4);
            // Setup the anchor
            SelLevInfo[] topInfo = new SelLevInfo[4];
            topInfo[0].tag  = (int)StText.StTextTags.kflidParagraphs;
            topInfo[0].ihvo = iParaStart;
            topInfo[0].hvo  = paraStart.Hvo;
            topInfo[1].tag  = setupForHeadingStart ? (int)ScrSection.ScrSectionTags.kflidHeading :
                              (int)ScrSection.ScrSectionTags.kflidContent;
            topInfo[1].ihvo = 0;
            topInfo[1].hvo  = setupForHeadingStart ? sectionStart.HeadingOA.Hvo :
                              sectionStart.ContentOA.Hvo;
            topInfo[2].tag  = (int)ScrBook.ScrBookTags.kflidSections;
            topInfo[2].ihvo = iSecStart;
            topInfo[2].hvo  = sectionStart.Hvo;
            topInfo[3].tag  = (int)Scripture.ScriptureTags.kflidScriptureBooks;
            topInfo[3].ihvo = iBookStart;
            topInfo[3].hvo  = bookStart.Hvo;

            // Setup the end
            SelLevInfo[] bottomInfo = new SelLevInfo[4];
            bottomInfo[0].tag  = (int)StText.StTextTags.kflidParagraphs;
            bottomInfo[0].ihvo = iParaEnd;
            bottomInfo[0].hvo  = paraEnd.Hvo;
            bottomInfo[1].tag  = setupForHeadingEnd ? (int)ScrSection.ScrSectionTags.kflidHeading :
                                 (int)ScrSection.ScrSectionTags.kflidContent;
            bottomInfo[1].ihvo = 0;
            bottomInfo[1].hvo  = setupForHeadingEnd ? sectionEnd.HeadingOA.Hvo :
                                 sectionEnd.ContentOA.Hvo;
            bottomInfo[2].tag  = (int)ScrBook.ScrBookTags.kflidSections;
            bottomInfo[2].ihvo = iSecEnd;
            bottomInfo[2].hvo  = sectionEnd.Hvo;
            bottomInfo[3].tag  = (int)Scripture.ScriptureTags.kflidScriptureBooks;
            bottomInfo[3].ihvo = iBookEnd;
            bottomInfo[3].hvo  = bookEnd.Hvo;

            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("IchAnchor", ichStart);
            fakeSelHelper.SetupResult("IchEnd", ichEnd);
            fakeSelHelper.SetupResult("IsValid", true);
            fakeSelHelper.SetupResult("AssocPrev", false);
            fakeSelHelper.Ignore("get_IsRange");
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Anchor);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.Bottom);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.End);
            fakeSelHelper.SetupResultForParams("GetIch", ichStart,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
                                               SelectionHelper.SelLimitType.Bottom);
            m_viewSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }