aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java85
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java64
-rw-r--r--src/java/org/apache/fop/render/rtf/TableAttributesConverter.java5
3 files changed, 122 insertions, 32 deletions
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index 86210b07a..a6c08747f 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -38,6 +38,7 @@ import org.apache.fop.area.Block;
import org.apache.fop.area.BlockViewport;
import org.apache.fop.area.CTM;
import org.apache.fop.area.NormalFlow;
+import org.apache.fop.area.RegionReference;
import org.apache.fop.area.RegionViewport;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.ForeignObject;
@@ -96,19 +97,20 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
*/
protected void handleRegionTraits(RegionViewport region) {
Rectangle2D viewArea = region.getViewArea();
+ RegionReference referenceArea = region.getRegionReference();
float startx = (float)(viewArea.getX() / 1000f);
float starty = (float)(viewArea.getY() / 1000f);
float width = (float)(viewArea.getWidth() / 1000f);
float height = (float)(viewArea.getHeight() / 1000f);
- if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) {
- currentBPPosition = region.getBorderAndPaddingWidthBefore();
- currentIPPosition = region.getBorderAndPaddingWidthStart();
- }
- drawBackAndBorders(region, startx, starty, width, height);
+ // adjust the current position according to region borders and padding
+ currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore();
+ currentIPPosition = referenceArea.getBorderAndPaddingWidthStart();
+ // draw background (traits are in the RegionViewport)
+ // and borders (traits are in the RegionReference)
+ drawBackAndBorders(region, referenceArea, startx, starty, width, height);
}
-
/**
* Draw the background and borders.
* This draws the background and border traits for an area given
@@ -123,14 +125,57 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
protected void drawBackAndBorders(Area area,
float startx, float starty,
float width, float height) {
+ drawBackAndBorders(area, area, startx, starty, width, height);
+ }
+
+ /**
+ * Draw the background and borders.
+ * This draws the background and border traits for an area given
+ * the position.
+ *
+ * @param backgroundArea the area to get the background traits from
+ * @param borderArea the area to get the border traits from
+ * @param startx the start x position
+ * @param starty the start y position
+ * @param width the width of the area
+ * @param height the height of the area
+ */
+ protected void drawBackAndBorders(Area backgroundArea, Area borderArea,
+ float startx, float starty,
+ float width, float height) {
// draw background then border
- BorderProps bpsBefore = (BorderProps)area.getTrait(Trait.BORDER_BEFORE);
- BorderProps bpsAfter = (BorderProps)area.getTrait(Trait.BORDER_AFTER);
- BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START);
- BorderProps bpsEnd = (BorderProps)area.getTrait(Trait.BORDER_END);
+ BorderProps bpsBefore = (BorderProps)borderArea.getTrait(Trait.BORDER_BEFORE);
+ BorderProps bpsAfter = (BorderProps)borderArea.getTrait(Trait.BORDER_AFTER);
+ BorderProps bpsStart = (BorderProps)borderArea.getTrait(Trait.BORDER_START);
+ BorderProps bpsEnd = (BorderProps)borderArea.getTrait(Trait.BORDER_END);
- Trait.Background back = (Trait.Background)area.getTrait(Trait.BACKGROUND);
+ drawBackground(startx, starty, width, height,
+ (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND),
+ bpsBefore, bpsAfter, bpsStart, bpsEnd);
+ drawBorders(startx, starty, width, height,
+ bpsBefore, bpsAfter, bpsStart, bpsEnd);
+ }
+
+ /**
+ * Draw the background.
+ * This draws the background given the position and the traits.
+ *
+ * @param startx the start x position
+ * @param starty the start y position
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param back the background traits
+ * @param bpsBefore the border-before traits
+ * @param bpsAfter the border-after traits
+ * @param bpsStart the border-start traits
+ * @param bpsEnd the border-end traits
+ */
+ protected void drawBackground(float startx, float starty,
+ float width, float height,
+ Trait.Background back,
+ BorderProps bpsBefore, BorderProps bpsAfter,
+ BorderProps bpsStart, BorderProps bpsEnd) {
if (back != null) {
endTextObject();
@@ -201,7 +246,25 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
restoreGraphicsState();
}
}
+ }
+ /**
+ * Draw the borders.
+ * This draws the border traits given the position and the traits.
+ *
+ * @param startx the start x position
+ * @param starty the start y position
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param bpsBefore the border-before traits
+ * @param bpsAfter the border-after traits
+ * @param bpsStart the border-start traits
+ * @param bpsEnd the border-end traits
+ */
+ protected void drawBorders(float startx, float starty,
+ float width, float height,
+ BorderProps bpsBefore, BorderProps bpsAfter,
+ BorderProps bpsStart, BorderProps bpsEnd) {
Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index 05aade551..6171e68b4 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -76,6 +76,8 @@ import org.apache.fop.fo.flow.ListItemLabel;
import org.apache.fop.fo.flow.PageNumber;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.flow.table.TableColumn;
import org.apache.fop.fo.flow.table.TableHeader;
@@ -611,25 +613,29 @@ public class RTFHandler extends FOEventHandler {
/**
* {@inheritDoc}
*/
- public void startHeader(TableBody th) {
+ public void startHeader(TableHeader header) {
+ startPart(header);
}
/**
* {@inheritDoc}
*/
- public void endHeader(TableBody th) {
+ public void endHeader(TableHeader header) {
+ endPart(header);
}
/**
* {@inheritDoc}
*/
- public void startFooter(TableBody tf) {
+ public void startFooter(TableFooter footer) {
+ startPart(footer);
}
/**
* {@inheritDoc}
*/
- public void endFooter(TableBody tf) {
+ public void endFooter(TableFooter footer) {
+ endPart(footer);
}
/**
@@ -687,31 +693,25 @@ public class RTFHandler extends FOEventHandler {
}
}
- /**
- * {@inheritDoc}
- */
- public void startBody(TableBody tb) {
+ private void startPart(TablePart part) {
if (bDefer) {
return;
}
try {
- RtfAttributes atts = TableAttributesConverter.convertTableBodyAttributes(tb);
+ RtfAttributes atts = TableAttributesConverter.convertTablePartAttributes(part);
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(atts);
} catch (IOException ioe) {
handleIOTrouble(ioe);
} catch (Exception e) {
- log.error("startBody: " + e.getMessage());
+ log.error("startPart: " + e.getMessage());
throw new RuntimeException(e.getMessage());
- }
+ }
}
- /**
- * {@inheritDoc}
- */
- public void endBody(TableBody tb) {
+ private void endPart(TablePart tb) {
if (bDefer) {
return;
}
@@ -722,9 +722,25 @@ public class RTFHandler extends FOEventHandler {
} catch (IOException ioe) {
handleIOTrouble(ioe);
} catch (Exception e) {
- log.error("endBody: " + e.getMessage());
+ log.error("endPart: " + e.getMessage());
throw new RuntimeException(e.getMessage());
- }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void startBody(TableBody body) {
+ startPart(body);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void endBody(TableBody body) {
+ endPart(body);
}
/**
@@ -1552,7 +1568,7 @@ public class RTFHandler extends FOEventHandler {
} else if (foNode instanceof FOText) {
if (bStart) {
FOText text = (FOText) foNode;
- text(text, text.ca, text.startIndex, text.endIndex);
+ text(text, text.getCharArray(), 0, text.length());
}
} else if (foNode instanceof Character) {
if (bStart) {
@@ -1607,6 +1623,18 @@ public class RTFHandler extends FOEventHandler {
} else {
endTable( (Table) foNode);
}
+ } else if (foNode instanceof TableHeader) {
+ if (bStart) {
+ startHeader( (TableHeader) foNode);
+ } else {
+ endHeader( (TableHeader) foNode);
+ }
+ } else if (foNode instanceof TableFooter) {
+ if (bStart) {
+ startFooter( (TableFooter) foNode);
+ } else {
+ endFooter( (TableFooter) foNode);
+ }
} else if (foNode instanceof TableBody) {
if (bStart) {
startBody( (TableBody) foNode);
diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
index 677832418..a28d91d36 100644
--- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
@@ -24,12 +24,11 @@ import java.awt.Color;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.flow.table.TableHeader;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.FixedLength;
import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
@@ -91,7 +90,7 @@ public final class TableAttributesConverter {
*
* @throws ConverterException On convertion error
*/
- static RtfAttributes convertTableBodyAttributes(TableBody fobj)
+ static RtfAttributes convertTablePartAttributes(TablePart part)
throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
return attrib;