public class Range extends Object
| Modifier and Type | Field and Description |
|---|---|
protected List<CHPX> |
_characters
All CharacterRuns that belong to the document this Range belongs to.
|
protected int |
_charEnd
The end index in the characterRuns list for this Range.
|
protected boolean |
_charRangeFound
Have we loaded the characterRun indexes yet.
|
protected int |
_charStart
The start index in the characterRuns list for this Range
|
protected HWPFDocumentCore |
_doc
The document this range blongs to.
|
protected int |
_end
The ending character offset of this range.
|
protected List<PAPX> |
_paragraphs
All paragraphs that belong to the document this Range belongs to.
|
protected int |
_parEnd
The end index in the paragraphs list for this Range, exclusive
|
protected boolean |
_parRangeFound
Have we loaded the paragraph indexes yet.
|
protected int |
_parStart
The start index in the paragraphs list for this Range, inclusive
|
protected int |
_sectionEnd
The end index in the sections list for this Range.
|
protected List<SEPX> |
_sections
All sections that belong to the document this Range belongs to.
|
protected int |
_sectionStart
The start index in the sections list for this Range
|
protected int |
_start
The starting character offset of this range.
|
protected StringBuilder |
_text |
static int |
TYPE_CHARACTER
Deprecated.
|
static int |
TYPE_LISTENTRY
Deprecated.
|
static int |
TYPE_PARAGRAPH
Deprecated.
|
static int |
TYPE_SECTION
Deprecated.
|
static int |
TYPE_TABLE
Deprecated.
|
static int |
TYPE_TEXT
Deprecated.
|
static int |
TYPE_UNDEFINED
Deprecated.
|
| Modifier | Constructor and Description |
|---|---|
|
Range(int start,
int end,
HWPFDocumentCore doc)
Used to construct a Range from a document.
|
protected |
Range(int startIdx,
int endIdx,
int idxType,
Range parent)
Deprecated.
|
protected |
Range(int start,
int end,
Range parent)
Used to create Ranges that are children of other Ranges.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
adjustFIB(int adjustment)
Adjust the value of the various FIB character count fields, eg
FIB.CCPText after an insert or a delete... |
void |
delete() |
CharacterRun |
getCharacterRun(int index)
Gets the character run at index.
|
protected HWPFDocumentCore |
getDocument() |
int |
getEndOffset() |
Paragraph |
getParagraph(int index)
Gets the paragraph at index.
|
Section |
getSection(int index)
Gets the section at index.
|
int |
getStartOffset() |
Table |
getTable(Paragraph paragraph)
Gets the table that starts with paragraph.
|
protected void |
initAll()
loads all of the list indexes.
|
Paragraph |
insertAfter(ParagraphProperties props,
int styleIndex)
Deprecated.
Use code shall not work with
ParagraphProperties |
ListEntry |
insertAfter(ParagraphProperties props,
int listID,
int level,
int styleIndex)
Deprecated.
Use code shall not work with
ParagraphProperties |
protected Paragraph |
insertAfter(ParagraphProperties props,
int styleIndex,
String text)
Deprecated.
Use code shall not work with
ParagraphProperties |
CharacterRun |
insertAfter(String text)
Inserts text onto the end of this range
|
CharacterRun |
insertAfter(String text,
CharacterProperties props)
Deprecated.
User code should not work with
CharacterProperties |
Paragraph |
insertBefore(ParagraphProperties props,
int styleIndex)
Deprecated.
Use code shall not work with
ParagraphProperties |
ListEntry |
insertBefore(ParagraphProperties props,
int listID,
int level,
int styleIndex)
Deprecated.
Use code shall not work with
ParagraphProperties |
protected Paragraph |
insertBefore(ParagraphProperties props,
int styleIndex,
String text)
Deprecated.
Use code shall not work with
ParagraphProperties |
CharacterRun |
insertBefore(String text)
Inserts text into the front of this range.
|
CharacterRun |
insertBefore(String text,
CharacterProperties props)
Deprecated.
User code should not work with
CharacterProperties |
Table |
insertBefore(TableProperties props,
int rows)
Deprecated.
Use code shall not work with
TableProperties. Use
insertTableBefore(short, int) instead |
Table |
insertTableBefore(short columns,
int rows)
Inserts a simple table into the beginning of this range.
|
int |
numCharacterRuns() |
int |
numParagraphs()
Used to get the number of paragraphs in a range.
|
int |
numSections()
Used to get the number of sections in a range.
|
void |
replaceText(String newText,
boolean addAfter)
Replace range text with new one, adding it to the range and deleting
original text from document
|
void |
replaceText(String pPlaceHolder,
String pValue)
Replace (all instances of) a piece of text with another...
|
void |
replaceText(String pPlaceHolder,
String pValue,
int pOffset)
Replace (one instance of) a piece of text with another...
|
protected void |
reset()
resets the list indexes.
|
boolean |
sanityCheck()
Method for debug purposes.
|
static String |
stripFields(String text)
Removes any fields (eg macros, page markers etc) from the string.
|
String |
text()
Gets the text that this Range contains.
|
String |
toString() |
int |
type()
Deprecated.
|
boolean |
usesUnicode()
Deprecated.
Range is not linked to any text piece anymore, so to check if
unicode is used please access
TextPieceTable during
document load time |
@Deprecated public static final int TYPE_PARAGRAPH
@Deprecated public static final int TYPE_CHARACTER
@Deprecated public static final int TYPE_SECTION
@Deprecated public static final int TYPE_TEXT
@Deprecated public static final int TYPE_LISTENTRY
@Deprecated public static final int TYPE_TABLE
@Deprecated public static final int TYPE_UNDEFINED
protected int _start
protected int _end
protected HWPFDocumentCore _doc
protected List<SEPX> _sections
protected int _sectionStart
protected int _sectionEnd
protected boolean _parRangeFound
protected List<PAPX> _paragraphs
protected int _parStart
protected int _parEnd
protected boolean _charRangeFound
protected List<CHPX> _characters
protected int _charStart
protected int _charEnd
protected StringBuilder _text
public Range(int start,
int end,
HWPFDocumentCore doc)
start - Starting character offset of the range.end - Ending character offset of the range.doc - The HWPFDocument the range is based on.protected Range(int start,
int end,
Range parent)
start - Starting character offset of the range.end - Ending character offset of the range.parent - The parent this range belongs to.@Deprecated protected Range(int startIdx, int endIdx, int idxType, Range parent)
startIdx - The starting index in the list, inclusiveendIdx - The ending index in the list, exclusiveidxType - The list type.parent - The parent Range this range belongs to.@Deprecated public boolean usesUnicode()
TextPieceTable during
document load timepublic String text()
public static String stripFields(String text)
public int numSections()
public int numParagraphs()
public int numCharacterRuns()
public CharacterRun insertBefore(String text)
text - The text to insertpublic CharacterRun insertAfter(String text)
text - The text to insert@Deprecated public CharacterRun insertBefore(String text, CharacterProperties props)
CharacterPropertiestext - The text to insert.props - The CharacterProperties to give the text.@Deprecated public CharacterRun insertAfter(String text, CharacterProperties props)
CharacterPropertiestext - The text to insert.props - The CharacterProperties to give the text.@Deprecated public Paragraph insertBefore(ParagraphProperties props, int styleIndex)
ParagraphPropertiesprops - The properties that the new paragraph will have.styleIndex - The index into the stylesheet for the new paragraph.@Deprecated protected Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)
ParagraphPropertiesprops - The paragraph's properties.styleIndex - The index of the paragraph's style in the style sheet.text - The text to insert.@Deprecated public Paragraph insertAfter(ParagraphProperties props, int styleIndex)
ParagraphPropertiesprops - The properties that the new paragraph will have.styleIndex - The index into the stylesheet for the new paragraph.@Deprecated protected Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
ParagraphPropertiesprops - The paragraph's properties.styleIndex - The index of the paragraph's style in the style sheet.text - The text to insert.public void delete()
@Deprecated public Table insertBefore(TableProperties props, int rows)
TableProperties. Use
insertTableBefore(short, int) insteadprops - The table properties for the table.rows - The number of rows.public Table insertTableBefore(short columns, int rows)
columns - The number of columnsrows - The number of rows.@Deprecated public ListEntry insertBefore(ParagraphProperties props, int listID, int level, int styleIndex)
ParagraphPropertiesprops - The properties of the list entry. All list entries are
paragraphs.listID - The id of the list that contains the properties.level - The indentation level of the list.styleIndex - The base style's index in the stylesheet.@Deprecated public ListEntry insertAfter(ParagraphProperties props, int listID, int level, int styleIndex)
ParagraphPropertiesprops - The properties of the list entry. All list entries are
paragraphs.listID - The id of the list that contains the properties.level - The indentation level of the list.styleIndex - The base style's index in the stylesheet.public void replaceText(String newText, boolean addAfter)
newText - The text to be replaced withaddAfter - if true the text will be added at the end of current
range, otherwise to the beginning@Internal public void replaceText(String pPlaceHolder, String pValue, int pOffset)
pPlaceHolder - The text to be replaced (e.g., "${organization}")pValue - The replacement text (e.g., "Apache Software Foundation")pOffset - The offset or index where the text to be replaced begins
(relative to/within this Range)public void replaceText(String pPlaceHolder, String pValue)
pPlaceHolder - The text to be replaced (e.g., "${organization}")pValue - The replacement text (e.g., "Apache Software Foundation")public CharacterRun getCharacterRun(int index)
index - The index of the character run to get.public Section getSection(int index)
index - The index of the section to get.public Paragraph getParagraph(int index)
index - The index of the paragraph to get.@Deprecated public int type()
public Table getTable(Paragraph paragraph)
paragraph - The paragraph that is the first paragraph in the table.protected void initAll()
protected void reset()
protected void adjustFIB(int adjustment)
FIB.CCPText after an insert or a delete...
Works on all CCP fields from this range onwardsadjustment - The (signed) value that should be added to the FIB CCP fieldspublic int getStartOffset()
public int getEndOffset()
protected HWPFDocumentCore getDocument()
public boolean sanityCheck()
Copyright © 2020. All rights reserved.