import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore;
-import org.apache.poi.hwpf.usermodel.CharacterRun;
-import org.apache.poi.hwpf.usermodel.Paragraph;
-import org.apache.poi.hwpf.usermodel.ParagraphProperties;
-import org.apache.poi.hwpf.usermodel.Section;
-
import org.apache.poi.hwpf.model.CPSplitCalculator;
import org.apache.poi.hwpf.model.FileInformationBlock;
import org.apache.poi.hwpf.model.PropertyNode;
boolean _sectionRangeFound;
/** All sections that belong to the document this Range belongs to. */
- protected List _sections;
+ protected List<SEPX> _sections;
/** The start index in the sections list for this Range */
protected int _sectionStart;
protected boolean _parRangeFound;
/** All paragraphs that belong to the document this Range belongs to. */
- protected List _paragraphs;
+ protected List<PAPX> _paragraphs;
/** The start index in the paragraphs list for this Range */
protected int _parStart;
protected boolean _charRangeFound;
/** All CharacterRuns that belong to the document this Range belongs to. */
- protected List _characters;
+ protected List<CHPX> _characters;
/** The start index in the characterRuns list for this Range */
protected int _charStart;
protected boolean _textRangeFound;
/** All text pieces that belong to the document this Range belongs to. */
- protected List _text;
+ protected List<TextPiece> _text;
/** The start index in the text list for this Range. */
protected int _textStart;
case TYPE_PARAGRAPH:
_parStart = parent._parStart + startIdx;
_parEnd = parent._parStart + endIdx;
- _start = ((PropertyNode) _paragraphs.get(_parStart)).getStart();
- _end = ((PropertyNode) _paragraphs.get(_parEnd)).getEnd();
+ _start = _paragraphs.get(_parStart).getStart();
+ _end = _paragraphs.get(_parEnd).getEnd();
_parRangeFound = true;
break;
case TYPE_CHARACTER:
_charStart = parent._charStart + startIdx;
_charEnd = parent._charStart + endIdx;
- _start = ((PropertyNode) _characters.get(_charStart)).getStart();
- _end = ((PropertyNode) _characters.get(_charEnd)).getEnd();
+ _start = _characters.get(_charStart).getStart();
+ _end = _characters.get(_charEnd).getEnd();
_charRangeFound = true;
break;
case TYPE_SECTION:
_sectionStart = parent._sectionStart + startIdx;
_sectionEnd = parent._sectionStart + endIdx;
- _start = ((PropertyNode) _sections.get(_sectionStart)).getStart();
- _end = ((PropertyNode) _sections.get(_sectionEnd)).getEnd();
+ _start = _sections.get(_sectionStart).getStart();
+ _end = _sections.get(_sectionEnd).getEnd();
_sectionRangeFound = true;
break;
case TYPE_TEXT:
_textStart = parent._textStart + startIdx;
_textEnd = parent._textStart + endIdx;
- _start = ((PropertyNode) _text.get(_textStart)).getStart();
- _end = ((PropertyNode) _text.get(_textEnd)).getEnd();
+ _start = _text.get(_textStart).getStart();
+ _end = _text.get(_textEnd).getEnd();
_textRangeFound = true;
break;
}
initText();
for (int i = _textStart; i < _textEnd; i++) {
- TextPiece piece = (TextPiece) _text.get(i);
+ TextPiece piece = _text.get(i);
if (piece.isUnicode())
return true;
}
StringBuffer sb = new StringBuffer();
for (int x = _textStart; x < _textEnd; x++) {
- TextPiece piece = (TextPiece) _text.get(x);
+ TextPiece piece = _text.get(x);
// Figure out where in this piece the text
// we're after lives
{
initAll();
- TextPiece tp = (TextPiece) _text.get(_textStart);
+ TextPiece tp = _text.get(_textStart);
StringBuffer sb = tp.getStringBuffer();
// Since this is the first item in our list, it is safe to assume that
initAll();
int listIndex = _textEnd - 1;
- TextPiece tp = (TextPiece) _text.get(listIndex);
+ TextPiece tp = _text.get(listIndex);
StringBuffer sb = tp.getStringBuffer();
int insertIndex = _end - tp.getStart();
// throws UnsupportedEncodingException
{
initAll();
- PAPX papx = (PAPX) _paragraphs.get(_parStart);
+ PAPX papx = _paragraphs.get(_parStart);
short istd = papx.getIstd();
StyleSheet ss = _doc.getStyleSheet();
// throws UnsupportedEncodingException
{
initAll();
- PAPX papx = (PAPX) _paragraphs.get(_parEnd - 1);
+ PAPX papx = _paragraphs.get(_parEnd - 1);
short istd = papx.getIstd();
StyleSheet ss = _doc.getStyleSheet();
int numTextPieces = _text.size();
for (int x = _charStart; x < numRuns; x++) {
- CHPX chpx = (CHPX) _characters.get(x);
+ CHPX chpx = _characters.get(x);
chpx.adjustForDelete(_start, _end - _start);
}
for (int x = _parStart; x < numParagraphs; x++) {
- PAPX papx = (PAPX) _paragraphs.get(x);
+ PAPX papx = _paragraphs.get(x);
// System.err.println("Paragraph " + x + " was " + papx.getStart() +
// " -> " + papx.getEnd());
papx.adjustForDelete(_start, _end - _start);
}
for (int x = _sectionStart; x < numSections; x++) {
- SEPX sepx = (SEPX) _sections.get(x);
+ SEPX sepx = _sections.get(x);
// System.err.println("Section " + x + " was " + sepx.getStart() +
// " -> " + sepx.getEnd());
sepx.adjustForDelete(_start, _end - _start);
}
for (int x = _textStart; x < numTextPieces; x++) {
- TextPiece piece = (TextPiece) _text.get(x);
+ TextPiece piece = _text.get(x);
piece.adjustForDelete(_start, _end - _start);
}
*/
public CharacterRun getCharacterRun(int index) {
initCharacterRuns();
- CHPX chpx = (CHPX) _characters.get(index + _charStart);
+ CHPX chpx = _characters.get(index + _charStart);
int[] point = findRange(_paragraphs, _parStart, Math.max(chpx.getStart(), _start), chpx
.getEnd());
- PAPX papx = (PAPX) _paragraphs.get(point[0]);
+ PAPX papx = _paragraphs.get(point[0]);
short istd = papx.getIstd();
CharacterRun chp = new CharacterRun(chpx, _doc.getStyleSheet(), istd, this);
*/
public Section getSection(int index) {
initSections();
- SEPX sepx = (SEPX) _sections.get(index + _sectionStart);
+ SEPX sepx = _sections.get(index + _sectionStart);
Section sep = new Section(sepx, this);
return sep;
}
public Paragraph getParagraph(int index) {
initParagraphs();
- PAPX papx = (PAPX) _paragraphs.get(index + _parStart);
+ PAPX papx = _paragraphs.get(index + _parStart);
ParagraphProperties props = papx.getParagraphProperties(_doc.getStyleSheet());
Paragraph pap = null;
}
public int getStartOffset() {
-
return _start;
}
public int getEndOffset() {
-
return _end;
}
protected HWPFDocumentCore getDocument() {
-
return _doc;
}
}