/// ------------------------------------------------------------------------------------ /// <summary> /// Sets up 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, IStText text, IStTxtPara para, SelectionHelper.SelLimitType limit, FwRootSite view) { Debug.Assert((view is DraftView && ((DraftView)view).TeEditingHelper != null) || (view is FootnoteView && ((FootnoteView)view).EditingHelper != null)); helper.SetTextPropId(limit, StTxtParaTags.kflidContents); if (view is DraftView) { DraftView draftView = (DraftView)view; if ((text.OwningFlid == ScrSectionTags.kflidContent || text.OwningFlid == ScrSectionTags.kflidHeading)) { // text belongs to section heading or contents IScrSection section = (IScrSection)text.Owner; Debug.Assert(section.OwningFlid == ScrBookTags.kflidSections); helper.SetNumberOfLevels(limit, 4); SelLevInfo[] info = helper.GetLevelInfo(limit); info[0].ihvo = para.IndexInOwner; info[0].tag = StTextTags.kflidParagraphs; info[1].ihvo = 0; info[1].tag = text.OwningFlid; info[2].ihvo = section.IndexInOwner; info[2].tag = ScrBookTags.kflidSections; info[3].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex((IScrBook)section.Owner); info[3].tag = draftView.TeEditingHelper.BookFilter.Tag; } else { // text belongs to a book title Debug.Assert(text.OwningFlid == ScrBookTags.kflidTitle); IScrBook book = (IScrBook)text.Owner; helper.SetNumberOfLevels(limit, 3); SelLevInfo[] info = helper.GetLevelInfo(limit); info[0].ihvo = para.IndexInOwner; info[0].tag = StTextTags.kflidParagraphs; info[1].ihvo = 0; info[1].tag = text.OwningFlid; info[2].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(book); info[2].tag = draftView.TeEditingHelper.BookFilter.Tag; } } else if (view is FootnoteView && text.OwningFlid == ScrBookTags.kflidFootnotes) { // text belongs to a footnote FootnoteView footnoteView = (FootnoteView)view; IStFootnote footnote = (IStFootnote)para.Owner; IScrBook book = (IScrBook)text.Owner; helper.SetNumberOfLevels(limit, 3); SelLevInfo[] info = helper.GetLevelInfo(limit); info[0].hvo = text.Hvo; info[0].tag = StTextTags.kflidParagraphs; info[1].hvo = footnote.Hvo; info[1].ihvo = footnote.IndexInOwner; info[1].tag = ScrBookTags.kflidFootnotes; info[2].hvo = book.Hvo; info[2].ihvo = footnoteView.BookFilter.GetBookIndex(book); info[2].tag = footnoteView.BookFilter.Tag; info[0].ich = info[1].ich = info[2].ich = -1; } }
/// ------------------------------------------------------------------------------------ /// <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); } }