public class Range
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.List<CHPX> |
_characters
All CharacterRuns that belong to the document this Range belongs to.
(属于此 Range 所属文档的所有 CharacterRun。)
|
protected int |
_charEnd
The end index in the characterRuns list for this Range.
(此 Range 的 characterRuns 列表中的结束索引。)
|
protected boolean |
_charRangeFound
Have we loaded the characterRun indexes yet.
(我们是否已经加载了 characterRun 索引。)
|
protected int |
_charStart
The start index in the characterRuns list for this Range
(此 Range 的 characterRuns 列表中的起始索引)
|
protected HWPFDocumentCore |
_doc
The document this range belongs to.
(此范围所属的文档。)
|
protected int |
_end
The ending character offset of this range.
(此范围的结束字符偏移量。)
|
protected java.util.List<PAPX> |
_paragraphs
All paragraphs that belong to the document this Range belongs to.
(属于此 Range 所属文档的所有段落。)
|
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 java.util.List<SEPX> |
_sections
All sections that belong to the document this Range belongs to.
(属于此 Range 所属文档的所有部分。)
|
protected int |
_sectionStart
The start index in the sections list for this Range
(此 Range 的部分列表中的起始索引)
|
protected int |
_start
The starting character offset of this range.
(此范围的起始字符偏移量。)
|
protected java.lang.StringBuilder |
_text |
static int |
TYPE_CHARACTER
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_LISTENTRY
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_PARAGRAPH
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_SECTION
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_TABLE
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_TEXT
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
static int |
TYPE_UNDEFINED
Deprecated.
POI 3.8 beta 5
(已弃用。 POI 3.8 测试版 5)
|
Modifier | Constructor and Description |
---|---|
|
Range(int start, int end, HWPFDocumentCore doc)
Used to construct a Range from a document.
(用于从文档构造 Range。)
|
protected |
Range(int start, int end, Range parent)
Used to create Ranges that are children of other Ranges.
(用于创建作为其他 Ranges 子级的 Ranges。)
|
protected |
Range(Range other) |
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...
(调整各种 FIB 字符计数字段的值,例如插入或删除后的 FIB.CCPText...)
|
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.
(加载所有列表索引。)
|
CharacterRun |
insertAfter(java.lang.String text)
Inserts text onto the end of this range
(在此范围的末尾插入文本)
|
CharacterRun |
insertBefore(java.lang.String text)
Inserts text into the front of this range.
(将文本插入此范围的前面。)
|
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(java.lang.String newText, boolean addAfter)
Replace range text with new one, adding it to the range and deleting original text from document
(用新文本替换范围文本,将其添加到范围并从文档中删除原始文本)
|
void |
replaceText(java.lang.String pPlaceHolder, java.lang.String pValue)
Replace (all instances of) a piece of text with another...
(用另一个文本替换(所有实例)一段文本......)
|
void |
replaceText(java.lang.String pPlaceHolder, java.lang.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 java.lang.String |
stripFields(java.lang.String text)
Removes any fields (eg macros, page markers etc) from the string.
(从字符串中删除任何字段(例如宏、页标记等)。)
|
java.lang.String |
text()
Gets the text that this Range contains.
(获取此 Range 包含的文本。)
|
java.lang.String |
toString() |
@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 final int _start
protected int _end
protected final HWPFDocumentCore _doc
protected final java.util.List<SEPX> _sections
protected int _sectionStart
protected int _sectionEnd
protected boolean _parRangeFound
protected final java.util.List<PAPX> _paragraphs
protected int _parStart
protected int _parEnd
protected boolean _charRangeFound
protected java.util.List<CHPX> _characters
protected int _charStart
protected int _charEnd
protected java.lang.StringBuilder _text
public Range(int start, int end, HWPFDocumentCore doc)
start
- Starting character offset of the range.
(start - 范围的起始字符偏移量。)
end
- Ending character offset of the range.
(end - 范围的结束字符偏移量。)
doc
- The HWPFDocument the range is based on.
(doc - 范围所基于的 HWPFDocument。)
protected Range(int start, int end, Range parent)
start
- Starting character offset of the range.
(start - 范围的起始字符偏移量。)
end
- Ending character offset of the range.
(end - 范围的结束字符偏移量。)
parent
- The parent this range belongs to.
(parent - 此范围所属的父级。)
protected Range(Range other)
public java.lang.String text()
public static java.lang.String stripFields(java.lang.String text)
public int numSections()
public int numParagraphs()
public int numCharacterRuns()
public CharacterRun insertBefore(java.lang.String text)
text
- The text to insert
(text - 要插入的文本)
public CharacterRun insertAfter(java.lang.String text)
text
- The text to insert
(text - 要插入的文本)
public void delete()
public Table insertTableBefore(short columns, int rows)
columns
- The number of columns
(columns - 列数)
rows
- The number of rows.
(rows - 行数。)
public void replaceText(java.lang.String newText, boolean addAfter)
newText
- The text to be replaced with
(newText - 要替换的文本)
addAfter
- if
true the text will be added at the end of current range, otherwise to the beginning
(addAfter - 如果为 true,则文本将添加到当前范围的末尾,否则添加到开头)
@Internal public void replaceText(java.lang.String pPlaceHolder, java.lang.String pValue, int pOffset)
pPlaceHolder
- The text to be replaced (e.g., "${organization}")
(pPlaceHolder - 要替换的文本(例如,“${organization}”))
pValue
- The replacement text (e.g., "Apache Software Foundation")
(pValue - 替换文本(例如,“Apache Software Foundation”))
pOffset
- The offset or index where the text to be replaced begins (relative to/within this
Range
)
(pOffset - 要替换的文本开始的偏移量或索引(相对于/在此范围内))
public void replaceText(java.lang.String pPlaceHolder, java.lang.String pValue)
pPlaceHolder
- The text to be replaced (e.g., "${organization}")
(pPlaceHolder - 要替换的文本(例如,“${organization}”))
pValue
- The replacement text (e.g., "Apache Software Foundation")
(pValue - 替换文本(例如,“Apache Software Foundation”))
public CharacterRun getCharacterRun(int index)
index
- The index of the character run to get.
(index - 要获取的字符的索引。)
public Section getSection(int index)
index
- The index of the section to get.
(index - 要获取的部分的索引。)
public Paragraph getParagraph(int index)
index
- The index of the paragraph to get.
(index - 要获取的段落索引。)
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 onwards
(调整各种 FIB 字符计数字段的值,例如插入或删除后的 FIB.CCPText... 适用于此范围以后的所有 CCP 字段)
adjustment
- The (signed) value that should be added to the FIB CCP fields
(调整 - 应添加到 FIB CCP 字段的(有符号)值)
public int getStartOffset()
public int getEndOffset()
protected HWPFDocumentCore getDocument()
public java.lang.String toString()
toString
in class
java.lang.Object
public boolean sanityCheck()
IllegalArgumentException
if checks fail.
(用于调试目的的方法。检查所有已解析的元素是否在当前范围内。如果检查失败,则抛出 IllegalArgumentException。)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.