/** * Gets the number of the specified RtfColor * * @param color The RtfColor for which to get the number * @return The number of the color */ public int GetColorNumber(ST.RtfColor color) { return(this.colorList.GetColorNumber(color)); }
/** * 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(); // } } }
/** * Constructs a RtfChunk based on the content of a Chunk * * @param doc The RtfDocument that this Chunk belongs to * @param chunk The Chunk that this RtfChunk is based on */ public RtfChunk(RtfDocument doc, Chunk chunk) : base(doc) { if (chunk == null) { return; } if (chunk.Attributes != null && chunk.Attributes[Chunk.SUBSUPSCRIPT] != null) { this.superSubScript = (float)chunk.Attributes[Chunk.SUBSUPSCRIPT]; } if (chunk.Attributes != null && chunk.Attributes[Chunk.BACKGROUND] != null) { this.background = new RtfColor(this.document, (Color) ((Object[]) chunk.Attributes[Chunk.BACKGROUND])[0]); } font = new ST.RtfFont(doc, chunk.Font); content = chunk.Content; }
/** * 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(); }
/** * 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) { } } }
/** * Returns the index of the given RtfColor in the colour list. If the RtfColor * is not in the list of colours, then it is added. * * @param color The RtfColor for which to get the index * @return The index of the RtfColor */ public int GetColorNumber(RtfColor color) { int colorIndex = -1; for (int i = 0; i < colorList.Count; i++) { if (colorList[i].Equals(color)) { colorIndex = i; } } if (colorIndex == -1) { colorIndex = colorList.Count; colorList.Add(color); } return colorIndex; }
/** * Constructs a RtfColor as a clone of an existing RtfColor * * @param doc The RtfDocument this RtfColor belongs to * @param col The RtfColor to use as a base */ public RtfColor(RtfDocument doc, RtfColor col) : base(doc) { if (col != null) { this.red = col.GetRed(); this.green = col.GetGreen(); this.blue = col.GetBlue(); } if (this.document != null) { this.colorNumber = this.document.GetDocumentHeader().GetColorNumber(this); } }
/** * Constructs a RtfBorder * * @param doc The RtfDocument this RtfBorder belongs to * @param borderType The type of border this RtfBorder is * @param borderPosition The position of this RtfBorder * @param borderStyle The style of this RtfBorder * @param borderWidth The width of this RtfBorder * @param borderColor The colour of this RtfBorder */ protected internal RtfBorder(RtfDocument doc, int borderType, int borderPosition, int borderStyle, float borderWidth, Color borderColor) : base(doc) { this.borderType = borderType; this.borderPosition = borderPosition; this.borderStyle = borderStyle; if (borderWidth > 2) { borderWidth = 2; } this.borderWidth = (int) (borderWidth * TWIPS_FACTOR); if (this.borderWidth == 0) { this.borderStyle = BORDER_NONE; } if (borderColor == null) { this.borderColor = new RtfColor(this.document, new Color(0, 0, 0)); } else { this.borderColor = new RtfColor(this.document, borderColor); } }
/** * Imports a color value. The color number for the color defined * by its red, green and blue values is determined and then the * resulting mapping is added. * * @param colorNr The original color number. * @param color The color to import. */ public void ImportColor(String colorNr, Color color) { RtfColor rtfColor = new RtfColor(this.rtfDoc, color); this.importColorMapping[colorNr] = rtfColor.GetColorNumber().ToString(); }
/** * Makes a copy of the given RtfBorder * * @param doc The RtfDocument this RtfBorder belongs to * @param borderType The border type of this RtfBorder * @param border The RtfBorder to copy */ protected internal RtfBorder(RtfDocument doc, int borderType, RtfBorder border) : base(doc) { this.borderType = borderType; this.borderPosition = border.GetBorderPosition(); this.borderStyle = border.GetBorderStyle(); this.borderWidth = border.GetBorderWidth(); this.borderColor = new RtfColor(this.document, border.GetBorderColor()); }
/** * @see com.lowagie.text.Font#setColor(int, int, int) */ public override void SetColor(int red, int green, int blue) { base.SetColor(red,green,blue); this.color = new RtfColor(document, red, green, blue); }
/** * Special constructor for the default font * * @param doc The RtfDocument this font appears in * @param fontNumber The id of this font */ protected internal RtfFont(RtfDocument doc, int fontNumber) { this.document = doc; this.fontNumber = fontNumber; color = new RtfColor(doc, 0, 0, 0); }
/** * @see com.lowagie.text.Font#setColor(int, int, int) */ public override void SetColor(int red, int green, int blue) { base.SetColor(red, green, blue); this.color = new RtfColor(document, red, green, blue); }