/** * 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. * * @param doc The RtfDocument this RtfSection belongs to * @param section The Section this RtfSection is based on */ public RtfSection(RtfDocument doc, Section section) : base(doc) { items = new ArrayList(); try { if (section.Title != null) { this.title = (RtfParagraph)doc.GetMapper().MapElement(section.Title)[0]; } if (document.GetAutogenerateTOCEntries()) { StringBuilder titleText = new StringBuilder(); foreach (IElement element in section.Title) { if (element.Type == Element.CHUNK) { titleText.Append(((Chunk)element).Content); } } if (titleText.ToString().Trim().Length > 0) { FD.RtfTOCEntry tocEntry = new FD.RtfTOCEntry(titleText.ToString()); tocEntry.SetRtfDocument(this.document); this.items.Add(tocEntry); } } foreach (IElement element in section) { IRtfBasicElement[] rtfElements = doc.GetMapper().MapElement(element); for (int i = 0; i < rtfElements.Length; i++) { if (rtfElements[i] != null) { items.Add(rtfElements[i]); } } } UpdateIndentation(section.IndentationLeft, section.IndentationRight, section.Indentation); } catch (DocumentException) { } }
/** * 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. * * @param doc The RtfDocument this RtfSection belongs to * @param section The Section this RtfSection is based on */ public RtfSection(RtfDocument doc, Section section) : base(doc) { items = new ArrayList(); try { if (section.Title != null) { this.title = (RtfParagraph) doc.GetMapper().MapElement(section.Title)[0]; } if (document.GetAutogenerateTOCEntries()) { StringBuilder titleText = new StringBuilder(); foreach (IElement element in section.Title) { if (element.Type == Element.CHUNK) { titleText.Append(((Chunk) element).Content); } } if (titleText.ToString().Trim().Length > 0) { FD.RtfTOCEntry tocEntry = new FD.RtfTOCEntry(titleText.ToString()); tocEntry.SetRtfDocument(this.document); this.items.Add(tocEntry); } } foreach (IElement element in section) { IRtfBasicElement[] rtfElements = doc.GetMapper().MapElement(element); for (int i = 0; i < rtfElements.Length; i++) { if (rtfElements[i] != null) { items.Add(rtfElements[i]); } } } UpdateIndentation(section.IndentationLeft, section.IndentationRight, section.Indentation); } catch (DocumentException) { } }