protected void renderRegion(RegionReference region) {
List blocks = region.getBlocks();
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
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);
if (sep != null) {
renderBlock(sep);
}
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
}
// the normal flow reference area contains stacked blocks
List blocks = flow.getChildAreas();
if (blocks != null) {
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
}
}
startVParea(ctm);
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
endVParea();
// clip if necessary
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;
handleBlockTraits(block);
- renderBlocks(children);
+ renderBlocks(block, children);
// absolute blocks do not effect the layout
currentBPPosition = saveBP;
handleBlockTraits(block);
- renderBlocks(children);
+ renderBlocks(block, children);
// stacked and relative blocks effect stacking
currentBPPosition = saveBP + block.getHeight();
int saveBP = currentBPPosition;
List blocks = cont.getBlocks();
- renderBlocks(blocks);
+ renderBlocks(null, blocks);
currentIPPosition = saveIP;
currentBlockIPPosition = saveBlockIP;
currentBPPosition = saveBP;
}
/**
- * @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
/* 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);
}
/**
startVParea(ctm);
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
endVParea();
if (bv.getClip()) {
startVParea(ctm);
}
handleBlockTraits(bv);
- renderBlocks(children);
+ renderBlocks(bv, children);
if (ctm != null) {
endVParea();
}
* @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);
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();
-
}
/**