WriteContent() public method

public WriteContent ( Stream result ) : void
result Stream
return void
コード例 #1
0
        /// <summary>
        /// Write the cell definition part of this RtfCell
        /// </summary>
        /// <returns>A byte array with the cell definition</returns>
        public virtual void WriteDefinition(Stream result)
        {
            byte[] t;
            if (_mergeType == MergeVertParent)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clvmgf"), 0, t.Length);
            }
            else if (_mergeType == MergeVertChild)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clvmrg"), 0, t.Length);
            }
            switch (verticalAlignment)
            {
            case ALIGN_BOTTOM:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalb"), 0, t.Length);
                break;

            case ALIGN_CENTER:
            case ALIGN_MIDDLE:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalc"), 0, t.Length);
                break;

            case ALIGN_TOP:
                result.Write(t = DocWriter.GetIsoBytes("\\clvertalt"), 0, t.Length);
                break;
            }
            _borders.WriteContent(result);

            if (_backgroundColor != null)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clcbpat"), 0, t.Length);
                result.Write(t = intToByteArray(_backgroundColor.GetColorNumber()), 0, t.Length);
            }
            _document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetIsoBytes("\\clftsWidth3"), 0, t.Length);
            _document.OutputDebugLinebreak(result);

            result.Write(t = DocWriter.GetIsoBytes("\\clwWidth"), 0, t.Length);
            result.Write(t = intToByteArray(_cellWidth), 0, t.Length);
            _document.OutputDebugLinebreak(result);

            if (_cellPadding > 0)
            {
                result.Write(t = DocWriter.GetIsoBytes("\\clpadl"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadt"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadr"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadb"), 0, t.Length);
                result.Write(t = intToByteArray(_cellPadding / 2), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfl3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadft3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfr3"), 0, t.Length);
                result.Write(t = DocWriter.GetIsoBytes("\\clpadfb3"), 0, t.Length);
            }
            result.Write(t = DocWriter.GetIsoBytes("\\cellx"), 0, t.Length);
            result.Write(t = intToByteArray(_cellRight), 0, t.Length);
        }
コード例 #2
0
        /**
         * Writes the row definition/settings.
         *
         * @param result The <code>Stream</code> to write the definitions to.
         */
        private void WriteRowDefinition(Stream result)
        {
            byte[] t;
            result.Write(ROW_BEGIN, 0, ROW_BEGIN.Length);
            this.document.OutputDebugLinebreak(result);
            result.Write(ROW_WIDTH_STYLE, 0, ROW_WIDTH_STYLE.Length);
            result.Write(ROW_WIDTH, 0, ROW_WIDTH.Length);
            result.Write(t = IntToByteArray(this.width), 0, t.Length);
            if (this.parentTable.GetCellsFitToPage())
            {
                result.Write(ROW_KEEP_TOGETHER, 0, ROW_KEEP_TOGETHER.Length);
            }
            if (this.rowNumber <= this.parentTable.GetHeaderRows())
            {
                result.Write(ROW_HEADER_ROW, 0, ROW_HEADER_ROW.Length);
            }
            switch (this.parentTable.GetAlignment())
            {
            case Element.ALIGN_LEFT:
                result.Write(ROW_ALIGN_LEFT, 0, ROW_ALIGN_LEFT.Length);
                break;

            case Element.ALIGN_RIGHT:
                result.Write(ROW_ALIGN_RIGHT, 0, ROW_ALIGN_RIGHT.Length);
                break;

            case Element.ALIGN_CENTER:
                result.Write(ROW_ALIGN_CENTER, 0, ROW_ALIGN_CENTER.Length);
                break;

            case Element.ALIGN_JUSTIFIED:
            case Element.ALIGN_JUSTIFIED_ALL:
                result.Write(ROW_ALIGN_JUSTIFIED, 0, ROW_ALIGN_JUSTIFIED.Length);
                break;
            }
            result.Write(ROW_GRAPH, 0, ROW_GRAPH.Length);

            RtfBorderGroup borders = this.parentTable.GetBorders();

            if (borders != null)
            {
                borders.WriteContent(result);
            }

            if (this.parentTable.GetCellSpacing() > 0)
            {
                result.Write(ROW_CELL_SPACING_LEFT, 0, ROW_CELL_SPACING_LEFT.Length);
                result.Write(t = IntToByteArray((int)(this.parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(ROW_CELL_SPACING_LEFT_STYLE, 0, ROW_CELL_SPACING_LEFT_STYLE.Length);
                result.Write(ROW_CELL_SPACING_TOP, 0, ROW_CELL_SPACING_TOP.Length);
                result.Write(t = IntToByteArray((int)(this.parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(ROW_CELL_SPACING_TOP_STYLE, 0, ROW_CELL_SPACING_TOP_STYLE.Length);
                result.Write(ROW_CELL_SPACING_RIGHT, 0, ROW_CELL_SPACING_RIGHT.Length);
                result.Write(t = IntToByteArray((int)(this.parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(ROW_CELL_SPACING_RIGHT_STYLE, 0, ROW_CELL_SPACING_RIGHT_STYLE.Length);
                result.Write(ROW_CELL_SPACING_BOTTOM, 0, ROW_CELL_SPACING_BOTTOM.Length);
                result.Write(t = IntToByteArray((int)(this.parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(ROW_CELL_SPACING_BOTTOM_STYLE, 0, ROW_CELL_SPACING_BOTTOM_STYLE.Length);
            }

            result.Write(ROW_CELL_PADDING_LEFT, 0, ROW_CELL_PADDING_LEFT.Length);
            result.Write(t = IntToByteArray((int)(this.parentTable.GetCellPadding() / 2)), 0, t.Length);
            result.Write(ROW_CELL_PADDING_RIGHT, 0, ROW_CELL_PADDING_RIGHT.Length);
            result.Write(t = IntToByteArray((int)(this.parentTable.GetCellPadding() / 2)), 0, t.Length);
            result.Write(ROW_CELL_PADDING_LEFT_STYLE, 0, ROW_CELL_PADDING_LEFT_STYLE.Length);
            result.Write(ROW_CELL_PADDING_RIGHT_STYLE, 0, ROW_CELL_PADDING_RIGHT_STYLE.Length);

            this.document.OutputDebugLinebreak(result);

            for (int i = 0; i < this.cells.Count; i++)
            {
                RtfCell rtfCell = (RtfCell)this.cells[i];
                rtfCell.WriteDefinition(result);
            }
        }
コード例 #3
0
        /// <summary>
        /// Writes the row definition/settings.
        /// </summary>
        /// <param name="result">The  Stream  to write the definitions to.</param>
        private void writeRowDefinition(Stream result)
        {
            byte[] t;
            result.Write(_rowBegin, 0, _rowBegin.Length);
            Document.OutputDebugLinebreak(result);
            result.Write(_rowWidthStyle, 0, _rowWidthStyle.Length);
            result.Write(_rowWidth, 0, _rowWidth.Length);
            result.Write(t = IntToByteArray(_width), 0, t.Length);
            if (_parentTable.GetCellsFitToPage())
            {
                result.Write(_rowKeepTogether, 0, _rowKeepTogether.Length);
            }
            if (_rowNumber <= _parentTable.GetHeaderRows())
            {
                result.Write(_rowHeaderRow, 0, _rowHeaderRow.Length);
            }
            switch (_parentTable.GetAlignment())
            {
            case Element.ALIGN_LEFT:
                result.Write(_rowAlignLeft, 0, _rowAlignLeft.Length);
                break;

            case Element.ALIGN_RIGHT:
                result.Write(_rowAlignRight, 0, _rowAlignRight.Length);
                break;

            case Element.ALIGN_CENTER:
                result.Write(_rowAlignCenter, 0, _rowAlignCenter.Length);
                break;

            case Element.ALIGN_JUSTIFIED:
            case Element.ALIGN_JUSTIFIED_ALL:
                result.Write(_rowAlignJustified, 0, _rowAlignJustified.Length);
                break;
            }
            result.Write(_rowGraph, 0, _rowGraph.Length);

            RtfBorderGroup borders = _parentTable.GetBorders();

            if (borders != null)
            {
                borders.WriteContent(result);
            }

            if (_parentTable.GetCellSpacing() > 0)
            {
                result.Write(_rowCellSpacingLeft, 0, _rowCellSpacingLeft.Length);
                result.Write(t = IntToByteArray((int)(_parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(_rowCellSpacingLeftStyle, 0, _rowCellSpacingLeftStyle.Length);
                result.Write(_rowCellSpacingTop, 0, _rowCellSpacingTop.Length);
                result.Write(t = IntToByteArray((int)(_parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(_rowCellSpacingTopStyle, 0, _rowCellSpacingTopStyle.Length);
                result.Write(_rowCellSpacingRight, 0, _rowCellSpacingRight.Length);
                result.Write(t = IntToByteArray((int)(_parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(_rowCellSpacingRightStyle, 0, _rowCellSpacingRightStyle.Length);
                result.Write(_rowCellSpacingBottom, 0, _rowCellSpacingBottom.Length);
                result.Write(t = IntToByteArray((int)(_parentTable.GetCellSpacing() / 2)), 0, t.Length);
                result.Write(_rowCellSpacingBottomStyle, 0, _rowCellSpacingBottomStyle.Length);
            }

            result.Write(_rowCellPaddingLeft, 0, _rowCellPaddingLeft.Length);
            result.Write(t = IntToByteArray((int)(_parentTable.GetCellPadding() / 2)), 0, t.Length);
            result.Write(_rowCellPaddingRight, 0, _rowCellPaddingRight.Length);
            result.Write(t = IntToByteArray((int)(_parentTable.GetCellPadding() / 2)), 0, t.Length);
            result.Write(_rowCellPaddingLeftStyle, 0, _rowCellPaddingLeftStyle.Length);
            result.Write(_rowCellPaddingRightStyle, 0, _rowCellPaddingRightStyle.Length);

            Document.OutputDebugLinebreak(result);

            for (int i = 0; i < _cells.Count; i++)
            {
                RtfCell rtfCell = (RtfCell)_cells[i];
                rtfCell.WriteDefinition(result);
            }
        }