internal void AddMatch(string s, Location ml, bool offsetPos, Predicate<ChangeType> changeTypeSelector) { Location mlDup = ml.Clone() as Location; int charsToGoBack = s.Length - 1 ; if (offsetPos) { mlDup.CharOffset--; mlDup.RedlineCharPos--; } if (mlDup.CharOffset == -1) { mlDup.CharOffset = 0; charsToGoBack++; } // we are looking at the last char in the string when we get called, so offset back to the first WorkBackwards(mlDup, charsToGoBack, changeTypeSelector); #if DEBUG TextRun tr = mlDup.TargetObject as TextRun; Debug.Assert(tr != null); if (mlDup.CharOffset + mlDup.Length <= tr.Content.Length) { string sCheck = tr.Content.Substring(mlDup.CharOffset, mlDup.Length); Debug.Assert(sCheck.ToUpper() == s.ToUpper()); } else { Debug.Assert(s.ToUpper().StartsWith(tr.Content.ToUpper().Substring(mlDup.CharOffset))); } #endif MatchLocations.Add(mlDup); }
private void WorkBackwards(Location l, int charCount, Predicate<ChangeType> changeTypeSelector) { while (charCount > 0) { int stepBackNow = Math.Max(0, Math.Min(charCount, l.CharOffset)); l.CharOffset -= stepBackNow; l.RedlineCharPos -= stepBackNow; charCount -= stepBackNow; if (charCount > 0) l.GoBackToPreviousRun(changeTypeSelector); } }
private ISummaryItem BuildItem(Location ml) { _si = new SummaryItem(); DocObjectWithContent dowc = null; int index = -1; foreach (LocationElement le in ml.LocationStack) { if (le.Container.Content.Count > 1 || SummaryItemBuilder.StartsNewContext(le.Container)) { dowc = le.Container; index = le.ChildIndex; } } if (dowc == null) throw new InvalidCastException(); while (index > 0) { index--; if (dowc.Content[index] is ParaMarker) { break; } if (SummaryItemBuilder.StartsNewContext(dowc.Content[index])) { index++; break; } } _charsToGrab = 0; _seenTarget = false; _location = ml; AddContentToSummaryItem(dowc, index); return _si; }
private Change FindChangeInLocationStack(Location l) { foreach (LocationElement le in l.LocationStack) { if (le.Container is Change) return le.Container as Change; } return null; }
private DocObject FindObject(RedlineDocument rd, Location l) { DocObject result = null; DocObjectWithContent container = rd; foreach (LocationElement le in l.LocationStack) { Assert.AreSame(container, le.Container); result = container.Content[le.ChildIndex]; container = result as DocObjectWithContent; } return result; }