Inheritance: iTextSharp.text.Cell, IRtfExtendedElement
コード例 #1
0
        /**
         * Writes the content of this RtfRow
         *
         * @return A byte array with the content of this RtfRow
         */
        public override byte[] Write()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                result.Write(t = WriteRowDefinitions(), 0, t.Length);

                for (int i = 0; i < this.cells.Count; i++)
                {
                    RtfCell rtfCell = (RtfCell)this.cells[i];
                    result.Write(t = rtfCell.Write(), 0, t.Length);
                }

                result.Write(DELIMITER, 0, DELIMITER.Length);

                if (this.document.GetDocumentSettings().IsOutputTableRowDefinitionAfter())
                {
                    result.Write(t = WriteRowDefinitions(), 0, t.Length);
                }

                result.Write(ROW_END, 0, ROW_END.Length);
                result.WriteByte((byte)'\n');
            } catch (IOException) {
            }
            return(result.ToArray());
        }
コード例 #2
0
 /**
  * Merge this cell into the parent cell.
  *
  * @param mergeParent The RtfCell to merge with
  */
 protected internal void SetCellMergeChild(RtfCell mergeParent)
 {
     this.mergeType         = MERGE_VERT_CHILD;
     this.cellWidth         = mergeParent.GetCellWidth();
     this.cellRight         = mergeParent.GetCellRight();
     this.cellPadding       = mergeParent.GetCellpadding();
     this.borders           = mergeParent.GetBorders();
     this.verticalAlignment = mergeParent.GetVerticalAlignment();
     this.backgroundColor   = mergeParent.GetBackgroundColor();
 }
コード例 #3
0
 /// <summary>
 /// Merge this cell into the parent cell.
 /// </summary>
 /// <param name="mergeParent">The RtfCell to merge with</param>
 protected internal void SetCellMergeChild(RtfCell mergeParent)
 {
     _mergeType        = MergeVertChild;
     _cellWidth        = mergeParent.GetCellWidth();
     _cellRight        = mergeParent.GetCellRight();
     _cellPadding      = mergeParent.GetCellpadding();
     _borders          = mergeParent.GetBorders();
     verticalAlignment = mergeParent.VerticalAlignment;
     _backgroundColor  = mergeParent.GetRtfBackgroundColor();
 }
コード例 #4
0
        /// <summary>
        /// Performs a second pass over all cells to handle cell row/column spanning.
        /// </summary>
        protected internal void HandleCellSpanning()
        {
            var deletedCell = new RtfCell(true);

            for (var i = 0; i < _cells.Count; i++)
            {
                var rtfCell = (RtfCell)_cells[i];
                if (rtfCell.Colspan > 1)
                {
                    var cSpan = rtfCell.Colspan;
                    for (var j = i + 1; j < i + cSpan; j++)
                    {
                        if (j < _cells.Count)
                        {
                            var rtfCellMerge = (RtfCell)_cells[j];
                            rtfCell.SetCellRight(rtfCell.GetCellRight() + rtfCellMerge.GetCellWidth());
                            rtfCell.SetCellWidth(rtfCell.GetCellWidth() + rtfCellMerge.GetCellWidth());
                            _cells[j] = deletedCell;
                        }
                    }
                }
                if (rtfCell.Rowspan > 1)
                {
                    var rows = _parentTable.GetRows();
                    for (var j = 1; j < rtfCell.Rowspan; j++)
                    {
                        var mergeRow = (RtfRow)rows[_rowNumber + j];
                        if (_rowNumber + j < rows.Count)
                        {
                            var rtfCellMerge = (RtfCell)mergeRow.GetCells()[i];
                            rtfCellMerge.SetCellMergeChild(rtfCell);
                        }
                        if (rtfCell.Colspan > 1)
                        {
                            var cSpan = rtfCell.Colspan;
                            for (var k = i + 1; k < i + cSpan; k++)
                            {
                                if (k < mergeRow.GetCells().Count)
                                {
                                    mergeRow.GetCells()[k] = deletedCell;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        /**
         * Performs a second pass over all cells to handle cell row/column spanning.
         */
        protected internal void HandleCellSpanning()
        {
            RtfCell deletedCell = new RtfCell(true);

            for (int i = 0; i < this.cells.Count; i++)
            {
                RtfCell rtfCell = (RtfCell)this.cells[i];
                if (rtfCell.Colspan > 1)
                {
                    int cSpan = rtfCell.Colspan;
                    for (int j = i + 1; j < i + cSpan; j++)
                    {
                        if (j < this.cells.Count)
                        {
                            RtfCell rtfCellMerge = (RtfCell)this.cells[j];
                            rtfCell.SetCellRight(rtfCell.GetCellRight() + rtfCellMerge.GetCellWidth());
                            rtfCell.SetCellWidth(rtfCell.GetCellWidth() + rtfCellMerge.GetCellWidth());
                            this.cells[j] = deletedCell;
                        }
                    }
                }
                if (rtfCell.Rowspan > 1)
                {
                    ArrayList rows = this.parentTable.GetRows();
                    for (int j = 1; j < rtfCell.Rowspan; j++)
                    {
                        RtfRow mergeRow = (RtfRow)rows[this.rowNumber + j];
                        if (this.rowNumber + j < rows.Count)
                        {
                            RtfCell rtfCellMerge = (RtfCell)mergeRow.GetCells()[i];
                            rtfCellMerge.SetCellMergeChild(rtfCell);
                        }
                        if (rtfCell.Colspan > 1)
                        {
                            int cSpan = rtfCell.Colspan;
                            for (int k = i + 1; k < i + cSpan; k++)
                            {
                                if (k < mergeRow.GetCells().Count)
                                {
                                    mergeRow.GetCells()[k] = deletedCell;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        /**
         * Writes the content of this RtfRow
         */
        public override void WriteContent(Stream result)
        {
            WriteRowDefinition(result);

            for (int i = 0; i < this.cells.Count; i++)
            {
                RtfCell rtfCell = (RtfCell)this.cells[i];
                rtfCell.WriteContent(result);
            }

            result.Write(DELIMITER, 0, DELIMITER.Length);

            if (this.document.GetDocumentSettings().IsOutputTableRowDefinitionAfter())
            {
                WriteRowDefinition(result);
            }

            result.Write(ROW_END, 0, ROW_END.Length);
            this.document.OutputDebugLinebreak(result);
        }
コード例 #7
0
        /// <summary>
        /// Writes the content of this RtfRow
        /// </summary>
        public override void WriteContent(Stream result)
        {
            writeRowDefinition(result);

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

            result.Write(Delimiter, 0, Delimiter.Length);

            if (Document.GetDocumentSettings().IsOutputTableRowDefinitionAfter())
            {
                writeRowDefinition(result);
            }

            result.Write(_rowEnd, 0, _rowEnd.Length);
            Document.OutputDebugLinebreak(result);
        }
コード例 #8
0
        /// <summary>
        /// Imports a Row and copies all settings
        /// </summary>
        /// <param name="row">The Row to import</param>
        private void importRow(Row row)
        {
            _cells = new ArrayList();
            _width = Document.GetDocumentHeader().GetPageSetting().GetPageWidth() - Document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - Document.GetDocumentHeader().GetPageSetting().GetMarginRight();
            _width = (int)(_width * _parentTable.GetTableWidthPercent() / 100);

            var cellRight = 0;
            var cellWidth = 0;

            for (var i = 0; i < row.Columns; i++)
            {
                cellWidth = (int)(_width * _parentTable.GetProportionalWidths()[i] / 100);
                cellRight = cellRight + cellWidth;

                var cell    = (Cell)row.GetCell(i);
                var rtfCell = new RtfCell(Document, this, cell);
                rtfCell.SetCellRight(cellRight);
                rtfCell.SetCellWidth(cellWidth);
                _cells.Add(rtfCell);
            }
        }
コード例 #9
0
        /**
         * Imports a Row and copies all settings
         *
         * @param row The Row to import
         */
        private void ImportRow(Row row)
        {
            this.cells = new ArrayList();
            this.width = this.document.GetDocumentHeader().GetPageSetting().GetPageWidth() - this.document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - this.document.GetDocumentHeader().GetPageSetting().GetMarginRight();
            this.width = (int)(this.width * this.parentTable.GetTableWidthPercent() / 100);

            int cellRight = 0;
            int cellWidth = 0;

            for (int i = 0; i < row.Columns; i++)
            {
                cellWidth = (int)(this.width * this.parentTable.GetProportionalWidths()[i] / 100);
                cellRight = cellRight + cellWidth;

                Cell    cell    = (Cell)row.GetCell(i);
                RtfCell rtfCell = new RtfCell(this.document, this, cell);
                rtfCell.SetCellRight(cellRight);
                rtfCell.SetCellWidth(cellWidth);
                this.cells.Add(rtfCell);
            }
        }
コード例 #10
0
        /// <summary>
        /// Imports a PdfPRow and copies all settings
        /// @since 2.1.3
        /// </summary>
        /// <param name="row">The PdfPRow to import</param>
        private void importRow(PdfPRow row)
        {
            _cells = new ArrayList();
            _width = Document.GetDocumentHeader().GetPageSetting().GetPageWidth() - Document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - Document.GetDocumentHeader().GetPageSetting().GetMarginRight();
            _width = (int)(_width * _parentTable.GetTableWidthPercent() / 100);

            int cellRight = 0;
            int cellWidth = 0;

            PdfPCell[] cells = row.GetCells();
            for (int i = 0; i < cells.Length; i++)
            {
                cellWidth = (int)(_width * _parentTable.GetProportionalWidths()[i] / 100);
                cellRight = cellRight + cellWidth;

                PdfPCell cell    = cells[i];
                RtfCell  rtfCell = new RtfCell(Document, this, cell);
                rtfCell.SetCellRight(cellRight);
                rtfCell.SetCellWidth(cellWidth);
                _cells.Add(rtfCell);
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
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);
            }
        }
コード例 #13
0
        /**
         * Writes the row definition/settings.
         *
         * @return A byte array with the row definitions/settings.
         */
        private byte[] WriteRowDefinitions()
        {
            MemoryStream result = new MemoryStream();

            byte[] t;
            try {
                result.Write(ROW_BEGIN, 0, ROW_BEGIN.Length);
                result.WriteByte((byte)'\n');
                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);

                result.Write(t = this.parentTable.GetBorders().Write(), 0, t.Length);

                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);

                result.WriteByte((byte)'\n');

                for (int i = 0; i < this.cells.Count; i++)
                {
                    RtfCell rtfCell = (RtfCell)this.cells[i];
                    result.Write(t = rtfCell.WriteDefinition(), 0, t.Length);
                }
            } catch (IOException) {
            }
            return(result.ToArray());
        }