// Token: 0x060067A6 RID: 26534 RVA: 0x001D0CB8 File Offset: 0x001CEEB8
        private UpdateRecord UpdateRecordFromDtr(DtrList dtrs, DirtyTextRange dtr, int dcpContent)
        {
            UpdateRecord updateRecord = new UpdateRecord();

            updateRecord.Dtr = dtr;
            BaseParagraph baseParagraph = this._firstChild;
            int           num           = dcpContent;

            if (num < updateRecord.Dtr.StartIndex)
            {
                while (baseParagraph != null && num + baseParagraph.LastFormatCch <= updateRecord.Dtr.StartIndex && (num + baseParagraph.LastFormatCch != updateRecord.Dtr.StartIndex || !(baseParagraph is TextParagraph)))
                {
                    num          += baseParagraph.LastFormatCch;
                    baseParagraph = baseParagraph.Next;
                }
            }
            updateRecord.FirstPara = baseParagraph;
            if (baseParagraph == null)
            {
                updateRecord.ChangeType = PTS.FSKCHANGE.fskchNew;
            }
            else if (num < updateRecord.Dtr.StartIndex)
            {
                updateRecord.ChangeType = PTS.FSKCHANGE.fskchInside;
            }
            else
            {
                updateRecord.ChangeType = PTS.FSKCHANGE.fskchNew;
            }
            updateRecord.SyncPara = null;
            while (baseParagraph != null)
            {
                if (num + baseParagraph.LastFormatCch > updateRecord.Dtr.StartIndex + updateRecord.Dtr.PositionsRemoved || (num + baseParagraph.LastFormatCch == updateRecord.Dtr.StartIndex + updateRecord.Dtr.PositionsRemoved && updateRecord.ChangeType != PTS.FSKCHANGE.fskchNew))
                {
                    updateRecord.SyncPara = baseParagraph.Next;
                    break;
                }
                num          += baseParagraph.LastFormatCch;
                baseParagraph = baseParagraph.Next;
            }
            return(updateRecord);
        }
        // ------------------------------------------------------------------
        // Build UpdateRecord from DTR.
        // ------------------------------------------------------------------
        private UpdateRecord UpdateRecordFromDtr(
            DtrList dtrs,
            DirtyTextRange dtr,
            int dcpContent)
        {
            UpdateRecord ur = new UpdateRecord();

            // (1) Initialize DTR
            ur.Dtr = dtr;

            // (2) Find first paragraph affected by DTR
            BaseParagraph para = _firstChild;
            BaseParagraph paraPrev = null;
            // There might be gaps between paragraphs (example: content of List element, only 
            // nested Lists or ListItems are valid paragraphs, all other content is skipped).
            // For this reason always use para.ParagraphStartCharacterPosition to get the first
            // character position of the current paragraph.
            int dcpPara = dcpContent;
            if (dcpPara < ur.Dtr.StartIndex)
            {
                while (para != null)
                {
                    // We're looking for first affected para - We start with dco content. For
                    // all paras but TextParagraph, StartPosition/EndPosition is 
                    // |<Section></Section>|, so insertion at edge points is adding new paragraphs,
                    // not affecting current. For textpara, <Paragraph>|abcde|</Paragraph>, 
                    // insertion at edge points is a change inside for that text paragraph.
                    if (
                        dcpPara + para.LastFormatCch > ur.Dtr.StartIndex ||
                        (dcpPara + para.LastFormatCch == ur.Dtr.StartIndex && para is TextParagraph))
                    {
                        break; // the first paragraph is found
                    }

                    dcpPara += para.LastFormatCch;
                    paraPrev = para;
                    para = para.Next;
                }
            }
            // else the change is before the first paragraph
            ur.FirstPara = para;

            // (3) Determine change type for the fist affected paragraph
            if (para == null)
            {
                ur.ChangeType = PTS.FSKCHANGE.fskchNew;
            }
            else if (dcpPara < ur.Dtr.StartIndex)
            {
                ur.ChangeType = PTS.FSKCHANGE.fskchInside;
            }
            else
            {
                ur.ChangeType = PTS.FSKCHANGE.fskchNew;
            }

            // (4) Find synchronization point, the first paragraph after DTR
            ur.SyncPara = null;
            while (para != null)
            {
                if (   (dcpPara + para.LastFormatCch > ur.Dtr.StartIndex + ur.Dtr.PositionsRemoved)
                    || (dcpPara + para.LastFormatCch == ur.Dtr.StartIndex + ur.Dtr.PositionsRemoved && ur.ChangeType != PTS.FSKCHANGE.fskchNew))
                {
                    ur.SyncPara = para.Next;
                    break;
                }
                dcpPara += para.LastFormatCch;
                para = para.Next;
            }
            return ur;
        }
        // Token: 0x060067A5 RID: 26533 RVA: 0x001D0AF4 File Offset: 0x001CECF4
        private void BuildUpdateRecord()
        {
            this._ur = null;
            DtrList      dtrList = base.StructuralCache.DtrsFromRange(base.ParagraphStartCharacterPosition, base.LastFormatCch);
            UpdateRecord updateRecord2;

            if (dtrList != null)
            {
                UpdateRecord updateRecord = null;
                for (int i = 0; i < dtrList.Length; i++)
                {
                    int cpfromElement = TextContainerHelper.GetCPFromElement(base.StructuralCache.TextContainer, base.Element, ElementEdge.AfterStart);
                    updateRecord2 = this.UpdateRecordFromDtr(dtrList, dtrList[i], cpfromElement);
                    if (updateRecord == null)
                    {
                        this._ur = updateRecord2;
                    }
                    else
                    {
                        updateRecord.Next = updateRecord2;
                    }
                    updateRecord = updateRecord2;
                }
                updateRecord2 = this._ur;
                while (updateRecord2.Next != null)
                {
                    if (updateRecord2.SyncPara != null)
                    {
                        if (updateRecord2.SyncPara.Previous == updateRecord2.Next.FirstPara)
                        {
                            updateRecord2.MergeWithNext();
                        }
                        else if (updateRecord2.SyncPara == updateRecord2.Next.FirstPara && updateRecord2.Next.ChangeType == PTS.FSKCHANGE.fskchNew)
                        {
                            updateRecord2.MergeWithNext();
                        }
                        else
                        {
                            updateRecord2 = updateRecord2.Next;
                        }
                    }
                    else
                    {
                        updateRecord2.MergeWithNext();
                    }
                }
            }
            updateRecord2 = this._ur;
            while (updateRecord2 != null && updateRecord2.FirstPara != null)
            {
                BaseParagraph baseParagraph;
                if (updateRecord2.ChangeType == PTS.FSKCHANGE.fskchInside)
                {
                    baseParagraph = updateRecord2.FirstPara.Next;
                    updateRecord2.FirstPara.Next = null;
                }
                else
                {
                    baseParagraph = updateRecord2.FirstPara;
                }
                while (baseParagraph != updateRecord2.SyncPara)
                {
                    if (baseParagraph.Next != null)
                    {
                        baseParagraph.Next.Previous = null;
                    }
                    if (baseParagraph.Previous != null)
                    {
                        baseParagraph.Previous.Next = null;
                    }
                    baseParagraph.Dispose();
                    baseParagraph = baseParagraph.Next;
                }
                updateRecord2 = updateRecord2.Next;
            }
            if (this._ur != null && this._ur.FirstPara == this._firstChild && this._ur.ChangeType == PTS.FSKCHANGE.fskchNew)
            {
                this._firstChild = null;
            }
            this._firstParaValidInUpdateMode = true;
        }