/** * Creates a MarkedObject with a Section or Chapter object. * @param section the marked section */ public MarkedSection(Section section) : base() { if (section.Title != null) { title = new MarkedObject(section.Title); section.Title = null; } this.element = section; }
/** * 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) { } }
// methods that return a Section /// <summary> /// Creates a Section, adds it to this Section and returns it. /// </summary> /// <param name="indentation">the indentation of the new section</param> /// <param name="title">the title of the new section</param> /// <param name="numberDepth">the numberDepth of the section</param> /// <returns>the newly added Section</returns> public virtual Section AddSection(float indentation, Paragraph title, int numberDepth) { if (AddedCompletely) { throw new InvalidOperationException("This LargeElement has already been added to the Document."); } Section section = new Section(title, numberDepth); section.Indentation = indentation; Add(section); return section; }