aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFinn Bock <bckfnn@apache.org>2004-01-29 19:45:48 +0000
committerFinn Bock <bckfnn@apache.org>2004-01-29 19:45:48 +0000
commitc5823e6381fe8a48bf93bfde6cb9d57bdd5f652b (patch)
tree308fe469de2ff66dfb168900a286976e427c54ae /src
parentdabb2c3f3886d15176eef1c701bd7e616b474c5e (diff)
downloadxmlgraphics-fop-c5823e6381fe8a48bf93bfde6cb9d57bdd5f652b.tar.gz
xmlgraphics-fop-c5823e6381fe8a48bf93bfde6cb9d57bdd5f652b.zip
Handle SPACE_START trait for block areas.
PR: 25802. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197296 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/AbstractRenderer.java30
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java71
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderer.java4
3 files changed, 73 insertions, 32 deletions
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index bdc924864..13b874379 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -374,7 +374,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
protected void renderRegion(RegionReference region) {
List blocks = region.getBlocks();
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
@@ -406,7 +406,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
protected void renderBeforeFloat(BeforeFloat bf) {
List blocks = bf.getChildAreas();
if (blocks != null) {
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
Block sep = bf.getSeparator();
if (sep != null) {
renderBlock(sep);
@@ -426,7 +426,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
if (sep != null) {
renderBlock(sep);
}
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
}
@@ -471,7 +471,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
// the normal flow reference area contains stacked blocks
List blocks = flow.getChildAreas();
if (blocks != null) {
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
}
@@ -506,7 +506,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
startVParea(ctm);
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
endVParea();
// clip if necessary
@@ -514,16 +514,26 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
currentIPPosition = saveIP;
currentBPPosition = saveBP;
} else {
- renderBlocks(children);
+ // save position and offset
+ int saveIP = currentIPPosition;
+ int saveBP = currentBPPosition;
+
+ handleBlockTraits(bv);
+ renderBlocks(bv, children);
+
+ currentIPPosition = saveIP;
+ currentBPPosition = saveBP + bv.getHeight();
}
}
/**
* Renders a list of block areas.
*
+ * @param parent the parent block if the parent is a block, otherwise
+ * a null value.
* @param blocks The block areas
*/
- protected void renderBlocks(List blocks) {
+ protected void renderBlocks(Block parent, List blocks) {
// the position of the containing block is used for
// absolutely positioned areas
int contBP = currentBPPosition;
@@ -575,7 +585,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
handleBlockTraits(block);
- renderBlocks(children);
+ renderBlocks(block, children);
// absolute blocks do not effect the layout
currentBPPosition = saveBP;
@@ -586,7 +596,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
handleBlockTraits(block);
- renderBlocks(children);
+ renderBlocks(block, children);
// stacked and relative blocks effect stacking
currentBPPosition = saveBP + block.getHeight();
@@ -649,7 +659,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled
int saveBP = currentBPPosition;
List blocks = cont.getBlocks();
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
currentIPPosition = saveIP;
currentBlockIPPosition = saveBlockIP;
currentBPPosition = saveBP;
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index 571f14a6e..de20910ed 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -504,15 +504,39 @@ public class PDFRenderer extends PrintRenderer {
}
/**
- * @see org.apache.fop.render.AbstractRenderer#renderBlock(Block)
+ * @see org.apache.fop.render.AbstractRenderer#renderBlocks(Block, List)
*/
- protected void renderBlock(Block block) {
- int marginOffset = IPMarginOffset;
- super.renderBlock(block);
- // super.renderBlock() may render child blocks (with their own offsets)
- // so need to restore (this parent's) IPMarginOffset when finished.
- IPMarginOffset = marginOffset;
- }
+ protected void renderBlocks(Block block, List blocks) {
+ int saveIPMargin = IPMarginOffset;
+ int saveBPMargin = BPMarginOffset;
+ if (block != null) {
+ Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START);
+ if (spaceStart != null) {
+ IPMarginOffset += spaceStart.intValue();
+ }
+
+ Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
+ if (paddingStart != null) {
+ IPMarginOffset += paddingStart.intValue();
+ }
+ Integer paddingBefore= (Integer) block.getTrait(Trait.PADDING_BEFORE);
+ if (paddingBefore != null) {
+ BPMarginOffset += paddingBefore.intValue();
+ }
+
+ BorderProps borderStartWidth = (BorderProps) block.getTrait(Trait.BORDER_START);
+ if (borderStartWidth != null) {
+ IPMarginOffset += borderStartWidth.width;
+ }
+ BorderProps borderBeforeWidth = (BorderProps) block.getTrait(Trait.BORDER_BEFORE);
+ if (borderBeforeWidth != null) {
+ BPMarginOffset += borderBeforeWidth.width;
+ }
+ }
+ super.renderBlocks(block, blocks);
+ IPMarginOffset = saveIPMargin;
+ BPMarginOffset = saveBPMargin;
+ }
/**
* Handle the traits for a region
@@ -550,15 +574,23 @@ public class PDFRenderer extends PrintRenderer {
/* IPMarginOffset for a particular block = region border +
* region padding + parent block padding + current block padding
*/
- Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
- if (paddingStart != null) {
- IPMarginOffset += paddingStart.intValue();
- }
float startx = (currentIPPosition + IPMarginOffset) / 1000f;
float starty = (currentBPPosition + BPMarginOffset) / 1000f;
+ float width = block.getWidth() / 1000f;
+
+ Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START);
+ if (spaceStart != null) {
+ startx += spaceStart.floatValue() / 1000;
+ width -= spaceStart.floatValue() / 1000;
+ }
+ Integer spaceEnd = (Integer) block.getTrait(Trait.SPACE_END);
+ if (spaceEnd != null) {
+ width -= spaceEnd.floatValue() / 1000;
+ }
+
drawBackAndBorders(block, startx, starty,
- block.getWidth() / 1000f, block.getHeight() / 1000f);
+ width, block.getHeight() / 1000f);
}
/**
@@ -730,7 +762,7 @@ public class PDFRenderer extends PrintRenderer {
startVParea(ctm);
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
endVParea();
if (bv.getClip()) {
@@ -780,7 +812,7 @@ public class PDFRenderer extends PrintRenderer {
startVParea(ctm);
}
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
if (ctm != null) {
endVParea();
}
@@ -836,8 +868,8 @@ public class PDFRenderer extends PrintRenderer {
* @param ip the inline parent area
*/
public void renderInlineParent(InlineParent ip) {
- float start = currentBlockIPPosition / 1000f;
- float top = (ip.getOffset() + currentBPPosition) / 1000f;
+ float start = (currentBlockIPPosition + IPMarginOffset) / 1000f;
+ float top = (ip.getOffset() + currentBPPosition + BPMarginOffset) / 1000f;
float width = ip.getWidth() / 1000f;
float height = ip.getHeight() / 1000f;
drawBackAndBorders(ip, start, top, width, height);
@@ -1175,11 +1207,10 @@ public class PDFRenderer extends PrintRenderer {
saveGraphicsState();
currentStream.add(((float) w) + " 0 0 "
+ ((float) -h) + " "
- + (((float) currentBlockIPPosition) / 1000f + x) + " "
- + (((float)(currentBPPosition + 1000 * h)) / 1000f
+ + (((float) currentBlockIPPosition + IPMarginOffset) / 1000f + x) + " "
+ + (((float)(currentBPPosition + BPMarginOffset + 1000 * h)) / 1000f
+ y) + " cm\n" + "/Im" + xobj + " Do\n");
restoreGraphicsState();
-
}
/**
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index bc2062b7d..724f5df06 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -565,7 +565,7 @@ public class PSRenderer extends AbstractRenderer {
startVParea(ctm);
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
endVParea();
if (bv.getClip()) {
@@ -615,7 +615,7 @@ public class PSRenderer extends AbstractRenderer {
startVParea(ctm);
}
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
if (ctm != null) {
endVParea();
}