Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Go to the previous footnote in the footnote view
        /// </summary>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override ScrFootnote GoToPreviousFootnote()
        {
            CheckDisposed();

            // In case no footnote is selected - can happen when footnote pane is first opened.
            if (CurrentSelection == null)
            {
                return(null);
            }

            // Get the information needed from the current selection
            int     iBook     = CurrentSelection.GetLevelInfoForTag(BookFilter.Tag).ihvo;
            int     iFootnote = CurrentSelection.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidFootnotes).ihvo;
            ScrBook book      = BookFilter.GetBook(iBook);

            // Get the previous footnote if it exists
            if (--iFootnote < 0)
            {
                return(null);
            }
            ScrFootnote footnote = new ScrFootnote(m_cache, book.FootnotesOS.HvoArray[iFootnote]);

            ScrollToFootnote(iBook, iFootnote, 0);
            return(footnote);
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes footnotes when there is a range selection.
        /// </summary>
        /// <param name="helper"></param>
        /// ------------------------------------------------------------------------------------
        private void DeleteFootnoteRange(SelectionHelper helper)
        {
            int nTopLevels    = helper.GetNumberOfLevels(SelectionHelper.SelLimitType.Top);
            int nBottomLevels = helper.GetNumberOfLevels(SelectionHelper.SelLimitType.Bottom);

            // Get the index of the book containing the first footnote in the selection.
            // Then get the index of the footnote within that book.
            int iFirstBook =
                helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[nTopLevels - 1].ihvo;
            int iFirstFootnote =
                helper.GetLevelInfo(SelectionHelper.SelLimitType.Top)[nTopLevels - 2].ihvo;

            // Get the index of the book containing the last footnote in the selection.
            // Then get the index of the footnote within that book.
            int iLastBook =
                helper.GetLevelInfo(SelectionHelper.SelLimitType.Bottom)[nBottomLevels - 1].ihvo;
            int iLastFootnote =
                helper.GetLevelInfo(SelectionHelper.SelLimitType.Bottom)[nBottomLevels - 2].ihvo;

            // Loop through the books containing footnotes in the selection.
            for (int iBook = iFirstBook; iBook <= iLastBook; iBook++)
            {
                IScrBook book = BookFilter.GetBook(iBook);

                int iBeg = iFirstFootnote;
                if (iFirstBook != iLastBook && iBook > iFirstBook)
                {
                    iBeg = 0;
                }

                int iEnd = iLastFootnote;
                if (iFirstBook != iLastBook && iBook < iLastBook)
                {
                    iEnd = book.FootnotesOS.Count - 1;
                }

                // Loop through the footnotes from the selection that are in the
                // current book. Go in reverse order through the collection.
                for (int i = iEnd; i >= iBeg; i--)
                {
                    // TODO: check filter for each HVO
                    IScrFootnote footnote =
                        Cache.ServiceLocator.GetInstance <IScrFootnoteRepository>().GetObject(book.FootnotesOS[i].Hvo);
                    book.FootnotesOS.Remove(footnote);
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Goto the next footnote in the footnote view
        /// </summary>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override IScrFootnote GoToNextFootnote()
        {
            CheckDisposed();

            // In case no footnote is selected - can happen when footnote pane is first opened.
            if (CurrentSelection == null)
            {
                return(null);
            }

            // Get the information needed from the current selection
            int      iBook     = CurrentSelection.GetLevelInfoForTag(BookFilter.Tag).ihvo;
            int      iFootnote = CurrentSelection.GetLevelInfoForTag(ScrBookTags.kflidFootnotes).ihvo;
            IScrBook book      = BookFilter.GetBook(iBook);

            // Get the next footnote if it exists
            if (++iFootnote >= book.FootnotesOS.Count)
            {
                return(null);
            }

            ScrollToFootnote(iBook, iFootnote, 0);
            return((IScrFootnote)book.FootnotesOS[iFootnote]);
        }