You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/09/05 10:10:22 UTC

svn commit: r278690 [1/3] - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/pagination/ src/java/org/apache/fop/layoutmgr/inline/ src/java/org/apache/fop/render/ src/java/org/apache/f...

Author: jeremias
Date: Mon Sep  5 01:09:42 2005
New Revision: 278690

URL: http://svn.apache.org/viewcvs?rev=278690&view=rev
Log:
Bugzilla #36487:
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>

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

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java Mon Sep  5 01:09:42 2005
@@ -92,14 +92,21 @@
          * 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 @@
         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 @@
     
     /**
      * 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

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java?rev=278690&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java Mon Sep  5 01:09:42 2005
@@ -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();
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java Mon Sep  5 01:09:42 2005
@@ -18,60 +18,24 @@
 
 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 @@
      * @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 @@
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        checkId(id);
+        checkId(getId());
         getFOEventHandler().image(this);
     }
 
@@ -153,83 +91,6 @@
     }
 
     /**
-     * @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.
      */
     public String getSrc() {
@@ -241,27 +102,6 @@
      */
     public String getURL() {
         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;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Mon Sep  5 01:09:42 2005
@@ -19,59 +19,21 @@
 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
@@ -87,43 +49,10 @@
     }
 
     /**
-     * @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());
     }
 
     /**
@@ -148,126 +77,6 @@
         } else if (childNodes != null) {
             tooManyNodesError(loc, "child element");
         }
-    }
-
-    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;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java Mon Sep  5 01:09:42 2005
@@ -99,11 +99,11 @@
 
     /**
      * @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,

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java Mon Sep  5 01:09:42 2005
@@ -40,31 +40,43 @@
     }
 
     /**
-     * @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;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java Mon Sep  5 01:09:42 2005
@@ -46,28 +46,33 @@
     }
 
     /**
-     * @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 @@
             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;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java Mon Sep  5 01:09:42 2005
@@ -63,13 +63,14 @@
              * 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 @@
 
     /**
      * Return the "column-count" property.
+     * @return the "column-count" property.
      */
     public int getColumnCount() {
         return columnCount.getValue();
@@ -84,35 +86,60 @@
 
     /**
      * 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);
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java Mon Sep  5 01:09:42 2005
@@ -39,23 +39,33 @@
     }
 
     /**
-     * @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 @@
             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;
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java Mon Sep  5 01:09:42 2005
@@ -39,32 +39,40 @@
     }
 
     /**
-     * @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;
     }
 

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=278690&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Mon Sep  5 01:09:42 2005
@@ -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();
+    }
+
+}
+

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java Mon Sep  5 01:09:42 2005
@@ -18,41 +18,19 @@
 
 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 @@
      * 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 @@
         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());
     }
-
+    
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java Mon Sep  5 01:09:42 2005
@@ -18,33 +18,21 @@
 
 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 @@
     /**
      * 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();
-    }
-
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Mon Sep  5 01:09:42 2005
@@ -187,8 +187,11 @@
                         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);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Mon Sep  5 01:09:42 2005
@@ -375,6 +375,7 @@
             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 @@
         atts.clear();
         addAreaAttributes(viewport);
         addTraitAttributes(viewport);
+        addAttribute("offset", viewport.getOffset());
         startElement("viewport", atts);
         super.renderViewport(viewport);
         endElement("viewport");
@@ -554,6 +556,8 @@
     /**
      * 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 @@
         endElement("inlineparent");
     }
 
+    /**
+     * @see org.apache.fop.render.AbstractRenderer#renderInlineBlockParent(InlineBlockParent)
+     */
     protected void renderInlineBlockParent(InlineBlockParent ibp) {
         atts.clear();
         addAreaAttributes(ibp);

Modified: xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.txt
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.txt?rev=278690&r1=278689&r2=278690&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.txt (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.txt Mon Sep  5 01:09:42 2005
@@ -4,11 +4,12 @@
 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_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



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org