// ------------------------------------------------------------------ // // TextSource Implementation // // ------------------------------------------------------------------ #region TextSource Implementation /// <summary> /// Get a text run at specified text source position and return it. /// </summary> /// <param name="dcp"> /// dcp of position relative to start of line /// </param> internal override TextRun GetTextRun(int dcp) { TextRun run = null; ITextContainer textContainer = _paraClient.Paragraph.StructuralCache.TextContainer; StaticTextPointer position = textContainer.CreateStaticPointerAtOffset(_cpPara + dcp); switch (position.GetPointerContext(LogicalDirection.Forward)) { case TextPointerContext.Text: run = HandleText(position); break; case TextPointerContext.ElementStart: run = HandleElementStartEdge(position); break; case TextPointerContext.ElementEnd: run = HandleElementEndEdge(position); break; case TextPointerContext.EmbeddedElement: run = HandleEmbeddedObject(dcp, position); break; case TextPointerContext.None: run = new ParagraphBreakRun(_syntheticCharacterLength, PTS.FSFLRES.fsflrEndOfParagraph); break; } Invariant.Assert(run != null, "TextRun has not been created."); Invariant.Assert(run.Length > 0, "TextRun has to have positive length."); return(run); }
// Token: 0x060035B8 RID: 13752 RVA: 0x000F417C File Offset: 0x000F237C private StaticTextPointer GetRunEndPosition(int index) { StaticTextPointer result; if (index + 1 < this._runList.Count) { result = this.GetRun(index + 1).Position.CreateStaticPointer(); } else { SpellerStatusTable.Run run = this.GetRun(index); ITextContainer textContainer = run.Position.TextContainer; result = textContainer.CreateStaticPointerAtOffset(textContainer.SymbolCount); } return(result); }
// Returns the end position of run. private StaticTextPointer GetRunEndPosition(int index) { StaticTextPointer position; if (index + 1 < _runList.Count) { position = GetRun(index + 1).Position.CreateStaticPointer(); } else { Run run = GetRun(index); ITextContainer textContainer = run.Position.TextContainer; position = textContainer.CreateStaticPointerAtOffset(textContainer.SymbolCount); } return(position); }
// Token: 0x0600724E RID: 29262 RVA: 0x0020AE65 File Offset: 0x00209065 internal static StaticTextPointer GetStaticTextPointerFromCP(ITextContainer textContainer, int cp) { return(textContainer.CreateStaticPointerAtOffset(cp)); }
/// <summary> /// Gets static TextPointer form character position. /// </summary> internal static StaticTextPointer GetStaticTextPointerFromCP(ITextContainer textContainer, int cp) { return textContainer.CreateStaticPointerAtOffset(cp); }
// Token: 0x06002CE0 RID: 11488 RVA: 0x000CA4F8 File Offset: 0x000C86F8 private void OnHighlightChanged(object sender, HighlightChangedEventArgs args) { ITextContainer fixedContainer = this.FixedContainer; Highlights highlights = null; FixedDocumentSequence fixedDocumentSequence = base.Parent as FixedDocumentSequence; if (fixedDocumentSequence != null) { highlights = fixedDocumentSequence.TextContainer.Highlights; } else { highlights = this.FixedContainer.Highlights; } List <FixedPage> list = new List <FixedPage>(); foreach (FixedPage item in this._highlights.Keys) { list.Add(item); } this._highlights.Clear(); StaticTextPointer staticTextPointer = fixedContainer.CreateStaticPointerAtOffset(0); for (;;) { if (!highlights.IsContentHighlighted(staticTextPointer, LogicalDirection.Forward)) { staticTextPointer = highlights.GetNextHighlightChangePosition(staticTextPointer, LogicalDirection.Forward); if (staticTextPointer.IsNull) { break; } } object highlightValue = highlights.GetHighlightValue(staticTextPointer, LogicalDirection.Forward, typeof(TextSelection)); StaticTextPointer textPosition = staticTextPointer; FixedHighlightType fixedHighlightType = FixedHighlightType.None; Brush foregroundBrush = null; Brush backgroundBrush = null; if (highlightValue != DependencyProperty.UnsetValue) { do { staticTextPointer = highlights.GetNextHighlightChangePosition(staticTextPointer, LogicalDirection.Forward); }while (highlights.GetHighlightValue(staticTextPointer, LogicalDirection.Forward, typeof(TextSelection)) != DependencyProperty.UnsetValue); fixedHighlightType = FixedHighlightType.TextSelection; foregroundBrush = null; backgroundBrush = null; } else { AnnotationHighlightLayer.HighlightSegment highlightSegment = highlights.GetHighlightValue(textPosition, LogicalDirection.Forward, typeof(HighlightComponent)) as AnnotationHighlightLayer.HighlightSegment; if (highlightSegment != null) { staticTextPointer = highlights.GetNextHighlightChangePosition(staticTextPointer, LogicalDirection.Forward); fixedHighlightType = FixedHighlightType.AnnotationHighlight; backgroundBrush = highlightSegment.Fill; } } if (fixedHighlightType != FixedHighlightType.None) { this.FixedContainer.GetMultiHighlights((FixedTextPointer)textPosition.CreateDynamicTextPointer(LogicalDirection.Forward), (FixedTextPointer)staticTextPointer.CreateDynamicTextPointer(LogicalDirection.Forward), this._highlights, fixedHighlightType, foregroundBrush, backgroundBrush); } } ArrayList arrayList = new ArrayList(); IList ranges = args.Ranges; for (int i = 0; i < ranges.Count; i++) { TextSegment textSegment = (TextSegment)ranges[i]; int pageNumber = this.FixedContainer.GetPageNumber(textSegment.Start); int pageNumber2 = this.FixedContainer.GetPageNumber(textSegment.End); for (int j = pageNumber; j <= pageNumber2; j++) { if (arrayList.IndexOf(j) < 0) { arrayList.Add(j); } } } ICollection <FixedPage> keys = this._highlights.Keys; foreach (FixedPage fixedPage in list) { if (!keys.Contains(fixedPage)) { int indexOfPage = this.GetIndexOfPage(fixedPage); if (indexOfPage >= 0 && indexOfPage < this.PageCount && arrayList.IndexOf(indexOfPage) < 0) { arrayList.Add(indexOfPage); } } } arrayList.Sort(); foreach (object obj in arrayList) { int index = (int)obj; HighlightVisual highlightVisual = HighlightVisual.GetHighlightVisual(this.SyncGetPage(index, false)); if (highlightVisual != null) { highlightVisual.InvalidateHighlights(); } } }