public RtfSection(RtfDocument doc,
Section section) {
super(doc);
items = new ArrayList();
try {
if(section.getTitle() != null) {
this.title = (RtfParagraph) doc.getMapper().mapElement(section.getTitle())[0];
}
if(document.getAutogenerateTOCEntries()) {
StringBuffer titleText = new StringBuffer();
Iterator it = section.getTitle().iterator();
while(it.hasNext()) {
Element element = (Element) it.next();
if(element.type() == Element.CHUNK) {
titleText.append(((Chunk) element).getContent());
}
}
if(titleText.toString().trim().length() > 0) {
RtfTOCEntry tocEntry = new RtfTOCEntry(titleText.toString());
tocEntry.setRtfDocument(this.document);
this.items.add(tocEntry);
}
}
Iterator iterator = section.iterator();
while(iterator.hasNext()) {
Element element = (Element) iterator.next();
RtfBasicElement[] rtfElements = doc.getMapper().mapElement(element);
for(int i = 0; i < rtfElements.length; i++) {
if(rtfElements[i] != null) {
items.add(rtfElements[i]);
}
}
}
updateIndentation(section.getIndentationLeft(), section.getIndentationRight(), section.getIndentation());
} catch(DocumentException de) {
de.printStackTrace();
}
}
Constructs a RtfSection for a given Section. If the autogenerateTOCEntries
property of the RtfDocument is set and the title is not empty then a TOC entry
is generated for the title. Parameters:
doc - The RtfDocument this RtfSection belongs to
section - The Section this RtfSection is based on
|