| Method from org.apache.poi.hssf.usermodel.HSSFRichTextString Detail: |
public void applyFont(HSSFFont font) {
applyFont(0, string.getCharCount(), font);
}
Sets the font of the entire string. |
public void applyFont(short fontIndex) {
applyFont(0, string.getCharCount(), fontIndex);
}
Applies the specified font to the entire string. |
public void applyFont(int startIndex,
int endIndex,
short fontIndex) {
if (startIndex > endIndex)
throw new IllegalArgumentException("Start index must be less than end index.");
if (startIndex < 0 || endIndex > length())
throw new IllegalArgumentException("Start and end index not in range.");
if (startIndex == endIndex)
return;
//Need to check what the font is currently, so we can reapply it after
//the range is completed
short currentFont = NO_FONT;
if (endIndex != length()) {
currentFont = this.getFontAtIndex(startIndex);
}
//Need to clear the current formatting between the startIndex and endIndex
string = cloneStringIfRequired();
Iterator formatting = string.formatIterator();
if (formatting != null) {
while (formatting.hasNext()) {
UnicodeString.FormatRun r = (UnicodeString.FormatRun)formatting.next();
if ((r.getCharacterPos() >= startIndex) && (r.getCharacterPos() < endIndex))
formatting.remove();
}
}
string.addFormatRun(new UnicodeString.FormatRun((short)startIndex, fontIndex));
if (endIndex != length())
string.addFormatRun(new UnicodeString.FormatRun((short)endIndex, currentFont));
addToSSTIfRequired();
}
Applies a font to the specified characters of a string. |
public void applyFont(int startIndex,
int endIndex,
HSSFFont font) {
applyFont(startIndex, endIndex, font.getIndex());
}
Applies a font to the specified characters of a string. |
public void clearFormatting() {
string = cloneStringIfRequired();
string.clearFormatting();
addToSSTIfRequired();
}
Removes any formatting that may have been applied to the string. |
public int compareTo(Object o) {
HSSFRichTextString r = (HSSFRichTextString)o;
return string.compareTo(r.string);
}
Compares one rich text string to another. |
public boolean equals(Object o) {
if (o instanceof HSSFRichTextString) {
return string.equals(((HSSFRichTextString)o).string);
}
return false;
}
|
public short getFontAtIndex(int index) {
int size = string.getFormatRunCount();
UnicodeString.FormatRun currentRun = null;
for (int i=0;i< size;i++) {
UnicodeString.FormatRun r = string.getFormatRun(i);
if (r.getCharacterPos() > index)
break;
else currentRun = r;
}
if (currentRun == null)
return NO_FONT;
else return currentRun.getFontIndex();
}
Returns the font in use at a particular index. |
public short getFontOfFormattingRun(int index) {
UnicodeString.FormatRun r = string.getFormatRun(index);
return r.getFontIndex();
}
Gets the font used in a particular formatting run. |
public int getIndexOfFormattingRun(int index) {
UnicodeString.FormatRun r = string.getFormatRun(index);
return r.getCharacterPos();
}
The index within the string to which the specified formatting run applies. |
public String getString() {
return string.getString();
}
Returns the plain string representation. |
UnicodeString getUnicodeString() {
return cloneStringIfRequired();
}
Used internally by the HSSFCell to get the internal string value |
public int length() {
return string.getCharCount();
}
|
public int numFormattingRuns() {
return string.getFormatRunCount();
}
|
void setUnicodeString(UnicodeString str) {
this.string = str;
}
Used internally by the HSSFCell to set the internal string value |
void setWorkbookReferences(Workbook book,
LabelSSTRecord record) {
this.book = book;
this.record = record;
}
This must be called to setup the internal work book references whenever
a RichTextString is added to a cell |
public String toString() {
return string.toString();
}
|