/** * Writes the content of this RtfListItem. * * @return A byte array with the content of this RtfListItem. */ public override byte[] Write() { MemoryStream result = new MemoryStream(); try { byte[] t; for (int i = 0; i < chunks.Count; i++) { IRtfBasicElement rtfElement = (IRtfBasicElement)chunks[i]; if (rtfElement is RtfChunk) { ((RtfChunk)rtfElement).SetSoftLineBreaks(true); } else if (rtfElement is RtfList) { result.Write(RtfParagraph.PARAGRAPH, 0, RtfParagraph.PARAGRAPH.Length); this.containsInnerList = true; } result.Write(t = rtfElement.Write(), 0, t.Length); if (rtfElement is RtfList) { result.Write(t = this.parentList.WriteListBeginning(), 0, t.Length); result.Write(t = DocWriter.GetISOBytes("\\tab"), 0, t.Length); } } } catch (IOException) { } return(result.ToArray()); }
/** * Adds an element to the rtf document * * @param element The element to add */ public void Add(IRtfBasicElement element) { try { if (element is RtfInfoElement) { this.documentHeader.AddInfoElement((RtfInfoElement)element); } else { if (element is RtfImage) { ((RtfImage)element).SetTopLevelElement(true); } byte[] t = element.Write(); data.GetOutputStream().Write(t, 0, t.Length); this.lastElementWritten = element; } } catch (IOException) { } }
/** * Write the content of this RtfCell * * @return A byte array with the content of this RtfCell */ public byte[] Write() { MemoryStream result = new MemoryStream(); byte[] t; try { if (this.content.Count == 0) { result.Write(RtfParagraph.PARAGRAPH_DEFAULTS, 0, RtfParagraph.PARAGRAPH_DEFAULTS.Length); if (this.parentRow.GetParentTable().GetTableFitToPage()) { result.Write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT, 0, RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT.Length); } result.Write(RtfParagraph.IN_TABLE, 0, RtfParagraph.IN_TABLE.Length); } else { for (int i = 0; i < this.content.Count; i++) { IRtfBasicElement rtfElement = (IRtfBasicElement)this.content[i]; if (rtfElement is RtfParagraph) { ((RtfParagraph)rtfElement).SetKeepTogetherWithNext(this.parentRow.GetParentTable().GetTableFitToPage()); } result.Write(t = rtfElement.Write(), 0, t.Length); if (rtfElement is RtfParagraph && i < (this.content.Count - 1)) { result.Write(RtfParagraph.PARAGRAPH, 0, RtfParagraph.PARAGRAPH.Length); } } } result.Write(t = DocWriter.GetISOBytes("\\cell"), 0, t.Length); } catch (IOException) { } return(result.ToArray()); }
/** * Adds an element to the rtf document * * @param element The element to add */ public void Add(IRtfBasicElement element) { try { if (element is RtfInfoElement) { this.documentHeader.AddInfoElement((RtfInfoElement) element); } else { if(element is RtfImage) { ((RtfImage) element).SetTopLevelElement(true); } byte[] t = element.Write(); data.GetOutputStream().Write(t, 0, t.Length); this.lastElementWritten = element; } } catch (IOException) { } }