From: Karen Lease Date: Sat, 23 Feb 2002 16:50:58 +0000 (+0000) Subject: Correct margin handling on body region for writing-mode X-Git-Tag: fop-0_20_4-doc~134 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=76705cc4238b38ecec2e4088b48358cbe3231934;p=xmlgraphics-fop.git Correct margin handling on body region for writing-mode git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194669 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 5a6429ed2..b2132c330 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -13,7 +13,9 @@ import java.awt.geom.Rectangle2D; // FOP import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.Property; import org.apache.fop.fo.properties.Overflow; import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.FODimension; @@ -32,22 +34,35 @@ public class RegionBody extends Region { protected Rectangle getViewportRectangle (FODimension reldims) { - // Common Margin Properties-Block - // Need these in writing-mode relative coordinates - // Or shall we get absolute and transform to relative using writing mode? + /* + * Use space-before and space-after which will use corresponding + * absolute margin properties if specified. For indents: + * try to get corresponding absolute margin property using the + * writing-mode on the page (not on the region-body!). If that's not + * set but indent is explicitly set, it will return that. + */ MarginProps mProps = propMgr.getMarginProps(); - /** - System.err.println("BodyRegion margin props=" + mProps.startIndent + "," - + mProps.spaceBefore + "," + mProps.endIndent + "," - + mProps.spaceAfter); - - return new Rectangle( mProps.startIndent, mProps.spaceBefore, - reldims.ipd - mProps.startIndent - mProps.endIndent, - reldims.bpd - mProps.spaceBefore - mProps.spaceAfter); - **/ - return new Rectangle( mProps.marginLeft, mProps.marginTop, - reldims.ipd - mProps.marginLeft - mProps.marginRight, - reldims.bpd - mProps.marginTop - mProps.marginBottom); + int start = getRelMargin(PropertyList.START, "start-indent"); + return new Rectangle( start, mProps.spaceBefore, + reldims.ipd - start - + getRelMargin(PropertyList.END, "end-indent"), + reldims.bpd - mProps.spaceBefore - + mProps.spaceAfter); + } + + /** + * Get the relative margin using parent's writing mode, not own + * writing mode. + */ + private int getRelMargin(int reldir, String sRelPropName) { + FObj parent = (FObj) getParent(); + String sPropName = "margin-" + + parent.properties.wmRelToAbs(reldir); + Property prop = properties.getExplicitBaseProp(sPropName); + if (prop == null) { + prop = properties.getExplicitBaseProp(sRelPropName); + } + return ((prop != null)? prop.getLength().mvalue() : 0); } protected void setRegionTraits(RegionReference r, Rectangle2D absRegVPRect) { diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index 9cd1dea09..73be3f0e2 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -125,6 +125,10 @@ public class SimplePageMaster extends FObj { properties = null; } + public boolean generatesReferenceAreas() { + return true; + } + public PageMaster getPageMaster() { return this.pageMaster; } diff --git a/src/org/apache/fop/layout/MarginProps.java b/src/org/apache/fop/layout/MarginProps.java index 2d8bfcf32..793fb8acf 100644 --- a/src/org/apache/fop/layout/MarginProps.java +++ b/src/org/apache/fop/layout/MarginProps.java @@ -8,7 +8,7 @@ package org.apache.fop.layout; /** - * Store all hyphenation related properties on an FO. + * Store all block-level margin related properties on an FO. * Public "structure" allows direct member access. */ public class MarginProps {