// Token: 0x06007BDB RID: 31707 RVA: 0x0022D22C File Offset: 0x0022B42C private static ITextPointer FindEndVisibleTextPointer(DocumentPage documentPage) { ITextPointer textPointer; ITextPointer textPointer2; if (!FixedTextSelectionProcessor.GetTextViewRange(documentPage, out textPointer, out textPointer2)) { return(null); } if (!textPointer2.IsAtInsertionPosition && !textPointer2.MoveToNextInsertionPosition(LogicalDirection.Backward)) { return(null); } if (textPointer.CompareTo(textPointer2) > 0) { return(null); } return(textPointer2); }
// Token: 0x06007BD3 RID: 31699 RVA: 0x0022CD00 File Offset: 0x0022AF00 public override object ResolveLocatorPart(ContentLocatorPart locatorPart, DependencyObject startNode, out AttachmentLevel attachmentLevel) { if (startNode == null) { throw new ArgumentNullException("startNode"); } DocumentPage documentPage = null; FixedPage fixedPage = startNode as FixedPage; if (fixedPage != null) { documentPage = this.GetDocumentPage(fixedPage); } else { DocumentPageView documentPageView = startNode as DocumentPageView; if (documentPageView != null) { documentPage = (documentPageView.DocumentPage as FixedDocumentPage); if (documentPage == null) { documentPage = (documentPageView.DocumentPage as FixedDocumentSequenceDocumentPage); } } } if (documentPage == null) { throw new ArgumentException(SR.Get("StartNodeMustBeDocumentPageViewOrFixedPage"), "startNode"); } if (locatorPart == null) { throw new ArgumentNullException("locatorPart"); } attachmentLevel = AttachmentLevel.Unresolved; ITextView textView = (ITextView)((IServiceProvider)documentPage).GetService(typeof(ITextView)); ReadOnlyCollection <TextSegment> textSegments = textView.TextSegments; if (textSegments == null || textSegments.Count <= 0) { return(null); } TextAnchor textAnchor = new TextAnchor(); if (documentPage != null) { string text = locatorPart.NameValuePairs["Count"]; if (text == null) { throw new ArgumentException(SR.Get("InvalidLocatorPart", new object[] { "Count" })); } int num = int.Parse(text, NumberFormatInfo.InvariantInfo); for (int i = 0; i < num; i++) { Point point; Point point2; this.GetLocatorPartSegmentValues(locatorPart, i, out point, out point2); ITextPointer textPointer; if (double.IsNaN(point.X) || double.IsNaN(point.Y)) { textPointer = FixedTextSelectionProcessor.FindStartVisibleTextPointer(documentPage); } else { textPointer = textView.GetTextPositionFromPoint(point, true); } if (textPointer != null) { ITextPointer textPointer2; if (double.IsNaN(point2.X) || double.IsNaN(point2.Y)) { textPointer2 = FixedTextSelectionProcessor.FindEndVisibleTextPointer(documentPage); } else { textPointer2 = textView.GetTextPositionFromPoint(point2, true); } Invariant.Assert(textPointer2 != null, "end TP is null when start TP is not"); attachmentLevel = AttachmentLevel.Full; textAnchor.AddTextSegment(textPointer, textPointer2); } } } if (textAnchor.TextSegments.Count > 0) { return(textAnchor); } return(null); }