/* $Id$ */
+package org.apache.fop.render.rtf;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf;
-
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes;
/** Constants for RTF border attribute names, and a static method for converting
* fo attribute strings. */
-public class BorderAttributesConverter {
+public final class BorderAttributesConverter {
+ /**
+ * Constructor is private, because it's just a utility class.
+ */
+ private BorderAttributesConverter() {
+ }
+
/**
* Create a border control word in attributes, with border properties
* as specified in color, style and width.
return this;
}
+ /**
+ * Set an attribute that has a Color value.
+ * @param name name of attribute
+ * @param color value of attribute
+ * @return this (which now contains the new entry)
+ */
public RtfAttributes set(String name, ColorType color) {
int redComponent = ColorTypeProperty.convertChannelToInteger (color.getRed());
int greenComponent = ColorTypeProperty.convertChannelToInteger (color.getGreen());
int blueComponent = ColorTypeProperty.convertChannelToInteger (color.getBlue());
set(name, RtfColorTable.getInstance().getColorNumber(
- redComponent,greenComponent, blueComponent).intValue());
+ redComponent, greenComponent, blueComponent).intValue());
return this;
}
}
* for the JFOR project and is now integrated into FOP.
*/
-class FoUnitsConverter {
+final class FoUnitsConverter {
private static final FoUnitsConverter INSTANCE = new FoUnitsConverter();
/** points to twips: 1 twip is 1/20 of a point */
/** convert a font size given in points like "12pt" */
int convertFontSize(String size) throws FOPException {
size = size.trim();
- final String FONT_SUFFIX = "pt";
- if (!size.endsWith(FONT_SUFFIX)) {
+ final String sFONTSUFFIX = "pt";
+ if (!size.endsWith(sFONTSUFFIX)) {
throw new FOPException("Invalid font size '" + size + "', must end with '"
- + FONT_SUFFIX + "'");
+ + sFONTSUFFIX + "'");
}
float result = 0;
- size = size.substring(0, size.length() - FONT_SUFFIX.length());
+ size = size.substring(0, size.length() - sFONTSUFFIX.length());
try {
result = (Float.valueOf(size).floatValue());
} catch (Exception e) {
/**
* Provides methods to convert list attributes to RtfAttributes.
*/
-public class ListAttributesConverter {
+public final class ListAttributesConverter {
+ /**
+ * Constructor is private, because it's just a utility class.
+ */
+ private ListAttributesConverter() {
+ }
+ /**
+ * Reads an FO object's properties and adds returns them as RtfAttributes.
+ * @param fobj FO object
+ * @return RtfAttributes object which contains the read values.
+ * @throws FOPException Thrown when an IO-problem occurs.
+ */
static RtfAttributes convertAttributes(ListBlock fobj)
throws FOPException {
/* $Id$ */
-
package org.apache.fop.render.rtf;
import org.apache.commons.logging.Log;
* @author Peter Herweg, pherweg@web.de
*/
-class PageAttributesConverter {
+final class PageAttributesConverter {
private static Log log = new SimpleLog("FOP/RTF");
+ /**
+ * Constructor is private, because it's just a utility class.
+ */
+ private PageAttributesConverter() {
+ }
+
/** convert xsl:fo attributes to RTF text attributes */
static RtfAttributes convertPageAttributes(SimplePageMaster pagemaster) {
FOPRtfAttributes attrib = new FOPRtfAttributes();
import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FOText;
import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
TableContext tableContext = new TableContext(builderContext);
try {
- RtfAttributes atts
- = TableAttributesConverter.convertTableAttributes(tbl);
-
final IRtfTableContainer tc
= (IRtfTableContainer)builderContext.getContainer(
- IRtfTableContainer.class, true, null);
- builderContext.pushContainer(tc.newTable(atts, tableContext));
+ IRtfTableContainer.class, true, null);
+
+ RtfAttributes atts
+ = TableAttributesConverter.convertTableAttributes(tbl);
+
+ RtfTable table = tc.newTable(atts, tableContext);
+
+ CommonBorderPaddingBackground border = tbl.getCommonBorderPaddingBackground();
+ RtfAttributes borderAttributes = new RtfAttributes();
+
+ BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.BEFORE,
+ borderAttributes, ITableAttributes.CELL_BORDER_TOP);
+ BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.AFTER,
+ borderAttributes, ITableAttributes.CELL_BORDER_BOTTOM);
+ BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.START,
+ borderAttributes, ITableAttributes.CELL_BORDER_LEFT);
+ BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.END,
+ borderAttributes, ITableAttributes.CELL_BORDER_RIGHT);
+
+ table.setBorderAttributes(borderAttributes);
+
+ builderContext.pushContainer(table);
} catch (Exception e) {
log.error("startTable:" + e.getMessage());
throw new RuntimeException(e.getMessage());
/**
* Helper class for converting SVG to bitmap images.
*/
-public class SVGConverter {
+public final class SVGConverter {
/** logger instance */
private static Log log = LogFactory.getLog(SVGConverter.class);
+ /**
+ * Constructor is private, because it's just a utility class.
+ */
+ private SVGConverter() {
+ }
+
/**
* Converts a SVG image to a JPEG bitmap.
* @param image the SVG image
* Provides methods to convert the attributes to RtfAttributes.
*/
-public class TableAttributesConverter {
+public final class TableAttributesConverter {
private static Log log = new SimpleLog("FOP/RTF");
//////////////////////////////////////////////////
/**
- * Constructor.
+ * Constructor is private, because it's just a utility class.
*/
private TableAttributesConverter() {
}
* @author Chris Scott
* @author rmarra
*/
-class TextAttributesConverter {
+final class TextAttributesConverter {
+
+ /**
+ * Constructor is private, because it's just a utility class.
+ */
+ private TextAttributesConverter() {
+ }
/**
* Converts all known text FO properties to RtfAttributes
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.exceptions;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.exceptions;
-
/** Base class for rtflib exceptions.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.exceptions;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.exceptions;
-
/** Thrown when a method call would lead to an invalid RTF document structure.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
private RtfTableRow row;
private int highestRow = 0;
private Boolean isNestedTable = null;
+ private RtfAttributes borderAttributes = null;
/** Added by Boris Poudérous on 07/22/2002 in order to process
* number-columns-spanned attribute */
return null;
}
+
+ /**
+ * Sets the RtfAttributes for the borders of the table.
+ * @param attributes Border attributes of the table.
+ */
+ public void setBorderAttributes(RtfAttributes attributes) {
+ borderAttributes = attributes;
+ }
+
+ /**
+ * Returns the RtfAttributes for the borders of the table.
+ * @return Border attributes of the table.
+ */
+ public RtfAttributes getBorderAttributes() {
+ return borderAttributes;
+ }
}
xPos = ((Integer)leftIndent).intValue();
}
+ RtfAttributes tableBorderAttributes = getTable().getBorderAttributes();
+
int index = 0;
for (Iterator it = getChildren().iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
if (e instanceof RtfTableCell) {
- // Added by Normand Masse
+
+ RtfTableCell rtfcell = (RtfTableCell)e;
+
// Adjust the cell's display attributes so the table's/row's borders
// are drawn properly.
- RtfTableCell rtfcell = (RtfTableCell)e;
+
+ // get border attributes from table
+ if (index == 0) {
+ if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_LEFT)) {
+ rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_LEFT,
+ (RtfAttributes) tableBorderAttributes.getValue(
+ ITableAttributes.CELL_BORDER_LEFT));
+ }
+ }
+
+ if (index == this.getChildCount() - 1) {
+ if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_RIGHT)) {
+ rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_RIGHT,
+ (RtfAttributes) tableBorderAttributes.getValue(
+ ITableAttributes.CELL_BORDER_RIGHT));
+ }
+ }
+
+ if (isFirstRow()) {
+ if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_TOP)) {
+ rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
+ (RtfAttributes) (RtfAttributes) tableBorderAttributes.getValue(
+ ITableAttributes.CELL_BORDER_TOP));
+ }
+ }
+
+ if ((parentTable != null) && (parentTable.isHighestRow(id))) {
+ if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_BOTTOM)) {
+ rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_BOTTOM,
+ (RtfAttributes) tableBorderAttributes.getValue(
+ ITableAttributes.CELL_BORDER_BOTTOM));
+ }
+ }
+
+ // get border attributes from row
if (index == 0) {
if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_LEFT)) {
rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_LEFT,
- (String)attrib.getValue(ITableAttributes.ROW_BORDER_LEFT));
+ (String) attrib.getValue(ITableAttributes.ROW_BORDER_LEFT));
}
}
if (index == this.getChildCount() - 1) {
if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_RIGHT)) {
rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_RIGHT,
- (String)attrib.getValue(ITableAttributes.ROW_BORDER_RIGHT));
+ (String) attrib.getValue(ITableAttributes.ROW_BORDER_RIGHT));
}
}
if (isFirstRow()) {
if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_TOP)) {
rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
- (String)attrib.getValue(ITableAttributes.ROW_BORDER_TOP));
+ (String) attrib.getValue(ITableAttributes.ROW_BORDER_TOP));
}
}
if ((parentTable != null) && (parentTable.isHighestRow(id))) {
if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_BOTTOM)) {
rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_BOTTOM,
- (String)attrib.getValue(ITableAttributes.ROW_BORDER_BOTTOM));
+ (String) attrib.getValue(ITableAttributes.ROW_BORDER_BOTTOM));
}
}
+ // write cell's definition
xPos = rtfcell.writeCellDef(xPos);
}
index++; // Added by Boris POUDEROUS on 2002/07/02