Hi, Please have a look at the attached FO file and the resulting PDF.
If I replace margin-top with space-before on the outer block, I get the expected result. I’ve tried to look at the code but I’ve trouble finding my way in the part that deals with properties. However, in FOPropertyMapping there is a setUseParent(true) for the space-before property. I don’t really understand the purpose of this method but that looks suspicious to me. From what I figured out from a debugging session, when getting the value of space-before, the inner blocks first look if the corresponding absolute property (margin-top) is set. It is not on those blocks, but it is on the parent outer-block, so they get the answer yes. So they try to retrieve the value of this property, but as it isn’t set on the inner block they get null. Thus they put the default value of 0 for space-before. Setting setUseParent to false seems to solve the problem and doesn’t break any testcase, but I’d prefer to have confirmation from property experts (see attached patch). Same issue for space-after, by the way. Thanks, Vincent
<?xml version="1.0" encoding="UTF-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="a4" margin="5mm" page-width="210mm" page-height="297mm"> <fo:region-body/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="a4"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:block space-before="20pt">First Line</fo:block> <fo:block space-before="20pt">Second Line</fo:block> <fo:block space-before="20pt">Third Line</fo:block> </fo:block> <fo:block id="outer-block" margin-top="1in" background-color="yellow"> <fo:block space-before="20pt">First Line</fo:block> <fo:block space-before="20pt">Second Line</fo:block> <fo:block space-before="20pt">Third Line</fo:block> </fo:block> </fo:flow> </fo:page-sequence> </fo:root>
res.pdf
Description: Adobe PDF document
Index: src/java/org/apache/fop/fo/FOPropertyMapping.java
===================================================================
--- src/java/org/apache/fop/fo/FOPropertyMapping.java (revision 592399)
+++ src/java/org/apache/fop/fo/FOPropertyMapping.java (working copy)
@@ -1141,7 +1141,7 @@
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT);
- corr.setUseParent(true);
+ corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-before", m);
@@ -1150,7 +1150,7 @@
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT);
- corr.setUseParent(true);
+ corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-after", m);
