Esempio n. 1
0
        private bool IsRangeInUrl(MarkupRange range)
        {
            //must have this range cloned, otherwise in some cases IsInsideURL call
            // was MOVING the current word range! if "www.foo.com" was in the editor,
            // when the final "\"" was the current word, this call MOVED the current
            // word range BACK to www.foo.com, then nextWord would get "\"" and a loop
            // would occur (bug 411528)
            range = range.Clone();
            IMarkupPointer2Raw p2StartRaw = (IMarkupPointer2Raw)range.Start.PointerRaw;
            bool insideUrl;

            p2StartRaw.IsInsideURL(range.End.PointerRaw, out insideUrl);
            return(insideUrl);
        }
        public OleUndoUnit(MshtmlMarkupServices markupServices, MarkupRange selection)
        {
            _markupServices = markupServices;

            //serialize the current position of the markup pointers so that they can be restored if
            //the DOM gets rolled back into the same state via an undo/redo operation.
            if (selection != null && selection.Positioned)
            {
                IMarkupPointer2Raw pointer2StartRaw = selection.Start.PointerRaw as IMarkupPointer2Raw;
                IMarkupPointer2Raw pointer2EndRaw   = selection.End.PointerRaw as IMarkupPointer2Raw;
                pointer2StartRaw.GetMarkupPosition(out _startPosition);
                pointer2EndRaw.GetMarkupPosition(out _endPosition);
                pointer2StartRaw.GetContainer(out _markupContainer);
            }

            _description = "OleUndoUnit" + Guid.NewGuid().ToString();

            Undo = true;
        }
        protected MarkupRange GetMarkupRange()
        {
            MarkupRange range = null;

            try
            {
                if (_markupContainer != null)
                {
                    range = _markupServices.CreateMarkupRange();
                    IMarkupPointer2Raw pointer2StartRaw = range.Start.PointerRaw as IMarkupPointer2Raw;
                    IMarkupPointer2Raw pointer2EndRaw   = range.End.PointerRaw as IMarkupPointer2Raw;
                    pointer2StartRaw.MoveToMarkupPosition(_markupContainer, _startPosition);
                    pointer2EndRaw.MoveToMarkupPosition(_markupContainer, _endPosition);
                }
            }
            catch (Exception e)
            {
                Debug.Fail("Failed to get markup range", e.ToString());
            }

            return(range);
        }