Пример #1
0
 /**
 * Write the beginning of a new <code>Paragraph</code>
 *
 * @param paragraphElement The <code>Paragraph</code> to be written
 * @param outp The <code>MemoryStream</code> to write to
 *
 * @throws IOException
 */
 private void WriteParagraph(Paragraph paragraphElement, MemoryStream outp)
 {
     outp.WriteByte(escape);
     outp.Write(paragraphDefaults, 0, paragraphDefaults.Length);
     if (inTable) {
         outp.WriteByte(escape);
         outp.Write(RtfCell.cellInTable, 0, RtfCell.cellInTable.Length);
     }
     switch (paragraphElement.Alignment) {
         case Element.ALIGN_LEFT:
             outp.WriteByte(escape);
             outp.Write(alignLeft, 0, alignLeft.Length);
             break;
         case Element.ALIGN_RIGHT:
             outp.WriteByte(escape);
             outp.Write(alignRight, 0, alignRight.Length);
             break;
         case Element.ALIGN_CENTER:
             outp.WriteByte(escape);
             outp.Write(alignCenter, 0, alignCenter.Length);
             break;
         case Element.ALIGN_JUSTIFIED:
         case Element.ALIGN_JUSTIFIED_ALL:
             outp.WriteByte(escape);
             outp.Write(alignJustify, 0, alignJustify.Length);
             break;
     }
     outp.WriteByte(escape);
     outp.Write(listIndent, 0, listIndent.Length);
     WriteInt(outp, (int) (paragraphElement.IndentationLeft * TWIPSFACTOR));
     outp.WriteByte(escape);
     outp.Write(rightIndent, 0, rightIndent.Length);
     WriteInt(outp, (int) (paragraphElement.IndentationRight * TWIPSFACTOR));
     foreach (Chunk ch in paragraphElement.Chunks) {
         ch.Font = paragraphElement.Font.Difference(ch.Font);
     }
     MemoryStream save = content;
     content = outp;
     paragraphElement.Process(this);
     content = save;
     if (!inTable) {
         outp.WriteByte(escape);
         outp.Write(paragraph, 0, paragraph.Length);
     }
 }