Exemplo n.º 1
0
        // Token: 0x06006B2A RID: 27434 RVA: 0x001EF184 File Offset: 0x001ED384
        internal void UpdGetChangeInText(out int dcpStart, out int ddcpOld, out int ddcpNew)
        {
            DtrList dtrList = base.StructuralCache.DtrsFromRange(base.ParagraphStartCharacterPosition, base.LastFormatCch);

            if (dtrList != null)
            {
                dcpStart = dtrList[0].StartIndex - base.ParagraphStartCharacterPosition;
                ddcpNew  = dtrList[0].PositionsAdded;
                ddcpOld  = dtrList[0].PositionsRemoved;
                if (dtrList.Length > 1)
                {
                    for (int i = 1; i < dtrList.Length; i++)
                    {
                        int num = dtrList[i].StartIndex - dtrList[i - 1].StartIndex;
                        ddcpNew += num + dtrList[i].PositionsAdded;
                        ddcpOld += num + dtrList[i].PositionsRemoved;
                    }
                }
                if (!base.StructuralCache.CurrentFormatContext.FinitePage)
                {
                    this.UpdateEmbeddedObjectsCache <AttachedObject>(ref this._attachedObjects, dcpStart, ddcpOld, ddcpNew - ddcpOld);
                    this.UpdateEmbeddedObjectsCache <InlineObject>(ref this._inlineObjects, dcpStart, ddcpOld, ddcpNew - ddcpOld);
                }
                Invariant.Assert(dcpStart >= 0 && base.Cch >= dcpStart && base.LastFormatCch >= dcpStart);
                ddcpOld = Math.Min(ddcpOld, base.LastFormatCch - dcpStart + 1);
                ddcpNew = Math.Min(ddcpNew, base.Cch - dcpStart + 1);
                return;
            }
            dcpStart = (ddcpOld = (ddcpNew = 0));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add new DirtyTextRange.
 /// </summary>
 /// <param name="dtr">New DTR being added.</param>
 internal void AddDirtyTextRange(DirtyTextRange dtr)
 {
     if (_dtrs == null)
     {
         _dtrs = new DtrList();
     }
     _dtrs.Merge(dtr);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Invalidates main text segment for bottomless pages if DTR list for this para is non-null.
        /// </summary>
        private void InvalidateMainTextSegment()
        {
            DtrList dtrs = StructuralCache.DtrsFromRange(ParagraphStartCharacterPosition, LastFormatCch);

            if (dtrs != null && dtrs.Length > 0)
            {
                _mainTextSegment.InvalidateStructure(dtrs[0].StartIndex);
            }
        }
Exemplo n.º 4
0
        // Token: 0x0600682B RID: 26667 RVA: 0x001D5720 File Offset: 0x001D3920
        private void InvalidateMainTextSegment()
        {
            DtrList dtrList = base.StructuralCache.DtrsFromRange(base.ParagraphStartCharacterPosition, base.LastFormatCch);

            if (dtrList != null && dtrList.Length > 0)
            {
                this._mainTextSegment.InvalidateStructure(dtrList[0].StartIndex);
            }
        }
Exemplo n.º 5
0
        // ------------------------------------------------------------------
        // Retrieve list of dtrs from range.
        //
        //      dcpNew - Distance from the beginning of TextContainer after all
        //              tree changes.
        //      cchOld - Number of characters in the range, but before any
        //              tree changes.
        //
        // Returns: List of DRTs for specified range.
        // ------------------------------------------------------------------
        internal DtrList DtrsFromRange(int dcpNew, int cchOld)
        {
            DtrList dtrs = null;
            int     i = 0;
            int     first, last;
            int     positionsAdded = 0;

            // Find the first dtr intersecting with the specified range.
            // Since DTRs store dcp before any changes, during iteration
            // accumulate positionsAdded (number of characters added to the tree
            // up to the current point).
            while (i < _count)
            {
                if (dcpNew <= _dtrs[i].StartIndex + positionsAdded + _dtrs[i].PositionsAdded)
                {
                    break;
                }
                positionsAdded += _dtrs[i].PositionsAdded - _dtrs[i].PositionsRemoved;
                ++i;
            }
            first = i;

            // Find the last dtr intersecting with the specified range.
            // dcpNew-positionsAdded points to position before any tree changes, from
            // where we start counting cchOld.
            // Do not add characters (positionsAdded), since start position has been already found.
            while (i < _count)
            {
                if (dcpNew - positionsAdded + cchOld <= _dtrs[i].StartIndex + _dtrs[i].PositionsRemoved)
                {
                    // If there is no intersection with the current DTR, go to the previous one.
                    if (dcpNew - positionsAdded + cchOld < _dtrs[i].StartIndex)
                    {
                        --i;
                    }
                    break;
                }
                ++i;
            }
            last = (i < _count) ? i : _count - 1;

            // If there are DTRs in the specified range, create new DtrList object
            if (last >= first)
            {
                dtrs = new DtrList();
                while (last >= first)
                {
                    // Since dcpNew is after tree changes, add positionsAdded to all dtrs
                    // to build dtr list relative to dcpNew position.
                    DirtyTextRange dtr = _dtrs[first];
                    dtr.StartIndex += positionsAdded;
                    dtrs.Append(dtr);
                    ++first;
                }
            }
            return(dtrs);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Invalidate content's structural cache.
 /// </summary>
 internal void InvalidateStructure()
 {
     if (_mainTextSegment != null)
     {
         DtrList dtrs = _structuralCache.DtrList;
         if (dtrs != null)
         {
             _mainTextSegment.InvalidateStructure(dtrs[0].StartIndex);
         }
     }
 }
 // Token: 0x06006A4A RID: 27210 RVA: 0x001E40A0 File Offset: 0x001E22A0
 internal void InvalidateStructure()
 {
     if (this._mainTextSegment != null)
     {
         DtrList dtrList = this._structuralCache.DtrList;
         if (dtrList != null)
         {
             this._mainTextSegment.InvalidateStructure(dtrList[0].StartIndex);
         }
     }
 }
Exemplo n.º 8
0
        // Token: 0x060067B4 RID: 26548 RVA: 0x001D1260 File Offset: 0x001CF460
        internal DtrList DtrsFromRange(int dcpNew, int cchOld)
        {
            DtrList dtrList = null;
            int     i       = 0;
            int     num     = 0;

            while (i < this._count && dcpNew > this._dtrs[i].StartIndex + num + this._dtrs[i].PositionsAdded)
            {
                num += this._dtrs[i].PositionsAdded - this._dtrs[i].PositionsRemoved;
                i++;
            }
            int num2 = i;

            while (i < this._count)
            {
                if (dcpNew - num + cchOld <= this._dtrs[i].StartIndex + this._dtrs[i].PositionsRemoved)
                {
                    if (dcpNew - num + cchOld < this._dtrs[i].StartIndex)
                    {
                        i--;
                        break;
                    }
                    break;
                }
                else
                {
                    i++;
                }
            }
            int j = (i < this._count) ? i : (this._count - 1);

            if (j >= num2)
            {
                dtrList = new DtrList();
                while (j >= num2)
                {
                    DirtyTextRange dtr = this._dtrs[num2];
                    dtr.StartIndex += num;
                    dtrList.Append(dtr);
                    num2++;
                }
            }
            return(dtrList);
        }
        // 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);
        }
 // Token: 0x0600679A RID: 26522 RVA: 0x001CFD2C File Offset: 0x001CDF2C
 internal void UpdGetSegmentChange(out PTS.FSKCHANGE fskch)
 {
     if (base.StructuralCache.CurrentFormatContext.FinitePage)
     {
         DtrList dtrList = base.StructuralCache.DtrsFromRange(TextContainerHelper.GetCPFromElement(base.StructuralCache.TextContainer, base.Element, ElementEdge.BeforeStart), base.LastFormatCch);
         if (dtrList != null)
         {
             int            cpfromElement  = TextContainerHelper.GetCPFromElement(base.StructuralCache.TextContainer, base.Element, ElementEdge.AfterStart);
             DirtyTextRange dirtyTextRange = dtrList[0];
             int            num            = cpfromElement;
             BaseParagraph  baseParagraph  = this._firstChild;
             if (num < dirtyTextRange.StartIndex)
             {
                 while (baseParagraph != null && num + baseParagraph.LastFormatCch <= dirtyTextRange.StartIndex && (num + baseParagraph.LastFormatCch != dirtyTextRange.StartIndex || !(baseParagraph is TextParagraph)))
                 {
                     num          += baseParagraph.Cch;
                     baseParagraph = baseParagraph.Next;
                 }
                 if (baseParagraph != null)
                 {
                     baseParagraph.SetUpdateInfo(PTS.FSKCHANGE.fskchInside, false);
                 }
             }
             else
             {
                 baseParagraph.SetUpdateInfo(PTS.FSKCHANGE.fskchNew, false);
             }
             if (baseParagraph != null)
             {
                 for (baseParagraph = baseParagraph.Next; baseParagraph != null; baseParagraph = baseParagraph.Next)
                 {
                     baseParagraph.SetUpdateInfo(PTS.FSKCHANGE.fskchNew, false);
                 }
             }
             this._changeType = PTS.FSKCHANGE.fskchInside;
         }
     }
     fskch = this._changeType;
 }
Exemplo n.º 11
0
        // ------------------------------------------------------------------
        // Retrieve list of dtrs from range.
        //
        //      dcpNew - Distance from the beginning of TextContainer after all
        //              tree changes.
        //      cchOld - Number of characters in the range, but before any 
        //              tree changes.
        //
        // Returns: List of DRTs for specified range.
        // ------------------------------------------------------------------
        internal DtrList DtrsFromRange(int dcpNew, int cchOld)
        {
            DtrList dtrs = null;
            int i = 0;
            int first, last;
            int positionsAdded = 0;

            // Find the first dtr intersecting with the specified range.
            // Since DTRs store dcp before any changes, during iteration
            // accumulate positionsAdded (number of characters added to the tree
            // up to the current point).
            while (i < _count)
            {
                if (dcpNew <= _dtrs[i].StartIndex + positionsAdded + _dtrs[i].PositionsAdded)
                {
                    break;
                }
                positionsAdded += _dtrs[i].PositionsAdded - _dtrs[i].PositionsRemoved;
                ++i;
            }
            first = i;

            // Find the last dtr intersecting with the specified range.
            // dcpNew-positionsAdded points to position before any tree changes, from
            // where we start counting cchOld.
            // Do not add characters (positionsAdded), since start position has been already found.
            while (i < _count)
            {
                if (dcpNew - positionsAdded + cchOld <= _dtrs[i].StartIndex + _dtrs[i].PositionsRemoved)
                {
                    // If there is no intersection with the current DTR, go to the previous one.
                    if (dcpNew - positionsAdded + cchOld < _dtrs[i].StartIndex)
                    {
                        --i;
                    }
                    break;
                }
                ++i;
            }
            last = (i < _count) ? i : _count-1;

            // If there are DTRs in the specified range, create new DtrList object
            if (last >= first)
            {
                dtrs = new DtrList();
                while (last >= first)
                {
                    // Since dcpNew is after tree changes, add positionsAdded to all dtrs
                    // to build dtr list relative to dcpNew position.
                    DirtyTextRange dtr = _dtrs[first];
                    dtr.StartIndex += positionsAdded;
                    dtrs.Append(dtr);
                    ++first;
                }
            }
            return dtrs;
        }
Exemplo n.º 12
0
        // Callback from the TextContainer when a highlight changes.
        private void OnHighlightChanged(object sender, HighlightChangedEventArgs args)
        {
            // The only supported highlight type for TextBoxView is SpellerHighlight.
            if (args.OwnerType != typeof(SpellerHighlightLayer))
            {
                return;
            }

            if (_dirtyList == null)
            {
                _dirtyList = new DtrList();
            }

            //
            // Add the change to our dirty list.
            //

            foreach (TextSegment segment in args.Ranges)
            {
                int positionsCovered = segment.End.Offset - segment.Start.Offset;
                DirtyTextRange dirtyTextRange = new DirtyTextRange(segment.Start.Offset, positionsCovered, positionsCovered);
                _dirtyList.Merge(dirtyTextRange);
            }

            //
            // Force a re-measure.
            //
            // NB: it's not currently possible to InvalidateArrange here.
            // "Render only" changes from the highlight layer change the way we
            // ultimately feed text to the formatter.  Introducing breaks for
            // highlights may actually change the layout of the text as
            // characters are interpreted in different contexts.  Dev10 Bugs
            // 511849 has an example.
            //
            InvalidateMeasure();
        }
Exemplo n.º 13
0
        // Callback from the TextContainer on a document edit.
        private void OnTextContainerChange(object sender, TextContainerChangeEventArgs args)
        {
            if (args.Count == 0)
            {
                // A no-op for this control.  Happens when IMECharCount updates happen
                // without corresponding SymbolCount changes.
                return;
            }

            //
            // Add the change to our dirty list.
            //

            if (_dirtyList == null)
            {
                _dirtyList = new DtrList();
            }

            DirtyTextRange dirtyTextRange = new DirtyTextRange(args);
            _dirtyList.Merge(dirtyTextRange);

            //
            // Force a re-measure.
            //
            InvalidateMeasure();
        }
        // ------------------------------------------------------------------
        // 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;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Add new DirtyTextRange.
 /// </summary>
 /// <param name="dtr">New DTR being added.</param> 
 internal void AddDirtyTextRange(DirtyTextRange dtr)
 { 
     if (_dtrs == null) 
     {
         _dtrs = new DtrList(); 
     }
     _dtrs.Merge(dtr);
 }
        // Token: 0x060067A4 RID: 26532 RVA: 0x001D0AC8 File Offset: 0x001CECC8
        private bool NeedsUpdate()
        {
            DtrList dtrList = base.StructuralCache.DtrsFromRange(base.ParagraphStartCharacterPosition, base.LastFormatCch);

            return(dtrList != null);
        }
        // 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;
        }