Example #1
0
        private void InitializeUniquePart(int lastUniqueWordIndex, bool fullParentMatched)
        {
            this.lastUniqueWord = ((lastUniqueWordIndex < this.childBodyFragment.EndWordIndex) ? lastUniqueWordIndex : (this.childBodyFragment.EndWordIndex - 1));
            int lastNormalFragmentIndex = BodyDiffer.GetLastNormalFragmentIndex(this.childBodyFragment, lastUniqueWordIndex);
            int num = (this.ChildScanner.Fragments.Count > lastNormalFragmentIndex + 1) ? ((int)this.ChildScanner.Fragments[lastNormalFragmentIndex + 1].FirstLine) : this.childBodyFragment.EndLineIndex;

            num = ((num >= this.childBodyFragment.EndLineIndex) ? this.childBodyFragment.EndLineIndex : num);
            int startLineIndex = this.childBodyFragment.StartLineIndex;

            FragmentInfo.TrimBoundary(this.ChildScanner, ref startLineIndex, ref num);
            if (fullParentMatched)
            {
                for (int i = this.childBodyFragment.StartLineIndex; i < num; i++)
                {
                    if ((ulong)this.ChildScanner.Lines[i].FirstWordIndex > (ulong)((long)this.lastUniqueWord))
                    {
                        num = i;
                        FragmentInfo.TrimBoundary(this.ChildScanner, ref startLineIndex, ref num);
                        if (num > 0 && this.ChildScanner.Lines[num - 1].Category == ConversationBodyScanner.Scanner.LineCategory.PotentialNonMsHeader)
                        {
                            num--;
                        }
                    }
                }
            }
            this.uniqueBodyPart = new FragmentInfo(this.ChildScanner, startLineIndex, num);
        }
Example #2
0
        private bool MatchWordWithHref(int iChildWordIndex, int iParentWordIndex)
        {
            TextRun textRun = this.ChildScanner.Words[iChildWordIndex];
            TextRun right   = this.ParentScanner.Words[iParentWordIndex];
            int     num;
            int     num2;

            return(BodyDiffer.GetHrefTagIndex(textRun, out num, out num2) && BodyDiffer.IsSameWord(textRun, right, 0, num, 0, num) && BodyDiffer.IsSameWord(textRun, right, num2 + 1, textRun.WordLength, num, right.WordLength));
        }
Example #3
0
        private void WordByWordDiff()
        {
            if (this.parentBodyFragment.StartWordIndex == this.parentBodyFragment.EndWordIndex)
            {
                this.uniqueBodyPart = this.childBodyFragment.Trim();
                return;
            }
            if (this.childBodyFragment.IsEmpty)
            {
                return;
            }
            int lastNormalFragmentIndex  = BodyDiffer.GetLastNormalFragmentIndex(this.parentBodyFragment, this.parentBodyFragment.EndWordIndex);
            int lastNormalFragmentIndex2 = BodyDiffer.GetLastNormalFragmentIndex(this.childBodyFragment, this.childBodyFragment.EndWordIndex);
            int num  = this.childBodyFragment.StartWordIndex;
            int num2 = this.parentBodyFragment.StartWordIndex;
            int disclaimerWordStart = this.childBodyFragment.EndWordIndex;

            if (lastNormalFragmentIndex < this.ParentScanner.Fragments.Count && lastNormalFragmentIndex2 < this.ChildScanner.Fragments.Count && this.ParentScanner.Fragments[lastNormalFragmentIndex].FirstWord < this.parentBodyFragment.EndWordIndex && this.ChildScanner.Fragments[lastNormalFragmentIndex2].FirstWord < this.childBodyFragment.EndWordIndex)
            {
                num  = this.ChildScanner.Fragments[lastNormalFragmentIndex2].FirstWord;
                num2 = this.ParentScanner.Fragments[lastNormalFragmentIndex].FirstWord;
                while (num < this.childBodyFragment.EndWordIndex && num2 < this.parentBodyFragment.EndWordIndex && this.MatchWord(ref num, ref num2, true, 0))
                {
                    num++;
                    num2++;
                }
            }
            if (num2 != this.parentBodyFragment.EndWordIndex)
            {
                num  = this.childBodyFragment.EndWordIndex - 1;
                num2 = this.parentBodyFragment.EndWordIndex - 1;
            }
            else
            {
                disclaimerWordStart = num;
                num  = this.ChildScanner.Fragments[lastNormalFragmentIndex2].FirstWord - 1;
                num2 = this.ParentScanner.Fragments[lastNormalFragmentIndex].FirstWord - 1;
            }
            while (num >= this.childBodyFragment.StartWordIndex && num2 >= this.parentBodyFragment.StartWordIndex && this.MatchWord(ref num, ref num2, false, 0))
            {
                num--;
                num2--;
            }
            this.InitializeUniquePart(num, num2 < 0);
            this.InitializeDisclaimerPart(disclaimerWordStart);
            if (this.uniqueBodyPart.IsEmpty && !this.disclaimerPart.IsEmpty)
            {
                this.uniqueBodyPart = this.disclaimerPart;
                this.disclaimerPart = FragmentInfo.Empty;
            }
        }
Example #4
0
 private static bool IsSameWord(TextRun left, TextRun right, int leftBegin, int leftEnd, int rightBegin, int rightEnd)
 {
     if (leftEnd - leftBegin != rightEnd - rightBegin)
     {
         return(false);
     }
     if (leftEnd <= left.WordLength && rightEnd <= right.WordLength)
     {
         while (leftBegin < leftEnd && rightBegin < rightEnd)
         {
             if (!BodyDiffer.IsSameChar(left.GetWordChar(leftBegin), right.GetWordChar(rightBegin)))
             {
                 return(false);
             }
             leftBegin++;
             rightBegin++;
         }
         return(true);
     }
     return(false);
 }
Example #5
0
 private static bool IsSameWord(TextRun left, TextRun right)
 {
     return(BodyDiffer.IsSameWord(left, right, 0, left.WordLength, 0, right.WordLength));
 }
Example #6
0
        private bool MatchWord(ref int childWordIndex, ref int parentWordIndex, bool forwardMatch, int recursionLevel)
        {
            int num = forwardMatch ? 1 : -1;

            if (recursionLevel > 5)
            {
                return(false);
            }
            if (childWordIndex >= this.childBodyFragment.EndWordIndex || parentWordIndex >= this.parentBodyFragment.EndWordIndex || childWordIndex < 0 || parentWordIndex < 0)
            {
                return(false);
            }
            if (BodyDiffer.IsSameWord(this.ParentScanner.Words[parentWordIndex], this.ChildScanner.Words[childWordIndex]))
            {
                return(true);
            }
            int num5;
            int num6;

            if (this.IsHrefBeginText(childWordIndex, forwardMatch))
            {
                int num2 = this.HrefTextEndIndex(childWordIndex, forwardMatch);
                if (this.MatchWord(ref num2, ref parentWordIndex, forwardMatch, recursionLevel + 1))
                {
                    childWordIndex = num2;
                    return(true);
                }
            }
            else if (this.IsHorizontalLine(this.ChildScanner.Words[childWordIndex]))
            {
                int num3 = childWordIndex + num;
                if (this.MatchWord(ref num3, ref parentWordIndex, forwardMatch, recursionLevel + 1))
                {
                    childWordIndex = num3;
                    return(true);
                }
            }
            else if (this.IsHorizontalLine(this.ParentScanner.Words[parentWordIndex]))
            {
                int num4 = parentWordIndex + num;
                if (this.MatchWord(ref childWordIndex, ref num4, forwardMatch, recursionLevel + 1))
                {
                    parentWordIndex = num4;
                    return(true);
                }
            }
            else if (BodyDiffer.GetHrefTagIndex(this.ChildScanner.Words[childWordIndex], out num5, out num6))
            {
                if (num5 == 0)
                {
                    int num7 = childWordIndex + num;
                    if (this.MatchWord(ref num7, ref parentWordIndex, forwardMatch, recursionLevel + 1))
                    {
                        childWordIndex = num7;
                        return(true);
                    }
                }
                else if (this.MatchWordWithHref(childWordIndex, parentWordIndex))
                {
                    return(true);
                }
            }
            else if (this.ChildScanner.Words[childWordIndex].WordLength == 1 && this.ChildScanner.Words[childWordIndex].GetWordChar(0) == '>')
            {
                int num8 = childWordIndex + num;
                if (this.MatchWord(ref num8, ref parentWordIndex, forwardMatch, recursionLevel + 1))
                {
                    childWordIndex = num8;
                    return(true);
                }
            }
            else if (BodyDiffer.IsListNumberOrBullet(this.ChildScanner.Words[childWordIndex]))
            {
                int num9 = childWordIndex + num;
                if (this.MatchWord(ref num9, ref parentWordIndex, forwardMatch, recursionLevel + 1))
                {
                    childWordIndex = num9;
                    return(true);
                }
            }
            else if (BodyDiffer.IsListNumberOrBullet(this.ParentScanner.Words[parentWordIndex]))
            {
                int num10 = parentWordIndex + num;
                if (this.MatchWord(ref childWordIndex, ref num10, forwardMatch, recursionLevel + 1))
                {
                    parentWordIndex = num10;
                    return(true);
                }
            }
            return(false);
        }