// 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); }
public HeaderFooterPaginator(int pageNumberOffset, FlowDocument document) { if (document == null) { throw new ArgumentNullException("document"); } _paginatorSource = document; if (_paginatorSource == null) { throw new InvalidOperationException("Could not create a clone of the document being paginated."); } _originalPaginator = ((IDocumentPaginatorSource)_paginatorSource).DocumentPaginator as DynamicDocumentPaginator; if (_originalPaginator == null) { throw new InvalidOperationException("The paginator must be a DynamicDocumentPaginator."); } _headerTemplate = GetModelDataTemplate(typeof(THeaderModel)); _footerTemplate = GetModelDataTemplate(typeof(TFooterModel)); var headerSize = GetModelContentSize(new THeaderModel { PageNumber = int.MaxValue }, _headerTemplate, _originalPaginator.PageSize); var footerSize = GetModelContentSize(new TFooterModel { PageNumber = int.MaxValue }, _footerTemplate, _originalPaginator.PageSize); _headerHeight = double.IsInfinity(headerSize.Height) ? 0 : headerSize.Height; _footerHeight = double.IsInfinity(footerSize.Height) ? 0 : footerSize.Height; _pageNumberOffset = pageNumberOffset; SetPageSize(new Size(document.PageWidth, document.PageHeight)); }
/// <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); }