From 0e77a21e89c79f08a5f55f245081a767572279a4 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 17 Feb 2005 09:17:36 +0000 Subject: [PATCH] Fix for bad page-master and region margin calculations. All margin calculations now use margin-* attributes directly, ignoring start|end-indent and space-*. Better check for borders and padding on regions. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198436 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/pagination/Region.java | 36 +++++++++++-------- .../apache/fop/fo/pagination/RegionBody.java | 21 ++++------- .../layoutmgr/PageSequenceLayoutManager.java | 12 ++----- 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index c92404c77..0d3aa6991 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; /** @@ -79,6 +80,12 @@ public abstract class Region extends FObj { + " is not permitted.", locator); } } + + if (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false) != 0 + || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false) != 0) { + throw new PropertyException("Border and padding for a region " + + "must be '0' (See 6.4.13 in XSL 1.0)."); + } } /** @@ -90,6 +97,10 @@ public abstract class Region extends FObj { invalidChildError(loc, nsURI, localName); } + /** + * @param pageRefRect reference dimension of the page area. + * @return the rectangle for the viewport area + */ public abstract Rectangle getViewportRectangle(FODimension pageRefRect); /** @@ -132,36 +143,33 @@ public abstract class Region extends FObj { } /** - * Return the Common Border, Padding, and Background Properties. + * @return the Background Properties (border and padding are not used here). */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { return commonBorderPaddingBackground; } - /** - * Return the "region-name" property. - */ + /** @return the "region-name" property. */ public String getRegionName() { return regionName; } - /** - * Return the "writing-mode" property. - */ + /** @return the "writing-mode" property. */ public int getWritingMode() { return writingMode; } - /** - * Return the "overflow" property. - */ + /** @return the "overflow" property. */ public int getOverflow() { return overflow; } - /** - * Return the "reference-orientation" property. - */ + /** @return the display-align property. */ + public int getDisplayAlign() { + return displayAlign; + } + + /** @return the "reference-orientation" property. */ public int getReferenceOrientation() { return referenceOrientation.getValue(); } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 0f7a26464..47fb7e8e8 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -81,20 +81,13 @@ public class RegionBody extends Region { * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ public Rectangle getViewportRectangle (FODimension reldims) { - /* - * 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. - */ - int start = commonMarginBlock.startIndent.getValue(); - int end = commonMarginBlock.endIndent.getValue(); - int before = commonMarginBlock.spaceBefore.getOptimum().getLength().getValue(); - int after = commonMarginBlock.spaceAfter.getOptimum().getLength().getValue(); - return new Rectangle(start, before, - reldims.ipd - start - end, - reldims.bpd - before - after); + int left = commonMarginBlock.marginLeft.getValue(); + int right = commonMarginBlock.marginRight.getValue(); + int top = commonMarginBlock.marginTop.getValue(); + int bottom = commonMarginBlock.marginBottom.getValue(); + return new Rectangle(left, top, + reldims.ipd - left - right, + reldims.bpd - top - bottom); } /** diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 922a9e207..47f313798 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -486,9 +486,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { RegionViewport rv = curPage.getPage().getRegionViewport( FO_REGION_BODY); curBody = (BodyRegion) rv.getRegion(); - flowBPD = (int) curBody.getBPD() - - rv.getBorderAndPaddingWidthBefore() - - rv.getBorderAndPaddingWidthAfter(); + flowBPD = (int) curBody.getBPD(); return curPage; } @@ -805,11 +803,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { // transforming it using the page CTM RegionViewport rv = new RegionViewport(absRegionRect); rv.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE); - if (r.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false) != 0 - || r.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false) != 0) { - log.error("Border and padding for a region must be '0'."); - //See 6.4.13 in XSL 1.0 - } rv.setBPD((int)relRegionRect.getHeight()); rv.setIPD((int)relRegionRect.getWidth()); setRegionViewportTraits(r, rv); @@ -824,8 +817,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { * @param r the region viewport */ private void setRegionViewportTraits(Region r, RegionViewport rv) { - // Common Border, Padding, and Background Properties - TraitSetter.addBorders(rv, r.getCommonBorderPaddingBackground()); + // Apply Background Properties, no border and padding on region viewports TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground()); } -- 2.39.5