Exemple #1
0
        /// <summary>
        /// Write the content of the RtfCell.
        /// </summary>
        /// <param name="os">
        /// The Stream to which to write the content of the RtfCell to.
        /// </param>
        /// <returns>true is successful</returns>
        public bool writeCellContent(MemoryStream os)
        {
            try {
                // <!-- steffen
                if (mergeType == MERGE_HORIZ_PREV || mergeType == MERGE_BOTH_PREV)
                {
                    return(true);
                }
                // -->

                /*            switch(store.horizontalAlignment())
                 *                      {
                 *                              case Element.ALIGN_LEFT      : os.WriteByte(RtfWriter.escape);
                 *                              os.Write(cellHorizontalAlignLeft); break;
                 *                              case Element.ALIGN_CENTER    : os.WriteByte(RtfWriter.escape);
                 *                              os.Write(cellHorizontalAlignCenter); break;
                 *                              case Element.ALIGN_RIGHT     : os.WriteByte(RtfWriter.escape);
                 *                              os.Write(cellHorizontalAlignRight); break;
                 *                              case Element.ALIGN_JUSTIFIED : os.WriteByte(RtfWriter.escape);
                 *                              os.Write(cellHorizontalAlignJustified); break;
                 *                      }*/

                if (!emptyCell)
                {
                    for (int i = 0; i < store.Elements.Count; i++)
                    {
                        IElement element = (IElement)store.Elements[i];

                        // if horizontal alignment is undefined overwrite
                        // with that of enclosing cell
                        if (element is Paragraph && ((Paragraph)element).Alignment == Element.ALIGN_UNDEFINED)
                        {
                            ((Paragraph)element).Alignment = store.HorizontalAlignment;
                        }
                        writer.addElement(element, os);
                        if (element.Type == Element.PARAGRAPH && i < store.Elements.Count - 1)
                        {
                            os.WriteByte(RtfWriter.escape);
                            os.Write(RtfWriter.paragraph, 0, RtfWriter.paragraph.Length);
                        }
                    }
                }
                else
                {
                    os.WriteByte(RtfWriter.escape);
                    os.Write(RtfWriter.paragraphDefaults, 0, RtfWriter.paragraphDefaults.Length);
                    os.WriteByte(RtfWriter.escape);
                    os.Write(cellInTable, 0, cellInTable.Length);
                }
                os.WriteByte(RtfWriter.escape);
                os.Write(cellEnd, 0, cellEnd.Length);
                //            os.Write((byte)'\n');
            }
            catch (IOException e) {
                return(false);
            }
            return(true);
        }