Exemple #1
0
        /// <summary>
        /// Gets a list of ITextViews spanned by this text segment
        /// </summary>
        /// <param name="segment">the text segment</param>
        /// <returns>the TextViews list</returns>
        internal static List <ITextView> GetDocumentPageTextViews(TextSegment segment)
        {
            List <ITextView> res = null;
            int startPageNumber, endPageNumber;

            //revert the logical direction of the pointers
            ITextPointer start = segment.Start.CreatePointer(LogicalDirection.Forward);
            ITextPointer end   = segment.End.CreatePointer(LogicalDirection.Backward);

            DependencyObject content = start.TextContainer.Parent as DependencyObject;

            if (content != null)
            {
                FlowDocumentScrollViewer scrollViewer = PathNode.GetParent(content) as FlowDocumentScrollViewer;
                if (scrollViewer != null)
                {
                    IServiceProvider provider = scrollViewer.ScrollViewer.Content as IServiceProvider;
                    Invariant.Assert(provider != null, "FlowDocumentScrollViewer should be an IServiceProvider.");
                    res = new List <ITextView>(1);
                    res.Add(provider.GetService(typeof(ITextView)) as ITextView);
                    return(res);
                }
            }

            IDocumentPaginatorSource idp = GetPointerPage(start, out startPageNumber);
            DynamicDocumentPaginator ddp = idp.DocumentPaginator as DynamicDocumentPaginator;

            endPageNumber = ddp != null?ddp.GetPageNumber((ContentPosition)end) : -1;

            if (startPageNumber == -1 || endPageNumber == -1)
            {
                // If either page couldn't be found, we return an empty list.  This
                // could be caused by a failure in paginating the document.
                res = new List <ITextView>(0);
            }
            else if (startPageNumber == endPageNumber)
            {
                res = ProcessSinglePage(idp, startPageNumber);
            }
            else
            {
                res = ProcessMultiplePages(idp, startPageNumber, endPageNumber);
            }

            return(res);
        }
Exemple #2
0
        // Token: 0x06007C3A RID: 31802 RVA: 0x0022EE98 File Offset: 0x0022D098
        public static IDocumentPaginatorSource GetPointerPage(ITextPointer pointer, out int pageNumber)
        {
            Invariant.Assert(pointer != null, "unknown pointer");
            IDocumentPaginatorSource documentPaginatorSource = pointer.TextContainer.Parent as IDocumentPaginatorSource;
            FixedDocument            fixedDocument           = documentPaginatorSource as FixedDocument;

            if (fixedDocument != null)
            {
                FixedDocumentSequence fixedDocumentSequence = fixedDocument.Parent as FixedDocumentSequence;
                if (fixedDocumentSequence != null)
                {
                    documentPaginatorSource = fixedDocumentSequence;
                }
            }
            Invariant.Assert(documentPaginatorSource != null);
            DynamicDocumentPaginator dynamicDocumentPaginator = documentPaginatorSource.DocumentPaginator as DynamicDocumentPaginator;

            pageNumber = ((dynamicDocumentPaginator != null) ? dynamicDocumentPaginator.GetPageNumber((ContentPosition)pointer) : -1);
            return(documentPaginatorSource);
        }
Exemple #3
0
        // Token: 0x06007C3D RID: 31805 RVA: 0x0022F01C File Offset: 0x0022D21C
        internal static List <ITextView> GetDocumentPageTextViews(TextSegment segment)
        {
            ITextPointer     textPointer  = segment.Start.CreatePointer(LogicalDirection.Forward);
            ITextPointer     textPointer2 = segment.End.CreatePointer(LogicalDirection.Backward);
            DependencyObject parent       = textPointer.TextContainer.Parent;

            if (parent != null)
            {
                FlowDocumentScrollViewer flowDocumentScrollViewer = PathNode.GetParent(parent) as FlowDocumentScrollViewer;
                if (flowDocumentScrollViewer != null)
                {
                    IServiceProvider serviceProvider = flowDocumentScrollViewer.ScrollViewer.Content as IServiceProvider;
                    Invariant.Assert(serviceProvider != null, "FlowDocumentScrollViewer should be an IServiceProvider.");
                    return(new List <ITextView>(1)
                    {
                        serviceProvider.GetService(typeof(ITextView)) as ITextView
                    });
                }
            }
            int num;
            IDocumentPaginatorSource pointerPage = TextSelectionHelper.GetPointerPage(textPointer, out num);
            DynamicDocumentPaginator dynamicDocumentPaginator = pointerPage.DocumentPaginator as DynamicDocumentPaginator;
            int num2 = (dynamicDocumentPaginator != null) ? dynamicDocumentPaginator.GetPageNumber((ContentPosition)textPointer2) : -1;
            List <ITextView> result;

            if (num == -1 || num2 == -1)
            {
                result = new List <ITextView>(0);
            }
            else if (num == num2)
            {
                result = TextSelectionHelper.ProcessSinglePage(pointerPage, num);
            }
            else
            {
                result = TextSelectionHelper.ProcessMultiplePages(pointerPage, num, num2);
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Gets DocumentViewerBase and a page number for specified TextPointer
        /// </summary>
        /// <param name="pointer">a TP from the container</param>
        /// <param name="pageNumber">the page number</param>
        /// <returns>DocumentViewerBase</returns>
        public static IDocumentPaginatorSource GetPointerPage(ITextPointer pointer, out int pageNumber)
        {
            Invariant.Assert(pointer != null, "unknown pointer");

            IDocumentPaginatorSource idp      = pointer.TextContainer.Parent as IDocumentPaginatorSource;
            FixedDocument            fixedDoc = idp as FixedDocument;

            if (fixedDoc != null)
            {
                FixedDocumentSequence sequence = fixedDoc.Parent as FixedDocumentSequence;
                if (sequence != null)
                {
                    idp = sequence;
                }
            }

            Invariant.Assert(idp != null);
            DynamicDocumentPaginator ddp = idp.DocumentPaginator as DynamicDocumentPaginator;

            pageNumber = ddp != null?ddp.GetPageNumber((ContentPosition)pointer) : -1;

            return(idp);
        }
Exemple #5
0
 public override int GetPageNumber(ContentPosition contentPosition)
 {
     return(_originalPaginator.GetPageNumber(contentPosition));
 }