Beispiel #1
0
        /// <summary>
        /// Finds the previous redaction mark in previous document stories of the current type (e.g. previous headers).
        /// </summary>
        /// <param name="CurrentRange">The range containing the starting point of the search. Changes to the location of the output mark if one is found.</param>
        /// <returns>True if a mark was found, otherwise False.</returns>
        private static bool FindPreviousMarkInStoryRanges(ref Word.Range CurrentRange)
        {
            object CollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;

            Word.WdHeaderFooterIndex?headerFooterId = null;

            Word.Range PreviousStoryRange = RedactCommon.PreviousStoryRange(CurrentRange);
            while (PreviousStoryRange != null)
            {
                //if we're in headers/footers, we need to get our location so we can update the current view
                if (CurrentRange.StoryType != Word.WdStoryType.wdTextFrameStory)
                {
                    headerFooterId = RedactCommon.GetHeaderFooterType(CurrentRange.StoryType);
                }

                CurrentRange       = PreviousStoryRange;
                PreviousStoryRange = RedactCommon.PreviousStoryRange(CurrentRange);
                CurrentRange.Collapse(ref CollapseEnd);
                if (FindPreviousMarkInCurrentStoryRange(ref CurrentRange))
                {
                    //move the focus in the view
                    if (RedactCommon.IsHeaderFooter(CurrentRange.StoryType))
                    {
                        MoveHeaderFooterFocus(CurrentRange, RedactCommon.FindSectionWithHeaderFooter(CurrentRange.Document, CurrentRange), headerFooterId);
                    }
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Finds the next redaction mark in subsequent document stories of the current type (e.g. subsequent headers).
        /// </summary>
        /// <param name="CurrentRange">The range containing the starting point of the search. Changes to the location of the output mark if one is found.</param>
        /// <returns>True if a mark was found, otherwise False.</returns>
        private static bool FindNextMarkInStoryRanges(ref Word.Range SelectionRange)
        {
            object CollapseStart = Word.WdCollapseDirection.wdCollapseStart;

            Word.WdHeaderFooterIndex?headerFooterId = null;

            while (SelectionRange.NextStoryRange != null)
            {
                //get the header/footer ID
                if (SelectionRange.StoryType != Word.WdStoryType.wdTextFrameStory)
                {
                    headerFooterId = RedactCommon.GetHeaderFooterType(SelectionRange.StoryType);
                }

                SelectionRange = SelectionRange.NextStoryRange;
                SelectionRange.Collapse(ref CollapseStart);
                if (FindNextMarkInCurrentStoryRange(ref SelectionRange))
                {
                    //move the focus in the view
                    if (RedactCommon.IsHeaderFooter(SelectionRange.StoryType))
                    {
                        MoveHeaderFooterFocus(SelectionRange, RedactCommon.FindSectionWithHeaderFooter(SelectionRange.Document, SelectionRange), headerFooterId);
                    }
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Finds the next redaction mark in subsequent document stories.
        /// </summary>
        /// <param name="CurrentRange">The range containing the starting point of the search. Changes to the location of the output mark if one is found.</param>
        /// <returns>True if a mark was found, otherwise False.</returns>
        private bool FindNextMarkInOtherStory(ref Word.Range CurrentRange)
        {
            //move forward a story
            int NextStory = (int)CurrentRange.StoryType + 1;

            while (NextStory <= 17)
            {
                try
                {
                    CurrentRange = CurrentRange.Document.StoryRanges[(Word.WdStoryType)NextStory];
                    CurrentRange.Collapse(ref CollapseStart);

                    if (FindNextMarkInCurrentStory(ref CurrentRange))
                    {
                        if (RedactCommon.IsHeaderFooter((Word.WdStoryType)NextStory))
                        {
                            MoveHeaderFooterFocus(CurrentRange, RedactCommon.FindSectionWithHeaderFooter(CurrentRange.Document, CurrentRange), RedactCommon.GetHeaderFooterType((Word.WdStoryType)NextStory));
                        }
                        return(true);
                    }
                }
                catch (COMException)
                { }

                NextStory++;
            }

            return(false);
        }
Beispiel #4
0
        /// <summary>
        /// Finds the previous redaction mark in previous document stories.
        /// </summary>
        /// <param name="CurrentRange">The range containing the starting point of the search. Changes to the location of the output mark if one is found.</param>
        /// <returns>True if a mark was found, otherwise False.</returns>
        private bool FindPreviousMarkInOtherStory(ref Word.Range CurrentRange)
        {
            //move backward a story
            int PrevStory = (int)CurrentRange.StoryType - 1;

            while (PrevStory >= 1)
            {
                try
                {
                    CurrentRange = CurrentRange.Document.StoryRanges[(Word.WdStoryType)PrevStory];
                    while (CurrentRange.NextStoryRange != null)
                    {
                        CurrentRange = CurrentRange.NextStoryRange;
                    }
                    CurrentRange.Collapse(ref CollapseEnd);
                }
                catch (COMException)
                { }

                if (FindPreviousMarkInCurrentStory(ref CurrentRange))
                {
                    if (RedactCommon.IsHeaderFooter((Word.WdStoryType)PrevStory))
                    {
                        MoveHeaderFooterFocus(CurrentRange, RedactCommon.FindSectionWithHeaderFooter(CurrentRange.Document, CurrentRange), RedactCommon.GetHeaderFooterType((Word.WdStoryType)PrevStory));
                    }
                    else if (CurrentRange.Document.ActiveWindow.View.Type == Word.WdViewType.wdPrintView)
                    {
                        CurrentRange.Document.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekMainDocument; //set the seek back to the document
                    }
                    return(true);
                }

                PrevStory--;
            }

            return(false);
        }