You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ph...@apache.org on 2006/02/19 17:56:47 UTC
svn commit: r378923 - in
/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf: ./
rtflib/exceptions/ rtflib/rtfdoc/
Author: pherweg
Date: Sun Feb 19 08:56:45 2006
New Revision: 378923
URL: http://svn.apache.org/viewcvs?rev=378923&view=rev
Log:
added support for borders at fo:table; fixed a few checkstyle warnings
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/SVGConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java Sun Feb 19 08:56:45 2006
@@ -16,6 +16,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -24,8 +25,6 @@
* 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;
@@ -35,8 +34,14 @@
/** 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.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java Sun Feb 19 08:56:45 2006
@@ -63,12 +63,18 @@
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;
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java Sun Feb 19 08:56:45 2006
@@ -35,7 +35,7 @@
* 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 */
@@ -124,14 +124,14 @@
/** 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) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java Sun Feb 19 08:56:45 2006
@@ -36,9 +36,20 @@
/**
* 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 {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java Sun Feb 19 08:56:45 2006
@@ -16,7 +16,6 @@
/* $Id$ */
-
package org.apache.fop.render.rtf;
import org.apache.commons.logging.Log;
@@ -37,10 +36,16 @@
* @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();
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Sun Feb 19 08:56:45 2006
@@ -63,6 +63,7 @@
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;
@@ -497,13 +498,30 @@
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());
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/SVGConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/SVGConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/SVGConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/SVGConverter.java Sun Feb 19 08:56:45 2006
@@ -31,11 +31,17 @@
/**
* 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
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java Sun Feb 19 08:56:45 2006
@@ -48,7 +48,7 @@
* Provides methods to convert the attributes to RtfAttributes.
*/
-public class TableAttributesConverter {
+public final class TableAttributesConverter {
private static Log log = new SimpleLog("FOP/RTF");
@@ -57,7 +57,7 @@
//////////////////////////////////////////////////
/**
- * Constructor.
+ * Constructor is private, because it's just a utility class.
*/
private TableAttributesConverter() {
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Sun Feb 19 08:56:45 2006
@@ -50,7 +50,13 @@
* @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
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java Sun Feb 19 08:56:45 2006
@@ -16,6 +16,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.exceptions;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -23,8 +24,6 @@
* contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
* the FOP project.
*/
-
-package org.apache.fop.render.rtf.rtflib.exceptions;
/** Base class for rtflib exceptions.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java Sun Feb 19 08:56:45 2006
@@ -16,6 +16,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.exceptions;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -23,8 +24,6 @@
* contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
* 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
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java Sun Feb 19 08:56:45 2006
@@ -36,6 +36,7 @@
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 */
@@ -208,5 +209,21 @@
}
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;
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java?rev=378923&r1=378922&r2=378923&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java Sun Feb 19 08:56:45 2006
@@ -186,42 +186,81 @@
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
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org