// Token: 0x06002F9C RID: 12188 RVA: 0x000D671C File Offset: 0x000D491C
        internal void GetFlowNode(LogicalDirection direction, out FlowNode flowNode, out int offsetStart)
        {
            FlowPosition clingPosition = this.GetClingPosition(direction);

            offsetStart = clingPosition._offset;
            flowNode    = clingPosition._flowNode;
        }
Example #2
0
        //Find the first valid insertion position after or before the boundary node
        private bool _GetFirstFixedPosition(FixedTextPointer ftp, out FixedPosition fixedP)
        {
            LogicalDirection dir = LogicalDirection.Forward;

            if (ftp.FlowPosition.FlowNode.Fp != 0)
            {
                //End boundary
                dir = LogicalDirection.Backward;
            }
            FlowPosition flowP = (FlowPosition)ftp.FlowPosition.Clone();

            //Get the first node that comes before or after the boundary node(probably a start or end node)
            flowP.Move(dir);

            FixedTextPointer nav = new FixedTextPointer(true, dir, flowP);

            if (flowP.IsStart || flowP.IsEnd)
            {
                ((ITextPointer)nav).MoveToNextInsertionPosition(dir);
            }
            if (this.Container.GetPageNumber(nav) == this.PageIndex)
            {
                return(Container.FixedTextBuilder.GetFixedPosition(nav.FlowPosition, dir, out fixedP));
            }
            else
            {
                //This position is on another page.
                fixedP = new FixedPosition(this.Container.FixedTextBuilder.FixedFlowMap.FixedStartEdge, 0);
                return(false);
            }
        }
        // Token: 0x06002F97 RID: 12183 RVA: 0x000D65F8 File Offset: 0x000D47F8
        internal FixedElement GetScopingElement()
        {
            FlowPosition       flowPosition = (FlowPosition)this.Clone();
            int                num          = 0;
            TextPointerContext pointerContext;

            while (flowPosition.FlowNode.Fp > 0 && !this.IsVirtual(this._FixedFlowMap[flowPosition.FlowNode.Fp - 1]) && (pointerContext = flowPosition.GetPointerContext(LogicalDirection.Backward)) != TextPointerContext.None)
            {
                if (pointerContext == TextPointerContext.ElementStart)
                {
                    if (num == 0)
                    {
                        FlowPosition clingPosition = flowPosition.GetClingPosition(LogicalDirection.Backward);
                        return((FixedElement)clingPosition._flowNode.Cookie);
                    }
                    num--;
                }
                else if (pointerContext == TextPointerContext.ElementEnd)
                {
                    num++;
                }
                flowPosition.Move(LogicalDirection.Backward);
            }
            return(this._container.ContainerElement);
        }
        // Token: 0x06002F95 RID: 12181 RVA: 0x000D652C File Offset: 0x000D472C
        internal object GetAdjacentElement(LogicalDirection dir)
        {
            FlowPosition clingPosition = this.GetClingPosition(dir);
            FlowNodeType type          = clingPosition._flowNode.Type;

            if (type == FlowNodeType.Noop)
            {
                return(string.Empty);
            }
            object @object = ((FixedElement)clingPosition._flowNode.Cookie).GetObject();
            Image  image   = @object as Image;

            if (type == FlowNodeType.Object && image != null)
            {
                FixedSOMElement[] fixedSOMElements = clingPosition._flowNode.FixedSOMElements;
                if (fixedSOMElements != null && fixedSOMElements.Length != 0)
                {
                    FixedSOMImage fixedSOMImage = fixedSOMElements[0] as FixedSOMImage;
                    if (fixedSOMImage != null)
                    {
                        image.Width  = fixedSOMImage.BoundingRect.Width;
                        image.Height = fixedSOMImage.BoundingRect.Height;
                    }
                }
            }
            return(@object);
        }
        // Token: 0x06002F94 RID: 12180 RVA: 0x000D64A0 File Offset: 0x000D46A0
        internal int GetTextInRun(LogicalDirection dir, int maxLength, char[] chars, int startIndex)
        {
            FlowPosition clingPosition = this.GetClingPosition(dir);
            int          nodeLength    = clingPosition._NodeLength;
            int          val;

            if (dir == LogicalDirection.Forward)
            {
                val = nodeLength - clingPosition._offset;
            }
            else
            {
                val = clingPosition._offset;
            }
            maxLength = Math.Min(maxLength, val);
            string flowText = this._container.FixedTextBuilder.GetFlowText(clingPosition._flowNode);

            if (dir == LogicalDirection.Forward)
            {
                Array.Copy(flowText.ToCharArray(clingPosition._offset, maxLength), 0, chars, startIndex, maxLength);
            }
            else
            {
                Array.Copy(flowText.ToCharArray(clingPosition._offset - maxLength, maxLength), 0, chars, startIndex, maxLength);
            }
            return(maxLength);
        }
Example #6
0
        internal void GetFlowNode(LogicalDirection direction, out FlowNode flowNode, out int offsetStart)
        {
            FlowPosition fp = GetClingPosition(direction);

            offsetStart = fp._offset;
            flowNode    = fp._flowNode;
        }
Example #7
0
        // return FlowNode within this range
        internal void GetFlowNodes(FlowPosition pEnd, out FlowNode[] flowNodes, out int offsetStart, out int offsetEnd)
        {
            Debug.Assert(this._OverlapAwareCompare(pEnd) < 0);
            flowNodes   = null;
            offsetStart = 0;
            offsetEnd   = 0;

            FlowPosition flowScan = GetClingPosition(LogicalDirection.Forward);

            offsetStart = flowScan._offset;

            ArrayList ar       = new ArrayList();
            int       distance = GetDistance(pEnd);

            // keep moving until we hit distance
            while (distance > 0)
            {
                int scan = flowScan._vScan(LogicalDirection.Forward, distance);

                distance -= scan;
                if (flowScan.IsRun || flowScan.IsObject)
                {
                    ar.Add(flowScan._flowNode);
                    offsetEnd = flowScan._offset;
                }
            }
            flowNodes = (FlowNode [])ar.ToArray(typeof(FlowNode));
        }
Example #8
0
        // Get Embedeed Object instance
        internal object GetAdjacentElement(LogicalDirection dir)
        {
            FlowPosition flow = GetClingPosition(dir);
            FlowNodeType type = flow._flowNode.Type;

            Debug.Assert(type == FlowNodeType.Object || type == FlowNodeType.Noop || type == FlowNodeType.Start || type == FlowNodeType.End);

            if (type == FlowNodeType.Noop)
            {
                return(String.Empty);
            }
            else
            {
                Object obj   = ((FixedElement)flow._flowNode.Cookie).GetObject();
                Image  image = obj as Image;
                if (type == FlowNodeType.Object && image != null)
                {
                    //Set width and height properties by looking at corresponding SOMImage
                    FixedSOMElement[] elements = flow._flowNode.FixedSOMElements;
                    if (elements != null && elements.Length > 0)
                    {
                        FixedSOMImage somImage = elements[0] as FixedSOMImage;
                        if (somImage != null)
                        {
                            image.Width  = somImage.BoundingRect.Width;
                            image.Height = somImage.BoundingRect.Height;
                        }
                    }
                }
                return(obj);
            }
        }
Example #9
0
        // Immediate scoping element. If no element scops the position,
        // returns the container element.
        internal FixedElement GetScopingElement()
        {
            FlowPosition       flowScan      = (FlowPosition)this.Clone();
            int                nestedElement = 0;
            TextPointerContext tst;

            while (flowScan.FlowNode.Fp > 0 && !IsVirtual(_FixedFlowMap[flowScan.FlowNode.Fp - 1]) && // do not de-virtualize nodes
                   (tst = flowScan.GetPointerContext(LogicalDirection.Backward)) != TextPointerContext.None)
            {
                if (tst == TextPointerContext.ElementStart)
                {
                    if (nestedElement == 0)
                    {
                        FlowPosition flowEnd = flowScan.GetClingPosition(LogicalDirection.Backward);
                        return((FixedElement)flowEnd._flowNode.Cookie);
                    }
                    nestedElement--;
                }
                else if (tst == TextPointerContext.ElementEnd)
                {
                    nestedElement++;
                }

                flowScan.Move(LogicalDirection.Backward);
            }
            return(_container.ContainerElement);
        }
        // Token: 0x06002FAD RID: 12205 RVA: 0x000D6B3C File Offset: 0x000D4D3C
        private int _OverlapAwareCompare(FlowPosition flow)
        {
            if (this == flow)
            {
                return(0);
            }
            int num = this._flowNode.CompareTo(flow._flowNode);

            if (num < 0)
            {
                if (this._flowNode.Fp == flow._flowNode.Fp - 1 && this._offset == this._NodeLength && flow._offset == 0)
                {
                    return(0);
                }
            }
            else if (num > 0)
            {
                if (flow._flowNode.Fp == this._flowNode.Fp - 1 && flow._offset == flow._NodeLength && this._offset == 0)
                {
                    return(0);
                }
            }
            else
            {
                num = this._offset.CompareTo(flow._offset);
            }
            return(num);
        }
Example #11
0
        // Token: 0x06002E74 RID: 11892 RVA: 0x000D2774 File Offset: 0x000D0974
        private static void _GetFirstPageSearchPointers(ITextPointer start, ITextPointer end, int pageNumber, bool matchLast, out ITextPointer firstSearchPageStart, out ITextPointer firstSearchPageEnd)
        {
            if (matchLast)
            {
                DocumentSequenceTextPointer documentSequenceTextPointer = end as DocumentSequenceTextPointer;
                if (documentSequenceTextPointer != null)
                {
                    FlowPosition pageStartFlowPosition = ((FixedTextContainer)documentSequenceTextPointer.ChildBlock.ChildContainer).FixedTextBuilder.GetPageStartFlowPosition(pageNumber);
                    firstSearchPageStart = new DocumentSequenceTextPointer(documentSequenceTextPointer.ChildBlock, new FixedTextPointer(false, LogicalDirection.Forward, pageStartFlowPosition));
                }
                else
                {
                    FixedTextPointer fixedTextPointer = end as FixedTextPointer;
                    firstSearchPageStart = new FixedTextPointer(false, LogicalDirection.Forward, fixedTextPointer.FixedTextContainer.FixedTextBuilder.GetPageStartFlowPosition(pageNumber));
                }
                firstSearchPageEnd = end;
                return;
            }
            DocumentSequenceTextPointer documentSequenceTextPointer2 = start as DocumentSequenceTextPointer;

            if (documentSequenceTextPointer2 != null)
            {
                FlowPosition pageEndFlowPosition = ((FixedTextContainer)documentSequenceTextPointer2.ChildBlock.ChildContainer).FixedTextBuilder.GetPageEndFlowPosition(pageNumber);
                firstSearchPageEnd = new DocumentSequenceTextPointer(documentSequenceTextPointer2.ChildBlock, new FixedTextPointer(false, LogicalDirection.Backward, pageEndFlowPosition));
            }
            else
            {
                FixedTextPointer fixedTextPointer2 = start as FixedTextPointer;
                firstSearchPageEnd = new FixedTextPointer(false, LogicalDirection.Backward, fixedTextPointer2.FixedTextContainer.FixedTextBuilder.GetPageEndFlowPosition(pageNumber));
            }
            firstSearchPageStart = start;
        }
        // Token: 0x06002F91 RID: 12177 RVA: 0x000D63C8 File Offset: 0x000D45C8
        internal int GetDistance(FlowPosition flow)
        {
            if (this._flowNode.Equals(flow._flowNode))
            {
                return(flow._offset - this._offset);
            }
            int          num = this._OverlapAwareCompare(flow);
            FlowPosition flowPosition;
            FlowPosition flowPosition2;

            if (num == -1)
            {
                flowPosition  = (FlowPosition)this.Clone();
                flowPosition2 = flow;
            }
            else
            {
                flowPosition  = (FlowPosition)flow.Clone();
                flowPosition2 = this;
            }
            int num2 = 0;

            while (!flowPosition._IsSamePosition(flowPosition2))
            {
                if (flowPosition._flowNode.Equals(flowPosition2._flowNode))
                {
                    num2 += flowPosition2._offset - flowPosition._offset;
                    break;
                }
                int num3 = flowPosition._vScan(LogicalDirection.Forward, -1);
                num2 += num3;
            }
            return(num * -1 * num2);
        }
        // Token: 0x06002F9E RID: 12190 RVA: 0x000D67CC File Offset: 0x000D49CC
        internal FlowPosition GetClingPosition(LogicalDirection dir)
        {
            FlowPosition flowPosition = (FlowPosition)this.Clone();

            if (dir == LogicalDirection.Forward)
            {
                if (this._offset == this._NodeLength)
                {
                    FlowNode flowNode = this._xGetNextFlowNode();
                    if (!FlowNode.IsNull(flowNode))
                    {
                        flowPosition._flowNode = flowNode;
                        flowPosition._offset   = 0;
                    }
                }
            }
            else if (this._offset == 0)
            {
                FlowNode flowNode = this._xGetPreviousFlowNode();
                if (!FlowNode.IsNull(flowNode))
                {
                    flowPosition._flowNode = flowNode;
                    flowPosition._offset   = flowPosition._NodeLength;
                }
            }
            return(flowPosition);
        }
Example #14
0
        //--------------------------------------------------------------------
        // Helper functions
        //---------------------------------------------------------------------

        // see if the two FlowPosition are indeed same position
        private bool _IsSamePosition(FlowPosition flow)
        {
            if (flow == null)
            {
                return(false);
            }

            return(_OverlapAwareCompare(flow) == 0);
        }
        // Token: 0x06002F93 RID: 12179 RVA: 0x000D6470 File Offset: 0x000D4670
        internal int GetTextRunLength(LogicalDirection dir)
        {
            FlowPosition clingPosition = this.GetClingPosition(dir);

            if (dir == LogicalDirection.Forward)
            {
                return(clingPosition._NodeLength - clingPosition._offset);
            }
            return(clingPosition._offset);
        }
        // Token: 0x06002EF8 RID: 12024 RVA: 0x000D4754 File Offset: 0x000D2954
        private ITextPointer _CreateTextPointer(FixedPosition fixedPosition, LogicalDirection edge)
        {
            FlowPosition flowPosition = this.Container.FixedTextBuilder.CreateFlowPosition(fixedPosition);

            if (flowPosition != null)
            {
                return(new FixedTextPointer(true, edge, flowPosition));
            }
            return(null);
        }
Example #17
0
        // Token: 0x0600350E RID: 13582 RVA: 0x000F0634 File Offset: 0x000EE834
        private ITextPointer _GetTextPosition(FixedNode node, int charIndex)
        {
            FixedPosition fixedPosition = new FixedPosition(node, charIndex);
            FlowPosition  flowPosition  = this._panel.FixedContainer.FixedTextBuilder.CreateFlowPosition(fixedPosition);

            if (flowPosition != null)
            {
                return(new FixedTextPointer(false, LogicalDirection.Forward, flowPosition));
            }
            return(null);
        }
        // Token: 0x06002EBD RID: 11965 RVA: 0x000D31A4 File Offset: 0x000D13A4
        ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
        {
            ValidationHelper.VerifyDirection(gravity, "gravity");
            FlowPosition flowPosition = (FlowPosition)this._flowPosition.Clone();

            if (!flowPosition.Move(distance))
            {
                throw new ArgumentException(SR.Get("BadDistance"), "distance");
            }
            return(new FixedTextPointer(true, gravity, flowPosition));
        }
Example #19
0
        // returns remaining text length on dir
        internal int GetTextRunLength(LogicalDirection dir)
        {
            Debug.Assert(GetPointerContext(dir) == TextPointerContext.Text);
            FlowPosition flow = GetClingPosition(dir);

            if (dir == LogicalDirection.Forward)
            {
                return(flow._NodeLength - flow._offset);
            }
            else
            {
                return(flow._offset);
            }
        }
Example #20
0
        //--------------------------------------------------------------------
        // FixedPosition --> ITextPointer
        //---------------------------------------------------------------------

        // Create a text position from description of a fixed position.
        // This is primarily called from HitTesting code
        private ITextPointer _CreateTextPointer(FixedPosition fixedPosition, LogicalDirection edge)
        {
            // Create a FlowPosition to represent this fixed position
            FlowPosition flowHit = Container.FixedTextBuilder.CreateFlowPosition(fixedPosition);

            if (flowHit != null)
            {
                DocumentsTrace.FixedTextOM.TextView.Trace(string.Format("_CreatetTextPointer {0}:{1}", fixedPosition.ToString(), flowHit.ToString()));

                // Create a TextPointer from the flow position
                return(new FixedTextPointer(true, edge, flowHit));
            }
            return(null);
        }
Example #21
0
        private ITextPointer _GetTextPosition(FixedNode node, int charIndex)
        {
            FixedPosition fixedPosition = new FixedPosition(node, charIndex);

            // Create a FlowPosition to represent this fixed position
            FlowPosition flowHit = _panel.FixedContainer.FixedTextBuilder.CreateFlowPosition(fixedPosition);

            if (flowHit != null)
            {
                // Create a TextPointer from the flow position
                return(new FixedTextPointer(false, LogicalDirection.Forward, flowHit));
            }
            return(null);
        }
Example #22
0
        // A canonical position is one that clings to a FlowNode
        internal FlowPosition GetClingPosition(LogicalDirection dir)
        {
            FlowPosition flow = (FlowPosition)this.Clone();
            FlowNode     fn;

            if (dir == LogicalDirection.Forward)
            {
                if (_offset == _NodeLength)
                {
                    // This position is at right side of a FlowNode
                    // look for next run
                    fn = _xGetNextFlowNode();
                    if (!FlowNode.IsNull(fn))
                    {
                        flow._flowNode = fn;
                        flow._offset   = 0;
                    }
#if DEBUG
                    else
                    {
                        DocumentsTrace.FixedTextOM.FlowPosition.Trace("GetClingPosition: Next FlowNode is null");
                    }
#endif
                }
            }
            else
            {
                Debug.Assert(dir == LogicalDirection.Backward);
                if (_offset == 0)
                {
                    // This position is at left side of a FlowNode
                    // look for previous run
                    fn = _xGetPreviousFlowNode();
                    if (!FlowNode.IsNull(fn))
                    {
                        flow._flowNode = fn;
                        flow._offset   = flow._NodeLength;
                    }
#if DEBUG
                    else
                    {
                        DocumentsTrace.FixedTextOM.FlowPosition.Trace("GetClingPosition: Next FlowNode is null");
                    }
#endif
                }
            }
            return(flow);
        }
Example #23
0
        // Compare two FixedTextPointer based on their flow order and offset
        public int CompareTo(object o)
        {
            if (o == null)
            {
                throw new ArgumentNullException("o");
            }

            FlowPosition flow = o as FlowPosition;

            if (flow == null)
            {
                throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, o.GetType(), typeof(FlowPosition)), "o");
            }

            return(_OverlapAwareCompare(flow));
        }
        private static void _GetFirstPageSearchPointers(ITextPointer start,
                                                        ITextPointer end,
                                                        int pageNumber,
                                                        bool matchLast,
                                                        out ITextPointer firstSearchPageStart,
                                                        out ITextPointer firstSearchPageEnd)
        {
            if (matchLast)
            {
                //The page in question is the last page
                //Need to search between the start of the last page and the end pointer
                DocumentSequenceTextPointer endAsDSTP = end as DocumentSequenceTextPointer;
                if (endAsDSTP != null)
                {
                    FlowPosition pageStartFlowPosition = ((FixedTextContainer)(endAsDSTP.ChildBlock.ChildContainer)).FixedTextBuilder.GetPageStartFlowPosition(pageNumber);
                    firstSearchPageStart = new DocumentSequenceTextPointer(endAsDSTP.ChildBlock,
                                                                           new FixedTextPointer(false, LogicalDirection.Forward, pageStartFlowPosition));
                }
                else
                {
                    FixedTextPointer endAsFTP = end as FixedTextPointer;
                    Debug.Assert(endAsFTP != null);
                    firstSearchPageStart = new FixedTextPointer(false, LogicalDirection.Forward, endAsFTP.FixedTextContainer.FixedTextBuilder.GetPageStartFlowPosition(pageNumber));
                }

                firstSearchPageEnd = end;
            }
            else
            {
                //The page in question is the first page
                //Need to search between the start pointer and the end of the first page
                DocumentSequenceTextPointer startAsDSTP = start as DocumentSequenceTextPointer;
                if (startAsDSTP != null)
                {
                    FlowPosition pageEndFlowPosition = ((FixedTextContainer)startAsDSTP.ChildBlock.ChildContainer).FixedTextBuilder.GetPageEndFlowPosition(pageNumber);
                    firstSearchPageEnd = new DocumentSequenceTextPointer(startAsDSTP.ChildBlock,
                                                                         new FixedTextPointer(false, LogicalDirection.Backward, pageEndFlowPosition));
                }
                else
                {
                    FixedTextPointer startAsFTP = start as FixedTextPointer;
                    Debug.Assert(startAsFTP != null);
                    firstSearchPageEnd = new FixedTextPointer(false, LogicalDirection.Backward, startAsFTP.FixedTextContainer.FixedTextBuilder.GetPageEndFlowPosition(pageNumber));
                }
                firstSearchPageStart = start;
            }
        }
Example #25
0
        //--------------------------------------------------------------------
        //
        // Public Properties
        //
        //---------------------------------------------------------------------

        //--------------------------------------------------------------------
        //
        // Public Events
        //
        //---------------------------------------------------------------------

        //--------------------------------------------------------------------
        //
        // Internal Methods
        //
        //---------------------------------------------------------------------

        #region Internal Methods

        //--------------------------------------------------------------------
        // Text OM Helper
        //---------------------------------------------------------------------
        #region Text OM Helper
        // Returns the count of symbols between pos1 and pos2
        internal int GetDistance(FlowPosition flow)
        {
            Debug.Assert(flow != null);
            // if both clings to the same flow node, simply
            // compare the offset
            if (_flowNode.Equals(flow._flowNode))
            {
                return(flow._offset - _offset);
            }

            // otherwise scan to find out distance
            // Make sure scanning from low to high flow order
            int          np = _OverlapAwareCompare(flow);
            FlowPosition flowScan, flowEnd;

            if (np == -1)
            {
                // scan forward
                flowScan = (FlowPosition)this.Clone();
                flowEnd  = flow;
            }
            else
            {
                // scan backward
                flowScan = (FlowPosition)flow.Clone();
                flowEnd  = this;
            }

            // scan from low to high and accumulate counts
            // devirtualize the node as it scans
            int distance = 0;

            while (!flowScan._IsSamePosition(flowEnd))
            {
                if (flowScan._flowNode.Equals(flowEnd._flowNode))
                {
                    distance += (flowEnd._offset - flowScan._offset);
                    break;
                }
                int scan = flowScan._vScan(LogicalDirection.Forward, -1);

                distance += scan;
            }
            return(np * (-1) * distance);
        }
        // Token: 0x06002F8F RID: 12175 RVA: 0x000D6350 File Offset: 0x000D4550
        public int CompareTo(object o)
        {
            if (o == null)
            {
                throw new ArgumentNullException("o");
            }
            FlowPosition flowPosition = o as FlowPosition;

            if (flowPosition == null)
            {
                throw new ArgumentException(SR.Get("UnexpectedParameterType", new object[]
                {
                    o.GetType(),
                    typeof(FlowPosition)
                }), "o");
            }
            return(this._OverlapAwareCompare(flowPosition));
        }
Example #27
0
        // Get Text until end-of-run or maxLength/limit is hit.
        internal int GetTextInRun(LogicalDirection dir, int maxLength, char[] chars, int startIndex)
        {
            Debug.Assert(GetPointerContext(dir) == TextPointerContext.Text);

            // make sure the position is clinged to text run
            FlowPosition flow = GetClingPosition(dir);

            int runLength = flow._NodeLength;
            int remainingLength;

            if (dir == LogicalDirection.Forward)
            {
                remainingLength = runLength - flow._offset;
            }
            else
            {
                remainingLength = flow._offset;
            }
            maxLength = Math.Min(maxLength, remainingLength);

            //
            // THIS IS VERY INEFFICIENT!
            // We need to add a function in FixedTextBuilder that
            // allows copying segement of the flow node text run directly.
            //

            string text = _container.FixedTextBuilder.GetFlowText(flow._flowNode);

            if (dir == LogicalDirection.Forward)
            {
                Array.Copy(text.ToCharArray(flow._offset, maxLength), 0, chars, startIndex, maxLength);
            }
            else
            {
                Array.Copy(text.ToCharArray(flow._offset - maxLength, maxLength), 0, chars, startIndex, maxLength);
            }
            return(maxLength);
        }
        // Token: 0x06002F9D RID: 12189 RVA: 0x000D6744 File Offset: 0x000D4944
        internal void GetFlowNodes(FlowPosition pEnd, out FlowNode[] flowNodes, out int offsetStart, out int offsetEnd)
        {
            flowNodes   = null;
            offsetStart = 0;
            offsetEnd   = 0;
            FlowPosition clingPosition = this.GetClingPosition(LogicalDirection.Forward);

            offsetStart = clingPosition._offset;
            ArrayList arrayList = new ArrayList();
            int       i         = this.GetDistance(pEnd);

            while (i > 0)
            {
                int num = clingPosition._vScan(LogicalDirection.Forward, i);
                i -= num;
                if (clingPosition.IsRun || clingPosition.IsObject)
                {
                    arrayList.Add(clingPosition._flowNode);
                    offsetEnd = clingPosition._offset;
                }
            }
            flowNodes = (FlowNode[])arrayList.ToArray(typeof(FlowNode));
        }
Example #29
0
        // intelligent compare routine that understands position overlap
        private int _OverlapAwareCompare(FlowPosition flow)
        {
            Debug.Assert(flow != null);
            if ((object)this == (object)flow)
            {
                return(0);
            }

            int comp = this._flowNode.CompareTo(flow._flowNode);

            if (comp < 0)
            {
                // Check overlap positions
                // Positions are the same if they are at end of previous run or begin of next run
                if (this._flowNode.Fp == flow._flowNode.Fp - 1 && this._offset == _NodeLength && flow._offset == 0)
                {
                    return(0);
                }
            }
            else if (comp > 0)
            {
                // Check overlap positions
                // Positions are the same if they are at end of previous run or begin of next run
                if (flow._flowNode.Fp == this._flowNode.Fp - 1 && flow._offset == flow._NodeLength && this._offset == 0)
                {
                    return(0);
                }
            }
            else
            {
                // compare offset only
                Debug.Assert(this._flowNode.Equals(flow._flowNode));
                comp = this._offset.CompareTo(flow._offset);
            }
            return(comp);
        }
        // Token: 0x06002EF7 RID: 12023 RVA: 0x000D46A8 File Offset: 0x000D28A8
        private bool _GetFirstFixedPosition(FixedTextPointer ftp, out FixedPosition fixedP)
        {
            LogicalDirection logicalDirection = LogicalDirection.Forward;

            if (ftp.FlowPosition.FlowNode.Fp != 0)
            {
                logicalDirection = LogicalDirection.Backward;
            }
            FlowPosition flowPosition = (FlowPosition)ftp.FlowPosition.Clone();

            flowPosition.Move(logicalDirection);
            FixedTextPointer fixedTextPointer = new FixedTextPointer(true, logicalDirection, flowPosition);

            if (flowPosition.IsStart || flowPosition.IsEnd)
            {
                ((ITextPointer)fixedTextPointer).MoveToNextInsertionPosition(logicalDirection);
            }
            if (this.Container.GetPageNumber(fixedTextPointer) == this.PageIndex)
            {
                return(this.Container.FixedTextBuilder.GetFixedPosition(fixedTextPointer.FlowPosition, logicalDirection, out fixedP));
            }
            fixedP = new FixedPosition(this.Container.FixedTextBuilder.FixedFlowMap.FixedStartEdge, 0);
            return(false);
        }
Example #31
0
        // intelligent compare routine that understands position overlap 
        private int _OverlapAwareCompare(FlowPosition flow)
        {
            Debug.Assert(flow != null);
            if ((object)this == (object)flow) 
            {
                return 0; 
            } 

            int comp = this._flowNode.CompareTo(flow._flowNode); 
            if (comp < 0)
            {
                // Check overlap positions
                // Positions are the same if they are at end of previous run or begin of next run 
                if (this._flowNode.Fp == flow._flowNode.Fp - 1 && this._offset == _NodeLength && flow._offset == 0)
                { 
                    return 0; 
                }
            } 
            else if (comp > 0)
            {
                // Check overlap positions
                // Positions are the same if they are at end of previous run or begin of next run 
                if (flow._flowNode.Fp == this._flowNode.Fp - 1 && flow._offset == flow._NodeLength && this._offset == 0)
                { 
                    return 0; 
                }
            } 
            else
            {
                // compare offset only
                Debug.Assert(this._flowNode.Equals(flow._flowNode)); 
                comp = this._offset.CompareTo(flow._offset);
            } 
            return comp; 
        }
Example #32
0
        //--------------------------------------------------------------------
        // Helper functions
        //--------------------------------------------------------------------- 

        // see if the two FlowPosition are indeed same position 
        private bool _IsSamePosition(FlowPosition flow) 
        {
            if (flow == null) 
            {
                return false;
            }
 
            return (_OverlapAwareCompare(flow) == 0);
        } 
Example #33
0
        // return FlowNode within this range 
        internal void GetFlowNodes(FlowPosition pEnd, out FlowNode[] flowNodes, out int offsetStart, out int offsetEnd)
        {
            Debug.Assert(this._OverlapAwareCompare(pEnd) < 0);
            flowNodes = null; 
            offsetStart = 0;
            offsetEnd = 0; 
 
            FlowPosition flowScan = GetClingPosition(LogicalDirection.Forward);
            offsetStart = flowScan._offset; 

            ArrayList ar = new ArrayList();
            int distance = GetDistance(pEnd);
            // keep moving until we hit distance 
            while (distance > 0)
            { 
                int scan = flowScan._vScan(LogicalDirection.Forward, distance); 

                distance -= scan; 
                if (flowScan.IsRun || flowScan.IsObject)
                {
                    ar.Add(flowScan._flowNode);
                    offsetEnd = flowScan._offset; 
                }
            } 
            flowNodes = (FlowNode [])ar.ToArray(typeof(FlowNode)); 
        }
Example #34
0
 // Move to next FlowPosition
 internal void MoveTo(FlowPosition flow)
 {
     _flowNode   = flow._flowNode; 
     _offset     = flow._offset;
 } 
Example #35
0
        //--------------------------------------------------------------------
        //
        // Public Properties 
        //
        //--------------------------------------------------------------------- 
 
        //--------------------------------------------------------------------
        // 
        // Public Events
        //
        //---------------------------------------------------------------------
 
        //-------------------------------------------------------------------
        // 
        // Internal Methods 
        //
        //--------------------------------------------------------------------- 

        #region Internal Methods

        //-------------------------------------------------------------------- 
        // Text OM Helper
        //--------------------------------------------------------------------- 
        #region Text OM Helper 
        // Returns the count of symbols between pos1 and pos2
        internal int GetDistance(FlowPosition flow) 
        {
            Debug.Assert(flow != null);
            // if both clings to the same flow node, simply
            // compare the offset 
            if (_flowNode.Equals(flow._flowNode))
            { 
                return flow._offset - _offset; 
            }
 
            // otherwise scan to find out distance
            // Make sure scanning from low to high flow order
            int np = _OverlapAwareCompare(flow);
            FlowPosition flowScan, flowEnd; 
            if (np == -1)
            { 
                // scan forward 
                flowScan = (FlowPosition)this.Clone();
                flowEnd  = flow; 
            }
            else
            {
                // scan backward 
                flowScan = (FlowPosition)flow.Clone();
                flowEnd  = this; 
            } 

            // scan from low to high and accumulate counts 
            // devirtualize the node as it scans
            int distance = 0;
            while (!flowScan._IsSamePosition(flowEnd))
            { 
                if (flowScan._flowNode.Equals(flowEnd._flowNode))
                { 
                    distance += (flowEnd._offset - flowScan._offset); 
                    break;
                } 
                int scan = flowScan._vScan(LogicalDirection.Forward, -1);

                distance += scan;
            } 
            return np * (-1) * distance;
        } 
Example #36
0
        internal void OnNewFlowElement(FixedElement parentElement, FixedElement.ElementType elementType, FlowPosition pStart, FlowPosition pEnd, Object source, int pageIndex)
        {
            FixedTextPointer eStart = new FixedTextPointer(false, LogicalDirection.Backward, pStart);
            FixedTextPointer eEnd = new FixedTextPointer(false, LogicalDirection.Forward, pEnd);
            FixedElement e = new FixedElement(elementType, eStart, eEnd, pageIndex);
            if (source != null)
            {
                e.Object = source;
            }
            // hook up logical tree
            parentElement.Append(e);

            // attach element to flownode for faster lookup later.
            pStart.AttachElement(e);
            pEnd.AttachElement(e);
        }
Example #37
0
 //------------------------------------------------------
 //
 //  Constructors
 //
 //------------------------------------------------------
 #region Constructors
 internal FixedTextPointer(bool mutable, LogicalDirection gravity, FlowPosition flow)
 {
     _isFrozen = !mutable;
     _gravity = gravity;
     _flowPosition = flow;
 }