Пример #1
0
        /**
         * Method for debug purposes. Checks that all resolved elements are inside
         * of current range.
         */
        public bool SanityCheck()
        {
            Debug.Assert(_start >= 0, "start < 0");
            Debug.Assert(_start <= _text.Length, "start > text length");
            Debug.Assert(_end >= 0, "end < 0");
            Debug.Assert(_end <= _text.Length, "end > text length");
            Debug.Assert(_start <= _end, "start > end");


            if (_charRangeFound)
            {
                for (int c = _charStart; c < _charEnd; c++)
                {
                    CHPX chpx = _characters[c];

                    int left  = Math.Max(this._start, chpx.Start);
                    int right = Math.Min(this._end, chpx.End);
                    Debug.Assert(left < right, "left >= right");
                }
            }
            if (_parRangeFound)
            {
                for (int p = _parStart; p < _parEnd; p++)
                {
                    PAPX papx = _paragraphs[p];

                    int left  = Math.Max(this._start, papx.Start);
                    int right = Math.Min(this._end, papx.End);

                    Debug.Assert(left < right, "left >= right");
                }
            }

            return(true);
        }
Пример #2
0
        public void Delete()
        {
            InitAll();

            int numSections   = _sections.Count;
            int numRuns       = _characters.Count;
            int numParagraphs = _paragraphs.Count;

            for (int x = _charStart; x < numRuns; x++)
            {
                CHPX chpx = _characters[x];
                chpx.AdjustForDelete(_start, _end - _start);
            }

            for (int x = _parStart; x < numParagraphs; x++)
            {
                PAPX papx = _paragraphs[x];
                // System.err.println("Paragraph " + x + " was " + papx.Start +
                // " -> " + papx.End);
                papx.AdjustForDelete(_start, _end - _start);
                // System.err.println("Paragraph " + x + " is now " +
                // papx.Start + " -> " + papx.End);
            }

            for (int x = _sectionStart; x < numSections; x++)
            {
                SEPX sepx = _sections[x];
                // System.err.println("Section " + x + " was " + sepx.Start +
                // " -> " + sepx.End);
                sepx.AdjustForDelete(_start, _end - _start);
                // System.err.println("Section " + x + " is now " + sepx.Start
                // + " -> " + sepx.End);
            }
            _text = _text.Remove(_start, _end - _start);
            Range parent = _parent;

            if (parent != null)
            {
                parent.AdjustForInsert(-(_end - _start));
            }
            // update the FIB.CCPText + friends field
            AdjustFIB(-(_end - _start));
        }
Пример #3
0
        /**
         * Gets the character run at index. The index is relative to this range.
         *
         * @param index
         *            The index of the character run to Get.
         * @return The character run at the specified index in this range.
         */
        public CharacterRun GetCharacterRun(int index)
        {
            InitCharacterRuns();

            if (index + _charStart >= _charEnd)
            {
                throw new IndexOutOfRangeException("CHPX #" + index + " ("
                                                   + (index + _charStart) + ") not in range [" + _charStart
                                                   + "; " + _charEnd + ")");
            }

            CHPX chpx = _characters[index + _charStart];

            if (chpx == null)
            {
                return(null);
            }
            short istd;

            if (this is Paragraph)
            {
                istd = ((Paragraph)this)._istd;
            }
            else
            {
                int[] point = FindRange(_paragraphs, Math.Max(chpx.Start, _start), Math.Min(chpx.End, _end));
                InitParagraphs();
                int parStart = Math.Max(point[0], _parStart);
                if (parStart >= _paragraphs.Count)
                {
                    return(null);
                }
                PAPX papx = _paragraphs[point[0]];
                istd = papx.GetIstd();
            }

            CharacterRun chp = new CharacterRun(chpx, _doc.GetStyleSheet(), istd, this);

            return(chp);
        }
Пример #4
0
 /**
  *
  * @param chpx The chpx this object is based on.
  * @param ss The stylesheet for the document this run belongs to.
  * @param istd The style index if this Run's base style.
  * @param parent The parent range of this character run (usually a paragraph).
  */
 internal CharacterRun(CHPX chpx, StyleSheet ss, short istd, Range parent)
     : base(Math.Max(parent._start, chpx.Start), Math.Min(parent._end, chpx.End), parent)
 {
     _props = chpx.GetCharacterProperties(ss, istd);
     _chpx  = chpx.GetSprmBuf();
 }