use of com.lowagie.text.rtf.style.RtfColor in project itext2 by albfernandez.
the class RtfListLevel method writeDefinition.
public void writeDefinition(final OutputStream result) throws IOException {
result.write(OPEN_GROUP);
result.write(LIST_LEVEL);
result.write(LIST_LEVEL_TYPE);
switch(this.listType) {
case LIST_TYPE_BULLET:
result.write(intToByteArray(23));
break;
case LIST_TYPE_NUMBERED:
result.write(intToByteArray(0));
break;
case LIST_TYPE_UPPER_LETTERS:
result.write(intToByteArray(3));
break;
case LIST_TYPE_LOWER_LETTERS:
result.write(intToByteArray(4));
break;
case LIST_TYPE_UPPER_ROMAN:
result.write(intToByteArray(1));
break;
case LIST_TYPE_LOWER_ROMAN:
result.write(intToByteArray(2));
break;
/* New types */
case LIST_TYPE_ARABIC:
result.write(intToByteArray(0));
break;
case LIST_TYPE_UPPERCASE_ROMAN_NUMERAL:
result.write(intToByteArray(1));
break;
case LIST_TYPE_LOWERCASE_ROMAN_NUMERAL:
result.write(intToByteArray(2));
break;
case LIST_TYPE_UPPERCASE_LETTER:
result.write(intToByteArray(3));
break;
case LIST_TYPE_ORDINAL_NUMBER:
result.write(intToByteArray(4));
break;
case LIST_TYPE_CARDINAL_TEXT_NUMBER:
result.write(intToByteArray(5));
break;
case LIST_TYPE_ORDINAL_TEXT_NUMBER:
result.write(intToByteArray(6));
break;
case LIST_TYPE_LOWERCASE_LETTER:
result.write(intToByteArray(7));
break;
case LIST_TYPE_ARABIC_LEADING_ZERO:
result.write(intToByteArray(22));
break;
case LIST_TYPE_NO_NUMBER:
result.write(intToByteArray(255));
break;
default:
// catch all for other unsupported types
if (this.listType >= RtfListLevel.LIST_TYPE_BASE) {
result.write(intToByteArray(this.listType - RtfListLevel.LIST_TYPE_BASE));
}
break;
}
result.write(LIST_LEVEL_TYPE_NEW);
switch(this.listType) {
case LIST_TYPE_BULLET:
result.write(intToByteArray(23));
break;
case LIST_TYPE_NUMBERED:
result.write(intToByteArray(0));
break;
case LIST_TYPE_UPPER_LETTERS:
result.write(intToByteArray(3));
break;
case LIST_TYPE_LOWER_LETTERS:
result.write(intToByteArray(4));
break;
case LIST_TYPE_UPPER_ROMAN:
result.write(intToByteArray(1));
break;
case LIST_TYPE_LOWER_ROMAN:
result.write(intToByteArray(2));
break;
/* New types */
case LIST_TYPE_ARABIC:
result.write(intToByteArray(0));
break;
case LIST_TYPE_UPPERCASE_ROMAN_NUMERAL:
result.write(intToByteArray(1));
break;
case LIST_TYPE_LOWERCASE_ROMAN_NUMERAL:
result.write(intToByteArray(2));
break;
case LIST_TYPE_UPPERCASE_LETTER:
result.write(intToByteArray(3));
break;
case LIST_TYPE_ORDINAL_NUMBER:
result.write(intToByteArray(4));
break;
case LIST_TYPE_CARDINAL_TEXT_NUMBER:
result.write(intToByteArray(5));
break;
case LIST_TYPE_ORDINAL_TEXT_NUMBER:
result.write(intToByteArray(6));
break;
case LIST_TYPE_LOWERCASE_LETTER:
result.write(intToByteArray(7));
break;
case LIST_TYPE_ARABIC_LEADING_ZERO:
result.write(intToByteArray(22));
break;
case LIST_TYPE_NO_NUMBER:
result.write(intToByteArray(255));
break;
default:
// catch all for other unsupported types
if (this.listType >= RtfListLevel.LIST_TYPE_BASE) {
result.write(intToByteArray(this.listType - RtfListLevel.LIST_TYPE_BASE));
}
break;
}
result.write(LIST_LEVEL_ALIGNMENT);
result.write(intToByteArray(0));
result.write(LIST_LEVEL_ALIGNMENT_NEW);
result.write(intToByteArray(0));
result.write(LIST_LEVEL_FOLOW);
result.write(intToByteArray(levelFollowValue));
result.write(LIST_LEVEL_START_AT);
result.write(intToByteArray(this.listStartAt));
if (this.isTentative) {
result.write(LIST_LEVEL_TENTATIVE);
}
if (this.isLegal) {
result.write(LIST_LEVEL_LEGAL);
}
result.write(LIST_LEVEL_SPACE);
result.write(intToByteArray(0));
result.write(LIST_LEVEL_INDENT);
result.write(intToByteArray(0));
if (levelPicture != -1) {
result.write(LIST_LEVEL_PICTURE);
result.write(intToByteArray(levelPicture));
}
// { leveltext
result.write(OPEN_GROUP);
result.write(LIST_LEVEL_TEXT);
result.write(LIST_LEVEL_TEMPLATE_ID);
result.write(intToByteArray(this.templateID));
// TODO Needs to be rewritten to support 1-9 levels, not just simple single level
if (this.listType != LIST_TYPE_BULLET) {
result.write(LIST_LEVEL_STYLE_NUMBERED_BEGIN);
if (this.levelTextNumber < 10) {
result.write(intToByteArray(0));
}
result.write(intToByteArray(this.levelTextNumber));
result.write(LIST_LEVEL_STYLE_NUMBERED_END);
} else {
result.write(LIST_LEVEL_STYLE_BULLETED_BEGIN);
this.document.filterSpecialChar(result, this.bulletCharacter, false, false);
result.write(LIST_LEVEL_STYLE_BULLETED_END);
}
// } leveltext
result.write(CLOSE_GROUP);
// { levelnumbers
result.write(OPEN_GROUP);
result.write(LIST_LEVEL_NUMBERS_BEGIN);
if (this.listType != LIST_TYPE_BULLET) {
result.write(LIST_LEVEL_NUMBERS_NUMBERED);
}
result.write(LIST_LEVEL_NUMBERS_END);
// { levelnumbers
result.write(CLOSE_GROUP);
// write properties now
result.write(RtfFontList.FONT_NUMBER);
if (this.listType != LIST_TYPE_BULLET) {
result.write(intToByteArray(fontNumber.getFontNumber()));
} else {
result.write(intToByteArray(fontBullet.getFontNumber()));
}
result.write(DocWriter.getISOBytes("\\cf"));
// document.getDocumentHeader().getColorNumber(new RtfColor(this.document,this.getFontNumber().getColor()));
result.write(intToByteArray(document.getDocumentHeader().getColorNumber(new RtfColor(this.document, this.getFontNumber().getColor()))));
writeIndentation(result);
result.write(CLOSE_GROUP);
this.document.outputDebugLinebreak(result);
}
use of com.lowagie.text.rtf.style.RtfColor in project itext2 by albfernandez.
the class RtfCell method importCell.
/**
* 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.getColspan();
this.rowspan = cell.getRowspan();
if (cell.getRowspan() > 1) {
this.mergeType = MERGE_VERT_PARENT;
}
if (cell instanceof RtfCell) {
this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, ((RtfCell) cell).getBorders());
} else {
this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.getBorder(), cell.getBorderWidth(), cell.getBorderColor());
}
this.verticalAlignment = cell.getVerticalAlignment();
if (cell.getBackgroundColor() == null) {
this.backgroundColor = new RtfColor(this.document, 255, 255, 255);
} else {
this.backgroundColor = new RtfColor(this.document, cell.getBackgroundColor());
}
this.cellPadding = (int) this.parentRow.getParentTable().getCellPadding();
Iterator cellIterator = cell.getElements();
Paragraph container = null;
while (cellIterator.hasNext()) {
try {
Element element = (Element) cellIterator.next();
// should we wrap it in a paragraph
if (!(element instanceof Paragraph) && !(element instanceof List)) {
if (container != null) {
container.add(element);
} else {
container = new Paragraph();
container.setAlignment(cell.getHorizontalAlignment());
container.add(element);
}
} else {
if (container != null) {
RtfBasicElement[] 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;
}
// with that of enclosing cell
if (element instanceof Paragraph && ((Paragraph) element).getAlignment() == Element.ALIGN_UNDEFINED) {
((Paragraph) element).setAlignment(cell.getHorizontalAlignment());
}
RtfBasicElement[] 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 de) {
de.printStackTrace();
}
}
if (container != null) {
try {
RtfBasicElement[] 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 de) {
de.printStackTrace();
}
}
}
use of com.lowagie.text.rtf.style.RtfColor in project itext2 by albfernandez.
the class RtfCell method importCell.
/**
* 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.getPaddingBottom();
this.cellPaddingTop = cell.getPaddingTop();
this.cellPaddingRight = cell.getPaddingRight();
this.cellPaddingLeft = cell.getPaddingLeft();
// BORDERS
this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.getBorder(), cell.getBorderWidth(), cell.getBorderColor());
// border colors
this.border = cell.getBorder();
this.borderColor = cell.getBorderColor();
this.borderColorBottom = cell.getBorderColorBottom();
this.borderColorTop = cell.getBorderColorTop();
this.borderColorLeft = cell.getBorderColorLeft();
this.borderColorRight = cell.getBorderColorRight();
// border widths
this.borderWidth = cell.getBorderWidth();
this.borderWidthBottom = cell.getBorderWidthBottom();
this.borderWidthTop = cell.getBorderWidthTop();
this.borderWidthLeft = cell.getBorderWidthLeft();
this.borderWidthRight = cell.getBorderWidthRight();
this.colspan = cell.getColspan();
// cell.getRowspan();
this.rowspan = 1;
// if(cell.getRowspan() > 1) {
// this.mergeType = MERGE_VERT_PARENT;
// }
this.verticalAlignment = cell.getVerticalAlignment();
if (cell.getBackgroundColor() == null) {
this.backgroundColor = new RtfColor(this.document, 255, 255, 255);
} else {
this.backgroundColor = new RtfColor(this.document, cell.getBackgroundColor());
}
// does it have column composite info?
java.util.List compositeElements = cell.getCompositeElements();
if (compositeElements != null) {
Iterator cellIterator = compositeElements.iterator();
// does it have column info?
Paragraph container = null;
while (cellIterator.hasNext()) {
try {
Element element = (Element) cellIterator.next();
// should we wrap it in a paragraph
if (!(element instanceof Paragraph) && !(element instanceof List)) {
if (container != null) {
container.add(element);
} else {
container = new Paragraph();
container.setAlignment(cell.getHorizontalAlignment());
container.add(element);
}
} else {
if (container != null) {
RtfBasicElement[] 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;
}
// with that of enclosing cell
if (element instanceof Paragraph && ((Paragraph) element).getAlignment() == Element.ALIGN_UNDEFINED) {
((Paragraph) element).setAlignment(cell.getHorizontalAlignment());
}
RtfBasicElement[] 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 de) {
de.printStackTrace();
}
}
if (container != null) {
try {
RtfBasicElement[] 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 de) {
de.printStackTrace();
}
}
}
// does it have image info?
Image img = cell.getImage();
if (img != null) {
try {
RtfBasicElement[] 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 e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// does it have phrase info?
Phrase phrase = cell.getPhrase();
if (phrase != null) {
try {
RtfBasicElement[] 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 e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// does it have table info?
PdfPTable table = cell.getTable();
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();
// }
}
}
use of com.lowagie.text.rtf.style.RtfColor in project itext2 by albfernandez.
the class RtfImportMgr method importColor.
/**
* 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.put(colorNr, Integer.toString(rtfColor.getColorNumber()));
}
Aggregations