/** * 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); }
/** * Gets the paragraph at index. The index is relative to this range. * * @param index * The index of the paragraph to Get. * @return The paragraph at the specified index in this range. */ public Paragraph GetParagraph(int index) { InitParagraphs(); PAPX papx = _paragraphs[index + _parStart]; ParagraphProperties props = papx.GetParagraphProperties(_doc.GetStyleSheet()); Paragraph pap = null; if (props.GetIlfo() > 0) { pap = new ListEntry(papx, this, _doc.GetListTables()); } else { if (((index + _parStart) == 0) && papx.Start > 0) { pap = new Paragraph(papx, this, 0); } else { pap = new Paragraph(papx, this); } } return(pap); }
internal Paragraph(PAPX papx, Range parent) : base(Math.Max(parent._start, papx.Start), Math.Min(parent._end, papx.End), parent) { _props = papx.GetParagraphProperties(_doc.GetStyleSheet()); _papx = papx.GetSprmBuf(); _istd = papx.GetIstd(); }
internal Paragraph(int startIdx, int endIdx, Table parent) : base(startIdx, endIdx, parent) { InitAll(); PAPX papx = (PAPX)_paragraphs[_parEnd - 1]; _props = papx.GetParagraphProperties(_doc.GetStyleSheet()); _papx = papx.GetSprmBuf(); _istd = papx.GetIstd(); }
internal ListEntry(PAPX papx, Range parent, ListTables tables) : base(papx, parent) { if (tables != null) { ListFormatOverride override1 = tables.GetOverride(_props.GetIlfo()); _overrideLevel = override1.GetOverrideLevel(_props.GetIlvl()); _level = tables.GetLevel(override1.GetLsid(), _props.GetIlvl()); } else { //log.log(POILogger.WARN, "No ListTables found for ListEntry - document probably partly corrupt, and you may experience problems"); } }
public CharacterRun InsertAfter(String text, CharacterProperties props) // { InitAll(); PAPX papx = _paragraphs[_parEnd - 1]; short istd = papx.GetIstd(); StyleSheet ss = _doc.GetStyleSheet(); CharacterProperties baseStyle = ss.GetCharacterStyle(istd); byte[] grpprl = CharacterSprmCompressor.CompressCharacterProperty(props, baseStyle); SprmBuffer buf = new SprmBuffer(grpprl); _doc.CharacterTable.Insert(_charEnd, _end, buf); _charEnd++; return(InsertAfter(text)); }
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)); }
/** * 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); }
public PAPXTreeNode(PAPX papx) { this.Record = papx; }