]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #36487:
authorJeremias Maerki <jeremias@apache.org>
Mon, 5 Sep 2005 08:09:42 +0000 (08:09 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 5 Sep 2005 08:09:42 +0000 (08:09 +0000)
Background images were incorrectly positioned in some absolute positioned blocks.
Some additional attributes output by the XMLRenderer.
Refactored the layout for e-g and i-f-o. Introduced common base classes for the
corresponding flow objects as well as the e-g and i-f-o LMs.
Fixed incorrectly applied margins on region-body when writing mode is not lr.
Fixed application of correct percent base for margins and extents on regions
when the reference orientation is 90 degrees.
Fixed incorrectly positioned regions when writing mode is different between the
simple-page-master setting and the setting on the region.
Several updates to the layout engine test cases.
Submitted by: Manuel Mall <mm.at.arcus.com.au>

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278690 13f79535-47bb-0310-9956-ffa450edef68

34 files changed:
src/java/org/apache/fop/area/Page.java
src/java/org/apache/fop/fo/flow/AbstractGraphics.java [new file with mode: 0644]
src/java/org/apache/fop/fo/flow/ExternalGraphic.java
src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
src/java/org/apache/fop/fo/pagination/Region.java
src/java/org/apache/fop/fo/pagination/RegionAfter.java
src/java/org/apache/fop/fo/pagination/RegionBefore.java
src/java/org/apache/fop/fo/pagination/RegionBody.java
src/java/org/apache/fop/fo/pagination/RegionEnd.java
src/java/org/apache/fop/fo/pagination/RegionStart.java
src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
test/layoutengine/disabled-testcases.txt
test/layoutengine/testcases/block-container_background-image_background-position-relative.xml
test/layoutengine/testcases/external-graphic_basic.xml
test/layoutengine/testcases/external-graphic_border_padding.xml
test/layoutengine/testcases/external-graphic_display-align.xml
test/layoutengine/testcases/inline-container_border_padding.xml [new file with mode: 0644]
test/layoutengine/testcases/inline_border_padding.xml [new file with mode: 0644]
test/layoutengine/testcases/instream-foreign-object_border_padding.xml
test/layoutengine/testcases/instream-foreign-object_display-align.xml
test/layoutengine/testcases/simple-page-master_reference-orientation_0_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_0_writing-mode_rl_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_180_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_180_writing-mode_rl_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_270_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_270_writing-mode_rl_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_90_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_reference-orientation_90_writing-mode_rl_region-body_margin_relative.xml [new file with mode: 0644]
test/layoutengine/testcases/simple-page-master_writing-mode_rl_region-body_writing-mode-lr.xml [new file with mode: 0644]
test/layoutengine/testcases/table-cell_background-image.xml

index 0778fab47287fcc4ca117e9b12b6d75c734093fb..3f03bfa8a00dc4e86378abd47da5db52f276bc2f 100644 (file)
@@ -92,14 +92,21 @@ public class Page implements Serializable, Cloneable {
          * use the LengthBase.BLOCK_WIDTH.
          */
         SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.ipd);
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
+                                            , pageViewPortDims.ipd);
         SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.bpd);
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
+                                            , pageViewPortDims.bpd);
 
-        Rectangle pageRefRect =
-            new Rectangle(mProps.marginLeft.getValue(pageWidthContext), mProps.marginTop.getValue(pageHeightContext),
-            pageViewPortDims.ipd - mProps.marginLeft.getValue(pageWidthContext) - mProps.marginRight.getValue(pageWidthContext),
-            pageViewPortDims.bpd - mProps.marginTop.getValue(pageHeightContext) - mProps.marginBottom.getValue(pageHeightContext));
+        Rectangle pageRefRect 
+            =  new Rectangle(mProps.marginLeft.getValue(pageWidthContext)
+                            , mProps.marginTop.getValue(pageHeightContext)
+                            , pageViewPortDims.ipd 
+                                - mProps.marginLeft.getValue(pageWidthContext) 
+                                - mProps.marginRight.getValue(pageWidthContext)
+                            , pageViewPortDims.bpd 
+                                - mProps.marginTop.getValue(pageHeightContext)
+                                - mProps.marginBottom.getValue(pageHeightContext));
 
         // Set up the CTM on the page reference area based on writing-mode
         // and reference-orientation
@@ -112,7 +119,7 @@ public class Page implements Serializable, Cloneable {
         for (Iterator regenum = spm.getRegions().values().iterator();
             regenum.hasNext();) {
             Region r = (Region)regenum.next();
-            RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, pageViewPortDims);
+            RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, spm);
             if (r.getNameId() == Constants.FO_REGION_BODY) {
                 rr = new BodyRegion((RegionBody) r, rvp);
             } else {
@@ -133,13 +140,15 @@ public class Page implements Serializable, Cloneable {
     
     /**
      * Creates a RegionViewport Area object for this pagination Region.
+     * @param r the region the viewport is to be created for
      * @param reldims relative dimensions
      * @param pageCTM page coordinate transformation matrix
+     * @param spm the simple-page-master for this page
      * @return the new region viewport
      */
     private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM,
-        FODimension pageViewPortDims) {
-        Rectangle2D relRegionRect = r.getViewportRectangle(reldims, pageViewPortDims);
+        SimplePageMaster spm) {
+        Rectangle2D relRegionRect = r.getViewportRectangle(reldims, spm);
         Rectangle2D absRegionRect = pageCTM.transform(relRegionRect);
         // Get the region viewport rectangle in absolute coords by
         // transforming it using the page CTM
diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
new file mode 100644 (file)
index 0000000..b9f360c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAural;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonMarginInline;
+import org.apache.fop.fo.properties.CommonRelativePosition;
+import org.apache.fop.fo.properties.KeepProperty;
+import org.apache.fop.fo.properties.LengthRangeProperty;
+
+/**
+ * Common base class for instream-foreign-object and external-graphics
+ * flow formatting objects.
+ */
+public abstract class AbstractGraphics extends FObj {
+    
+    // The value of properties relevant for fo:instream-foreign-object
+    // and external-graphics.
+    private CommonAccessibility commonAccessibility;
+    private CommonAural commonAural;
+    private CommonBorderPaddingBackground commonBorderPaddingBackground;
+    private CommonMarginInline commonMarginInline;
+    private CommonRelativePosition commonRelativePosition;
+    private Length alignmentAdjust;
+    private int alignmentBaseline;
+    private Length baselineShift;
+    private LengthRangeProperty blockProgressionDimension;
+    // private ToBeImplementedProperty clip;
+    private Length contentHeight;
+    private String contentType;
+    private Length contentWidth;
+    private int displayAlign;
+    private int dominantBaseline;
+    private Length height;
+    private String id;
+    private LengthRangeProperty inlineProgressionDimension;
+    private KeepProperty keepWithNext;
+    private KeepProperty keepWithPrevious;
+    private Length lineHeight;
+    private int overflow;
+    private int scaling;
+    private int scalingMethod;
+    private int textAlign;
+    private int verticalAlign; // shorthand!!!
+    private Length width;
+    // End of property values
+
+    /**
+     * constructs an instream-foreign-object object (called by Maker).
+     *
+     * @param parent the parent formatting object
+     */
+    public AbstractGraphics(FONode parent) {
+        super(parent);
+    }
+
+    /**
+     * @see org.apache.fop.fo.FObj#bind(PropertyList)
+     */
+    public void bind(PropertyList pList) throws FOPException {
+        commonAccessibility = pList.getAccessibilityProps();
+        commonAural = pList.getAuralProps();
+        commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
+        commonMarginInline = pList.getMarginInlineProps();
+        commonRelativePosition = pList.getRelativePositionProps();
+        alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
+        alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
+        baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
+        blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
+        // clip = pList.get(PR_CLIP);
+        contentHeight = pList.get(PR_CONTENT_HEIGHT).getLength();
+        contentType = pList.get(PR_CONTENT_TYPE).getString();
+        contentWidth = pList.get(PR_CONTENT_WIDTH).getLength();
+        displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
+        dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
+        height = pList.get(PR_HEIGHT).getLength();
+        id = pList.get(PR_ID).getString();
+        inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
+        keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
+        keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
+        lineHeight = pList.get(PR_LINE_HEIGHT).getLength();
+        overflow = pList.get(PR_OVERFLOW).getEnum();
+        scaling = pList.get(PR_SCALING).getEnum();
+        scalingMethod = pList.get(PR_SCALING_METHOD).getEnum();
+        textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
+        verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum();
+        width = pList.get(PR_WIDTH).getLength();
+    }
+
+    /**
+     * Given the ipd and the content width calculates the
+     * required x offset based on the text-align property
+     * @param ipd the inline-progression-dimension of the object
+     * @param cwidth the calculated content width of the object
+     * @return the X offset
+     */
+    public int computeXOffset (int ipd, int cwidth) {
+        int xoffset = 0;
+        switch (textAlign) {
+            case EN_CENTER:
+                xoffset = (ipd - cwidth) / 2;
+                break;
+            case EN_END:
+                xoffset = ipd - cwidth;
+                break;
+            case EN_START:
+                break;
+            case EN_JUSTIFY:
+            default:
+                break;
+        }
+        return xoffset;
+    }
+
+    /**
+     * Given the bpd and the content height calculates the
+     * required y offset based on the display-align property
+     * @param bpd the block-progression-dimension of the object
+     * @param cheight the calculated content height of the object
+     * @return the Y offset
+     */
+    public int computeYOffset(int bpd, int cheight) {
+        int yoffset = 0;
+        switch (displayAlign) {
+            case EN_BEFORE:
+                break;
+            case EN_AFTER:
+                yoffset = bpd - cheight;
+                break;
+            case EN_CENTER:
+                yoffset = (bpd - cheight) / 2;
+                break;
+            case EN_AUTO:
+            default:
+                break;
+        }
+        return yoffset;
+    }
+
+    /**
+     * @return the "id" property.
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * @return the Common Border, Padding, and Background Properties.
+     */
+    public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
+        return commonBorderPaddingBackground;
+    }
+
+    /**
+     * @return the "line-height" property.
+     */
+    public Length getLineHeight() {
+        return lineHeight;
+    }
+
+    /**
+     * @return the "inline-progression-dimension" property.
+     */
+    public LengthRangeProperty getInlineProgressionDimension() {
+        return inlineProgressionDimension;
+    }
+
+    /**
+     * @return the "block-progression-dimension" property.
+     */
+    public LengthRangeProperty getBlockProgressionDimension() {
+        return blockProgressionDimension;
+    }
+
+    /**
+     * @return the "height" property.
+     */
+    public Length getHeight() {
+        return height;
+    }
+
+    /**
+     * @return the "width" property.
+     */
+    public Length getWidth() {
+        return width;
+    }
+
+    /**
+     * @return the "content-height" property.
+     */
+    public Length getContentHeight() {
+        return contentHeight;
+    }
+
+    /**
+     * @return the "content-width" property.
+     */
+    public Length getContentWidth() {
+        return contentWidth;
+    }
+
+    /**
+     * @return the "scaling" property.
+     */
+    public int getScaling() {
+        return scaling;
+    }
+
+    /**
+     * @return the "vertical-align" property.
+     */
+    public int getVerticalAlign() {
+        return verticalAlign;
+    }
+
+    /**
+     * @return the "overflow" property.
+     */
+    public int getOverflow() {
+        return overflow;
+    }
+
+    /**
+     * @see org.apache.fop.fo.IntrinsicSizeAccess#getIntrinsicWidth()
+     */
+    public abstract int getIntrinsicWidth();
+
+    /**
+     * @see org.apache.fop.fo.IntrinsicSizeAccess#getIntrinsicHeight()
+     */
+    public abstract int getIntrinsicHeight();
+}
index 156d5bf216302d7506aae089dbbc295f0c3a84f5..5fa54cef480ea44e5f05af099b9b0616b080ecdf 100644 (file)
 
 package org.apache.fop.fo.flow;
 
-import org.xml.sax.Locator;
-
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.Length;
 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.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonMarginInline;
-import org.apache.fop.fo.properties.CommonRelativePosition;
-import org.apache.fop.fo.properties.KeepProperty;
-import org.apache.fop.fo.properties.LengthRangeProperty;
 import org.apache.fop.image.FopImage;
 import org.apache.fop.image.ImageFactory;
+import org.xml.sax.Locator;
 
 /**
  * External graphic formatting object.
  * This FO node handles the external graphic. It creates an image
  * inline area that can be added to the area tree.
  */
-public class ExternalGraphic extends FObj {
+public class ExternalGraphic extends AbstractGraphics {
     
     // The value of properties relevant for fo:external-graphic.
-    private CommonAccessibility commonAccessibility;
-    private CommonAural commonAural;
-    private CommonBorderPaddingBackground commonBorderPaddingBackground;
-    private CommonMarginInline commonMarginInline;
-    private CommonRelativePosition commonRelativePosition;
-    private Length alignmentAdjust;
-    private int alignmentBaseline;
-    private Length baselineShift;
-    private LengthRangeProperty blockProgressionDimension;
-    // private ToBeImplementedProperty clip;
-    private Length contentHeight;
-    private String contentType;
-    private Length contentWidth;
-    private int displayAlign;
-    private int dominantBaseline;
-    private Length height;
-    private String id;
-    private LengthRangeProperty inlineProgressionDimension;
-    private KeepProperty keepWithNext;
-    private KeepProperty keepWithPrevious;
-    private Length lineHeight;
-    private int overflow;
-    private int scaling;
-    private int scalingMethod;
+    // All but one of the e-g properties are kept in AbstractGraphics
     private String src;
-    private int textAlign;
-    private int verticalAlign; //Extra
-    private Length width;
     // End of property values
 
     //Additional values
@@ -91,34 +55,8 @@ public class ExternalGraphic extends FObj {
      * @see org.apache.fop.fo.FObj#bind(PropertyList)
      */
     public void bind(PropertyList pList) throws FOPException {
-        commonAccessibility = pList.getAccessibilityProps();
-        commonAural = pList.getAuralProps();
-        commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
-        commonMarginInline = pList.getMarginInlineProps();
-        commonRelativePosition = pList.getRelativePositionProps();
-        alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
-        alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
-        baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
-        blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
-        // clip = pList.get(PR_CLIP);
-        contentHeight = pList.get(PR_CONTENT_HEIGHT).getLength();
-        contentType = pList.get(PR_CONTENT_TYPE).getString();
-        contentWidth = pList.get(PR_CONTENT_WIDTH).getLength();
-        displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
-        dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
-        height = pList.get(PR_HEIGHT).getLength();
-        id = pList.get(PR_ID).getString();
-        inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
-        keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
-        keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
-        lineHeight = pList.get(PR_LINE_HEIGHT).getLength();
-        overflow = pList.get(PR_OVERFLOW).getEnum();
-        scaling = pList.get(PR_SCALING).getEnum();
-        scalingMethod = pList.get(PR_SCALING_METHOD).getEnum();
+        super.bind(pList);
         src = pList.get(PR_SRC).getString();
-        textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
-        verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum();
-        width = pList.get(PR_WIDTH).getLength();
         
         //Additional processing: preload image
         url = ImageFactory.getURL(getSrc());
@@ -139,7 +77,7 @@ public class ExternalGraphic extends FObj {
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        checkId(id);
+        checkId(getId());
         getFOEventHandler().image(this);
     }
 
@@ -152,83 +90,6 @@ public class ExternalGraphic extends FObj {
             invalidChildError(loc, nsURI, localName);
     }
 
-    /**
-     * @return the Common Border, Padding, and Background Properties.
-     */
-    public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
-        return commonBorderPaddingBackground;
-    }
-
-    /**
-     * @return the Common Margin Properties-Inline.
-     */
-    public CommonMarginInline getCommonMarginInline() {
-        return commonMarginInline;
-    }
-
-    /**
-     * @return the "block-progression-dimension" property.
-     */
-    public LengthRangeProperty getBlockProgressionDimension() {
-        return blockProgressionDimension;
-    }
-
-    /**
-     * @return the "content-height" property.
-     */
-    public Length getContentHeight() {
-        return contentHeight;
-    }
-
-    /**
-     * @return the "content-width" property.
-     */
-    public Length getContentWidth() {
-        return contentWidth;
-    }
-
-    /**
-     * @return the "display-align" property.
-     */
-    public int getDisplayAlign() {
-        return displayAlign;
-    }
-
-    /**
-     * @return the "height" property.
-     */
-    public Length getHeight() {
-        return height;
-    }
-
-    /**
-     * @return the "id" property.
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * @return the "inline-progression-dimension" property.
-     */
-    public LengthRangeProperty getInlineProgressionDimension() {
-        return inlineProgressionDimension;
-    }
-
-    /**
-     * @return the "overflow" property.
-     */
-    public int getOverflow() {
-        return overflow;
-    }
-    
-    /**
-     * @return the "scaling" property.
-     */
-    public int getScaling() {
-        return scaling;
-    }
-
     /**
      * @return the "src" property.
      */
@@ -243,27 +104,6 @@ public class ExternalGraphic extends FObj {
         return url;
     }
 
-    /**
-     * @return the "text-align" property.
-     */
-    public int getTextAlign() {
-        return textAlign;
-    }
-
-    /**
-     * @return the "width" property.
-     */
-    public Length getWidth() {
-        return width;
-    }
-
-    /**
-     * @return the "vertical-align" property.
-     */
-    public int getVerticalAlign() {
-        return verticalAlign;
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index cfe90d07f5c7a71a108676163407785c49e15af0..e59015947a1ae6a710ff2f712260fa72e3bbed66 100644 (file)
 package org.apache.fop.fo.flow;
 
 import java.awt.geom.Point2D;
-
-import org.xml.sax.Locator;
-
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.Length;
 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.XMLObj;
-import org.apache.fop.fo.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonMarginInline;
-import org.apache.fop.fo.properties.CommonRelativePosition;
-import org.apache.fop.fo.properties.KeepProperty;
-import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.xml.sax.Locator;
 
 /**
  * The instream-foreign-object flow formatting object.
  * This is an atomic inline object that contains
  * xml data.
  */
-public class InstreamForeignObject extends FObj {
+public class InstreamForeignObject extends AbstractGraphics {
     
     // The value of properties relevant for fo:instream-foreign-object.
-    private CommonAccessibility commonAccessibility;
-    private CommonAural commonAural;
-    private CommonBorderPaddingBackground commonBorderPaddingBackground;
-    private CommonMarginInline commonMarginInline;
-    private CommonRelativePosition commonRelativePosition;
-    private Length alignmentAdjust;
-    private int alignmentBaseline;
-    private Length baselineShift;
-    private LengthRangeProperty blockProgressionDimension;
-    // private ToBeImplementedProperty clip;
-    private Length contentHeight;
-    private String contentType;
-    private Length contentWidth;
-    private int displayAlign;
-    private int dominantBaseline;
-    private Length height;
-    private String id;
-    private LengthRangeProperty inlineProgressionDimension;
-    private KeepProperty keepWithNext;
-    private KeepProperty keepWithPrevious;
-    private Length lineHeight;
-    private int overflow;
-    private int scaling;
-    private int scalingMethod;
-    private int textAlign;
-    private int verticalAlign; // shorthand!!!
-    private Length width;
+    // All property values contained in AbstractGraphics
     // End of property values
 
     //Additional value
@@ -86,44 +48,11 @@ public class InstreamForeignObject extends FObj {
         super(parent);
     }
 
-    /**
-     * @see org.apache.fop.fo.FObj#bind(PropertyList)
-     */
-    public void bind(PropertyList pList) throws FOPException {
-        commonAccessibility = pList.getAccessibilityProps();
-        commonAural = pList.getAuralProps();
-        commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
-        commonMarginInline = pList.getMarginInlineProps();
-        commonRelativePosition = pList.getRelativePositionProps();
-        alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
-        alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
-        baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
-        blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
-        // clip = pList.get(PR_CLIP);
-        contentHeight = pList.get(PR_CONTENT_HEIGHT).getLength();
-        contentType = pList.get(PR_CONTENT_TYPE).getString();
-        contentWidth = pList.get(PR_CONTENT_WIDTH).getLength();
-        displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
-        dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
-        height = pList.get(PR_HEIGHT).getLength();
-        id = pList.get(PR_ID).getString();
-        inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
-        keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
-        keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
-        lineHeight = pList.get(PR_LINE_HEIGHT).getLength();
-        overflow = pList.get(PR_OVERFLOW).getEnum();
-        scaling = pList.get(PR_SCALING).getEnum();
-        scalingMethod = pList.get(PR_SCALING_METHOD).getEnum();
-        textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
-        verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum();
-        width = pList.get(PR_WIDTH).getLength();
-    }
-
     /**
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        checkId(id);
+        checkId(getId());
     }
 
     /**
@@ -150,126 +79,6 @@ public class InstreamForeignObject extends FObj {
         }
     }
 
-    public int computeXOffset (int ipd, int cwidth) {
-        int xoffset = 0;
-        switch (textAlign) {
-            case EN_CENTER:
-                xoffset = (ipd - cwidth) / 2;
-                break;
-            case EN_END:
-                xoffset = ipd - cwidth;
-                break;
-            case EN_START:
-                break;
-            case EN_JUSTIFY:
-            default:
-                break;
-        }
-        return xoffset;
-    }
-
-    public int computeYOffset(int bpd, int cheight) {
-        int yoffset = 0;
-        switch (displayAlign) {
-            case EN_BEFORE:
-                break;
-            case EN_AFTER:
-                yoffset = bpd - cheight;
-                break;
-            case EN_CENTER:
-                yoffset = (bpd - cheight) / 2;
-                break;
-            case EN_AUTO:
-            default:
-                break;
-        }
-        return yoffset;
-    }
-
-    /**
-     * @return the "id" property.
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * @return the Common Border, Padding, and Background Properties.
-     */
-    public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
-        return commonBorderPaddingBackground;
-    }
-
-    /**
-     * @return the "line-height" property.
-     */
-    public Length getLineHeight() {
-        return lineHeight;
-    }
-
-    /**
-     * @return the "inline-progression-dimension" property.
-     */
-    public LengthRangeProperty getInlineProgressionDimension() {
-        return inlineProgressionDimension;
-    }
-
-    /**
-     * @return the "block-progression-dimension" property.
-     */
-    public LengthRangeProperty getBlockProgressionDimension() {
-        return blockProgressionDimension;
-    }
-
-    /**
-     * @return the "height" property.
-     */
-    public Length getHeight() {
-        return height;
-    }
-
-    /**
-     * @return the "width" property.
-     */
-    public Length getWidth() {
-        return width;
-    }
-
-    /**
-     * @return the "content-height" property.
-     */
-    public Length getContentHeight() {
-        return contentHeight;
-    }
-
-    /**
-     * @return the "content-width" property.
-     */
-    public Length getContentWidth() {
-        return contentWidth;
-    }
-
-    /**
-     * @return the "scaling" property.
-     */
-    public int getScaling() {
-        return scaling;
-    }
-
-    /**
-     * @return the "vertical-align" property.
-     */
-    public int getVerticalAlign() {
-        return verticalAlign;
-    }
-
-    /**
-     * @return the "overflow" property.
-     */
-    public int getOverflow() {
-        return overflow;
-    }
-
     /**
      * @see org.apache.fop.fo.FObj#getName()
      */
index 4980d057e68a1621979b08a8a2bca6e01d45a9cb..756b2be03fed59e14643cf97ad70dffc0381ecdd 100644 (file)
@@ -99,11 +99,11 @@ public abstract class Region extends FObj {
 
     /**
      * @param pageRefRect reference dimension of the page area.
-     * @param pageViewRectRect page view port dimensions.
+     * @param spm the simple page master this region belongs to.
      * @return the rectangle for the viewport area
      */
     public abstract Rectangle getViewportRectangle(FODimension pageRefRect
-                                            , FODimension pageViewPortRect);
+                                                   , SimplePageMaster spm);
 
     /**
      * Returns the default region name (xsl-region-before, xsl-region-start,
index 68d6d066d6402ba3e2eab6433e27c6fcc8cfe7e6..776f9d76473d5a4330e79e64281ef81b99e3d900 100644 (file)
@@ -40,31 +40,43 @@ public class RegionAfter extends RegionBA {
     }
 
     /**
-     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
      */
-    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
-        // Depends on extent, precedence ans writing mode
-        /* Special rules apply to resolving extent.
-         * In the property subsystem the extent property is configured to 
-         * using BLOCK_WIDTH as its percent base.
-         * However, depending on the writing mode extent import resolved either
-         * against the page width or the page height.
+    public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+        /* Special rules apply to resolving extent as values are resolved relative 
+         * to the page size and reference orientation.
          */
-        Rectangle vpRect;
-        SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
-        SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext pageWidthContext;
+        SimplePercentBaseContext pageHeightContext;
+        if (spm.getReferenceOrientation() % 180 == 0) {
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageWidth().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageHeight().getValue());
+        } else {
+            // invert width and height since top left are rotated by 90 (cl or ccl)
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageHeight().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageWidth().getValue());
+        }
         SimplePercentBaseContext neighbourContext;
-        if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+        Rectangle vpRect;
+        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageWidthContext;
-            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext), reldims.ipd, getExtent().getValue(pageHeightContext));
+            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext)
+                                   , reldims.ipd, getExtent().getValue(pageHeightContext));
         } else {
             neighbourContext = pageHeightContext;
-            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext), getExtent().getValue(pageWidthContext), reldims.ipd);
+            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext)
+                                   , getExtent().getValue(pageWidthContext), reldims.ipd);
         }
         if (getPrecedence() == EN_FALSE) {
-            adjustIPD(vpRect, getWritingMode(), neighbourContext);
+            adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
         }
         return vpRect;
     }
index c1f683c05ccbc9c0ea0d30259616c55745b23924..53279e4da1efe043f4efdd7b08a7e113b611c2de 100644 (file)
@@ -46,28 +46,33 @@ public class RegionBefore extends RegionBA {
     }
 
     /**
-     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
      */
-    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
-        // Depends on extent, precedence and writing mode
-        // This should return rectangle in writing-mode coordinates relative
-        // to the page-reference area rectangle
-        // This means the origin is (start, before) and the dimensions are (ipd,bpd)
-        // Before is always 0, start depends on extent
-        // ipd depends on precedence, bpd=extent
-        /* Special rules apply to resolving extent.
-         * In the property subsystem the extent property is configured to 
-         * using BLOCK_WIDTH as its percent base.
-         * However, depending on the writing mode extent import resolved either
-         * against the page width or the page height.
+    public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+        /* Special rules apply to resolving extent as values are resolved relative 
+         * to the page size and reference orientation.
          */
-        Rectangle vpRect;
-        SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
-        SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext pageWidthContext;
+        SimplePercentBaseContext pageHeightContext;
+        if (spm.getReferenceOrientation() % 180 == 0) {
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageWidth().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageHeight().getValue());
+        } else {
+            // invert width and height since top left are rotated by 90 (cl or ccl)
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageHeight().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageWidth().getValue());
+        }
         SimplePercentBaseContext neighbourContext;
-        if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+        Rectangle vpRect;
+        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
         } else {
@@ -75,7 +80,7 @@ public class RegionBefore extends RegionBA {
             vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
         }
         if (getPrecedence() == EN_FALSE) {
-            adjustIPD(vpRect, getWritingMode(), neighbourContext);
+            adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
         }
         return vpRect;
     }
index 835802469ef224740eee8dfcaa61905b52321cca..855b2747f4e3f8f33892d1776e78364674dd8845 100644 (file)
@@ -63,13 +63,14 @@ public class RegionBody extends Region {
              * these cases, but we will need to be able to change Numeric
              * values in order to do this.
              */
-            attributeError("If overflow property is set to \"scroll\"," +
-                    " a column-count other than \"1\" may not be specified.");
+            attributeError("If overflow property is set to \"scroll\"," 
+                    " a column-count other than \"1\" may not be specified.");
         }
     }
 
     /**
      * Return the Common Margin Properties-Block.
+     * @return the Common Margin Properties-Block.
      */
     public CommonMarginBlock getCommonMarginBlock() {
         return commonMarginBlock;
@@ -77,6 +78,7 @@ public class RegionBody extends Region {
 
     /**
      * Return the "column-count" property.
+     * @return the "column-count" property.
      */
     public int getColumnCount() {
         return columnCount.getValue();
@@ -84,35 +86,60 @@ public class RegionBody extends Region {
 
     /**
      * Return the "column-gap" property.
+     * @return the "column-gap" property.
      */
     public int getColumnGap() {
         return columnGap.getValue();
     }
 
     /**
-     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
      */
-    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
+    public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
         /* Special rules apply to resolving margins in the page context.
          * Contrary to normal margins in this case top and bottom margin
          * are resolved relative to the height. In the property subsystem
          * all margin properties are configured to using BLOCK_WIDTH.
          * That's why we 'cheat' here and setup a context for the height but
          * use the LengthBase.BLOCK_WIDTH.
-         * Also the values are resolved relative to the page size.
+         * Also the values are resolved relative to the page size 
+         * and reference orientation.
          */
-        SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.ipd);
-        SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.bpd);
+        SimplePercentBaseContext pageWidthContext;
+        SimplePercentBaseContext pageHeightContext;
+        if (spm.getReferenceOrientation() % 180 == 0) {
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CONTAINING_BLOCK_WIDTH,
+                                                            spm.getPageWidth().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CONTAINING_BLOCK_WIDTH,
+                                                             spm.getPageHeight().getValue());
+        } else {
+            // invert width and height since top left are rotated by 90 (cl or ccl)
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CONTAINING_BLOCK_WIDTH,
+                                                            spm.getPageHeight().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CONTAINING_BLOCK_WIDTH,
+                                                             spm.getPageWidth().getValue());
+        }
 
-        int left = commonMarginBlock.marginLeft.getValue(pageWidthContext);
-        int right = commonMarginBlock.marginRight.getValue(pageWidthContext);
-        int top = commonMarginBlock.marginTop.getValue(pageHeightContext);
-        int bottom = commonMarginBlock.marginBottom.getValue(pageHeightContext);
-        return new Rectangle(left, top,
-                    reldims.ipd - left - right,
-                    reldims.bpd - top - bottom);
+        int start;
+        int end;
+        if (spm.getWritingMode() == EN_LR_TB) { // Left-to-right
+            start = commonMarginBlock.marginLeft.getValue(pageWidthContext);
+            end = commonMarginBlock.marginRight.getValue(pageWidthContext);
+        } else { // all other supported modes are right-to-left
+            start = commonMarginBlock.marginRight.getValue(pageWidthContext);
+            end = commonMarginBlock.marginLeft.getValue(pageWidthContext);
+        }
+        int before = commonMarginBlock.spaceBefore.getOptimum(pageHeightContext)
+                        .getLength().getValue(pageHeightContext);
+        int after = commonMarginBlock.spaceAfter.getOptimum(pageHeightContext)
+                        .getLength().getValue(pageHeightContext);
+        return new Rectangle(start, before,
+                    reldims.ipd - start - end,
+                    reldims.bpd - before - after);
     }
 
     /**
index a097ec3759509d56b1012d8716d8a2700698092f..eadc08992429435b015f66356135ca602ceea395 100644 (file)
@@ -39,23 +39,33 @@ public class RegionEnd extends RegionSE {
     }
 
     /**
-     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
      */
-    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
-        // Depends on extent, precedence and writing mode
-        /* Special rules apply to resolving extent.
-         * In the property subsystem the extent property is configured to 
-         * using BLOCK_WIDTH as its percent base.
-         * However, depending on the writing mode extent import resolved either
-         * against the page width or the page height.
+    public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+        /* Special rules apply to resolving extent as values are resolved relative 
+         * to the page size and reference orientation.
          */
-        Rectangle vpRect;
-        SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
-        SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext pageWidthContext;
+        SimplePercentBaseContext pageHeightContext;
+        if (spm.getReferenceOrientation() % 180 == 0) {
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageWidth().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageHeight().getValue());
+        } else {
+            // invert width and height since top left are rotated by 90 (cl or ccl)
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageHeight().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageWidth().getValue());
+        }
         SimplePercentBaseContext neighbourContext;
-        if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+        Rectangle vpRect;
+        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
                     getExtent().getValue(pageWidthContext), reldims.bpd);
@@ -65,7 +75,7 @@ public class RegionEnd extends RegionSE {
             vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
                     reldims.bpd, getExtent().getValue(pageHeightContext));
         }
-        adjustIPD(vpRect, getWritingMode(), neighbourContext);
+        adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
         return vpRect;
     }
 
index 2de7cc68f3669bfa0ac997ac65c1ee2a05d9ed9e..2d74069bc15c5a0fc49579e4bbf64dfd33237176 100644 (file)
@@ -39,32 +39,40 @@ public class RegionStart extends RegionSE {
     }
 
     /**
-     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+     * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
      */
-    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
-        // Depends on extent, precedence and writing mode
-        // This is the rectangle relative to the page-reference area in
-        // writing-mode relative coordinates
-        /* Special rules apply to resolving extent.
-         * In the property subsystem the extent property is configured to 
-         * using BLOCK_WIDTH as its percent base.
-         * However, depending on the writing mode extent import resolved either
-         * against the page width or the page height.
+    public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+        /* Special rules apply to resolving extent as values are resolved relative 
+         * to the page size and reference orientation.
          */
-        Rectangle vpRect;
-        SimplePercentBaseContext pageWidthContext 
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
-        SimplePercentBaseContext pageHeightContext
-            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext pageWidthContext;
+        SimplePercentBaseContext pageHeightContext;
+        if (spm.getReferenceOrientation() % 180 == 0) {
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageWidth().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageHeight().getValue());
+        } else {
+            // invert width and height since top left are rotated by 90 (cl or ccl)
+            pageWidthContext = new SimplePercentBaseContext(null, 
+                                                            LengthBase.CUSTOM_BASE,
+                                                            spm.getPageHeight().getValue());
+            pageHeightContext = new SimplePercentBaseContext(null,
+                                                             LengthBase.CUSTOM_BASE,
+                                                             spm.getPageWidth().getValue());
+        }
         SimplePercentBaseContext neighbourContext;
-        if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+        Rectangle vpRect;
+        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
         } else {
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext));
         }
-        adjustIPD(vpRect, getWritingMode(), neighbourContext);
+        adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
         return vpRect;
     }
 
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
new file mode 100644 (file)
index 0000000..ec36508
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * Copyright 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.inline;
+
+import java.awt.geom.Rectangle2D;
+import java.util.LinkedList;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Viewport;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.AbstractGraphics;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.TraitSetter;
+
+
+/**
+ * LayoutManager handling the common tasks for the fo:instream-foreign-object 
+ * and fo:external-graphics formatting objects
+ */
+public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManager {
+    
+    protected AbstractGraphics fobj;
+    
+    /**
+     * Constructor
+     * @param node the formatting object that creates this area
+     * @param parent the parent layout manager
+     */
+    public AbstractGraphicsLayoutManager(AbstractGraphics node) {
+        super(node);
+        fobj = node;
+    }
+
+    /**
+     * Get the inline area created by this element.
+     *
+     * @return the viewport inline area
+     */
+    private Viewport getInlineArea() {
+
+        // viewport size is determined by block-progression-dimension
+        // and inline-progression-dimension
+
+        // if replaced then use height then ignore block-progression-dimension
+        //int h = this.propertyList.get("height").getLength().mvalue();
+
+        // use specified line-height then ignore dimension in height direction
+        boolean hasLH = false; //propertyList.get("line-height").getSpecifiedValue() != null;
+
+        Length len;
+
+        int bpd = -1;
+        int ipd = -1;
+        boolean bpdauto = false;
+        if (hasLH) {
+            bpd = fobj.getLineHeight().getValue(this);
+        } else {
+            // this property does not apply when the line-height applies
+            // isn't the block-progression-dimension always in the same
+            // direction as the line height?
+            len = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
+            if (len.getEnum() != EN_AUTO) {
+                bpd = len.getValue(this);
+            } else {
+                len = fobj.getHeight();
+                if (len.getEnum() != EN_AUTO) {
+                    bpd = len.getValue(this);
+                }
+            }
+        }
+
+        len = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
+        if (len.getEnum() != EN_AUTO) {
+            ipd = len.getValue(this);
+        } else {
+            len = fobj.getWidth();
+            if (len.getEnum() != EN_AUTO) {
+                ipd = len.getValue(this);
+            }
+        }
+
+        // if auto then use the intrinsic size of the content scaled
+        // to the content-height and content-width
+        int cwidth = -1;
+        int cheight = -1;
+        len = fobj.getContentWidth();
+        if (len.getEnum() != EN_AUTO) {
+            if (len.getEnum() == EN_SCALE_TO_FIT) {
+                if (ipd != -1) {
+                    cwidth = ipd;
+                }
+            } else {
+                cwidth = len.getValue(this);
+            }
+        }
+        len = fobj.getContentHeight();
+        if (len.getEnum() != EN_AUTO) {
+            if (len.getEnum() == EN_SCALE_TO_FIT) {
+                if (bpd != -1) {
+                    cwidth = bpd;
+                }
+            } else {
+                cheight = len.getValue(this);
+            }
+        }
+
+        int scaling = fobj.getScaling();
+        if ((scaling == EN_UNIFORM) || (cwidth == -1) || cheight == -1) {
+            if (cwidth == -1 && cheight == -1) {
+                cwidth = fobj.getIntrinsicWidth();
+                cheight = fobj.getIntrinsicHeight();
+            } else if (cwidth == -1) {
+                cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight 
+                    / fobj.getIntrinsicHeight());
+            } else if (cheight == -1) {
+                cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth 
+                    / fobj.getIntrinsicWidth());
+            } else {
+                // adjust the larger
+                double rat1 = cwidth / fobj.getIntrinsicWidth();
+                double rat2 = cheight / fobj.getIntrinsicHeight();
+                if (rat1 < rat2) {
+                    // reduce cheight
+                    cheight = (int)(rat1 * fobj.getIntrinsicHeight());
+                } else if (rat1 > rat2) {
+                    cwidth = (int)(rat2 * fobj.getIntrinsicWidth());
+                }
+            }
+        }
+
+        if (ipd == -1) {
+            ipd = cwidth;
+        }
+        if (bpd == -1) {
+            bpd = cheight;
+        }
+
+        boolean clip = false;
+        if (cwidth > ipd || cheight > bpd) {
+            int overflow = fobj.getOverflow();
+            if (overflow == EN_HIDDEN) {
+                clip = true;
+            } else if (overflow == EN_ERROR_IF_OVERFLOW) {
+                fobj.getLogger().error("Object overflows the viewport: clipping");
+                clip = true;
+            }
+        }
+
+        int xoffset = fobj.computeXOffset(ipd, cwidth);
+        int yoffset = fobj.computeYOffset(bpd, cheight);
+
+        CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
+        
+        //Determine extra BPD from borders etc.
+        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
+        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
+                                             false);
+        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
+        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
+        
+        yoffset += beforeBPD;
+        //bpd += beforeBPD;
+        //bpd += afterBPD;
+        
+        //Determine extra IPD from borders etc.
+        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
+                false/*bNotFirst*/, this);
+        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
+                 false/*bNotFirst*/);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this);
+        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        
+        xoffset += startIPD;
+        //ipd += startIPD;
+        //ipd += endIPD;
+
+        Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
+
+        Area viewportArea = getChildArea();
+        TraitSetter.setProducerID(viewportArea, fobj.getId());
+
+        Viewport vp = new Viewport(viewportArea);
+        TraitSetter.setProducerID(vp, fobj.getId());
+        vp.setIPD(ipd);
+        vp.setBPD(bpd);
+        vp.setContentPosition(placement);
+        vp.setClip(clip);
+        vp.setOffset(0);
+
+        // Common Border, Padding, and Background Properties
+        TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this);
+        TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this);
+
+        return vp;
+    }
+    
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
+     */
+    public LinkedList getNextKnuthElements(LayoutContext context,
+                                           int alignment) {
+        Viewport areaCurrent = getInlineArea();
+        setCurrentArea(areaCurrent);
+        setAlignment(fobj.getVerticalAlign());
+        setLead(areaCurrent.getAllocBPD());
+        return super.getNextKnuthElements(context, alignment);
+    }
+    
+    /**
+     * @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId()
+     */
+    protected void addId() {
+        getPSLM().addIDToPage(fobj.getId());
+    }
+
+    /**
+     * Offset this area.
+     * Offset the inline area in the bpd direction when adding the
+     * inline area.
+     * This is used for vertical alignment.
+     * External graphic uses the large allocation rectangle so we have
+     * to take the border/padding into account as well.
+     * @param area the inline area to be updated
+     * @param context the layout context used for adding the area
+     * @see LeafNodeLayoutManager#offsetArea(InlineArae, LayoutContext)
+     */
+    protected void offsetArea(InlineArea area, LayoutContext context) {
+        int bpd = area.getBPD()
+                    + area.getBorderAndPaddingWidthBefore()
+                    + area.getBorderAndPaddingWidthAfter();
+        switch (verticalAlignment) {
+            case EN_MIDDLE:
+                area.setOffset(context.getMiddleBaseline() - bpd / 2);
+            break;
+            case EN_TOP:
+                area.setOffset(context.getTopBaseline());
+            break;
+            case EN_BOTTOM:
+                area.setOffset(context.getBottomBaseline() - bpd);
+            break;
+            case EN_BASELINE:
+            default:
+                area.setOffset(context.getBaseline() - bpd);
+            break;
+        }
+    }
+
+    /**
+     * Returns the image of foreign object area to be put into
+     * the viewport.
+     * @return the appropriate area
+     */
+    abstract Area getChildArea();
+    
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        switch (lengthBase) {
+        case LengthBase.IMAGE_INTRINSIC_WIDTH:
+            return getIntrinsicWidth();
+        case LengthBase.IMAGE_INTRINSIC_HEIGHT:
+            return getIntrinsicHeight();
+        default: // Delegate to super class
+            return super.getBaseLength(lengthBase, fobj);
+        }
+    }
+
+    /**
+     * Returns the intrinsic width of the e-g.
+     * @return the width of the element
+     */
+    protected int getIntrinsicWidth() {
+        return fobj.getIntrinsicWidth();
+    }
+
+    /**
+     * Returns the intrinsic height of the e-g.
+     * @return the height of the element
+     */
+    protected int getIntrinsicHeight() {
+        return fobj.getIntrinsicHeight();
+    }
+
+}
+
index b31b5ea04029775f4d37a9cc944c9e4a0e51083b..e6ddcffbd6f57f5c8fd3acb14e36427aab7eecb4 100644 (file)
 
 package org.apache.fop.layoutmgr.inline;
 
-// Java
 import java.awt.geom.Rectangle2D;
-import java.util.LinkedList;
-
-// FOP
+import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.ExternalGraphic;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.TraitSetter;
+
 
 /**
  * LayoutManager for the fo:external-graphic formatting object
  */
-public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
+public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager {
     
     private ExternalGraphic fobj;
 
-    private int breakAfter;
-    private int breakBefore;
-    private int align;
-    private int startIndent;
-    private int endIndent;
-    private int spaceBefore;
-    private int spaceAfter;
-    private int viewWidth = -1;
-    private int viewHeight = -1;
-    private boolean clip = false;
-    private Rectangle2D placement = null;
-
     /**
      * Constructor
      *
@@ -68,6 +46,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
      * This gets the sizes for the image and the dimensions and clipping.
      * @todo see if can simplify property handling logic
      */
+    /*
     private void setup() {
         // assume lr-tb for now and just use the .optimum value of the range
         Length ipd = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
@@ -195,97 +174,35 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
         afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
         
         yoffset += beforeBPD;
+        viewBPD = viewHeight;
         viewHeight += beforeBPD;
         viewHeight += afterBPD;
         
         //Determine extra IPD from borders etc.
         int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false/*bNotFirst*/, this);
+                false, this);
         startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
-                 false/*bNotFirst*/);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this);
-        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+                 false);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false, this);
+        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false);
         
         xoffset += startIPD;
+        viewIPD = viewWidth;
         viewWidth += startIPD;
         viewWidth += endIPD;
         
         placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
     }
-
-    /**
-     * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
-     */
-    public LinkedList getNextKnuthElements(LayoutContext context,
-                                           int alignment) {
-        setup();
-        InlineArea area = getExternalGraphicInlineArea();
-        setCurrentArea(area);
-        setAlignment(fobj.getVerticalAlign());
-        setLead(viewHeight);
-        return super.getNextKnuthElements(context, alignment);
-    }
-    
-     /**
-      * Get the inline area for this external grpahic.
-      * This creates the image area and puts it inside a viewport.
-      *
-      * @return the viewport containing the image area
-      */
-     public InlineArea getExternalGraphicInlineArea() {
-         Image imArea = new Image(fobj.getSrc());
-         TraitSetter.setProducerID(imArea, fobj.getId());
-         Viewport vp = new Viewport(imArea);
-         TraitSetter.setProducerID(vp, fobj.getId());
-         vp.setIPD(viewWidth);
-         vp.setBPD(viewHeight);
-         vp.setClip(clip);
-         vp.setContentPosition(placement);
-         vp.setOffset(0);
-
-         // Common Border, Padding, and Background Properties
-         TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this);
-         TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this);
-
-         return vp;
-     }
-     
-    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
-    protected void addId() {
-         getPSLM().addIDToPage(fobj.getId());
-     }
-
-    // --------- Property Resolution related functions --------- //
+    */
     
     /**
-     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
-     */
-    public int getBaseLength(int lengthBase, FObj fobj) {
-        switch (lengthBase) {
-        case LengthBase.IMAGE_INTRINSIC_WIDTH:
-            return getIntrinsicWidth();
-        case LengthBase.IMAGE_INTRINSIC_HEIGHT:
-            return getIntrinsicHeight();
-        default: // Delegate to super class
-            return super.getBaseLength(lengthBase, fobj);
-        }
-    }
-
-    /**
-     * Returns the intrinsic width of the e-g.
-     * @return the width of the element
-     */
-    protected int getIntrinsicWidth() {
-        return fobj.getIntrinsicWidth();
-    }
-
-    /**
-     * Returns the intrinsic height of the e-g.
-     * @return the height of the element
+     * Get the inline area created by this element.
+     *
+     * @return the inline area
      */
-    protected int getIntrinsicHeight() {
-        return fobj.getIntrinsicHeight();
+    protected Area getChildArea() {
+        return new Image(fobj.getSrc());
     }
-
+    
 }
 
index 995bfc6c2695efbfee57516be03aab995ff60bf3..4a6865543bdd1520d5c0a5f04577cbf39d005dbd 100644 (file)
 
 package org.apache.fop.layoutmgr.inline;
 
-// Java
-import java.awt.geom.Rectangle2D;
-import java.util.LinkedList;
-
-// FOP
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.fo.XMLObj;
 import org.apache.fop.fo.flow.InstreamForeignObject;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.inline.ForeignObject;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.fo.FObj;
-import org.apache.fop.layoutmgr.LayoutContext;
 
 /**
  * LayoutManager for the fo:instream-foreign-object formatting object
  */
-public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
+public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager {
     
     private InstreamForeignObject fobj;
     
     /**
      * Constructor
      * @param node the formatting object that creates this area
-     * @param parent the parent layout manager
      */
     public InstreamForeignObjectLM(InstreamForeignObject node) {
         super(node);
@@ -54,221 +42,16 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
     /**
      * Get the inline area created by this element.
      *
-     * @return the viewport inline area
+     * @return the inline area
      */
-    private Viewport getInlineArea() {
+    protected Area getChildArea() {
         XMLObj child = (XMLObj) fobj.getChildXMLObj();
 
-        // viewport size is determined by block-progression-dimension
-        // and inline-progression-dimension
-
-        // if replaced then use height then ignore block-progression-dimension
-        //int h = this.propertyList.get("height").getLength().mvalue();
-
-        // use specified line-height then ignore dimension in height direction
-        boolean hasLH = false; //propertyList.get("line-height").getSpecifiedValue() != null;
-
-        Length len;
-
-        int bpd = -1;
-        int ipd = -1;
-        boolean bpdauto = false;
-        if (hasLH) {
-            bpd = fobj.getLineHeight().getValue(this);
-        } else {
-            // this property does not apply when the line-height applies
-            // isn't the block-progression-dimension always in the same
-            // direction as the line height?
-            len = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
-            if (len.getEnum() != EN_AUTO) {
-                bpd = len.getValue(this);
-            } else {
-                len = fobj.getHeight();
-                if (len.getEnum() != EN_AUTO) {
-                    bpd = len.getValue(this);
-                }
-            }
-        }
-
-        len = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
-        if (len.getEnum() != EN_AUTO) {
-            ipd = len.getValue(this);
-        } else {
-            len = fobj.getWidth();
-            if (len.getEnum() != EN_AUTO) {
-                ipd = len.getValue(this);
-            }
-        }
-
-        // if auto then use the intrinsic size of the content scaled
-        // to the content-height and content-width
-        int cwidth = -1;
-        int cheight = -1;
-        len = fobj.getContentWidth();
-        if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
-                if (ipd != -1) {
-                    cwidth = ipd;
-                }
-            } else {
-                cwidth = len.getValue(this);
-            }
-        }
-        len = fobj.getContentHeight();
-        if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
-                if (bpd != -1) {
-                    cwidth = bpd;
-                }
-            } else {
-                cheight = len.getValue(this);
-            }
-        }
-
-        int scaling = fobj.getScaling();
-        if ((scaling == EN_UNIFORM) || (cwidth == -1) || cheight == -1) {
-            if (cwidth == -1 && cheight == -1) {
-                cwidth = fobj.getIntrinsicWidth();
-                cheight = fobj.getIntrinsicHeight();
-            } else if (cwidth == -1) {
-                cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight 
-                    / fobj.getIntrinsicHeight());
-            } else if (cheight == -1) {
-                cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth 
-                    / fobj.getIntrinsicWidth());
-            } else {
-                // adjust the larger
-                double rat1 = cwidth / fobj.getIntrinsicWidth();
-                double rat2 = cheight / fobj.getIntrinsicHeight();
-                if (rat1 < rat2) {
-                    // reduce cheight
-                    cheight = (int)(rat1 * fobj.getIntrinsicHeight());
-                } else if (rat1 > rat2) {
-                    cwidth = (int)(rat2 * fobj.getIntrinsicWidth());
-                }
-            }
-        }
-
-        if (ipd == -1) {
-            ipd = cwidth;
-        }
-        if (bpd == -1) {
-            bpd = cheight;
-        }
-
-        boolean clip = false;
-        if (cwidth > ipd || cheight > bpd) {
-            int overflow = fobj.getOverflow();
-            if (overflow == EN_HIDDEN) {
-                clip = true;
-            } else if (overflow == EN_ERROR_IF_OVERFLOW) {
-                fobj.getLogger().error("Instream foreign object overflows the viewport: clipping");
-                clip = true;
-            }
-        }
-
-        int xoffset = fobj.computeXOffset(ipd, cwidth);
-        int yoffset = fobj.computeYOffset(bpd, cheight);
-
-        CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
-        
-        //Determine extra BPD from borders etc.
-        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
-        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
-                                             false);
-        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
-        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
-        
-        yoffset += beforeBPD;
-        bpd += beforeBPD;
-        bpd += afterBPD;
-        
-        //Determine extra IPD from borders etc.
-        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false/*bNotFirst*/, this);
-        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
-                 false/*bNotFirst*/);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this);
-        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
-        
-        xoffset += startIPD;
-        ipd += startIPD;
-        ipd += endIPD;
-
-        Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
-
         org.w3c.dom.Document doc = child.getDOMDocument();
         String ns = child.getDocumentNamespace();
 
-        //fobj.childNodes = null; This is bad for i-f-o in static-content!!!!!
-        ForeignObject foreign = new ForeignObject(doc, ns);
-        TraitSetter.setProducerID(foreign, fobj.getId());
-
-        Viewport vp = new Viewport(foreign);
-        TraitSetter.setProducerID(vp, fobj.getId());
-        vp.setIPD(ipd);
-        vp.setBPD(bpd);
-        vp.setContentPosition(placement);
-        vp.setClip(clip);
-        vp.setOffset(0);
-
-        // Common Border, Padding, and Background Properties
-        TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this);
-        TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this);
-
-        return vp;
-    }
-    
-    /**
-     * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
-     */
-    public LinkedList getNextKnuthElements(LayoutContext context,
-                                           int alignment) {
-        Viewport areaCurrent = getInlineArea();
-        setCurrentArea(areaCurrent);
-        setAlignment(fobj.getVerticalAlign());
-        setLead(areaCurrent.getBPD());
-        return super.getNextKnuthElements(context, alignment);
-    }
-    
-    /**
-     * @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId()
-     */
-    protected void addId() {
-        getPSLM().addIDToPage(fobj.getId());
+        return new ForeignObject(doc, ns);
     }
-
-    // --------- Property Resolution related functions --------- //
     
-    /**
-     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
-     */
-    public int getBaseLength(int lengthBase, FObj fobj) {
-        switch (lengthBase) {
-        case LengthBase.IMAGE_INTRINSIC_WIDTH:
-            return getIntrinsicWidth();
-        case LengthBase.IMAGE_INTRINSIC_HEIGHT:
-            return getIntrinsicHeight();
-        default: // Delegate to super class
-            return super.getBaseLength(lengthBase, fobj);
-        }
-    }
-
-    /**
-     * Returns the intrinsic width of the e-g.
-     * @return the width of the element
-     */
-    protected int getIntrinsicWidth() {
-        return fobj.getIntrinsicWidth();
-    }
-
-    /**
-     * Returns the intrinsic height of the e-g.
-     * @return the height of the element
-     */
-    protected int getIntrinsicHeight() {
-        return fobj.getIntrinsicHeight();
-    }
-
 }
 
index 398ba939f134096d634b87091785edcf89578430..a89ee7383197f709c923429ea9646d996bdb565d 100644 (file)
@@ -187,8 +187,11 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
                         for (int y = 0; y < vertCount; y++) {
                             // place once
                             Rectangle2D pos;
-                            pos = new Rectangle2D.Float(sx + (x * fopimage.getIntrinsicWidth()),
-                                                        sy + (y * fopimage.getIntrinsicHeight()),
+                            // Image positions are relative to the currentIP/BP
+                            pos = new Rectangle2D.Float(sx - currentIPPosition 
+                                                            + (x * fopimage.getIntrinsicWidth()),
+                                                        sy - currentBPPosition
+                                                            + (y * fopimage.getIntrinsicHeight()),
                                                         fopimage.getIntrinsicWidth(),
                                                         fopimage.getIntrinsicHeight());
                             drawImage(back.getURL(), pos);
index 9622ecc870f507ac2e72c19c1f71621eb89a797c..ba395c984bf1b07ec94eec563daf645547dcf355 100644 (file)
@@ -375,6 +375,7 @@ public class XMLRenderer extends PrintRenderer {
             atts.clear();
             addAreaAttributes(region);
             addTraitAttributes(region);
+            addAttribute("ctm", region.getCTM().toString());
             if (region.getRegionClass() == FO_REGION_BEFORE) {
                 startElement("regionBefore", atts);
                 renderRegion(region);
@@ -524,6 +525,7 @@ public class XMLRenderer extends PrintRenderer {
         atts.clear();
         addAreaAttributes(viewport);
         addTraitAttributes(viewport);
+        addAttribute("offset", viewport.getOffset());
         startElement("viewport", atts);
         super.renderViewport(viewport);
         endElement("viewport");
@@ -554,6 +556,8 @@ public class XMLRenderer extends PrintRenderer {
     /**
      * Renders an fo:foreing-object.
      * @param fo the foreign object
+     * @param pos the position of the foreign object
+     * @see org.apache.fop.render.AbstractRenderer#renderForeignObject(ForeignObject, Rectangle2D)
      */
     public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
         atts.clear();
@@ -622,6 +626,9 @@ public class XMLRenderer extends PrintRenderer {
         endElement("inlineparent");
     }
 
+    /**
+     * @see org.apache.fop.render.AbstractRenderer#renderInlineBlockParent(InlineBlockParent)
+     */
     protected void renderInlineBlockParent(InlineBlockParent ibp) {
         atts.clear();
         addAreaAttributes(ibp);
index f782b308d12de4f8ebacb0bca4c60327dc5d172b..0f2397b8b30854fd2da2a56ed289a84ac0716247 100644 (file)
@@ -4,11 +4,12 @@ block_font-stretch.xml
 block_space-before_space-after_2.xml
 block_word-spacing.xml
 block_word-spacing_text-align_justify.xml
-external-graphic_content-height_content-width.xml
 external-graphic_oversized.xml
 inline-block_keep-together.xml
 inline_block_nested_3.xml
+inline_border_padding.xml
 inline-container_block_nested.xml
+inline-container_border_padding.xml
 inline_letter-spacing.xml
 inline_word-spacing.xml
 inline_word-spacing_text-align_justify.xml
@@ -24,7 +25,6 @@ page-number-citation_complex_2.xml
 page-number_initial-page-number_2.xml
 region-body_column-count_footnote.xml
 region-body_column-count_#36356.xml
-region-body_margin_relative_writing-mode_rl-tb.xml
 table-body_background-image.xml
 table_border-collapse_collapse_1.xml
 table_border-collapse_collapse_2.xml
index 74b000f95faea2868924fa91163762f8e4171380..ea09a97d623c74a868ba2b60f0b36f425a82d145 100644 (file)
   <fo>
     <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
       <fo:layout-master-set>
-        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in" margin="15pt">
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in" margin="0pt">
           <fo:region-body/>
         </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
-          <fo:block-container margin="0pt" padding="5pt" left="0in" top="0in" width="1.5in" height="1in" absolute-position="absolute" background-color="blue" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="0in" top="0in" width="90pt" height="70pt" absolute-position="absolute" background-color="blue" 
              background-image="##img"
              background-position-horizontal="right" 
              background-repeat="no-repeat">
             <fo:block>image in top right corner</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="1.75in" top="0in" width="1.5in" height="1in" absolute-position="absolute" background-color="green" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="120pt" top="0in" width="90pt" height="70pt" absolute-position="absolute" background-color="green" 
              background-image="##img"
              background-position-horizontal="right" 
              background-position-vertical="center" 
              background-repeat="no-repeat">
             <fo:block>image in center right</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="3.5in" top="0in" width="1.5in" height="1in" absolute-position="absolute" background-color="yellow" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="240pt" top="0in" width="90pt" height="70pt" absolute-position="absolute" background-color="yellow" 
              background-image="##img"
              background-position-horizontal="right" 
              background-position-vertical="bottom" 
              background-repeat="no-repeat">
             <fo:block>image in bottom right corner</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="0in" top="1.25in" width="1.5in" height="1in" absolute-position="absolute" background-color="yellow" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="0in" top="100pt" width="90pt" height="70pt" absolute-position="absolute" background-color="yellow" 
              background-image="##img"
              background-position-horizontal="center" 
              background-repeat="no-repeat">
             <fo:block>image in top center</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="1.75in" top="1.25in" width="1.5in" height="1in" absolute-position="absolute" background-color="blue" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="120pt" top="100pt" width="90pt" height="70pt" absolute-position="absolute" background-color="blue" 
              background-image="##img"
              background-position-horizontal="center" 
              background-position-vertical="center" 
              background-repeat="no-repeat">
             <fo:block>image in center</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="3.5in" top="1.25in" width="1.5in" height="1in" absolute-position="absolute" background-color="green" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="240pt" top="100pt" width="90pt" height="70pt" absolute-position="absolute" background-color="green" 
              background-image="##img"
              background-position-horizontal="center" 
              background-position-vertical="bottom" 
              background-repeat="no-repeat">
             <fo:block>image in bottom center</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="0in" top="2.5in" width="1.5in" height="1in" absolute-position="absolute" background-color="green" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="0in" top="200pt" width="90pt" height="70pt" absolute-position="absolute" background-color="green" 
              background-image="##img"
              background-repeat="no-repeat">
             <fo:block>image in top left</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="1.75in" top="2.5in" width="1.5in" height="1in" absolute-position="absolute" background-color="yellow" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="120pt" top="200pt" width="90pt" height="70pt" absolute-position="absolute" background-color="yellow" 
              background-image="##img"
              background-position-vertical="center" 
              background-repeat="no-repeat">
             <fo:block>image in center left</fo:block>
           </fo:block-container>
-          <fo:block-container margin="0pt" padding="5pt" left="3.5in" top="2.5in" width="1.5in" height="1in" absolute-position="absolute" background-color="blue" 
+          <fo:block-container margin="0pt" padding="5pt 10pt 20pt 15pt" left="240pt" top="200pt" width="90pt" height="70pt" absolute-position="absolute" background-color="blue" 
              background-image="##img"
              background-position-vertical="bottom" 
              background-repeat="no-repeat">
   </fo>
   <checks>
     <!-- first container in row 1 -->
-    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=77991,vertical=0" xpath="//flow/block[1]/@background"/>
+    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=74991,vertical=0" xpath="//flow/block[1]/@background"/>
     <!-- second container in row 1 -->
-    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=77991,vertical=20995" xpath="//flow/block[2]/@background"/>
+    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=74991,vertical=27495" xpath="//flow/block[2]/@background"/>
     <!-- third container in row 1 -->
-    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=77991,vertical=41991" xpath="//flow/block[3]/@background"/>
+    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=74991,vertical=54991" xpath="//flow/block[3]/@background"/>
     <!-- first container in row 2 -->
-    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=38995,vertical=0" xpath="//flow/block[4]/@background"/>
+    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=37495,vertical=0" xpath="//flow/block[4]/@background"/>
     <!-- second container in row 2 -->
-    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=38995,vertical=20995" xpath="//flow/block[5]/@background"/>
+    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=37495,vertical=27495" xpath="//flow/block[5]/@background"/>
     <!-- third container in row 2 -->
-    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=38995,vertical=41991" xpath="//flow/block[6]/@background"/>
+    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=37495,vertical=54991" xpath="//flow/block[6]/@background"/>
     <!-- first container in row 3 -->
     <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=0" xpath="//flow/block[7]/@background"/>
     <!-- second container in row 3 -->
-    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=20995" xpath="//flow/block[8]/@background"/>
+    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=27495" xpath="//flow/block[8]/@background"/>
     <!-- third container in row 3 -->
-    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=41991" xpath="//flow/block[9]/@background"/>
+    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=54991" xpath="//flow/block[9]/@background"/>
   </checks>
 </testcase>
index 736ade4b7ae42f01224624bacd98fe2c8a2f9561..a4ea4a45af6b49b07a5f9b97a0cb4b0a4970c578 100644 (file)
@@ -31,7 +31,7 @@
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:block>plain external-graphic</fo:block>
-          <fo:block>
+          <fo:block background-color="orange">
             <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg"/>EOG
           </fo:block>
           <fo:block>EOF</fo:block>
index f8bfa4d793ff33ceda7618cccc6c8e617ff21481..43ff49649a4fe5b700ceb450fd7f3f72a4bf548b 100644 (file)
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:block background-color="orange">
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" border="solid 5pt" padding="5pt" background-color="white"/>
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white"/> Normal font
+          </fo:block>
+          <fo:block background-color="yellow" font-size="140pt">
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white"/> FO
+          </fo:block>
+          <fo:block font-size="9pt">
+           In both blocks we have a setting of border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" on the e-g.
+           In the first block the e-g determines the height of the line in the 2nd block the font is bigger than the e-g.
           </fo:block>
-          <fo:block>EOF</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <eval expected="10000 10000 10000 10000" xpath="//flow/block[1]/lineArea/viewport/@bap"/>
+    <!-- first e-g -->
+    <eval expected="46080" xpath="//flow/block[1]/lineArea/viewport/@ipd"/>
+    <eval expected="46080" xpath="//flow/block[1]/lineArea/viewport/@bpd"/>
+    <eval expected="96080" xpath="//flow/block[1]/lineArea/viewport/@bpda"/>
+    <eval expected="1650" xpath="//flow/block[1]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[1]/lineArea/viewport/@bap"/>
     <eval expected="color=#ffffff" xpath="//flow/block[1]/lineArea/viewport/@background"/>
     <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-before"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-after"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-start"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-end"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-before"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[1]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[1]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[1]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[1]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-start"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 46080 46080" xpath="//flow/block[1]/lineArea/viewport/image/@pos"/>
+    <!-- second e-g -->
+    <eval expected="46080" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
+    <eval expected="46080" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
+    <eval expected="96080" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
+    <eval expected="23690" xpath="//flow/block[2]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[2]/lineArea/viewport/@bap"/>
+    <eval expected="color=#ffffff" xpath="//flow/block[2]/lineArea/viewport/@background"/>
+    <eval expected="(solid,#000000,5000)" xpath="//flow/block[2]/lineArea/viewport/@border-before"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[2]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[2]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[2]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[2]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[2]/lineArea/viewport/@padding-after"/>
+    <eval expected="5000" xpath="//flow/block[2]/lineArea/viewport/@padding-start"/>
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 46080 46080" xpath="//flow/block[2]/lineArea/viewport/image/@pos"/>
   </checks>
 </testcase>
index e828e3a77c82b1dc71bc2e952d4dbdba32015daf..76d74b791baf54d5b9c36602967453d092ac238a 100644 (file)
         <fo:flow flow-name="xsl-region-body">
           <fo:block>plain external-graphic</fo:block>
           <fo:block>
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" block-progression-dimension="60pt"/>EOG
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" block-progression-dimension="60pt" background-color="yellow"/>EOG
           </fo:block>
           <fo:block>external-graphic with display-align="auto"</fo:block>
           <fo:block>
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="auto" block-progression-dimension="60pt"/>EOG
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="auto" block-progression-dimension="60pt" background-color="yellow"/>EOG
           </fo:block>
           <fo:block>external-graphic with display-align="before"</fo:block>
           <fo:block>
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="before" block-progression-dimension="60pt"/>EOG
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="before" block-progression-dimension="60pt" background-color="yellow"/>EOG
           </fo:block>
           <fo:block>external-graphic with display-align="center"</fo:block>
           <fo:block>
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="center" block-progression-dimension="60pt"/>EOG
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="center" block-progression-dimension="60pt" background-color="yellow"/>EOG
           </fo:block>
           <fo:block>external-graphic with display-align="after"</fo:block>
           <fo:block>
-            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="after" block-progression-dimension="60pt"/>EOG
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" display-align="after" block-progression-dimension="60pt" background-color="yellow"/>EOG
           </fo:block>
           <fo:block>EOF</fo:block>
         </fo:flow>
diff --git a/test/layoutengine/testcases/inline-container_border_padding.xml b/test/layoutengine/testcases/inline-container_border_padding.xml
new file mode 100644 (file)
index 0000000..10ab7b6
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks the borders and the like for instream-foreign-object.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block background-color="orange">
+            Before <fo:inline-container border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white">
+                <fo:block>inside the container</fo:block>
+            </fo:inline-container> after
+          </fo:block>
+          <fo:block background-color="yellow" font-size="100pt">
+            BC <fo:inline-container border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white">
+                <fo:block font-size="12pt">inside the container</fo:block>
+            </fo:inline-container> AC
+          </fo:block>
+          <fo:block font-size="9pt">
+           In both blocks we have a setting of border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" on the i-f-o.
+           In the first block the i-f-o determines the height of the line in the 2nd block the font is bigger than the i-f-o.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- first e-g -->
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@ipd"/>
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@bpd"/>
+    <eval expected="70000" xpath="//flow/block[1]/lineArea/viewport/@bpda"/>
+    <eval expected="1650" xpath="//flow/block[1]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[1]/lineArea/viewport/@bap"/>
+    <eval expected="color=#ffffff" xpath="//flow/block[1]/lineArea/viewport/@background"/>
+    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-before"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[1]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[1]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[1]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[1]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
+    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-start"/>
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[1]/lineArea/viewport/foreignObject/@pos"/>
+    <!-- second e-g -->
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
+    <eval expected="70000" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
+    <eval expected="15550" xpath="//flow/block[2]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[2]/lineArea/viewport/@bap"/>
+    <eval expected="color=#ffffff" xpath="//flow/block[2]/lineArea/viewport/@background"/>
+    <eval expected="(solid,#000000,5000)" xpath="//flow/block[2]/lineArea/viewport/@border-before"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[2]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[2]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[2]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[2]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[2]/lineArea/viewport/@padding-after"/>
+    <eval expected="5000" xpath="//flow/block[2]/lineArea/viewport/@padding-start"/>
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[2]/lineArea/viewport/foreignObject/@pos"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/inline_border_padding.xml b/test/layoutengine/testcases/inline_border_padding.xml
new file mode 100644 (file)
index 0000000..4741914
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks inlines with border and padding properties.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body" font-size="10pt">
+          <fo:block background-color="yellow" margin="0pt">
+            Start of file
+          </fo:block>
+          <fo:block background-color="silver" margin="0pt">
+            Normal text <fo:inline border="solid 5pt red" padding="5pt" background-color="white">inline with border="solid 5pt red" padding="5pt"</fo:inline> normal finish
+          </fo:block>
+          <fo:block background-color="yellow" margin="0pt">
+            End of file
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+  </checks>
+</testcase>
index 3a1460ea1a843d2638cf03f133ca5cd3ff3a8fb6..51c1ffa0a19bd35e69d044762456bc60601d6346 100644 (file)
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:block background-color="orange">
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" border="solid 5pt" padding="5pt" background-color="white">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
                   <svg:rect x="5" y="5" width="15" height="15"/>
                 </svg:g>
               </svg:svg>
-            </fo:instream-foreign-object>
+            </fo:instream-foreign-object> Normal font
+          </fo:block>
+          <fo:block background-color="yellow" font-size="100pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" border-style="solid" border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" background-color="white">
+              <svg:svg viewBox="0 0 20 20">
+                <svg:g style="fill:red; stroke:#000000">
+                  <svg:rect x="0" y="0" width="15" height="15"/>
+                  <svg:rect x="5" y="5" width="15" height="15"/>
+                </svg:g>
+              </svg:svg>
+            </fo:instream-foreign-object> FOP
+          </fo:block>
+          <fo:block font-size="9pt">
+           In both blocks we have a setting of border-width="5pt 10pt 20pt 15pt" padding="15pt 20pt 10pt 5pt" on the i-f-o.
+           In the first block the i-f-o determines the height of the line in the 2nd block the font is bigger than the i-f-o.
           </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <eval expected="10000 10000 10000 10000" xpath="//flow/block[1]/lineArea/viewport/@bap"/>
+    <!-- first i-f-o -->
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@ipd"/>
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@bpd"/>
+    <eval expected="70000" xpath="//flow/block[1]/lineArea/viewport/@bpda"/>
+    <eval expected="1650" xpath="//flow/block[1]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[1]/lineArea/viewport/@bap"/>
     <eval expected="color=#ffffff" xpath="//flow/block[1]/lineArea/viewport/@background"/>
     <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-before"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-after"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-start"/>
-    <eval expected="(solid,#000000,5000)" xpath="//flow/block[1]/lineArea/viewport/@border-end"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-before"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[1]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[1]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[1]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[1]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-start"/>
-    <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[1]/lineArea/viewport/foreignObject/@pos"/>
+    <!-- second i-f-o -->
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
+    <eval expected="70000" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
+    <eval expected="15550" xpath="//flow/block[2]/lineArea/viewport/@offset"/>
+    <eval expected="20000 30000 20000 30000" xpath="//flow/block[2]/lineArea/viewport/@bap"/>
+    <eval expected="color=#ffffff" xpath="//flow/block[2]/lineArea/viewport/@background"/>
+    <eval expected="(solid,#000000,5000)" xpath="//flow/block[2]/lineArea/viewport/@border-before"/>
+    <eval expected="(solid,#000000,20000)" xpath="//flow/block[2]/lineArea/viewport/@border-after"/>
+    <eval expected="(solid,#000000,15000)" xpath="//flow/block[2]/lineArea/viewport/@border-start"/>
+    <eval expected="(solid,#000000,10000)" xpath="//flow/block[2]/lineArea/viewport/@border-end"/>
+    <eval expected="15000" xpath="//flow/block[2]/lineArea/viewport/@padding-before"/>
+    <eval expected="10000" xpath="//flow/block[2]/lineArea/viewport/@padding-after"/>
+    <eval expected="5000" xpath="//flow/block[2]/lineArea/viewport/@padding-start"/>
+    <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@padding-end"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[2]/lineArea/viewport/foreignObject/@pos"/>
   </checks>
 </testcase>
index 01ecfd5b46139653ee58e3bb4aafe5fa12fb5d37..a113ccc544a6e6efc193e2c092b647ed04f5303d 100644 (file)
@@ -32,7 +32,7 @@
         <fo:flow flow-name="xsl-region-body">
           <fo:block>plain instream-foreign-object</fo:block>
           <fo:block>
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" block-progression-dimension="30pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" block-progression-dimension="30pt" background-color="yellow">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
@@ -43,7 +43,7 @@
           </fo:block>
           <fo:block>instream-foreign-object with display-align="auto"</fo:block>
           <fo:block>
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="auto" block-progression-dimension="30pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="auto" block-progression-dimension="30pt" background-color="yellow">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
@@ -54,7 +54,7 @@
           </fo:block>
           <fo:block>instream-foreign-object with display-align="before"</fo:block>
           <fo:block>
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="before" block-progression-dimension="30pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="before" block-progression-dimension="30pt" background-color="yellow">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
@@ -65,7 +65,7 @@
           </fo:block>
           <fo:block>instream-foreign-object with display-align="center"</fo:block>
           <fo:block>
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="center" block-progression-dimension="30pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="center" block-progression-dimension="30pt" background-color="yellow">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
@@ -76,7 +76,7 @@
           </fo:block>
           <fo:block>instream-foreign-object with display-align="after"</fo:block>
           <fo:block>
-            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="after" block-progression-dimension="30pt">
+            <fo:instream-foreign-object content-width="20pt" content-height="20pt" display-align="after" block-progression-dimension="30pt" background-color="yellow">
               <svg:svg viewBox="0 0 20 20">
                 <svg:g style="fill:red; stroke:#000000">
                   <svg:rect x="0" y="0" width="15" height="15"/>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_0_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_0_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..c68c3aa
--- /dev/null
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="0">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="5%" margin-right="10%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference not rotated.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 194400 36000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 10800.0 18000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="10800 54000 10800 270000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 10800.0 54000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="183600 54000 21600 270000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 183600.0 54000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 324000 194400 18000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 10800.0 324000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 54000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 21600.0 54000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_0_writing-mode_rl_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_0_writing-mode_rl_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..3269fd9
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="0" writing-mode="rl">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="10%" margin-right="5%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference not rotated
+            and a rl writing-mode.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 194400 36000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 205200.0 18000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="194400 54000 10800 270000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 205200.0 54000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="10800 54000 21600 270000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 32400.0 54000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 324000 194400 18000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 205200.0 324000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="32400 54000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 194400.0 54000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_180_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_180_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..363edc6
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="180">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="5%" margin-right="10%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            180 degrees.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 306000 194400 36000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[-1.0 -0.0 0.0 -1.0 205200.0 342000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="194400 36000 10800 270000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[-1.0 -0.0 0.0 -1.0 205200.0 306000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="10800 36000 21600 270000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[-1.0 -0.0 0.0 -1.0 32400.0 306000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 18000 194400 18000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[-1.0 -0.0 0.0 -1.0 205200.0 36000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="32400 36000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[-1.0 -0.0 0.0 -1.0 194400.0 306000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_180_writing-mode_rl_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_180_writing-mode_rl_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..f17c83e
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="180" writing-mode="rl">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="10%" margin-right="5%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            180 degrees and a rl writing-mode.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 306000 194400 36000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 -1.0 10800.0 342000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="10800 36000 10800 270000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 -1.0 10800.0 306000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="183600 36000 21600 270000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 -1.0 183600.0 306000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 18000 194400 18000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 -1.0 10800.0 36000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 36000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 -1.0 21600.0 306000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_270_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_270_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..e6145ac
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="270">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="5%" margin-right="10%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            270 degrees.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="183600 18000 21600 324000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 205200.0 18000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="21600 18000 162000 18000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 183600.0 18000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="21600 306000 162000 36000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 183600.0 306000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 18000 10800 324000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 21600.0 18000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 36000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 183600.0 36000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_270_writing-mode_rl_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_270_writing-mode_rl_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..b3808fd
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="270" writing-mode="rl">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="10%" margin-right="5%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            270 degrees and a rl writing-mode.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="183600 18000 21600 324000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[-0.0 -1.0 -1.0 0.0 205200.0 342000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="21600 324000 162000 18000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[-0.0 -1.0 -1.0 0.0 183600.0 342000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="21600 18000 162000 36000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[-0.0 -1.0 -1.0 0.0 183600.0 54000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 18000 10800 324000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[-0.0 -1.0 -1.0 0.0 21600.0 342000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 54000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[-0.0 -1.0 -1.0 0.0 183600.0 324000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_90_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_90_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..959484c
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="90">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="5%" margin-right="10%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            90 degrees.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 21600 324000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[0.0 -1.0 1.0 0.0 10800.0 342000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="32400 324000 162000 18000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[0.0 -1.0 1.0 0.0 32400.0 342000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="32400 18000 162000 36000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[0.0 -1.0 1.0 0.0 32400.0 54000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="194400 18000 10800 324000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[0.0 -1.0 1.0 0.0 194400.0 342000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="32400 54000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[0.0 -1.0 1.0 0.0 32400.0 324000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_reference-orientation_90_writing-mode_rl_region-body_margin_relative.xml b/test/layoutengine/testcases/simple-page-master_reference-orientation_90_writing-mode_rl_region-body_margin_relative.xml
new file mode 100644 (file)
index 0000000..ac76356
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="90" writing-mode="rl">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="10%" margin-right="5%" background-color="yellow" />
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" />
+          <fo:region-end extent="10%" background-color="orange" />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference rotated by 
+            90 degrees and a rl writing-mode.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 21600 324000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[0.0 1.0 1.0 0.0 10800.0 18000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="32400 18000 162000 18000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="18000" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[0.0 1.0 1.0 0.0 32400.0 18000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="32400 306000 162000 36000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="36000" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[0.0 1.0 1.0 0.0 32400.0 306000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="194400 18000 10800 324000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[0.0 1.0 1.0 0.0 194400.0 18000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="32400 36000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[0.0 1.0 1.0 0.0 32400.0 36000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/simple-page-master_writing-mode_rl_region-body_writing-mode-lr.xml b/test/layoutengine/testcases/simple-page-master_writing-mode_rl_region-body_writing-mode-lr.xml
new file mode 100644 (file)
index 0000000..b538309
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 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.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks relative margin on region (region-body).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="3in" page-height="5in" margin="5%" reference-orientation="0" writing-mode="rl">
+          <fo:region-body margin-top="10%" margin-bottom="5%" margin-left="10%" margin-right="5%" background-color="yellow" writing-mode="lr"/>
+          <fo:region-before extent="10%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="5%" background-color="red" writing-mode="tb"/>
+          <fo:region-end extent="10%" background-color="orange"  writing-mode="tb"/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:static-content flow-name="xsl-region-before">
+          <fo:block>
+            r e g i o n  b e f o r e
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block>
+            r e g i o n  a f t e r
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-start">
+          <fo:block>
+            r e g i o n  s t a r t top - bottom
+          </fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="xsl-region-end">
+          <fo:block>
+            r e g i o n  e n d top - bottom
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            Demonstrates relative 5% margin on the page master, 10% margin on regions before
+            and end and 5% margin on regions start and after. Corresponding margins are set
+            on the region body. The page size is 5in x 3in with the page reference not rotated
+            and a rl writing-mode on the page master, a normal writing mode on the region-body
+            and tb writing mode on start and end regions.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 194400 36000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="36000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 205200.0 18000.0]" xpath="//page/regionViewport[1]/regionBefore/@ctm"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="194400 54000 10800 270000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 205200.0 54000.0]" xpath="//page/regionViewport[2]/regionStart/@ctm"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="10800 54000 21600 270000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="270000" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="21600" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <eval expected="[0.0 1.0 -1.0 0.0 32400.0 54000.0]" xpath="//page/regionViewport[3]/regionEnd/@ctm"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="10800 324000 194400 18000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <eval expected="[-1.0 0.0 0.0 1.0 205200.0 324000.0]" xpath="//page/regionViewport[4]/regionAfter/@ctm"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="32400 54000 162000 270000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="162000" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="270000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+    <eval expected="[1.0 0.0 0.0 1.0 32400.0 54000.0]" xpath="//page/regionViewport[5]/regionBody/@ctm"/>
+  </checks>
+</testcase>
index 9dcffe96e36bfeeae144b65e50493f8cf2201391..dbb9cd42f6c377bf1a9fc49981312d7d73898c38 100644 (file)
             <fo:table-column />\r
             <fo:table-body>\r
               <fo:table-row>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="blue" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="blue" \r
                    background-image="##img"\r
                    background-position-horizontal="right" \r
                    background-repeat="no-repeat">\r
                   <fo:block>image in top right corner</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="green" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="green" \r
                    background-image="##img"\r
                    background-position-horizontal="right" \r
                    background-position-vertical="center" \r
                    background-repeat="no-repeat">\r
                   <fo:block>image in center right</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="yellow" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="yellow" \r
                    background-image="##img"\r
                    background-position-horizontal="right" \r
                    background-position-vertical="bottom" \r
                 </fo:table-cell>\r
               </fo:table-row>\r
               <fo:table-row>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="yellow" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="yellow" \r
                    background-image="##img"\r
                    background-position-horizontal="center" \r
                    background-repeat="no-repeat">\r
                   <fo:block>image in top center</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="blue" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="blue" \r
                    background-image="##img"\r
                    background-position-horizontal="center" \r
                    background-position-vertical="center" \r
                    background-repeat="no-repeat">\r
                   <fo:block>image in center</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="green" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="green" \r
                    background-image="##img"\r
                    background-position-horizontal="center" \r
                    background-position-vertical="bottom" \r
                 </fo:table-cell>\r
               </fo:table-row>\r
               <fo:table-row>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="green" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="green" \r
                    background-image="##img"\r
                    background-repeat="no-repeat">\r
                   <fo:block>image in top left</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="yellow" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="yellow" \r
                    background-image="##img"\r
                    background-position-vertical="center" \r
                    background-repeat="no-repeat">\r
                   <fo:block>image in center left</fo:block>\r
                 </fo:table-cell>\r
-                <fo:table-cell margin="0pt" padding="5pt" height="1in" background-color="blue" \r
+                <fo:table-cell margin="0pt" padding="5pt 10pt 20pt 15pt" height="1in" background-color="blue" \r
                    background-image="##img"\r
                    background-position-vertical="bottom" \r
                    background-repeat="no-repeat">\r
     <!-- first cell in row 1 -->\r
     <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=69991,vertical=0" xpath="//flow/block/block[1]/@background"/>\r
     <!-- second cell in row 1 -->\r
-    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=69991,vertical=20995" xpath="//flow/block/block[2]/@background"/>\r
+    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=69991,vertical=28495" xpath="//flow/block/block[2]/@background"/>\r
     <!-- third cell in row 1 -->\r
-    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=69991,vertical=41991" xpath="//flow/block/block[3]/@background"/>\r
+    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=69991,vertical=56991" xpath="//flow/block/block[3]/@background"/>\r
     <!-- first cell in row 2 -->\r
     <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=34995,vertical=0" xpath="//flow/block/block[4]/@background"/>\r
     <!-- second cell in row 2 -->\r
-    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=34995,vertical=20995" xpath="//flow/block/block[5]/@background"/>\r
+    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=34995,vertical=28495" xpath="//flow/block/block[5]/@background"/>\r
     <!-- third cell in row 2 -->\r
-    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=34995,vertical=41991" xpath="//flow/block/block[6]/@background"/>\r
+    <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=34995,vertical=56991" xpath="//flow/block/block[6]/@background"/>\r
     <!-- first cell in row 3 -->\r
     <eval expected="color=#008000,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=0" xpath="//flow/block/block[7]/@background"/>\r
     <!-- second cell in row 3 -->\r
-    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=20995" xpath="//flow/block/block[8]/@background"/>\r
+    <eval expected="color=#ffff00,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=28495" xpath="//flow/block/block[8]/@background"/>\r
     <!-- third cell in row 3 -->\r
-    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=41991" xpath="//flow/block/block[9]/@background"/>\r
+    <eval expected="color=#0000ff,url=../../resources/images/box1.png,repeat=no-repeat,horiz=0,vertical=56991" xpath="//flow/block/block[9]/@background"/>\r
   </checks>\r
-</testcase>\r
+</testcase>
\ No newline at end of file