/** * Imports the rows and settings from the Table into this * RtfTable. * * @param table The source Table */ private void ImportTable(Table table) { this.rows = new ArrayList(); this.tableWidthPercent = table.Width; this.proportionalWidths = table.ProportionalWidths; this.cellPadding = (float)(table.Cellpadding * TWIPS_FACTOR); this.cellSpacing = (float)(table.Cellspacing * TWIPS_FACTOR); this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.Border, table.BorderWidth, table.BorderColor); this.alignment = table.Alignment; int i = 0; foreach (Row row in table) { this.rows.Add(new RtfRow(this.document, this, row, i)); i++; } for (i = 0; i < this.rows.Count; i++) { ((RtfRow)this.rows[i]).HandleCellSpanning(); ((RtfRow)this.rows[i]).CleanRow(); } #if __ANDROID__ || __IOS__ this.headerRows = table.LastHeaderRow; #endif this.cellsFitToPage = table.CellsFitPage; this.tableFitToPage = table.TableFitsPage; if (!float.IsNaN(table.Offset)) { this.offset = (int)(table.Offset * 2); } }
/** * Imports the rows and settings from the Table into this * RtfTable. * * @param table The source Table */ private void ImportTable(Table table) { this.rows = new ArrayList(); this.tableWidthPercent = table.WidthPercentage; this.proportionalWidths = table.ProportionalWidths; this.cellPadding = (float)(table.Cellpadding * TWIPS_FACTOR); this.cellSpacing = (float)(table.Cellspacing * TWIPS_FACTOR); this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.Border, table.BorderWidth, table.BorderColor); this.alignment = table.Alignment; int i = 0; foreach (Row row in table) { this.rows.Add(new RtfRow(this.document, this, row, i)); i++; } for (i = 0; i < this.rows.Count; i++) { ((RtfRow)this.rows[i]).HandleCellSpanning(); ((RtfRow)this.rows[i]).CleanRow(); } this.headerRows = table.LastHeaderRow; this.cellsFitToPage = table.HasToFitPageCells(); this.tableFitToPage = table.HasToFitPageTable(); }
/// <summary> /// Imports the rows and settings from the Table into this /// RtfTable. /// </summary> /// <param name="table">The source Table</param> private void importTable(Table table) { _rows = new ArrayList(); _tableWidthPercent = table.Width; _proportionalWidths = table.ProportionalWidths; _cellPadding = (float)(table.Cellpadding * TWIPS_FACTOR); _cellSpacing = (float)(table.Cellspacing * TWIPS_FACTOR); _borders = new RtfBorderGroup(Document, RtfBorder.ROW_BORDER, table.Border, table.BorderWidth, table.BorderColor); _alignment = table.Alignment; int i = 0; foreach (Row row in table) { _rows.Add(new RtfRow(Document, this, row, i)); i++; } for (i = 0; i < _rows.Count; i++) { ((RtfRow)_rows[i]).HandleCellSpanning(); ((RtfRow)_rows[i]).CleanRow(); } _headerRows = table.LastHeaderRow; _cellsFitToPage = table.CellsFitPage; _tableFitToPage = table.TableFitsPage; if (!float.IsNaN(table.Offset)) { _offset = (int)(table.Offset * 2); } }
/// <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(); }
/** * 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(); }
/// <summary> /// Constructs a RtfBorderGroup based on another RtfBorderGroup. /// </summary> /// <param name="doc">The RtfDocument this RtfBorderGroup belongs to</param> /// <param name="borderType">The type of borders this RtfBorderGroup contains</param> /// <param name="borderGroup">The RtfBorderGroup to use as a base</param> protected internal RtfBorderGroup(RtfDocument doc, int borderType, RtfBorderGroup borderGroup) : base(doc) { _borders = new Hashtable(); _borderType = borderType; if (borderGroup != null) { foreach (DictionaryEntry entry in borderGroup.GetBorders()) { int borderPos = (int)entry.Key; RtfBorder border = (RtfBorder)entry.Value; _borders[borderPos] = new RtfBorder(Document, _borderType, border); } } }
/** * Constructs a RtfCell based upon a String * * @param content The String to base the RtfCell on */ public RtfCell(String content) : base(content) { this.borders = new RtfBorderGroup(); }
/** * Constructs a RtfCell based upon an Element * * @param element The Element to base the RtfCell on * @throws BadElementException If the Element is not valid */ public RtfCell(IElement element) : base(element) { this.borders = new RtfBorderGroup(); }
/** * Constructs an empty RtfCell */ public RtfCell() : base() { this.borders = new RtfBorderGroup(); }
/// <summary> /// Set the borders of this RtfCell /// </summary> /// <param name="borderGroup">The RtfBorderGroup to use as borders</param> public void SetBorders(RtfBorderGroup borderGroup) { _borders = new RtfBorderGroup(_document, RtfBorder.CELL_BORDER, borderGroup); }
/** * Constructs a RtfCell based upon certain Properties * * @param properties The Properties for this RtfCell */ public RtfCell(Properties properties) : base(properties) { this.borders = new RtfBorderGroup(); }
/** * Set the borders of this RtfCell * * @param borderGroup The RtfBorderGroup to use as borders */ public void SetBorders(RtfBorderGroup borderGroup) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, borderGroup); }
/** * Constructs a RtfCell based upon an Element * * @param element The Element to base the RtfCell on * @throws BadElementException If the Element is not valid */ public RtfCell(IElement element) : base(element) { this.borders = new RtfBorderGroup(); verticalAlignment = Element.ALIGN_MIDDLE; }
/** * 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); } }
/** * Imports the rows and settings from the Table into this * RtfTable. * * @param table The source Table */ private void ImportTable(Table table) { this.rows = new ArrayList(); this.tableWidthPercent = table.Width; this.proportionalWidths = table.ProportionalWidths; this.cellPadding = (float) (table.Cellpadding * TWIPS_FACTOR); this.cellSpacing = (float) (table.Cellspacing * TWIPS_FACTOR); this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.Border, table.BorderWidth, table.BorderColor); this.alignment = table.Alignment; int i = 0; foreach (Row row in table) { this.rows.Add(new RtfRow(this.document, this, row, i)); i++; } for (i = 0; i < this.rows.Count; i++) { ((RtfRow) this.rows[i]).HandleCellSpanning(); ((RtfRow) this.rows[i]).CleanRow(); } this.headerRows = table.LastHeaderRow; this.cellsFitToPage = table.CellsFitPage; this.tableFitToPage = table.TableFitsPage; if (!float.IsNaN(table.Offset)) { this.offset = (int) (table.Offset * 2); } }
/// <summary> /// Imports the Cell properties into the RtfCell /// </summary> /// <param name="cell">The Cell to import</param> private void importCell(Cell cell) { _content = new ArrayList(); if (cell == null) { _borders = new RtfBorderGroup(_document, RtfBorder.CELL_BORDER, _parentRow.GetParentTable().GetBorders()); return; } colspan = cell.Colspan; rowspan = cell.Rowspan; if (cell.Rowspan > 1) { _mergeType = MergeVertParent; } if (cell is RtfCell) { _borders = new RtfBorderGroup(_document, RtfBorder.CELL_BORDER, ((RtfCell)cell).GetBorders()); } else { _borders = new RtfBorderGroup(_document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor); } verticalAlignment = cell.VerticalAlignment; if (cell.BackgroundColor == null) { _backgroundColor = new RtfColor(_document, 255, 255, 255); } else { _backgroundColor = new RtfColor(_document, cell.BackgroundColor); } _cellPadding = (int)_parentRow.GetParentTable().GetCellPadding(); Paragraph container = null; foreach (IElement element in cell.Elements) { try { // should we wrap it in a paragraph if (!(element is Paragraph) && !(element is List)) { if (container != null) { container.Add(element); } else { container = new Paragraph { Alignment = cell.HorizontalAlignment }; container.Add(element); } } else { if (container != null) { var rtfElements = _document.GetMapper().MapElement(container); for (var i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); _content.Add(rtfElements[i]); } container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element is Paragraph && ((Paragraph)element).Alignment == ALIGN_UNDEFINED) { ((Paragraph)element).Alignment = cell.HorizontalAlignment; } var rtfElements2 = _document.GetMapper().MapElement(element); for (var i = 0; i < rtfElements2.Length; i++) { rtfElements2[i].SetInTable(true); _content.Add(rtfElements2[i]); } } } catch (DocumentException) { } } if (container != null) { try { var rtfElements = _document.GetMapper().MapElement(container); for (var i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); _content.Add(rtfElements[i]); } } catch (DocumentException) { } } }
/// <summary> /// Constructs an empty RtfCell /// </summary> public RtfCell() { _borders = new RtfBorderGroup(); verticalAlignment = ALIGN_MIDDLE; }
/** * Imports the Cell properties into the RtfCell * * @param cell The Cell to import */ private void ImportCell(Cell cell) { this.content = new ArrayList(); if (cell == null) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, this.parentRow.GetParentTable().GetBorders()); return; } this.colspan = cell.Colspan; this.rowspan = cell.Rowspan; if (cell.Rowspan > 1) { this.mergeType = MERGE_VERT_PARENT; } if (cell is RtfCell) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, ((RtfCell) cell).GetBorders()); } else { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor); } this.verticalAlignment = cell.VerticalAlignment; if (cell.BackgroundColor == null) { this.backgroundColor = new RtfColor(this.document, 255, 255, 255); } else { this.backgroundColor = new RtfColor(this.document, cell.BackgroundColor); } this.cellPadding = (int) this.parentRow.GetParentTable().GetCellPadding(); Paragraph container = null; foreach (IElement element in cell.Elements) { try { // should we wrap it in a paragraph if (!(element is Paragraph) && !(element is List)) { if (container != null) { container.Add(element); } else { container = new Paragraph(); container.Alignment = cell.HorizontalAlignment; container.Add(element); } } else { if (container != null) { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element is Paragraph && ((Paragraph) element).Alignment == Element.ALIGN_UNDEFINED) { ((Paragraph) element).Alignment = cell.HorizontalAlignment; } IRtfBasicElement[] rtfElements2 = this.document.GetMapper().MapElement(element); for (int i = 0; i < rtfElements2.Length; i++) { rtfElements2[i].SetInTable(true); this.content.Add(rtfElements2[i]); } } } catch (DocumentException) { } } if (container != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } }
/** * Imports the Cell properties into the RtfCell * * @param cell The Cell to import */ private void ImportCell(Cell cell) { this.content = new ArrayList(); if (cell == null) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, this.parentRow.GetParentTable().GetBorders()); return; } this.colspan = cell.Colspan; this.rowspan = cell.Rowspan; if (cell.Rowspan > 1) { this.mergeType = MERGE_VERT_PARENT; } if (cell is RtfCell) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, ((RtfCell)cell).GetBorders()); } else { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor); } this.verticalAlignment = cell.VerticalAlignment; if (cell.BackgroundColor == null) { this.backgroundColor = new RtfColor(this.document, 255, 255, 255); } else { this.backgroundColor = new RtfColor(this.document, cell.BackgroundColor); } this.cellPadding = (int)this.parentRow.GetParentTable().GetCellPadding(); if (cell != null) { Paragraph container = null; foreach (IElement element in cell.Elements) { try { // should we wrap it in a paragraph if (!(element is Paragraph) && !(element is List)) { if (container != null) { container.Add(element); } else { container = new Paragraph(); container.Alignment = cell.HorizontalAlignment; container.Add(element); } } else { if (container != null) { IRtfBasicElement rtfElement = this.document.GetMapper().MapElement(container); rtfElement.SetInTable(true); this.content.Add(rtfElement); container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element is Paragraph && ((Paragraph)element).Alignment == Element.ALIGN_UNDEFINED) { ((Paragraph)element).Alignment = cell.HorizontalAlignment; } IRtfBasicElement rtfElement2 = this.document.GetMapper().MapElement(element); rtfElement2.SetInTable(true); this.content.Add(rtfElement2); } } catch (DocumentException) { } } if (container != null) { try { IRtfBasicElement rtfElement = this.document.GetMapper().MapElement(container); rtfElement.SetInTable(true); this.content.Add(rtfElement); } catch (DocumentException) { } } } }
/** * Imports the Cell properties into the RtfCell * * @param cell The PdfPCell to import * @since 2.1.3 */ private void ImportCell(PdfPCell cell) { this.content = new ArrayList(); if (cell == null) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, this.parentRow.GetParentTable().GetBorders()); return; } // padding this.cellPadding = (int)this.parentRow.GetParentTable().GetCellPadding(); this.cellPaddingBottom = cell.PaddingBottom; this.cellPaddingTop = cell.PaddingTop; this.cellPaddingRight = cell.PaddingRight; this.cellPaddingLeft = cell.PaddingLeft; // BORDERS this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor); // border colors this.border = cell.Border; this.borderColor = cell.BorderColor; this.borderColorBottom = cell.BorderColorBottom; this.borderColorTop = cell.BorderColorTop; this.borderColorLeft = cell.BorderColorLeft; this.borderColorRight = cell.BorderColorRight; // border widths this.borderWidth = cell.BorderWidth; this.borderWidthBottom = cell.BorderWidthBottom; this.borderWidthTop = cell.BorderWidthTop; this.borderWidthLeft = cell.BorderWidthLeft; this.borderWidthRight = cell.BorderWidthRight; this.colspan = cell.Colspan; this.rowspan = 1; //cell.GetRowspan(); // if (cell.GetRowspan() > 1) { // this.mergeType = MERGE_VERT_PARENT; // } this.verticalAlignment = cell.VerticalAlignment; if (cell.BackgroundColor == null) { this.backgroundColor = new RtfColor(this.document, 255, 255, 255); } else { this.backgroundColor = new RtfColor(this.document, cell.BackgroundColor); } // does it have column composite info? ArrayList compositeElements = cell.CompositeElements; if (compositeElements != null) { // does it have column info? Paragraph container = null; foreach (IElement element in compositeElements) { try { // should we wrap it in a paragraph if (!(element is Paragraph) && !(element is List)) { if (container != null) { container.Add(element); } else { container = new Paragraph(); container.Alignment = cell.HorizontalAlignment; container.Add(element); } } else { IRtfBasicElement[] rtfElements = null; if (container != null) { rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element is Paragraph && ((Paragraph)element).Alignment == Element.ALIGN_UNDEFINED) { ((Paragraph)element).Alignment = cell.HorizontalAlignment; } rtfElements = this.document.GetMapper().MapElement(element); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } } catch (DocumentException) { } } if (container != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } } // does it have image info? Image img = cell.Image; if (img != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(img); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } // does it have phrase info? Phrase phrase = cell.Phrase; if (phrase != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(phrase); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } // does it have table info? PdfPTable table = cell.Table; if (table != null) { this.Add(table); // try { // RtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(table); // for (int i = 0; i < rtfElements.length; i++) { // rtfElements[i].SetInTable(true); // this.content.Add(rtfElements[i]); // } // } catch (DocumentException e) { // // TODO Auto-generated catch block // e.PrintStackTrace(); // } } }
/// <summary> /// Constructs a RtfCell based upon a String /// </summary> /// <param name="content">The String to base the RtfCell on</param> public RtfCell(string content) : base(content) { _borders = new RtfBorderGroup(); verticalAlignment = ALIGN_MIDDLE; }
/// <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); } }
/** * 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.VerticalAlignment; this.backgroundColor = mergeParent.GetRtfBackgroundColor(); }
/** * Constructs a RtfBorderGroup based on another RtfBorderGroup. * * @param doc The RtfDocument this RtfBorderGroup belongs to * @param borderType The type of borders this RtfBorderGroup contains * @param borderGroup The RtfBorderGroup to use as a base */ protected internal RtfBorderGroup(RtfDocument doc, int borderType, RtfBorderGroup borderGroup) : base(doc) { this.borders = new Hashtable(); this.borderType = borderType; if (borderGroup != null) { foreach (DictionaryEntry entry in borderGroup.GetBorders()) { int borderPos = (int)entry.Key; RtfBorder border = (RtfBorder)entry.Value; this.borders[borderPos] = new RtfBorder(this.document, this.borderType, border); } } }
/** * Imports the Cell properties into the RtfCell * * @param cell The PdfPCell to import * @since 2.1.3 */ private void ImportCell(PdfPCell cell) { this.content = new ArrayList(); if (cell == null) { this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, this.parentRow.GetParentTable().GetBorders()); return; } // padding this.cellPadding = (int) this.parentRow.GetParentTable().GetCellPadding(); this.cellPaddingBottom = cell.PaddingBottom; this.cellPaddingTop = cell.PaddingTop; this.cellPaddingRight = cell.PaddingRight; this.cellPaddingLeft = cell.PaddingLeft; // BORDERS this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor); // border colors this.border = cell.Border; this.borderColor = cell.BorderColor; this.borderColorBottom = cell.BorderColorBottom; this.borderColorTop = cell.BorderColorTop; this.borderColorLeft = cell.BorderColorLeft; this.borderColorRight = cell.BorderColorRight; // border widths this.borderWidth = cell.BorderWidth; this.borderWidthBottom = cell.BorderWidthBottom; this.borderWidthTop = cell.BorderWidthTop; this.borderWidthLeft = cell.BorderWidthLeft; this.borderWidthRight = cell.BorderWidthRight; this.colspan = cell.Colspan; this.rowspan = 1; //cell.GetRowspan(); // if (cell.GetRowspan() > 1) { // this.mergeType = MERGE_VERT_PARENT; // } this.verticalAlignment = cell.VerticalAlignment; if (cell.BackgroundColor == null) { this.backgroundColor = new RtfColor(this.document, 255, 255, 255); } else { this.backgroundColor = new RtfColor(this.document, cell.BackgroundColor); } // does it have column composite info? ArrayList compositeElements = cell.CompositeElements; if (compositeElements != null) { // does it have column info? Paragraph container = null; foreach (IElement element in compositeElements) { try { // should we wrap it in a paragraph if (!(element is Paragraph) && !(element is List)) { if (container != null) { container.Add(element); } else { container = new Paragraph(); container.Alignment = cell.HorizontalAlignment; container.Add(element); } } else { IRtfBasicElement[] rtfElements = null; if (container != null) { rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element is Paragraph && ((Paragraph) element).Alignment == Element.ALIGN_UNDEFINED) { ((Paragraph) element).Alignment = cell.HorizontalAlignment; } rtfElements = this.document.GetMapper().MapElement(element); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } } catch (DocumentException) { } } if (container != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(container); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } } // does it have image info? Image img = cell.Image; if (img != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(img); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } // does it have phrase info? Phrase phrase = cell.Phrase; if (phrase != null) { try { IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(phrase); for (int i = 0; i < rtfElements.Length; i++) { rtfElements[i].SetInTable(true); this.content.Add(rtfElements[i]); } } catch (DocumentException) { } } // does it have table info? PdfPTable table = cell.Table; if (table != null) { this.Add(table); // try { // RtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(table); // for (int i = 0; i < rtfElements.length; i++) { // rtfElements[i].SetInTable(true); // this.content.Add(rtfElements[i]); // } // } catch (DocumentException e) { // // TODO Auto-generated catch block // e.PrintStackTrace(); // } } }