public void writeContent(final OutputStream result) throws IOException
{
result.write(OPEN_GROUP);
int itemNr = 0;
for(int i = 0; i < items.size(); i++) {
RtfElement rtfElement = (RtfElement) items.get(i);
if(rtfElement instanceof RtfListItem) {
itemNr++;
result.write(writeListBeginning());
result.write(writeListNumbers());
result.write(OPEN_GROUP);
result.write(LIST_TEXT);
result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
if(this.inTable) {
result.write(RtfParagraph.IN_TABLE);
}
result.write(RtfFontList.FONT_NUMBER);
if(this.listType != LIST_TYPE_BULLET) {
result.write(intToByteArray(fontNumber.getFontNumber()));
} else {
result.write(intToByteArray(fontBullet.getFontNumber()));
}
//.result.write(writeIndentations()); TODO Remove on deprecation
writeIndentation(result);
result.write(DELIMITER);
if(this.listType != LIST_TYPE_BULLET) {
switch(this.listType) {
case LIST_TYPE_NUMBERED : result.write(intToByteArray(itemNr)); break;
case LIST_TYPE_UPPER_LETTERS : result.write(RomanAlphabetFactory.getUpperCaseString(itemNr).getBytes()); break;
case LIST_TYPE_LOWER_LETTERS : result.write(RomanAlphabetFactory.getLowerCaseString(itemNr).getBytes()); break;
case LIST_TYPE_UPPER_ROMAN : result.write(RomanNumberFactory.getUpperCaseString(itemNr).getBytes()); break;
case LIST_TYPE_LOWER_ROMAN : result.write(RomanNumberFactory.getLowerCaseString(itemNr).getBytes()); break;
}
result.write(LIST_NUMBER_END);
} else {
this.document.filterSpecialChar(result, this.bulletCharacter, true, false);
}
result.write(TAB);
result.write(CLOSE_GROUP);
//result.write(rtfElement.write()); TODO Remove on deprecation
rtfElement.writeContent(result);
if(i < (items.size() - 1) || !this.inTable || this.listLevel > 0) { // TODO Fix no paragraph on last list item in tables
result.write(RtfParagraph.PARAGRAPH);
}
result.write("\n".getBytes());
} else if(rtfElement instanceof RtfList) {
//result.write(rtfElement.write()); TODO Remove on deprecation
rtfElement.writeContent(result);
result.write("\n".getBytes());
}
}
result.write(CLOSE_GROUP);