Beispiel #1
0
 /**
  * Write the content of this RtfCell
  */
 public virtual void WriteContent(Stream result)
 {
     byte[] t;
     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());
             }
             rtfElement.WriteContent(result);
             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);
 }
Beispiel #2
0
 /**
  * Writes the content of this RtfParagraph. First paragraph specific data is written
  * and then the RtfChunks of this RtfParagraph are added.
  */
 public override void WriteContent(Stream result)
 {
     result.Write(PARAGRAPH_DEFAULTS, 0, PARAGRAPH_DEFAULTS.Length);
     result.Write(PLAIN, 0, PLAIN.Length);
     if (inTable)
     {
         result.Write(IN_TABLE, 0, IN_TABLE.Length);
     }
     if (this.paragraphStyle != null)
     {
         this.paragraphStyle.WriteBegin(result);
     }
     result.Write(PLAIN, 0, PLAIN.Length);
     for (int i = 0; i < chunks.Count; i++)
     {
         IRtfBasicElement rbe = (IRtfBasicElement)chunks[i];
         rbe.WriteContent(result);
     }
     if (this.paragraphStyle != null)
     {
         this.paragraphStyle.WriteEnd(result);
     }
     if (!inTable)
     {
         result.Write(PARAGRAPH, 0, PARAGRAPH.Length);
     }
     this.document.OutputDebugLinebreak(result);
 }
Beispiel #3
0
 /// <summary>
 /// Write the content of this RtfCell
 /// </summary>
 public virtual void WriteContent(Stream result)
 {
     byte[] t;
     if (_content.Count == 0)
     {
         result.Write(RtfPhrase.ParagraphDefaults, 0, RtfPhrase.ParagraphDefaults.Length);
         if (_parentRow.GetParentTable().GetTableFitToPage())
         {
             result.Write(RtfParagraphStyle.KeepTogetherWithNext, 0, RtfParagraphStyle.KeepTogetherWithNext.Length);
         }
         result.Write(RtfPhrase.InTable, 0, RtfPhrase.InTable.Length);
     }
     else
     {
         for (int i = 0; i < _content.Count; i++)
         {
             IRtfBasicElement rtfElement = (IRtfBasicElement)_content[i];
             if (rtfElement is RtfParagraph)
             {
                 ((RtfParagraph)rtfElement).SetKeepTogetherWithNext(_parentRow.GetParentTable().GetTableFitToPage());
             }
             rtfElement.WriteContent(result);
             if (rtfElement is RtfParagraph && i < (_content.Count - 1))
             {
                 result.Write(RtfParagraph.Paragraph, 0, RtfParagraph.Paragraph.Length);
             }
         }
     }
     result.Write(t = DocWriter.GetIsoBytes("\\cell"), 0, t.Length);
 }
Beispiel #4
0
 /// <summary>
 /// Writes the content of this RtfParagraph. First paragraph specific data is written
 /// and then the RtfChunks of this RtfParagraph are added.
 /// </summary>
 public override void WriteContent(Stream result)
 {
     result.Write(ParagraphDefaults, 0, ParagraphDefaults.Length);
     result.Write(Plain, 0, Plain.Length);
     if (((RtfElement)this).InTable)
     {
         result.Write(InTable, 0, InTable.Length);
     }
     if (ParagraphStyle != null)
     {
         ParagraphStyle.WriteBegin(result);
     }
     result.Write(Plain, 0, Plain.Length);
     for (int i = 0; i < Chunks.Count; i++)
     {
         IRtfBasicElement rbe = (IRtfBasicElement)Chunks[i];
         rbe.WriteContent(result);
     }
     if (ParagraphStyle != null)
     {
         ParagraphStyle.WriteEnd(result);
     }
     if (!((RtfElement)this).InTable)
     {
         result.Write(Paragraph, 0, Paragraph.Length);
     }
     Document.OutputDebugLinebreak(result);
 }
Beispiel #5
0
 /// <summary>
 /// Write the content of this RtfHeaderFooter.
 /// </summary>
 public virtual void WriteContent(Stream result)
 {
     result.Write(RtfElement.OpenGroup, 0, RtfElement.OpenGroup.Length);
     if (_type == TYPE_HEADER)
     {
         if (_displayAt == DISPLAY_ALL_PAGES)
         {
             result.Write(_headerAll, 0, _headerAll.Length);
         }
         else if (_displayAt == DISPLAY_FIRST_PAGE)
         {
             result.Write(_headerFirst, 0, _headerFirst.Length);
         }
         else if (_displayAt == DISPLAY_LEFT_PAGES)
         {
             result.Write(_headerLeft, 0, _headerLeft.Length);
         }
         else if (_displayAt == DISPLAY_RIGHT_PAGES)
         {
             result.Write(_headerRight, 0, _headerRight.Length);
         }
     }
     else
     {
         if (_displayAt == DISPLAY_ALL_PAGES)
         {
             result.Write(_footerAll, 0, _footerAll.Length);
         }
         else if (_displayAt == DISPLAY_FIRST_PAGE)
         {
             result.Write(_footerFirst, 0, _footerFirst.Length);
         }
         else if (_displayAt == DISPLAY_LEFT_PAGES)
         {
             result.Write(_footerLeft, 0, _footerLeft.Length);
         }
         else if (_displayAt == DISPLAY_RIGHT_PAGES)
         {
             result.Write(_footerRight, 0, _footerRight.Length);
         }
     }
     result.Write(RtfElement.Delimiter, 0, RtfElement.Delimiter.Length);
     for (int i = 0; i < _content.Length; i++)
     {
         if (_content[i] is IRtfBasicElement)
         {
             IRtfBasicElement rbe = (IRtfBasicElement)_content[i];
             rbe.WriteContent(result);
         }
     }
     result.Write(RtfElement.CloseGroup, 0, RtfElement.CloseGroup.Length);
 }
Beispiel #6
0
 /**
  * Write the content of this RtfHeaderFooter.
  */
 public virtual void WriteContent(Stream result)
 {
     result.Write(RtfElement.OPEN_GROUP, 0, RtfElement.OPEN_GROUP.Length);
     if (this.type == TYPE_HEADER)
     {
         if (this.displayAt == DISPLAY_ALL_PAGES)
         {
             result.Write(HEADER_ALL, 0, HEADER_ALL.Length);
         }
         else if (this.displayAt == DISPLAY_FIRST_PAGE)
         {
             result.Write(HEADER_FIRST, 0, HEADER_FIRST.Length);
         }
         else if (this.displayAt == DISPLAY_LEFT_PAGES)
         {
             result.Write(HEADER_LEFT, 0, HEADER_LEFT.Length);
         }
         else if (this.displayAt == DISPLAY_RIGHT_PAGES)
         {
             result.Write(HEADER_RIGHT, 0, HEADER_RIGHT.Length);
         }
     }
     else
     {
         if (this.displayAt == DISPLAY_ALL_PAGES)
         {
             result.Write(FOOTER_ALL, 0, FOOTER_ALL.Length);
         }
         else if (this.displayAt == DISPLAY_FIRST_PAGE)
         {
             result.Write(FOOTER_FIRST, 0, FOOTER_FIRST.Length);
         }
         else if (this.displayAt == DISPLAY_LEFT_PAGES)
         {
             result.Write(FOOTER_LEFT, 0, FOOTER_LEFT.Length);
         }
         else if (this.displayAt == DISPLAY_RIGHT_PAGES)
         {
             result.Write(FOOTER_RIGHT, 0, FOOTER_RIGHT.Length);
         }
     }
     result.Write(RtfElement.DELIMITER, 0, RtfElement.DELIMITER.Length);
     for (int i = 0; i < this.content.Length; i++)
     {
         if (this.content[i] is IRtfBasicElement)
         {
             IRtfBasicElement rbe = (IRtfBasicElement)this.content[i];
             rbe.WriteContent(result);
         }
     }
     result.Write(RtfElement.CLOSE_GROUP, 0, RtfElement.CLOSE_GROUP.Length);
 }
Beispiel #7
0
        /**
         * Writes the content of this RtfListItem.
         */
        public override void WriteContent(Stream result)
        {
            byte[] t;
            if (this.paragraphStyle.GetSpacingBefore() > 0)
            {
                result.Write(RtfParagraphStyle.SPACING_BEFORE, 0, RtfParagraphStyle.SPACING_BEFORE.Length);
                result.Write(t = IntToByteArray(paragraphStyle.GetSpacingBefore()), 0, t.Length);
            }
            if (this.paragraphStyle.GetSpacingAfter() > 0)
            {
                result.Write(RtfParagraphStyle.SPACING_AFTER, 0, RtfParagraphStyle.SPACING_AFTER.Length);
                result.Write(t = IntToByteArray(this.paragraphStyle.GetSpacingAfter()), 0, t.Length);
            }
            if (this.paragraphStyle.GetLineLeading() > 0)
            {
                result.Write(RtfParagraph.LINE_SPACING, 0, RtfParagraph.LINE_SPACING.Length);
                result.Write(t = IntToByteArray(this.paragraphStyle.GetLineLeading()), 0, t.Length);
            }
            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;
                }
                rtfElement.WriteContent(result);
                if (rtfElement is RtfList)
                {
                    switch (this.parentList.GetLevelFollowValue())
                    {
                    case RtfListLevel.LIST_LEVEL_FOLLOW_NOTHING:
                        break;

                    case RtfListLevel.LIST_LEVEL_FOLLOW_TAB:
                        this.parentList.WriteListBeginning(result);
                        result.Write(RtfList.TAB, 0, RtfList.TAB.Length);
                        break;

                    case RtfListLevel.LIST_LEVEL_FOLLOW_SPACE:
                        this.parentList.WriteListBeginning(result);
                        result.Write(t = DocWriter.GetISOBytes(" "), 0, t.Length);
                        break;
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Writes the content of this RtfListItem.
        /// </summary>
        public override void WriteContent(Stream result)
        {
            byte[] t;
            if (ParagraphStyle.GetSpacingBefore() > 0)
            {
                result.Write(RtfParagraphStyle.SpacingBefore, 0, RtfParagraphStyle.SpacingBefore.Length);
                result.Write(t = IntToByteArray(ParagraphStyle.GetSpacingBefore()), 0, t.Length);
            }
            if (ParagraphStyle.GetSpacingAfter() > 0)
            {
                result.Write(RtfParagraphStyle.SpacingAfter, 0, RtfParagraphStyle.SpacingAfter.Length);
                result.Write(t = IntToByteArray(ParagraphStyle.GetSpacingAfter()), 0, t.Length);
            }
            if (ParagraphStyle.GetLineLeading() > 0)
            {
                result.Write(LineSpacing, 0, LineSpacing.Length);
                result.Write(t = IntToByteArray(ParagraphStyle.GetLineLeading()), 0, t.Length);
            }
            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(Paragraph, 0, Paragraph.Length);
                    _containsInnerList = true;
                }
                rtfElement.WriteContent(result);
                if (rtfElement is RtfList)
                {
                    switch (_parentList.GetLevelFollowValue())
                    {
                    case RtfListLevel.LIST_LEVEL_FOLLOW_NOTHING:
                        break;

                    case RtfListLevel.LIST_LEVEL_FOLLOW_TAB:
                        _parentList.WriteListBeginning(result);
                        result.Write(RtfList.Tab, 0, RtfList.Tab.Length);
                        break;

                    case RtfListLevel.LIST_LEVEL_FOLLOW_SPACE:
                        _parentList.WriteListBeginning(result);
                        result.Write(t = DocWriter.GetIsoBytes(" "), 0, t.Length);
                        break;
                    }
                }
            }
        }
Beispiel #9
0
 /**
  * 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);
             }
             element.WriteContent(this.data.GetOutputStream());
             this.lastElementWritten = element;
         }
     } catch (IOException) {
     }
 }
Beispiel #10
0
 /**
  * Writes the RtfChapter and its contents
  */
 public override void WriteContent(Stream result)
 {
     byte[] t;
     if (this.document.GetLastElementWritten() != null && !(this.document.GetLastElementWritten() is RtfChapter))
     {
         result.Write(t = DocWriter.GetISOBytes("\\page"), 0, t.Length);
     }
     result.Write(t = DocWriter.GetISOBytes("\\sectd"), 0, t.Length);
     document.GetDocumentHeader().WriteSectionDefinition(result);
     if (this.title != null)
     {
         this.title.WriteContent(result);
     }
     for (int i = 0; i < items.Count; i++)
     {
         IRtfBasicElement rbe = (IRtfBasicElement)items[i];
         rbe.WriteContent(result);
     }
     result.Write(t = DocWriter.GetISOBytes("\\sect"), 0, t.Length);
 }
Beispiel #11
0
 /**
 * 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);
             }
             element.WriteContent(this.data.GetOutputStream());
             this.lastElementWritten = element;
         }
     } catch (IOException) {
     }
 }