]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #36379:
authorFinn Bock <bckfnn@apache.org>
Wed, 31 Aug 2005 20:29:33 +0000 (20:29 +0000)
committerFinn Bock <bckfnn@apache.org>
Wed, 31 Aug 2005 20:29:33 +0000 (20:29 +0000)
Revised percentage resolution system.
Submitted by: Manuel Mall <mm.at.arcus.com.au>

Slightly modified to avoid early evaluation of getValue().

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

114 files changed:
src/java/org/apache/fop/area/Page.java
src/java/org/apache/fop/datatypes/Length.java
src/java/org/apache/fop/datatypes/LengthBase.java
src/java/org/apache/fop/datatypes/Numeric.java
src/java/org/apache/fop/datatypes/PercentBase.java
src/java/org/apache/fop/datatypes/PercentBaseContext.java [new file with mode: 0644]
src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java [new file with mode: 0644]
src/java/org/apache/fop/fo/Constants.java
src/java/org/apache/fop/fo/FOPropertyMapping.java
src/java/org/apache/fop/fo/InlineCharIterator.java
src/java/org/apache/fop/fo/expr/LabelEndFunction.java
src/java/org/apache/fop/fo/expr/NumericOp.java
src/java/org/apache/fop/fo/expr/NumericProperty.java
src/java/org/apache/fop/fo/expr/PropertyInfo.java
src/java/org/apache/fop/fo/expr/PropertyParser.java
src/java/org/apache/fop/fo/expr/RGBColorFunction.java
src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
src/java/org/apache/fop/fo/flow/ExternalGraphic.java
src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
src/java/org/apache/fop/fo/flow/Table.java
src/java/org/apache/fop/fo/flow/TableCell.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/RegionBA.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/RegionSE.java
src/java/org/apache/fop/fo/pagination/RegionStart.java
src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
src/java/org/apache/fop/fo/properties/CommonFont.java
src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
src/java/org/apache/fop/fo/properties/CondLengthProperty.java
src/java/org/apache/fop/fo/properties/EnumLength.java
src/java/org/apache/fop/fo/properties/FixedLength.java
src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
src/java/org/apache/fop/fo/properties/NumberProperty.java
src/java/org/apache/fop/fo/properties/PercentLength.java
src/java/org/apache/fop/fo/properties/PropertyMaker.java
src/java/org/apache/fop/fo/properties/SpaceProperty.java
src/java/org/apache/fop/fo/properties/TableColLength.java
src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/java/org/apache/fop/layoutmgr/LayoutManager.java
src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/TraitSetter.java
src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
src/java/org/apache/fop/layoutmgr/table/GridUnit.java
src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java
src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java
src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
src/java/org/apache/fop/traits/SpaceVal.java
test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java
test/layoutengine/disabled-testcases.txt
test/layoutengine/testcases/background-image-list1.xml
test/layoutengine/testcases/background-image-list2.xml
test/layoutengine/testcases/background-image-table1.xml
test/layoutengine/testcases/background-image-table2.xml
test/layoutengine/testcases/background-image-table3.xml
test/layoutengine/testcases/background-image-table4.xml
test/layoutengine/testcases/background-image-table5.xml
test/layoutengine/testcases/background-image2.xml
test/layoutengine/testcases/background-image3.xml
test/layoutengine/testcases/background-image5.xml
test/layoutengine/testcases/background-image7.xml
test/layoutengine/testcases/external-graphic1.xml
test/layoutengine/testcases/external-graphic2.xml
test/layoutengine/testcases/external-graphic4.xml
test/layoutengine/testcases/font-stretch.xml [new file with mode: 0644]
test/layoutengine/testcases/leader-alignment.xml [new file with mode: 0644]
test/layoutengine/testcases/leader-dots.xml
test/layoutengine/testcases/leader-rule.xml
test/layoutengine/testcases/leader-space.xml
test/layoutengine/testcases/leader-use-content.xml [new file with mode: 0644]
test/layoutengine/testcases/line-height.xml [new file with mode: 0644]
test/layoutengine/testcases/margin-block1.xml [new file with mode: 0644]
test/layoutengine/testcases/margin-block2.xml [new file with mode: 0644]
test/layoutengine/testcases/margin-region1.xml [new file with mode: 0644]
test/layoutengine/testcases/margin-region2.xml [new file with mode: 0644]
test/layoutengine/testcases/margin-region3.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-block-container1.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-block1.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-list1.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-list2.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-table1.xml [new file with mode: 0644]
test/layoutengine/testcases/padding-table2.xml [new file with mode: 0644]
test/layoutengine/testcases/table3.xml [new file with mode: 0644]

index 2f327b55af799cc390f7006cd414e3933873c4f6..e36e3338f8e449773832071ded1591ee1b500b59 100644 (file)
@@ -25,7 +25,9 @@ import java.util.HashMap;
 import java.util.Iterator;
 
 import org.apache.fop.datatypes.FODimension;
-import org.apache.fop.datatypes.PercentBase;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.pagination.Region;
 import org.apache.fop.fo.pagination.RegionBody;
@@ -70,22 +72,35 @@ public class Page implements Serializable, Cloneable {
      *            page-reference-area
      */
     public Page(SimplePageMaster spm) {
-        int pageWidth = spm.getPageWidth().getValue();
-        int pageHeight = spm.getPageHeight().getValue();
+        // Width and Height of the page view port
+        FODimension pageViewPortDims = new FODimension(spm.getPageWidth().getValue()
+                            ,  spm.getPageHeight().getValue());
 
         // Get absolute margin properties (top, left, bottom, right)
         CommonMarginBlock mProps = spm.getCommonMarginBlock();
-
+        
         /*
          * Create the page reference area rectangle (0,0 is at top left
          * of the "page media" and y increases
          * when moving towards the bottom of the page.
          * The media rectangle itself is (0,0,pageWidth,pageHeight).
          */
+        /* 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.
+         */
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.bpd);
+
         Rectangle pageRefRect =
-            new Rectangle(mProps.marginLeft.getValue(), mProps.marginTop.getValue(),
-            pageWidth - mProps.marginLeft.getValue() - mProps.marginRight.getValue(),
-            pageHeight - mProps.marginTop.getValue() - mProps.marginBottom.getValue());
+            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
@@ -98,9 +113,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);
-            r.setLayoutDimension(PercentBase.BLOCK_IPD, rvp.getIPD());
-            r.setLayoutDimension(PercentBase.BLOCK_BPD, rvp.getBPD());
+            RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, pageViewPortDims);
             if (r.getNameId() == Constants.FO_REGION_BODY) {
                 rr = new BodyRegion((RegionBody) r, rvp);
             } else {
@@ -125,15 +138,16 @@ public class Page implements Serializable, Cloneable {
      * @param pageCTM page coordinate transformation matrix
      * @return the new region viewport
      */
-    private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) {
-        Rectangle2D relRegionRect = r.getViewportRectangle(reldims);
+    private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM,
+        FODimension pageViewPortDims) {
+        Rectangle2D relRegionRect = r.getViewportRectangle(reldims, pageViewPortDims);
         Rectangle2D absRegionRect = pageCTM.transform(relRegionRect);
         // Get the region viewport rectangle in absolute coords by
         // transforming it using the page CTM
         RegionViewport rv = new RegionViewport(absRegionRect);
         rv.setBPD((int)relRegionRect.getHeight());
         rv.setIPD((int)relRegionRect.getWidth());
-        TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground());
+        TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground(), null);
         rv.setClip(r.getOverflow() == Constants.EN_HIDDEN 
                 || r.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW);
         return rv;
@@ -263,5 +277,6 @@ public class Page implements Serializable, Cloneable {
     public HashMap getUnresolvedReferences() {
         return unresolved;
     }
+
 }
 
index d64b2172df7c78daed01b6f38e2bf5c3201c8a62..13f7cf5dac2e9280b08407931842184a2562aa02 100644 (file)
@@ -27,4 +27,12 @@ public interface Length extends Numeric {
      * @return the length in millipoints
      */
     public int getValue();
+    
+    /**
+     * Returns the length in 1/1000ths of a point (millipoints)
+     * @param context The context for the length calculation (for percentage based lengths)
+     * @return the length in millipoints
+     */
+    public int getValue(PercentBaseContext context);
+
 }
index 21e15a86f6b3f58a65cf3674843a14f6f527e543..eceaf613962a2f831dde02d1c9237031991b231b 100644 (file)
@@ -36,67 +36,59 @@ public class LengthBase implements PercentBase {
     /** constant for an inh font-size percent-based length */
     public static final int INH_FONTSIZE = 2;
     /** constant for a containing box percent-based length */
-    public static final int CONTAINING_BOX = 3;
+    public static final int PARENT_AREA_WIDTH = 3;
     /** constant for a containing refarea percent-based length */
-    public static final int CONTAINING_REFAREA = 4;
+    public static final int CONTAINING_REFAREA_WIDTH = 4;
     /** constant for a containing block percent-based length */
-    public static final int BLOCK_WIDTH = 5;
+    public static final int CONTAINING_BLOCK_WIDTH = 5;
     /** constant for a containing block percent-based length */
-    public static final int BLOCK_HEIGHT = 6;
+    public static final int CONTAINING_BLOCK_HEIGHT = 6;
     /** constant for a image intrinsic percent-based length */
     public static final int IMAGE_INTRINSIC_WIDTH = 7;
     /** constant for a image intrinsic percent-based length */
     public static final int IMAGE_INTRINSIC_HEIGHT = 8;
+    /** constant for a image background position horizontal percent-based length */
+    public static final int IMAGE_BACKGROUND_POSITION_HORIZONTAL = 9;
+    /** constant for a image background position vertical percent-based length */
+    public static final int IMAGE_BACKGROUND_POSITION_VERTICAL = 10;
 
     /** array of valid percent-based length types */
     public static final int[] PERCENT_BASED_LENGTH_TYPES
-            = {CUSTOM_BASE, FONTSIZE, INH_FONTSIZE, CONTAINING_BOX,
-               CONTAINING_REFAREA, 
-               IMAGE_INTRINSIC_WIDTH, IMAGE_INTRINSIC_HEIGHT};
+            = {CUSTOM_BASE, FONTSIZE, INH_FONTSIZE, PARENT_AREA_WIDTH,
+               CONTAINING_REFAREA_WIDTH, 
+               IMAGE_INTRINSIC_WIDTH, IMAGE_INTRINSIC_HEIGHT,
+               IMAGE_BACKGROUND_POSITION_HORIZONTAL, IMAGE_BACKGROUND_POSITION_VERTICAL
+            };
 
     /**
-     * FO parent of the FO for which this property is to be calculated.
+     * The FO for which this property is to be calculated.
      */
-    protected /* final */ FObj parentFO;
-
-    /**
-     * PropertyList for the FO where this property is calculated.
-     */
-    private /* final */ PropertyList propertyList;
+    protected /* final */ FObj fobj;
 
     /**
      * One of the defined types of LengthBase
      */
     private /* final */ int iBaseType;
 
+    private Length fontSize;
+    
     /**
      * Constructor
      * @param parentFO parent FO for this
      * @param plist property list for this
      * @param iBaseType a member of {@link #PERCENT_BASED_LENGTH_TYPES}
      */
-    public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) {
-        this.parentFO = parentFO;
-        this.propertyList = plist;
+    public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) throws PropertyException {
+        this.fobj = plist.getFObj();
         this.iBaseType = iBaseType;
-    }
-
-    /**
-     * Accessor for parentFO object from subclasses which define
-     * custom kinds of LengthBase calculations.
-     * @return this object's parent FO
-     */
-    protected FObj getParentFO() {
-        return parentFO;
-    }
-
-    /**
-     * Accessor for propertyList object from subclasses which define
-     * custom kinds of LengthBase calculations.
-     * @return this object's PropertyList
-     */
-    protected PropertyList getPropertyList() {
-        return propertyList;
+        switch (iBaseType) {
+        case FONTSIZE:
+            this.fontSize = plist.get(Constants.PR_FONT_SIZE).getLength();
+            break;
+        case INH_FONTSIZE:
+            this.fontSize = plist.getInherited(Constants.PR_FONT_SIZE).getLength();
+            break;
+        }
     }
 
     /**
@@ -114,42 +106,17 @@ public class LengthBase implements PercentBase {
     }
 
     /** @see org.apache.fop.datatypes.PercentBase#getBaseLength() */
-    public int getBaseLength() throws PropertyException {
-        //TODO Don't use propertyList here
-        //See http://nagoya.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=10342
-        switch (iBaseType) {
-        case FONTSIZE:
-            return propertyList.get(Constants.PR_FONT_SIZE).getLength().getValue();
-        case INH_FONTSIZE:
-            return propertyList.getInherited(Constants.PR_FONT_SIZE).getLength().getValue();
-        case BLOCK_WIDTH:
-            return parentFO.getLayoutDimension(PercentBase.BLOCK_IPD).intValue();
-        case BLOCK_HEIGHT:
-            return parentFO.getLayoutDimension(PercentBase.BLOCK_BPD).intValue();
-        case CONTAINING_REFAREA:    // example: start-indent, end-indent
-            FObj fo;
-            fo = parentFO;
-            while (fo != null && !fo.generatesReferenceAreas()) {
-                fo = fo.findNearestAncestorFObj();
-            }
-            if (fo != null && fo instanceof FObj) {
-                return fo.getLayoutDimension(PercentBase.BLOCK_IPD).intValue();
-            } else {
-                return 0;
+    public int getBaseLength(PercentBaseContext context) throws PropertyException {
+        int baseLength = 0;
+        if (context != null) {
+            if (iBaseType == FONTSIZE || iBaseType == INH_FONTSIZE) {
+                return fontSize.getValue(context);
             }
-        case IMAGE_INTRINSIC_WIDTH:
-            return propertyList.getFObj()
-                .getLayoutDimension(PercentBase.IMAGE_INTRINSIC_WIDTH).intValue();
-        case IMAGE_INTRINSIC_HEIGHT:
-            return propertyList.getFObj()
-                .getLayoutDimension(PercentBase.IMAGE_INTRINSIC_HEIGHT).intValue();
-        case CUSTOM_BASE:
-            //log.debug("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!");
-            return 0;
-        default:
-            parentFO.getLogger().error("Unknown base type for LengthBase.");
-            return 0;
+            baseLength =  context.getBaseLength(iBaseType,  fobj);
+        } else {
+            fobj.getLogger().error("getBaseLength called without context");
         }
+        return baseLength;
     }
 
 }
index 85a41e862894c356023d062ca84bc06e0ee37642..c8b9af75c0213ec95c5ec39e0351e93e1ccbcd44 100644 (file)
@@ -40,6 +40,14 @@ public interface Numeric {
      */
     double getNumericValue() throws PropertyException;
     
+    /**
+     * Return the value of this Numeric
+     * @param context The context for the length calculation (for percentage based lengths)
+     * @return the computed value.
+     * @throws PropertyException
+     */
+    double getNumericValue(PercentBaseContext context) throws PropertyException;
+
     /**
      * Return the dimension of this numeric. Plain numbers has a dimension of
      * 0 and length has a dimension of 1. Other dimension can occur as a result
@@ -61,6 +69,13 @@ public interface Numeric {
      */
     public int getValue();
 
+    /**
+     * Returns the value of this numeric as an int.
+     * @param conext The context for the length calculation (for percentage based lengths)
+     * @return the value as an integer.
+     */
+    public int getValue(PercentBaseContext context);
+
     /**
      * Return the resolved value. This method will becalled during evaluation 
      * of the expression tree and relative numerics can then return a 
index 7011c774edaf030cfb561148492cf03fd4915bf7..a166725b18ee32a01e55bde2394932c90512709c 100644 (file)
@@ -30,18 +30,6 @@ public interface PercentBase {
     
     /** table units */
     LayoutDimension TABLE_UNITS = new LayoutDimension("table-units");
-    /** Block IPD */
-    LayoutDimension BLOCK_IPD = new LayoutDimension("block-ipd");
-    /** Block BPD */
-    LayoutDimension BLOCK_BPD = new LayoutDimension("block-bpd");
-    /** Reference Area IPD */
-    LayoutDimension REFERENCE_AREA_IPD = new LayoutDimension("reference-area-ipd");
-    /** Reference Area BPD */
-    LayoutDimension REFERENCE_AREA_BPD = new LayoutDimension("reference-area-bpd");
-    /** Intrinsic width of an image or foreign-object */ 
-    LayoutDimension IMAGE_INTRINSIC_WIDTH = new LayoutDimension("image-intrinsic-width");
-    /** Intrinsic height of an image or foreign-object */ 
-    LayoutDimension IMAGE_INTRINSIC_HEIGHT = new LayoutDimension("image-intrinsic-heigth");
     
     /**
      * Determines whether a numeric property is created or one with a percentage
@@ -53,13 +41,14 @@ public interface PercentBase {
     double getBaseValue();
 
     /**
+     * @param context The context for percentage evaluation
      * @return the integer size in millipoints of the object (this will be used 
      * as the base to which a percentage will be applied to compute the length 
      * of the referencing item)
      * @throws PropertyException if a problem occurs during evaluation of this
      *     value.
      */
-    int getBaseLength() throws PropertyException;
+    int getBaseLength(PercentBaseContext context) throws PropertyException;
     
     /** Enum class for dimension types. */
     public class LayoutDimension {
diff --git a/src/java/org/apache/fop/datatypes/PercentBaseContext.java b/src/java/org/apache/fop/datatypes/PercentBaseContext.java
new file mode 100644 (file)
index 0000000..6ba943e
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.datatypes;
+
+import org.apache.fop.fo.FObj;
+
+/**
+ * This interface is used by the layout managers to provide relevant information
+ * back to the property percentage resolution logic, that is
+ * the percentages based property getValue() functions expect an object implementing
+ * this interface as an argument.
+ */
+public interface PercentBaseContext {
+
+    /**
+     * Returns the base length for the given length base.
+     * Length base should be one of the constants defined in {@link LengthBase}.
+     * @param lengthBase Indicates which type of the base length value is to be returned
+     * @param fobj The FO object against which the percentage should be evaluated
+     * @return The base length value of the given kind
+     */
+    public int getBaseLength(int lengthBase, FObj fobj);
+    
+}
diff --git a/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java b/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java
new file mode 100644 (file)
index 0000000..acb4de6
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SimplePercentBaseContext.java
+ *
+ * Created on 29 August 2005, 17:02
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.FObj;
+
+/**
+ * Class to implement a simple lookup context for a single percent base value.
+ */
+public class SimplePercentBaseContext implements PercentBaseContext {
+    
+    private PercentBaseContext parentContext;
+    private int lengthBase;
+    private int lengthBaseValue;
+
+    /**
+     * @param parentContext the context to be used for all percentages other than lengthBase
+     * @param lengthBase the particular percentage length base for which this context provides a value
+     * @param lengthBaseValue the value to be returned for requests to the given lengthBase
+     */
+    public SimplePercentBaseContext(PercentBaseContext parentContext,
+                             int lengthBase,
+                             int lengthBaseValue) {
+        this.parentContext = parentContext;
+        this.lengthBase = lengthBase;
+        this.lengthBaseValue = lengthBaseValue;
+    }
+
+    /**
+     * Returns the value for the given lengthBase.
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, fobj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        // if its for us return our value otherwise delegate to parent context
+        if (lengthBase == this.lengthBase) {
+            return lengthBaseValue;
+        } else if (parentContext != null) {
+            return parentContext.getBaseLength(lengthBase, fobj);
+        }
+        return -1;
+    }
+
+}
index 833105498d0176cc0759a3b8b690d9e09e119437..a7674100fb9cd7d20f19e642f4ea55dfc72f5cc0 100644 (file)
 
 /* $Id$ */
 
-
 package org.apache.fop.fo;
 
+/**
+ * Definition of constants used throughout FOP.
+ * There are sets of constants describing:
+ * <ul>
+ * <li>Input and output formats</li>
+ * <li>Formatting objects</li>
+ * <li>Formatting properties</li>
+ * <li>Enumerated values used in formatting properties</li>
+ * </ul>
+ */
 public interface Constants {
 
     /* These constants are used by apps.CommandLineOptions and
@@ -27,6 +36,7 @@ public interface Constants {
        
     /** render constants for bounds checking */
     int RENDER_MIN_CONST = 1;
+    /** render constants for bounds checking */
     int RENDER_MAX_CONST = 12;
     /** input / output not set */
     int NOT_SET = 0;
@@ -60,505 +70,1006 @@ public interface Constants {
     int RENDER_PNG = 12;
 
     // element constants
-    int FO_UNKNOWN_NODE = 0;  // FObj base class
+    /** FObj base class */
+    int FO_UNKNOWN_NODE = 0;
+    /** FO element constant */
     int FO_BASIC_LINK = 1;
+    /** FO element constant */
     int FO_BIDI_OVERRIDE = 2;
+    /** FO element constant */
     int FO_BLOCK = 3;
+    /** FO element constant */
     int FO_BLOCK_CONTAINER = 4;
+    /** FO element constant */
     int FO_CHARACTER = 5;
+    /** FO element constant */
     int FO_COLOR_PROFILE = 6;
+    /** FO element constant */
     int FO_CONDITIONAL_PAGE_MASTER_REFERENCE = 7;
+    /** FO element constant */
     int FO_DECLARATIONS = 8;
+    /** FO element constant */
     int FO_EXTERNAL_GRAPHIC = 9;
+    /** FO element constant */
     int FO_FLOAT = 10;
+    /** FO element constant */
     int FO_FLOW = 11;
+    /** FO element constant */
     int FO_FOOTNOTE = 12;
+    /** FO element constant */
     int FO_FOOTNOTE_BODY = 13;
+    /** FO element constant */
     int FO_INITIAL_PROPERTY_SET = 14;
+    /** FO element constant */
     int FO_INLINE = 15;
+    /** FO element constant */
     int FO_INLINE_CONTAINER = 16;
+    /** FO element constant */
     int FO_INSTREAM_FOREIGN_OBJECT = 17;
+    /** FO element constant */
     int FO_LAYOUT_MASTER_SET = 18;
+    /** FO element constant */
     int FO_LEADER = 19;
+    /** FO element constant */
     int FO_LIST_BLOCK = 20;
+    /** FO element constant */
     int FO_LIST_ITEM = 21;
+    /** FO element constant */
     int FO_LIST_ITEM_BODY = 22;
+    /** FO element constant */
     int FO_LIST_ITEM_LABEL = 23;
+    /** FO element constant */
     int FO_MARKER = 24;
+    /** FO element constant */
     int FO_MULTI_CASE = 25;
+    /** FO element constant */
     int FO_MULTI_PROPERTIES = 26;
+    /** FO element constant */
     int FO_MULTI_PROPERTY_SET = 27;
+    /** FO element constant */
     int FO_MULTI_SWITCH = 28;
+    /** FO element constant */
     int FO_MULTI_TOGGLE = 29;
+    /** FO element constant */
     int FO_PAGE_NUMBER = 30;
+    /** FO element constant */
     int FO_PAGE_NUMBER_CITATION = 31;
+    /** FO element constant */
     int FO_PAGE_SEQUENCE = 32;
+    /** FO element constant */
     int FO_PAGE_SEQUENCE_MASTER = 33;
+    /** FO element constant */
     int FO_REGION_AFTER = 34;
+    /** FO element constant */
     int FO_REGION_BEFORE = 35;
+    /** FO element constant */
     int FO_REGION_BODY = 36;
+    /** FO element constant */
     int FO_REGION_END = 37;
+    /** FO element constant */
     int FO_REGION_START = 38;
+    /** FO element constant */
     int FO_REPEATABLE_PAGE_MASTER_ALTERNATIVES = 39;
+    /** FO element constant */
     int FO_REPEATABLE_PAGE_MASTER_REFERENCE = 40;
+    /** FO element constant */
     int FO_RETRIEVE_MARKER = 41;
+    /** FO element constant */
     int FO_ROOT = 42;
+    /** FO element constant */
     int FO_SIMPLE_PAGE_MASTER = 43;
+    /** FO element constant */
     int FO_SINGLE_PAGE_MASTER_REFERENCE = 44;
+    /** FO element constant */
     int FO_STATIC_CONTENT = 45;
+    /** FO element constant */
     int FO_TABLE = 46;
+    /** FO element constant */
     int FO_TABLE_AND_CAPTION = 47;
+    /** FO element constant */
     int FO_TABLE_BODY = 48;
+    /** FO element constant */
     int FO_TABLE_CAPTION = 49;
+    /** FO element constant */
     int FO_TABLE_CELL = 50;
+    /** FO element constant */
     int FO_TABLE_COLUMN = 51;
+    /** FO element constant */
     int FO_TABLE_FOOTER = 52;
+    /** FO element constant */
     int FO_TABLE_HEADER = 53;
+    /** FO element constant */
     int FO_TABLE_ROW = 54;
+    /** FO element constant */
     int FO_TITLE = 55;
+    /** FO element constant */
     int FO_WRAPPER = 56;
-    int FO_BOOKMARK_TREE = 57;          // XSL 1.1
-    int FO_BOOKMARK = 58;               // XSL 1.1
-    int FO_BOOKMARK_TITLE = 59;         // XSL 1.1
-    int FO_PAGE_SEQUENCE_WRAPPER = 60;  // XSL 1.1
+    /** FO element constant - XSL 1.1 */
+    int FO_BOOKMARK_TREE = 57;
+    /** FO element constant - XSL 1.1 */
+    int FO_BOOKMARK = 58;
+    /** FO element constant - XSL 1.1 */
+    int FO_BOOKMARK_TITLE = 59;
+    /** FO element constant - XSL 1.1 */
+    int FO_PAGE_SEQUENCE_WRAPPER = 60;
+    /** Number of FO element constants defined */
     int FRM_OBJ_COUNT = 60;
     
     // Masks
+    /** 
+     * For compound properties the property constant value is shifted by this amount.
+     * The low order bits hold the constant for the component property.
+     */
     int COMPOUND_SHIFT = 9;
-    int PROPERTY_MASK = (1 << COMPOUND_SHIFT)-1;
+    /** 
+     * Mask that when applied to a compound property returns the constant of
+     * the component property.
+     */
+    int PROPERTY_MASK = (1 << COMPOUND_SHIFT) - 1;
+    /** 
+     * Mask that when applied to a compound property returns the constant of
+     * the compound property.
+     */
     int COMPOUND_MASK = ~PROPERTY_MASK;
+    /** Number of compund properties defined */
     int COMPOUND_COUNT = 11;
     
     // property constants
+    /** Property constant */
     int PR_ABSOLUTE_POSITION = 1;
+    /** Property constant */
     int PR_ACTIVE_STATE = 2;
+    /** Property constant */
     int PR_ALIGNMENT_ADJUST = 3;
+    /** Property constant */
     int PR_ALIGNMENT_BASELINE = 4;
+    /** Property constant */
     int PR_AUTO_RESTORE = 5;
+    /** Property constant */
     int PR_AZIMUTH = 6;
+    /** Property constant */
     int PR_BACKGROUND = 7;
+    /** Property constant */
     int PR_BACKGROUND_ATTACHMENT = 8;
+    /** Property constant */
     int PR_BACKGROUND_COLOR = 9;
+    /** Property constant */
     int PR_BACKGROUND_IMAGE = 10;
+    /** Property constant */
     int PR_BACKGROUND_POSITION = 11;
+    /** Property constant */
     int PR_BACKGROUND_POSITION_HORIZONTAL = 12;
+    /** Property constant */
     int PR_BACKGROUND_POSITION_VERTICAL = 13;
+    /** Property constant */
     int PR_BACKGROUND_REPEAT = 14;
+    /** Property constant */
     int PR_BASELINE_SHIFT = 15;
+    /** Property constant */
     int PR_BLANK_OR_NOT_BLANK = 16;
+    /** Property constant */
     int PR_BLOCK_PROGRESSION_DIMENSION = 17;
+    /** Property constant */
     int PR_BORDER = 18;
+    /** Property constant */
     int PR_BORDER_AFTER_COLOR = 19;
+    /** Property constant */
     int PR_BORDER_AFTER_PRECEDENCE = 20;
+    /** Property constant */
     int PR_BORDER_AFTER_STYLE = 21;
+    /** Property constant */
     int PR_BORDER_AFTER_WIDTH = 22;
+    /** Property constant */
     int PR_BORDER_BEFORE_COLOR = 23;
+    /** Property constant */
     int PR_BORDER_BEFORE_PRECEDENCE = 24;
+    /** Property constant */
     int PR_BORDER_BEFORE_STYLE = 25;
+    /** Property constant */
     int PR_BORDER_BEFORE_WIDTH = 26;
+    /** Property constant */
     int PR_BORDER_BOTTOM = 27;
+    /** Property constant */
     int PR_BORDER_BOTTOM_COLOR = 28;
+    /** Property constant */
     int PR_BORDER_BOTTOM_STYLE = 29;
+    /** Property constant */
     int PR_BORDER_BOTTOM_WIDTH = 30;
+    /** Property constant */
     int PR_BORDER_COLLAPSE = 31;
+    /** Property constant */
     int PR_BORDER_COLOR = 32;
+    /** Property constant */
     int PR_BORDER_END_COLOR = 33;
+    /** Property constant */
     int PR_BORDER_END_PRECEDENCE = 34;
+    /** Property constant */
     int PR_BORDER_END_STYLE = 35;
+    /** Property constant */
     int PR_BORDER_END_WIDTH = 36;
+    /** Property constant */
     int PR_BORDER_LEFT = 37;
+    /** Property constant */
     int PR_BORDER_LEFT_COLOR = 38;
+    /** Property constant */
     int PR_BORDER_LEFT_STYLE = 39;
+    /** Property constant */
     int PR_BORDER_LEFT_WIDTH = 40;
+    /** Property constant */
     int PR_BORDER_RIGHT = 41;
+    /** Property constant */
     int PR_BORDER_RIGHT_COLOR = 42;
+    /** Property constant */
     int PR_BORDER_RIGHT_STYLE = 43;
+    /** Property constant */
     int PR_BORDER_RIGHT_WIDTH = 44;
+    /** Property constant */
     int PR_BORDER_SEPARATION = 45;
+    /** Property constant */
     int PR_BORDER_SPACING = 46;
+    /** Property constant */
     int PR_BORDER_START_COLOR = 47;
+    /** Property constant */
     int PR_BORDER_START_PRECEDENCE = 48;
+    /** Property constant */
     int PR_BORDER_START_STYLE = 49;
+    /** Property constant */
     int PR_BORDER_START_WIDTH = 50;
+    /** Property constant */
     int PR_BORDER_STYLE = 51;
+    /** Property constant */
     int PR_BORDER_TOP = 52;
+    /** Property constant */
     int PR_BORDER_TOP_COLOR = 53;
+    /** Property constant */
     int PR_BORDER_TOP_STYLE = 54;
+    /** Property constant */
     int PR_BORDER_TOP_WIDTH = 55;
+    /** Property constant */
     int PR_BORDER_WIDTH = 56;
+    /** Property constant */
     int PR_BOTTOM = 57;
+    /** Property constant */
     int PR_BREAK_AFTER = 58;
+    /** Property constant */
     int PR_BREAK_BEFORE = 59;
+    /** Property constant */
     int PR_CAPTION_SIDE = 60;
+    /** Property constant */
     int PR_CASE_NAME = 61;
+    /** Property constant */
     int PR_CASE_TITLE = 62;
+    /** Property constant */
     int PR_CHARACTER = 63;
+    /** Property constant */
     int PR_CLEAR = 64;
+    /** Property constant */
     int PR_CLIP = 65;
+    /** Property constant */
     int PR_COLOR = 66;
+    /** Property constant */
     int PR_COLOR_PROFILE_NAME = 67;
+    /** Property constant */
     int PR_COLUMN_COUNT = 68;
+    /** Property constant */
     int PR_COLUMN_GAP = 69;
+    /** Property constant */
     int PR_COLUMN_NUMBER = 70;
+    /** Property constant */
     int PR_COLUMN_WIDTH = 71;
+    /** Property constant */
     int PR_CONTENT_HEIGHT = 72;
+    /** Property constant */
     int PR_CONTENT_TYPE = 73;
+    /** Property constant */
     int PR_CONTENT_WIDTH = 74;
+    /** Property constant */
     int PR_COUNTRY = 75;
+    /** Property constant */
     int PR_CUE = 76;
+    /** Property constant */
     int PR_CUE_AFTER = 77;
+    /** Property constant */
     int PR_CUE_BEFORE = 78;
+    /** Property constant */
     int PR_DESTINATION_PLACEMENT_OFFSET = 79;
+    /** Property constant */
     int PR_DIRECTION = 80;
+    /** Property constant */
     int PR_DISPLAY_ALIGN = 81;
+    /** Property constant */
     int PR_DOMINANT_BASELINE = 82;
+    /** Property constant */
     int PR_ELEVATION = 83;
+    /** Property constant */
     int PR_EMPTY_CELLS = 84;
+    /** Property constant */
     int PR_END_INDENT = 85;
+    /** Property constant */
     int PR_ENDS_ROW = 86;
+    /** Property constant */
     int PR_EXTENT = 87;
+    /** Property constant */
     int PR_EXTERNAL_DESTINATION = 88;
+    /** Property constant */
     int PR_FLOAT = 89;
+    /** Property constant */
     int PR_FLOW_NAME = 90;
+    /** Property constant */
     int PR_FONT = 91;
+    /** Property constant */
     int PR_FONT_FAMILY = 92;
+    /** Property constant */
     int PR_FONT_SELECTION_STRATEGY = 93;
+    /** Property constant */
     int PR_FONT_SIZE = 94;
+    /** Property constant */
     int PR_FONT_SIZE_ADJUST = 95;
+    /** Property constant */
     int PR_FONT_STRETCH = 96;
+    /** Property constant */
     int PR_FONT_STYLE = 97;
+    /** Property constant */
     int PR_FONT_VARIANT = 98;
+    /** Property constant */
     int PR_FONT_WEIGHT = 99;
+    /** Property constant */
     int PR_FORCE_PAGE_COUNT = 100;
+    /** Property constant */
     int PR_FORMAT = 101;
+    /** Property constant */
     int PR_GLYPH_ORIENTATION_HORIZONTAL = 102;
+    /** Property constant */
     int PR_GLYPH_ORIENTATION_VERTICAL = 103;
+    /** Property constant */
     int PR_GROUPING_SEPARATOR = 104;
+    /** Property constant */
     int PR_GROUPING_SIZE = 105;
+    /** Property constant */
     int PR_HEIGHT = 106;
+    /** Property constant */
     int PR_HYPHENATE = 107;
+    /** Property constant */
     int PR_HYPHENATION_CHARACTER = 108;
+    /** Property constant */
     int PR_HYPHENATION_KEEP = 109;
+    /** Property constant */
     int PR_HYPHENATION_LADDER_COUNT = 110;
+    /** Property constant */
     int PR_HYPHENATION_PUSH_CHARACTER_COUNT = 111;
+    /** Property constant */
     int PR_HYPHENATION_REMAIN_CHARACTER_COUNT = 112;
+    /** Property constant */
     int PR_ID = 113;
+    /** Property constant */
     int PR_INDICATE_DESTINATION = 114;
+    /** Property constant */
     int PR_INITIAL_PAGE_NUMBER = 115;
+    /** Property constant */
     int PR_INLINE_PROGRESSION_DIMENSION = 116;
+    /** Property constant */
     int PR_INTERNAL_DESTINATION = 117;
+    /** Property constant */
     int PR_KEEP_TOGETHER = 118;
+    /** Property constant */
     int PR_KEEP_WITH_NEXT = 119;
+    /** Property constant */
     int PR_KEEP_WITH_PREVIOUS = 120;
+    /** Property constant */
     int PR_LANGUAGE = 121;
+    /** Property constant */
     int PR_LAST_LINE_END_INDENT = 122;
+    /** Property constant */
     int PR_LEADER_ALIGNMENT = 123;
+    /** Property constant */
     int PR_LEADER_LENGTH = 124;
+    /** Property constant */
     int PR_LEADER_PATTERN = 125;
+    /** Property constant */
     int PR_LEADER_PATTERN_WIDTH = 126;
+    /** Property constant */
     int PR_LEFT = 127;
+    /** Property constant */
     int PR_LETTER_SPACING = 128;
+    /** Property constant */
     int PR_LETTER_VALUE = 129;
+    /** Property constant */
     int PR_LINEFEED_TREATMENT = 130;
+    /** Property constant */
     int PR_LINE_HEIGHT = 131;
+    /** Property constant */
     int PR_LINE_HEIGHT_SHIFT_ADJUSTMENT = 132;
+    /** Property constant */
     int PR_LINE_STACKING_STRATEGY = 133;
+    /** Property constant */
     int PR_MARGIN = 134;
+    /** Property constant */
     int PR_MARGIN_BOTTOM = 135;
+    /** Property constant */
     int PR_MARGIN_LEFT = 136;
+    /** Property constant */
     int PR_MARGIN_RIGHT = 137;
+    /** Property constant */
     int PR_MARGIN_TOP = 138;
+    /** Property constant */
     int PR_MARKER_CLASS_NAME = 139;
+    /** Property constant */
     int PR_MASTER_NAME = 140;
+    /** Property constant */
     int PR_MASTER_REFERENCE = 141;
+    /** Property constant */
     int PR_MAX_HEIGHT = 142;
+    /** Property constant */
     int PR_MAXIMUM_REPEATS = 143;
+    /** Property constant */
     int PR_MAX_WIDTH = 144;
+    /** Property constant */
     int PR_MEDIA_USAGE = 145;
+    /** Property constant */
     int PR_MIN_HEIGHT = 146;
+    /** Property constant */
     int PR_MIN_WIDTH = 147;
+    /** Property constant */
     int PR_NUMBER_COLUMNS_REPEATED = 148;
+    /** Property constant */
     int PR_NUMBER_COLUMNS_SPANNED = 149;
+    /** Property constant */
     int PR_NUMBER_ROWS_SPANNED = 150;
+    /** Property constant */
     int PR_ODD_OR_EVEN = 151;
+    /** Property constant */
     int PR_ORPHANS = 152;
+    /** Property constant */
     int PR_OVERFLOW = 153;
+    /** Property constant */
     int PR_PADDING = 154;
+    /** Property constant */
     int PR_PADDING_AFTER = 155;
+    /** Property constant */
     int PR_PADDING_BEFORE = 156;
+    /** Property constant */
     int PR_PADDING_BOTTOM = 157;
+    /** Property constant */
     int PR_PADDING_END = 158;
+    /** Property constant */
     int PR_PADDING_LEFT = 159;
+    /** Property constant */
     int PR_PADDING_RIGHT = 160;
+    /** Property constant */
     int PR_PADDING_START = 161;
+    /** Property constant */
     int PR_PADDING_TOP = 162;
+    /** Property constant */
     int PR_PAGE_BREAK_AFTER = 163;
+    /** Property constant */
     int PR_PAGE_BREAK_BEFORE = 164;
+    /** Property constant */
     int PR_PAGE_BREAK_INSIDE = 165;
+    /** Property constant */
     int PR_PAGE_HEIGHT = 166;
+    /** Property constant */
     int PR_PAGE_POSITION = 167;
+    /** Property constant */
     int PR_PAGE_WIDTH = 168;
+    /** Property constant */
     int PR_PAUSE = 169;
+    /** Property constant */
     int PR_PAUSE_AFTER = 170;
+    /** Property constant */
     int PR_PAUSE_BEFORE = 171;
+    /** Property constant */
     int PR_PITCH = 172;
+    /** Property constant */
     int PR_PITCH_RANGE = 173;
+    /** Property constant */
     int PR_PLAY_DURING = 174;
+    /** Property constant */
     int PR_POSITION = 175;
+    /** Property constant */
     int PR_PRECEDENCE = 176;
+    /** Property constant */
     int PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS = 177;
+    /** Property constant */
     int PR_PROVISIONAL_LABEL_SEPARATION = 178;
+    /** Property constant */
     int PR_REFERENCE_ORIENTATION = 179;
+    /** Property constant */
     int PR_REF_ID = 180;
+    /** Property constant */
     int PR_REGION_NAME = 181;
+    /** Property constant */
     int PR_RELATIVE_ALIGN = 182;
+    /** Property constant */
     int PR_RELATIVE_POSITION = 183;
+    /** Property constant */
     int PR_RENDERING_INTENT = 184;
+    /** Property constant */
     int PR_RETRIEVE_BOUNDARY = 185;
+    /** Property constant */
     int PR_RETRIEVE_CLASS_NAME = 186;
+    /** Property constant */
     int PR_RETRIEVE_POSITION = 187;
+    /** Property constant */
     int PR_RICHNESS = 188;
+    /** Property constant */
     int PR_RIGHT = 189;
+    /** Property constant */
     int PR_ROLE = 190;
+    /** Property constant */
     int PR_RULE_STYLE = 191;
+    /** Property constant */
     int PR_RULE_THICKNESS = 192;
+    /** Property constant */
     int PR_SCALING = 193;
+    /** Property constant */
     int PR_SCALING_METHOD = 194;
+    /** Property constant */
     int PR_SCORE_SPACES = 195;
+    /** Property constant */
     int PR_SCRIPT = 196;
+    /** Property constant */
     int PR_SHOW_DESTINATION = 197;
+    /** Property constant */
     int PR_SIZE = 198;
+    /** Property constant */
     int PR_SOURCE_DOCUMENT = 199;
+    /** Property constant */
     int PR_SPACE_AFTER = 200;
+    /** Property constant */
     int PR_SPACE_BEFORE = 201;
+    /** Property constant */
     int PR_SPACE_END = 202;
+    /** Property constant */
     int PR_SPACE_START = 203;
+    /** Property constant */
     int PR_SPAN = 204;
+    /** Property constant */
     int PR_SPEAK = 205;
+    /** Property constant */
     int PR_SPEAK_HEADER = 206;
+    /** Property constant */
     int PR_SPEAK_NUMERAL = 207;
+    /** Property constant */
     int PR_SPEAK_PUNCTUATION = 208;
+    /** Property constant */
     int PR_SPEECH_RATE = 209;
+    /** Property constant */
     int PR_SRC = 210;
+    /** Property constant */
     int PR_START_INDENT = 211;
+    /** Property constant */
     int PR_STARTING_STATE = 212;
+    /** Property constant */
     int PR_STARTS_ROW = 213;
+    /** Property constant */
     int PR_STRESS = 214;
+    /** Property constant */
     int PR_SUPPRESS_AT_LINE_BREAK = 215;
+    /** Property constant */
     int PR_SWITCH_TO = 216;
+    /** Property constant */
     int PR_TABLE_LAYOUT = 217;
+    /** Property constant */
     int PR_TABLE_OMIT_FOOTER_AT_BREAK = 218;
+    /** Property constant */
     int PR_TABLE_OMIT_HEADER_AT_BREAK = 219;
+    /** Property constant */
     int PR_TARGET_PRESENTATION_CONTEXT = 220;
+    /** Property constant */
     int PR_TARGET_PROCESSING_CONTEXT = 221;
+    /** Property constant */
     int PR_TARGET_STYLESHEET = 222;
+    /** Property constant */
     int PR_TEXT_ALIGN = 223;
+    /** Property constant */
     int PR_TEXT_ALIGN_LAST = 224;
+    /** Property constant */
     int PR_TEXT_ALTITUDE = 225;
+    /** Property constant */
     int PR_TEXT_DECORATION = 226;
+    /** Property constant */
     int PR_TEXT_DEPTH = 227;
+    /** Property constant */
     int PR_TEXT_INDENT = 228;
+    /** Property constant */
     int PR_TEXT_SHADOW = 229;
+    /** Property constant */
     int PR_TEXT_TRANSFORM = 230;
+    /** Property constant */
     int PR_TOP = 231;
+    /** Property constant */
     int PR_TREAT_AS_WORD_SPACE = 232;
+    /** Property constant */
     int PR_UNICODE_BIDI = 233;
+    /** Property constant */
     int PR_VERTICAL_ALIGN = 234;
+    /** Property constant */
     int PR_VISIBILITY = 235;
+    /** Property constant */
     int PR_VOICE_FAMILY = 236;
+    /** Property constant */
     int PR_VOLUME = 237;
+    /** Property constant */
     int PR_WHITE_SPACE_COLLAPSE = 238;
+    /** Property constant */
     int PR_WHITE_SPACE_TREATMENT = 239;
+    /** Property constant */
     int PR_WIDOWS = 240;
+    /** Property constant */
     int PR_WIDTH = 241;
+    /** Property constant */
     int PR_WORD_SPACING = 242;
+    /** Property constant */
     int PR_WRAP_OPTION = 243;
+    /** Property constant */
     int PR_WRITING_MODE = 244;
+    /** Property constant */
     int PR_XML_LANG = 245;
+    /** Property constant */
     int PR_Z_INDEX = 246;
+    /** Property constant */
     int PR_INTRUSION_DISPLACE = 247;
-    int PR_INDEX_CLASS = 248;   // XSL 1.1
-    int PR_INDEX_KEY = 249;     // XSL 1.1
-    int PR_X_BLOCK_PROGRESSION_UNIT = 250; //Custom extension
+    /** Property constant - XSL 1.1 */
+    int PR_INDEX_CLASS = 248;
+    /** Property constant - XSL 1.1 */
+    int PR_INDEX_KEY = 249;
+    /** Property constant - Custom extension */
+    int PR_X_BLOCK_PROGRESSION_UNIT = 250;
+    /** Number of property constants defined */
     int PROPERTY_COUNT = 250;
 
     // compound property constants
 
+    /** Property constant for compund property */
     int CP_BLOCK_PROGRESSION_DIRECTION = 1 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_CONDITIONALITY = 2 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_INLINE_PROGRESSION_DIRECTION = 3 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_LENGTH = 4 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_MAXIMUM = 5 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_MINIMUM = 6 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_OPTIMUM = 7 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_PRECEDENCE = 8 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_WITHIN_COLUMN = 9 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_WITHIN_LINE = 10 << COMPOUND_SHIFT;
+    /** Property constant for compund property */
     int CP_WITHIN_PAGE = 11 << COMPOUND_SHIFT;
 
     // Enumeration constants
+    /** Enumeration constant */
     int EN_ABSOLUTE = 1;
+    /** Enumeration constant */
     int EN_ABSOLUTE_COLORMETRIC = 2;
+    /** Enumeration constant */
     int EN_AFTER = 3;
+    /** Enumeration constant */
     int EN_AFTER_EDGE = 4;
+    /** Enumeration constant */
     int EN_ALL = 5;
+    /** Enumeration constant */
     int EN_ALPHABETIC = 6;
+    /** Enumeration constant */
     int EN_ALWAYS = 7;
+    /** Enumeration constant */
     int EN_ANY = 8;
+    /** Enumeration constant */
     int EN_AUTO = 9;
+    /** Enumeration constant */
     int EN_AUTO_EVEN = 10;
+    /** Enumeration constant */
     int EN_AUTO_ODD = 11;
+    /** Enumeration constant */
     int EN_BASELINE = 12;
+    /** Enumeration constant */
     int EN_BEFORE = 13;
+    /** Enumeration constant */
     int EN_BEFORE_EDGE = 14;
+    /** Enumeration constant */
     int EN_BIDI_OVERRIDE = 15;
+    /** Enumeration constant */
     int EN_BLANK = 16;
+    /** Enumeration constant */
     int EN_BLINK = 17;
+    /** Enumeration constant */
     int EN_BLOCK = 18;
+    /** Enumeration constant */
     int EN_BOTH = 19;
+    /** Enumeration constant */
     int EN_BOTTOM = 20;
+    /** Enumeration constant */
     int EN_BOUNDED_IN_ONE_DIMENSION = 21;
+    /** Enumeration constant */
     int EN_CAPITALIZE = 22;
+    /** Enumeration constant */
     int EN_CENTER = 23;
+    /** Enumeration constant */
     int EN_CENTRAL = 24;
+    /** Enumeration constant */
     int EN_CHARACTER_BY_CHARACTER = 25;
+    /** Enumeration constant */
     int EN_COLLAPSE = 26;
+    /** Enumeration constant */
     int EN_COLLAPSE_WITH_PRECEDENCE = 27;
+    /** Enumeration constant */
     int EN_COLUMN = 28;
+    /** Enumeration constant */
     int EN_CONDENSED = 29;
+    /** Enumeration constant */
     int EN_CONSIDER_SHIFTS = 30;
+    /** Enumeration constant */
     int EN_DASHED = 31;
+    /** Enumeration constant */
     int EN_DISCARD = 32;
+    /** Enumeration constant */
     int EN_DISREGARD_SHIFTS = 33;
+    /** Enumeration constant */
     int EN_DOCUMENT = 34;
+    /** Enumeration constant */
     int EN_DOTS = 35;
+    /** Enumeration constant */
     int EN_DOTTED = 36;
+    /** Enumeration constant */
     int EN_DOUBLE = 37;
+    /** Enumeration constant */
     int EN_EMBED = 38;
+    /** Enumeration constant */
     int EN_END = 39;
+    /** Enumeration constant */
     int EN_END_ON_EVEN = 40;
+    /** Enumeration constant */
     int EN_END_ON_ODD = 41;
+    /** Enumeration constant */
     int EN_ERROR_IF_OVERFLOW = 42;
+    /** Enumeration constant */
     int EN_EVEN = 43;
+    /** Enumeration constant */
     int EN_EVEN_PAGE = 44;
+    /** Enumeration constant */
     int EN_EXPANDED = 45;
+    /** Enumeration constant */
     int EN_EXTRA_CONDENSED = 46;
+    /** Enumeration constant */
     int EN_EXTRA_EXPANDED = 47;
+    /** Enumeration constant */
     int EN_FALSE = 48;
+    /** Enumeration constant */
     int EN_FIC = 49;
+    /** Enumeration constant */
     int EN_FIRST = 50;
+    /** Enumeration constant */
     int EN_FIXED = 51;
+    /** Enumeration constant */
     int EN_FONT_HEIGHT = 52;
+    /** Enumeration constant */
     int EN_FORCE = 53;
+    /** Enumeration constant */
     int EN_FSWP = 54;
+    /** Enumeration constant */
     int EN_GROOVE = 55;
+    /** Enumeration constant */
     int EN_HANGING = 56;
+    /** Enumeration constant */
     int EN_HIDDEN = 57;
+    /** Enumeration constant */
     int EN_HIDE = 58;
+    /** Enumeration constant */
     int EN_IDEOGRAPHIC = 59;
+    /** Enumeration constant */
     int EN_IGNORE = 60;
+    /** Enumeration constant */
     int EN_IGNORE_IF_AFTER_LINEFEED = 61;
+    /** Enumeration constant */
     int EN_IGNORE_IF_BEFORE_LINEFEED = 62;
+    /** Enumeration constant */
     int EN_IGNORE_IF_SURROUNDING_LINEFEED = 63;
+    /** Enumeration constant */
     int EN_INDEFINITE = 64;
+    /** Enumeration constant */
     int EN_INDENT = 65;
+    /** Enumeration constant */
     int EN_INHERIT = 66;
+    /** Enumeration constant */
     int EN_INSET = 67;
+    /** Enumeration constant */
     int EN_INSIDE = 68;
+    /** Enumeration constant */
     int EN_INTEGER_PIXELS = 69;
+    /** Enumeration constant */
     int EN_JUSTIFY = 70;
+    /** Enumeration constant */
     int EN_LARGER = 71;
+    /** Enumeration constant */
     int EN_LAST = 72;
+    /** Enumeration constant */
     int EN_LEFT = 73;
+    /** Enumeration constant */
     int EN_LEWP = 74;
+    /** Enumeration constant */
     int EN_LINE = 75;
+    /** Enumeration constant */
     int EN_LINE_HEIGHT = 76;
+    /** Enumeration constant */
     int EN_LINE_THROUGH = 77;
+    /** Enumeration constant */
     int EN_LOWERCASE = 78;
+    /** Enumeration constant */
     int EN_LR_TB = 79;
+    /** Enumeration constant */
     int EN_LTR = 80;
+    /** Enumeration constant */
     int EN_LSWP = 81;
+    /** Enumeration constant */
     int EN_MATHEMATICAL = 82;
+    /** Enumeration constant */
     int EN_MAX_HEIGHT = 83;
+    /** Enumeration constant */
     int EN_MIDDLE = 84;
+    /** Enumeration constant */
     int EN_NARROWER = 85;
+    /** Enumeration constant */
     int EN_NO_BLINK = 86;
+    /** Enumeration constant */
     int EN_NO_CHANGE = 87;
+    /** Enumeration constant */
     int EN_NO_FORCE = 88;
+    /** Enumeration constant */
     int EN_NO_LIMIT = 89;
+    /** Enumeration constant */
     int EN_NO_LINE_THROUGH = 90;
+    /** Enumeration constant */
     int EN_NO_OVERLINE = 91;
+    /** Enumeration constant */
     int EN_NO_UNDERLINE = 92;
+    /** Enumeration constant */
     int EN_NO_WRAP = 93;
+    /** Enumeration constant */
     int EN_NON_UNIFORM = 94;
+    /** Enumeration constant */
     int EN_NONE = 95;
+    /** Enumeration constant */
     int EN_NOREPEAT = 96;
+    /** Enumeration constant */
     int EN_NORMAL = 97;
+    /** Enumeration constant */
     int EN_NOT_BLANK = 98;
+    /** Enumeration constant */
     int EN_ODD = 99;
+    /** Enumeration constant */
     int EN_ODD_PAGE = 100;
+    /** Enumeration constant */
     int EN_OUTSET = 101;
+    /** Enumeration constant */
     int EN_OUTSIDE = 102;
+    /** Enumeration constant */
     int EN_OVERLINE = 103;
+    /** Enumeration constant */
     int EN_PAGE = 104;
+    /** Enumeration constant */
     int EN_PAGE_SEQUENCE = 105;
+    /** Enumeration constant */
     int EN_PAGINATE = 106;
+    /** Enumeration constant */
     int EN_PERCEPTUAL = 107;
+    /** Enumeration constant */
     int EN_PRESERVE = 108;
+    /** Enumeration constant */
     int EN_REFERENCE_AREA = 109;
+    /** Enumeration constant */
     int EN_RELATIVE = 110;
+    /** Enumeration constant */
     int EN_RELATIVE_COLOMETRIC = 111;
+    /** Enumeration constant */
     int EN_REPEAT = 112;
+    /** Enumeration constant */
     int EN_REPEATX = 113;
+    /** Enumeration constant */
     int EN_REPEATY = 114;
+    /** Enumeration constant */
     int EN_RESAMPLE_ANY_METHOD = 115;
+    /** Enumeration constant */
     int EN_RESET_SIZE = 116;
+    /** Enumeration constant */
     int EN_REST = 117;
+    /** Enumeration constant */
     int EN_RETAIN = 118;
+    /** Enumeration constant */
     int EN_RIDGE = 119;
+    /** Enumeration constant */
     int EN_RIGHT = 120;
+    /** Enumeration constant */
     int EN_RL_TB = 121;
+    /** Enumeration constant */
     int EN_RTL = 122;
+    /** Enumeration constant */
     int EN_RULE = 123;
+    /** Enumeration constant */
     int EN_SATURATION = 124;
+    /** Enumeration constant */
     int EN_SCALE_TO_FIT = 125;
+    /** Enumeration constant */
     int EN_SCROLL = 126;
+    /** Enumeration constant */
     int EN_SEMI_CONDENSED = 127;
+    /** Enumeration constant */
     int EN_SEMI_EXPANDED = 128;
+    /** Enumeration constant */
     int EN_SEPARATE = 129;
+    /** Enumeration constant */
     int EN_SHOW = 130;
+    /** Enumeration constant */
     int EN_SMALL_CAPS = 131;
+    /** Enumeration constant */
     int EN_SMALLER = 132;
+    /** Enumeration constant */
     int EN_SOLID = 133;
+    /** Enumeration constant */
     int EN_SPACE = 134;
+    /** Enumeration constant */
     int EN_START = 135;
+    /** Enumeration constant */
     int EN_STATIC = 136;
+    /** Enumeration constant */
     int EN_SUB = 137;
+    /** Enumeration constant */
     int EN_SUPER = 138;
+    /** Enumeration constant */
     int EN_SUPPRESS = 139;
+    /** Enumeration constant */
     int EN_TB_RL = 140;
+    /** Enumeration constant */
     int EN_TEXT_AFTER_EDGE = 141;
+    /** Enumeration constant */
     int EN_TEXT_BEFORE_EDGE = 142;
+    /** Enumeration constant */
     int EN_TEXT_BOTTOM = 143;
+    /** Enumeration constant */
     int EN_TEXT_TOP = 144;
+    /** Enumeration constant */
     int EN_TOP = 145;
+    /** Enumeration constant */
     int EN_TRADITIONAL = 146;
+    /** Enumeration constant */
     int EN_TREAT_AS_SPACE = 147;
+    /** Enumeration constant */
     int EN_TREAT_AS_ZERO_WIDTH_SPACE = 148;
+    /** Enumeration constant */
     int EN_TRUE = 149;
+    /** Enumeration constant */
     int EN_ULTRA_CONDENSED = 150;
+    /** Enumeration constant */
     int EN_ULTRA_EXPANDED = 151;
+    /** Enumeration constant */
     int EN_UNBOUNDED = 152;
+    /** Enumeration constant */
     int EN_UNDERLINE = 153;
+    /** Enumeration constant */
     int EN_UNIFORM = 154;
+    /** Enumeration constant */
     int EN_UPPERCASE = 155;
+    /** Enumeration constant */
     int EN_USE_FONT_METRICS = 156;
+    /** Enumeration constant */
     int EN_USE_SCRIPT = 157;
+    /** Enumeration constant */
     int EN_USECONTENT = 158;
+    /** Enumeration constant */
     int EN_VISIBLE = 159;
+    /** Enumeration constant */
     int EN_WIDER = 160;
+    /** Enumeration constant */
     int EN_WRAP = 161;
-    int EN_X_FILL = 162; //non-standard for display-align
-    int EN_X_DISTRIBUTE = 163; //non-standard for display-align
+    /** Enumeration constant - non-standard for display-align */
+    int EN_X_FILL = 162;
+    /** Enumeration constant - non-standard for display-align */
+    int EN_X_DISTRIBUTE = 163;
+    /** Number of enumeration constants defined */
     int ENUM_COUNT = 163;
 }
index f49d4d94ea417ac4f87a941eca4851e650702815..7ff94a888639b7274cb167eb96e7202807ea3873 100644 (file)
@@ -280,12 +280,13 @@ public class FOPropertyMapping implements Constants {
         genericCondPadding.useGeneric(genericCondLength);
         genericCondPadding.setInherited(false);
         genericCondPadding.getSubpropMaker(CP_LENGTH).setDefault("0pt");
+        genericCondPadding.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
 
         // GenericPadding
         genericPadding = new LengthProperty.Maker(0);
         genericPadding.setInherited(false);
         genericPadding.setDefault("0pt");
-        genericPadding.setPercentBase(LengthBase.BLOCK_WIDTH);
+        genericPadding.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         genericPadding.addShorthand(s_generics[PR_PADDING]);
 
         // GenericCondBorderWidth
@@ -716,7 +717,7 @@ public class FOPropertyMapping implements Constants {
         m.addKeyword("left", "0%");
         m.addKeyword("center", "50%");
         m.addKeyword("right", "100%");
-        m.setPercentBase(LengthBase.CONTAINING_BOX);
+        m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL);
         addPropertyMaker("background-position-horizontal", m);
 
         // background-position-vertical
@@ -726,7 +727,7 @@ public class FOPropertyMapping implements Constants {
         m.addKeyword("top", "0%");
         m.addKeyword("center", "50%");
         m.addKeyword("bottom", "100%");
-        m.setPercentBase(LengthBase.CONTAINING_BOX);
+        m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL);
         addPropertyMaker("background-position-vertical", m);
 
         // border-before-color
@@ -1202,7 +1203,7 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(false);
         m.setDefault("0pt");
         m.addShorthand(s_generics[PR_MARGIN]);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("margin-top", m);
 
         // margin-bottom
@@ -1210,7 +1211,7 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(false);
         m.setDefault("0pt");
         m.addShorthand(s_generics[PR_MARGIN]);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("margin-bottom", m);
 
         // margin-left
@@ -1218,7 +1219,7 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(false);
         m.setDefault("0pt");
         m.addShorthand(s_generics[PR_MARGIN]);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("margin-left", m);
 
         // margin-right
@@ -1226,7 +1227,7 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(false);
         m.setDefault("0pt");
         m.addShorthand(s_generics[PR_MARGIN]);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("margin-right", m);
 
         // space-before
@@ -1407,26 +1408,26 @@ public class FOPropertyMapping implements Constants {
         // block-progression-dimension
         m = new LengthRangeProperty.Maker(PR_BLOCK_PROGRESSION_DIMENSION);
         m.setInherited(false);
-        m.setPercentBase(LengthBase.BLOCK_HEIGHT);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
 
         l = new LengthProperty.Maker(CP_MINIMUM);
         l.setDefault("auto");
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
         l = new LengthProperty.Maker(CP_OPTIMUM);
         l.setDefault("auto");
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
         l = new LengthProperty.Maker(CP_MAXIMUM);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
         l.setDefault("auto");
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
@@ -1462,33 +1463,33 @@ public class FOPropertyMapping implements Constants {
         l  = new LengthProperty.Maker(PR_HEIGHT);
         l.setInherited(false);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.BLOCK_HEIGHT);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
         l.setDefault("auto");
         addPropertyMaker("height", l);
 
         // inline-progression-dimension
         m = new LengthRangeProperty.Maker(PR_INLINE_PROGRESSION_DIMENSION);
         m.setInherited(false);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
 
         l = new LengthProperty.Maker(CP_MINIMUM);
         l.setDefault("auto");
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
         l = new LengthProperty.Maker(CP_OPTIMUM);
         l.setDefault("auto");
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
         l = new LengthProperty.Maker(CP_MAXIMUM);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
         l.setDefault("auto");
-        l.setPercentBase(LengthBase.CONTAINING_BOX);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         l.setByShorthand(true);
         m.addSubpropMaker(l);
 
@@ -1547,7 +1548,7 @@ public class FOPropertyMapping implements Constants {
         l  = new LengthProperty.Maker(PR_WIDTH);
         l.setInherited(false);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
-        l.setPercentBase(LengthBase.BLOCK_WIDTH);
+        l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         l.setDefault("auto");
         addPropertyMaker("width", l);
 
@@ -1679,7 +1680,7 @@ public class FOPropertyMapping implements Constants {
         m  = new LengthProperty.Maker(PR_TEXT_INDENT);
         m.setInherited(true);
         m.setDefault("0pt");
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("text-indent", m);
 
         // white-space-collapse
@@ -1957,29 +1958,29 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(true);
         m.setDefault("use-font-metrics", true);
         m.addKeyword("use-font-metrics", "0pt");
-        m.setPercentBase(LengthBase.CONTAINING_BOX);
+        m.setPercentBase(LengthBase.PARENT_AREA_WIDTH);
         addPropertyMaker("leader-pattern-width", m);
 
         // leader-length
         m  = new LengthRangeProperty.Maker(PR_LEADER_LENGTH);
         m.setInherited(true);
-        m.setPercentBase(LengthBase.CONTAINING_BOX);
+        m.setPercentBase(LengthBase.PARENT_AREA_WIDTH);
 
         sub = new LengthProperty.Maker(CP_MINIMUM);
         sub.setDefault("0pt");
-        sub.setPercentBase(LengthBase.BLOCK_WIDTH);
+        sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         sub.setByShorthand(true);
         m.addSubpropMaker(sub);
 
         sub = new LengthProperty.Maker(CP_OPTIMUM);
         sub.setDefault("12.0pt");
-        sub.setPercentBase(LengthBase.BLOCK_WIDTH);
+        sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         sub.setByShorthand(true);
         m.addSubpropMaker(sub);
 
         sub = new LengthProperty.Maker(CP_MAXIMUM);
         sub.setDefault("100%", true);
-        sub.setPercentBase(LengthBase.BLOCK_WIDTH);
+        sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         sub.setByShorthand(true);
         m.addSubpropMaker(sub);
         addPropertyMaker("leader-length", m);
@@ -2190,6 +2191,7 @@ public class FOPropertyMapping implements Constants {
         m  = new LengthProperty.Maker(PR_EXTENT);
         m.setInherited(true);
         m.setDefault("0pt");
+        m.setPercentBase(LengthBase.CUSTOM_BASE);
         addPropertyMaker("extent", m);
 
         // flow-name
@@ -2376,7 +2378,7 @@ public class FOPropertyMapping implements Constants {
         m  = new LengthProperty.Maker(PR_COLUMN_WIDTH);
         m.setInherited(false);
         m.setDefault("proportional-column-width(1)", true);
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("column-width", m);
 
         // empty-cells
@@ -2651,13 +2653,14 @@ public class FOPropertyMapping implements Constants {
         m.setInherited(false);
         m.setDefault("");
         m.setDatatypeParser(new BoxPropShorthandParser());
-        m.setPercentBase(LengthBase.BLOCK_WIDTH);
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("margin", m);
 
         // padding
         m  = new ListProperty.Maker(PR_PADDING);
         m.setInherited(false);
         m.setDatatypeParser(new BoxPropShorthandParser());
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("padding", m);
 
         // page-break-after
index 02ef5f341c07ded722eda508d387d188c1d069de..ed90d50c05a6e1172e00dfb922f612353d6fdda7 100644 (file)
@@ -40,9 +40,9 @@ public class InlineCharIterator extends RecursiveCharIterator {
 
     private void checkBoundaries(CommonBorderPaddingBackground bpb) {
         bStartBoundary = (bpb.getBorderStartWidth(false) > 0
-                       || bpb.getPaddingStart(false) > 0);
+                       || bpb.getPaddingStart(false, null) > 0); // TODO do we need context here?
         bEndBoundary = (bpb.getBorderEndWidth(false) > 0
-                     || bpb.getPaddingEnd(false) > 0);
+                     || bpb.getPaddingEnd(false, null) > 0); // TODO do we need context here?
     }
 
     /**
index d014662b3643e1059371ac393251e21083e628a1..4682272b5341940bde748633ddf3e2b116c8c69f 100644 (file)
@@ -66,7 +66,7 @@ public class LabelEndFunction extends FunctionBase {
         Length startIndent = pList.get(Constants.PR_START_INDENT).getLength();
 
         LengthBase base = new LengthBase(pList.getFObj(), pInfo.getPropertyList(),
-                                         LengthBase.CONTAINING_REFAREA);
+                                         LengthBase.CONTAINING_REFAREA_WIDTH);
         PercentLength refWidth = new PercentLength(1.0, base);
 
         Numeric labelEnd = distance; 
index 34aa29d00a575927b4f878413bef9eccbe57bf40..3edc41196e6505632069f7cb0ff4d453122d6e6c 100755 (executable)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.fo.expr;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.Numeric;
 
 /**
@@ -39,17 +40,17 @@ public class NumericOp {
      */
     public static Numeric addition(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return addition2(op1, op2);
+            return addition2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.ADDITION, op1, op2);
         }
     }
     
-    public static Numeric addition2(Numeric op1, Numeric op2) throws PropertyException {
+    public static Numeric addition2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
         if (op1.getDimension() != op2.getDimension()) {
             throw new PropertyException("Can't subtract Numerics of different dimensions");
         }
-        return numeric(op1.getNumericValue() + op2.getNumericValue(), op1.getDimension());
+        return numeric(op1.getNumericValue(context) + op2.getNumericValue(context), op1.getDimension());
     }
     
     /**
@@ -63,17 +64,17 @@ public class NumericOp {
      */
     public static Numeric subtraction(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return subtraction2(op1, op2);
+            return subtraction2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.SUBTRACTION, op1, op2);
         }
     }
 
-    public static Numeric subtraction2(Numeric op1, Numeric op2) throws PropertyException {
+    public static Numeric subtraction2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
         if (op1.getDimension() != op2.getDimension()) {
             throw new PropertyException("Can't subtract Numerics of different dimensions");
         }
-        return numeric(op1.getNumericValue() - op2.getNumericValue(), op1.getDimension());
+        return numeric(op1.getNumericValue(context) - op2.getNumericValue(context), op1.getDimension());
     }
     
     /**
@@ -87,14 +88,14 @@ public class NumericOp {
      */
     public static Numeric multiply(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return multiply2(op1, op2);
+            return multiply2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.MULTIPLY, op1, op2);
         }
     }    
 
-    public static Numeric multiply2(Numeric op1, Numeric op2) throws PropertyException {
-        return numeric(op1.getNumericValue() * op2.getNumericValue(), 
+    public static Numeric multiply2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+        return numeric(op1.getNumericValue(context) * op2.getNumericValue(context), 
                        op1.getDimension() + op2.getDimension());
     }
     
@@ -110,14 +111,14 @@ public class NumericOp {
      */
     public static Numeric divide(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return divide2(op1, op2);
+            return divide2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.DIVIDE, op1, op2);
         }
     }
     
-    public static Numeric divide2(Numeric op1, Numeric op2) throws PropertyException {
-        return numeric(op1.getNumericValue() / op2.getNumericValue(), 
+    public static Numeric divide2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+        return numeric(op1.getNumericValue(context) / op2.getNumericValue(context), 
                        op1.getDimension() - op2.getDimension());
     }
     
@@ -129,14 +130,14 @@ public class NumericOp {
      */
     public static Numeric modulo(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return modulo2(op1, op2);
+            return modulo2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.MODULO, op1, op2);
         }
     }
     
-    public static Numeric modulo2(Numeric op1, Numeric op2) throws PropertyException {
-        return numeric(op1.getNumericValue() % op2.getNumericValue(), op1.getDimension());
+    public static Numeric modulo2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+        return numeric(op1.getNumericValue(context) % op2.getNumericValue(context), op1.getDimension());
     }
 
     /**
@@ -146,14 +147,14 @@ public class NumericOp {
      */
     public static Numeric abs(Numeric op) throws PropertyException {
         if (op.isAbsolute()) {
-            return abs2(op);
+            return abs2(op, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.ABS, op);
         }
     }
 
-    public static Numeric abs2(Numeric op) throws PropertyException {
-        return numeric(Math.abs(op.getNumericValue()), op.getDimension());
+    public static Numeric abs2(Numeric op, PercentBaseContext context) throws PropertyException {
+        return numeric(Math.abs(op.getNumericValue(context)), op.getDimension());
     }
     
     /**
@@ -163,14 +164,14 @@ public class NumericOp {
      */
     public static Numeric negate(Numeric op) throws PropertyException {
         if (op.isAbsolute()) {
-            return negate2(op);
+            return negate2(op, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.NEGATE, op);
         }
     }
 
-    public static Numeric negate2(Numeric op) throws PropertyException {
-        return numeric(- op.getNumericValue(), op.getDimension());
+    public static Numeric negate2(Numeric op, PercentBaseContext context) throws PropertyException {
+        return numeric(- op.getNumericValue(context), op.getDimension());
     }
     
     /**
@@ -182,17 +183,17 @@ public class NumericOp {
      */
     public static Numeric max(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return max2(op1, op2);
+            return max2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.MAX, op1, op2);
         }
     }
 
-    public static Numeric max2(Numeric op1, Numeric op2) throws PropertyException {
+    public static Numeric max2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
         if (op1.getDimension() != op2.getDimension()) {
             throw new PropertyException("Arguments to max() must have same dimensions");
         }
-        return op1.getNumericValue() > op2.getNumericValue() ? op1 : op2;
+        return op1.getNumericValue(context) > op2.getNumericValue(context) ? op1 : op2;
     }
     
     /**
@@ -204,17 +205,17 @@ public class NumericOp {
      */
     public static Numeric min(Numeric op1, Numeric op2) throws PropertyException {
         if (op1.isAbsolute() && op2.isAbsolute()) {
-            return min2(op1, op2);
+            return min2(op1, op2, null);
         } else {
             return new RelativeNumericProperty(RelativeNumericProperty.MIN, op1, op2);
         }
     }
 
-    public static Numeric min2(Numeric op1, Numeric op2) throws PropertyException {
+    public static Numeric min2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
         if (op1.getDimension() != op2.getDimension()) {
             throw new PropertyException("Arguments to min() must have same dimensions");
         }
-        return op1.getNumericValue() <= op2.getNumericValue() ? op1 : op2;
+        return op1.getNumericValue(context) <= op2.getNumericValue(context) ? op1 : op2;
     }
     
     /**
index 72de277502c0ae04106095c7308abb3b46bd376e..dd146ce7ff46f983f22bced5dbb4941229be16d6 100644 (file)
@@ -19,6 +19,7 @@
 package org.apache.fop.fo.expr;
 
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.fo.properties.ColorTypeProperty;
 import org.apache.fop.fo.properties.Property;
@@ -59,6 +60,15 @@ public class NumericProperty extends Property implements Numeric, Length {
         return value;
     }
 
+    /**
+     * Return the value.
+     * @param Evaluation context
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) {
+        return value;
+    }
+
     /**
      * Return true of the numeric is absolute.
      * @see Numeric#isAbsolute()
@@ -88,6 +98,14 @@ public class NumericProperty extends Property implements Numeric, Length {
         return (int) value;
     }
 
+    /**
+     * Return the value of this numeric as a length in millipoints. 
+     * @param Evaluation context
+     */
+    public int getValue(PercentBaseContext context) {
+        return (int) value;
+    }
+
     /**
      * Cast this as a length. That is only possible when the dimension is 
      * one.
index fb59332de77ed5ac89f856481f3af5ecdf2dbf5f..9cd5e714e6144a90772f62a38738ff2212a53063 100644 (file)
@@ -20,11 +20,12 @@ package org.apache.fop.fo.expr;
 
 import java.util.Stack;
 
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.datatypes.PercentBase;
 
 
 /**
@@ -57,7 +58,7 @@ public class PropertyInfo {
      * Propagates to the Maker.
      * @return The PercentBase object or null if percentLengthOK()=false.
      */
-    public PercentBase getPercentBase() {
+    public PercentBase getPercentBase() throws PropertyException {
         PercentBase pcbase = getFunctionPercentBase();
         return (pcbase != null) ? pcbase : maker.getPercentBase(fo, plist);
     }
@@ -65,8 +66,8 @@ public class PropertyInfo {
     /**
      * @return the current font-size value as base units (milli-points).
      */
-    public int currentFontSize() throws PropertyException {
-        return plist.get(Constants.PR_FONT_SIZE).getLength().getValue();
+    public Length currentFontSize() throws PropertyException {
+        return plist.get(Constants.PR_FONT_SIZE).getLength();
     }
 
     /**
index 7d77d7f9bb77403a48c8efa5d1a674e0b8d97f0c..4ab7e72498d515ca0fa160d358daa763771edb4e 100644 (file)
@@ -285,18 +285,11 @@ public class PropertyParser extends PropertyTokenizer {
             String unitPart = currentTokenValue.substring(numLen);
             Double numPart = new Double(currentTokenValue.substring(0,
                     numLen));
-            LengthProperty length = null;
             if (unitPart.equals(RELUNIT)) {
-                length = new FixedLength(numPart.doubleValue(),
+                prop = (Property) NumericOp.multiply(new NumberProperty(numPart.doubleValue()),
                                     propInfo.currentFontSize());
             } else {
-                length = new FixedLength(numPart.doubleValue(), unitPart);
-            }
-            if (length == null) {
-                throw new PropertyException("unrecognized unit name: "
-                                            + currentTokenValue);
-            } else {
-                prop = length;
+                prop = new FixedLength(numPart.doubleValue(), unitPart);
             }
             break;
 
index ee1e28daaf5eb4f9c8309030f03020a0a629454d..4e050bd085dc4b7d67a0c6ad0faca16939557d1a 100644 (file)
 package org.apache.fop.fo.expr;
 
 
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.properties.ColorTypeProperty;
 import org.apache.fop.fo.properties.Property;
-import org.apache.fop.datatypes.PercentBase;
 
 class RGBColorFunction extends FunctionBase {
     public int nbArgs() {
@@ -68,7 +69,7 @@ class RGBColorFunction extends FunctionBase {
             return 255f;
         }
 
-        public int getBaseLength() {
+        public int getBaseLength(PercentBaseContext context) {
             return 0;
         }
 
index 97e940d0bf3d67819dc9982640e64140c49dee5e..15017440db2c4a7959e56ad491af2efa9b92fbd8 100755 (executable)
@@ -18,6 +18,8 @@
 
 package org.apache.fop.fo.expr;
 
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.properties.Property;
@@ -96,29 +98,30 @@ public class RelativeNumericProperty extends Property implements Numeric, Length
 
     /**
      * Return a resolved (calculated) Numeric with the value of the expression.
+     * @param context Evaluation context
      * @throws PropertyException when an exception occur during evaluation.
      */
-    private Numeric getResolved() throws PropertyException {
+    private Numeric getResolved(PercentBaseContext context) throws PropertyException {
         Numeric n;
         switch (operation) {
         case ADDITION:
-            return NumericOp.addition2(op1, op2);
+            return NumericOp.addition2(op1, op2, context);
         case SUBTRACTION:
-            return NumericOp.subtraction2(op1, op2);
+            return NumericOp.subtraction2(op1, op2, context);
         case MULTIPLY:
-            return NumericOp.multiply2(op1, op2);
+            return NumericOp.multiply2(op1, op2, context);
         case DIVIDE:
-            return NumericOp.divide2(op1, op2);
+            return NumericOp.divide2(op1, op2, context);
         case MODULO:
-            return NumericOp.modulo2(op1, op2);
+            return NumericOp.modulo2(op1, op2, context);
         case NEGATE:
-            return NumericOp.negate2(op1);
+            return NumericOp.negate2(op1, context);
         case ABS:
-            return NumericOp.abs2(op1);
+            return NumericOp.abs2(op1, context);
         case MAX:
-            return NumericOp.max2(op1, op2);
+            return NumericOp.max2(op1, op2, context);
         case MIN:
-            return NumericOp.min2(op1, op2);
+            return NumericOp.min2(op1, op2, context);
         default:
             throw new PropertyException("Unknown expr operation " + operation);  
         }
@@ -129,7 +132,16 @@ public class RelativeNumericProperty extends Property implements Numeric, Length
      * @see Numeric#getNumericValue()
      */
     public double getNumericValue() throws PropertyException {
-        return getResolved().getNumericValue();
+        return getResolved(null).getNumericValue(null);
+    }
+
+    /**
+     * Return the value.
+     * @param Evaluation context
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) throws PropertyException {
+        return getResolved(context).getNumericValue(context);
     }
 
     /**
@@ -174,6 +186,19 @@ public class RelativeNumericProperty extends Property implements Numeric, Length
         return 0;
     }
 
+    /**
+     * Return the value of this numeric as a length in millipoints. 
+     * @param Evaluation context
+     */
+    public int getValue(PercentBaseContext context) {
+        try {
+            return (int) getNumericValue(context);
+        } catch (PropertyException exc) {
+            log.error(exc);
+        }
+        return 0;
+    }
+
     /**
      * Return a string represention of the expression. Only used for debugging. 
      */
index eeaa5080ad3a5c99422b51ba4008a32a2e4cbc48..5dbc1606c426937142bed450934e3d0f0071e900 100644 (file)
@@ -279,19 +279,6 @@ public class ExternalGraphic extends FObj {
         return FO_EXTERNAL_GRAPHIC;
     }
 
-    /**
-     * @see org.apache.fop.fo.FObj#getLayoutDimension(org.apache.fop.datatypes.PercentBase.LayoutDimension)
-     */
-    public Number getLayoutDimension(PercentBase.LayoutDimension key) {
-        if (key == PercentBase.IMAGE_INTRINSIC_WIDTH) {
-            return new Integer(getIntrinsicWidth());
-        } else if (key == PercentBase.IMAGE_INTRINSIC_HEIGHT) {
-            return new Integer(getIntrinsicHeight());
-        } else {
-            return super.getLayoutDimension(key);
-        }
-    }
-    
     /**
      * @see org.apache.fop.fo.IntrinsicSizeAccess#getIntrinsicWidth()
      */
index 5c67135ef82b665a70bdf7ba059e5d4eb217aba4..070162ed010c7e92d4db4cf9feea6e774a9adfe5 100644 (file)
@@ -285,17 +285,6 @@ public class InstreamForeignObject extends FObj {
         return FO_INSTREAM_FOREIGN_OBJECT;
     }
 
-    /** @see org.apache.fop.fo.FObj */
-    public Number getLayoutDimension(PercentBase.LayoutDimension key) {
-        if (key == PercentBase.IMAGE_INTRINSIC_WIDTH) {
-            return new Integer(getIntrinsicWidth());
-        } else if (key == PercentBase.IMAGE_INTRINSIC_HEIGHT) {
-            return new Integer(getIntrinsicHeight());
-        } else {
-            return super.getLayoutDimension(key);
-        }
-    }
-    
     /**
      * Preloads the image so the intrinsic size is available.
      */
index bb9f126e28117b3c7e79f3d0d6f81edcdf84d0c2..4b0dd7a7c80178be246374f70d3052e719002f84 100644 (file)
@@ -132,11 +132,13 @@ public class Table extends FObj {
         PropertyList colPList = new StaticPropertyList(defaultColumn, pList);
         colPList.setWritingMode();
         defaultColumn.bind(colPList);
-        
+
+        /* TODO hasPadding requires context for evaluation - need to move this to layout
         if (borderCollapse != EN_SEPARATE && commonBorderPaddingBackground.hasPadding()) {
             //See "17.6.2 The collapsing border model" in CSS2
             getLogger().error("Table may not have padding when using the collapsing border model.");
         }
+        */
         if (borderCollapse != EN_SEPARATE) {
             getLogger().warn("The collapsing border model on an fo:table "
                     + "is currently not supported by FOP");
index 3951c35154c57c28b61b6ea7d6ac94cbc4ec9d18..b3583d37f014b82a91662512e4e1b5df6e31422a 100644 (file)
@@ -188,95 +188,97 @@ public class TableCell extends FObj {
      * Calculate cell border and padding, including offset of content
      * rectangle from the theoretical grid position.
      */
-    private void calcBorders(CommonBorderPaddingBackground bp) {
-        if (this.borderCollapse == EN_SEPARATE) {
-            /*
-             * Easy case.
-             * Cell border is the property specified directly on cell.
-             * Offset content rect by half the border-separation value,
-             * in addition to the border and padding values. Note:
-             * border-separate should only be specified on the table object,
-             * but it inherits.
-             */
-            int iSep = borderSeparation.getIPD().getLength().getValue();
-            this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false)
-                               + bp.getPaddingStart(false);
-
-            this.widthAdjust = startAdjust + iSep - iSep / 2
-                               + bp.getBorderEndWidth(false)
-                               + bp.getPaddingEnd(false);
-
-            // Offset of content rectangle in the block-progression direction
-            int bSep = borderSeparation.getBPD().getLength().getValue();
-            this.beforeOffset = bSep / 2
-                                + bp.getBorderBeforeWidth(false)
-                                + bp.getPaddingBefore(false);
-
-        } else {
-            // System.err.println("Collapse borders");
-            /*
-             * Hard case.
-             * Cell border is combination of other cell borders, or table
-             * border for edge cells. Also seems to border values specified
-             * on row and column FO in the table (if I read CR correclty.)
-             */
-
-            // Set up before and after borders, taking into account row
-            // and table border properties.
-            // ??? What about table-body, header,footer
-
-            /*
-             * We can't calculate before and after because we aren't sure
-             * whether this row will be the first or last in its area, due
-             * to redoing break decisions (at least in the "new" architecture.)
-             * So in the general case, we will calculate two possible values:
-             * the first/last one and the "middle" one.
-             * Example: border-before
-             * 1. If the cell is in the first row in the first table body, it
-             * will combine with the last row of the header, or with the
-             * top (before) table border if there is no header.
-             * 2. Otherwise there are two cases:
-             * a. the row is first in its (non-first) Area.
-             * The border can combine with either:
-             * i.  the last row of table-header and its cells, or
-             * ii. the table before border (no table-header or it is
-             * omitted on non-first Areas).
-             * b. the row isn't first in its Area.
-             * The border combines with the border of the previous
-             * row and the cells which end in that row.
-             */
-
-            /*
-             * if-first
-             * Calculate the effective border of the cell before-border,
-             * it's parent row before-border, the last header row after-border,
-             * the after border of the cell(s) which end in the last header
-             * row.
-             */
-            /*
-             * if-not-first
-             * Calculate the effective border of the cell before-border,
-             * it's parent row before-border, the previous row after-border,
-             * the after border of the cell(s) which end in the previous
-             * row.
-             */
-
-
-            /* ivan demakov */
-            int borderStart = bp.getBorderStartWidth(false);
-            int borderEnd = bp.getBorderEndWidth(false);
-            int borderBefore = bp.getBorderBeforeWidth(false);
-            int borderAfter = bp.getBorderAfterWidth(false);
-
-            this.startAdjust = borderStart / 2 + bp.getPaddingStart(false);
-
-            this.widthAdjust = startAdjust + borderEnd / 2
-                               + bp.getPaddingEnd(false);
-            this.beforeOffset = borderBefore / 2 + bp.getPaddingBefore(false);
-            // Half border height to fix overestimate of area size!
-            this.borderHeight = (borderBefore + borderAfter) / 2;
-        }
-    }
+// TODO This whole method is not used it refers to padding which requires layout
+// context to evaluate
+//    private void calcBorders(CommonBorderPaddingBackground bp) {
+//        if (this.borderCollapse == EN_SEPARATE) {
+//            /*
+//             * Easy case.
+//             * Cell border is the property specified directly on cell.
+//             * Offset content rect by half the border-separation value,
+//             * in addition to the border and padding values. Note:
+//             * border-separate should only be specified on the table object,
+//             * but it inherits.
+//             */
+//            int iSep = borderSeparation.getIPD().getLength().getValue();
+//            this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false)
+//                               + bp.getPaddingStart(false);
+//
+//            this.widthAdjust = startAdjust + iSep - iSep / 2
+//                               + bp.getBorderEndWidth(false)
+//                               + bp.getPaddingEnd(false);
+//
+//            // Offset of content rectangle in the block-progression direction
+//            int bSep = borderSeparation.getBPD().getLength().getValue();
+//            this.beforeOffset = bSep / 2
+//                                + bp.getBorderBeforeWidth(false)
+//                                + bp.getPaddingBefore(false);
+//
+//        } else {
+//            // System.err.println("Collapse borders");
+//            /*
+//             * Hard case.
+//             * Cell border is combination of other cell borders, or table
+//             * border for edge cells. Also seems to border values specified
+//             * on row and column FO in the table (if I read CR correclty.)
+//             */
+//
+//            // Set up before and after borders, taking into account row
+//            // and table border properties.
+//            // ??? What about table-body, header,footer
+//
+//            /*
+//             * We can't calculate before and after because we aren't sure
+//             * whether this row will be the first or last in its area, due
+//             * to redoing break decisions (at least in the "new" architecture.)
+//             * So in the general case, we will calculate two possible values:
+//             * the first/last one and the "middle" one.
+//             * Example: border-before
+//             * 1. If the cell is in the first row in the first table body, it
+//             * will combine with the last row of the header, or with the
+//             * top (before) table border if there is no header.
+//             * 2. Otherwise there are two cases:
+//             * a. the row is first in its (non-first) Area.
+//             * The border can combine with either:
+//             * i.  the last row of table-header and its cells, or
+//             * ii. the table before border (no table-header or it is
+//             * omitted on non-first Areas).
+//             * b. the row isn't first in its Area.
+//             * The border combines with the border of the previous
+//             * row and the cells which end in that row.
+//             */
+//
+//            /*
+//             * if-first
+//             * Calculate the effective border of the cell before-border,
+//             * it's parent row before-border, the last header row after-border,
+//             * the after border of the cell(s) which end in the last header
+//             * row.
+//             */
+//            /*
+//             * if-not-first
+//             * Calculate the effective border of the cell before-border,
+//             * it's parent row before-border, the previous row after-border,
+//             * the after border of the cell(s) which end in the previous
+//             * row.
+//             */
+//
+//
+//            /* ivan demakov */
+//            int borderStart = bp.getBorderStartWidth(false);
+//            int borderEnd = bp.getBorderEndWidth(false);
+//            int borderBefore = bp.getBorderBeforeWidth(false);
+//            int borderAfter = bp.getBorderAfterWidth(false);
+//
+//            this.startAdjust = borderStart / 2 + bp.getPaddingStart(false);
+//
+//            this.widthAdjust = startAdjust + borderEnd / 2
+//                               + bp.getPaddingEnd(false);
+//            this.beforeOffset = borderBefore / 2 + bp.getPaddingBefore(false);
+//            // Half border height to fix overestimate of area size!
+//            this.borderHeight = (borderBefore + borderAfter) / 2;
+//        }
+//    }
 
     /**
      * @return the Common Border, Padding, and Background Properties.
index 0d3aa69917728966e75148df61157d3e4951dd66..4980d057e68a1621979b08a8a2bca6e01d45a9cb 100644 (file)
@@ -81,8 +81,8 @@ public abstract class Region extends FObj {
             }
         }
         
-        if (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false) != 0
-                || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false) != 0) {
+        if (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0 //TODO do we need context here?
+                || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0) { //TODO do we need context here?
             throw new PropertyException("Border and padding for a region "
                     + "must be '0' (See 6.4.13 in XSL 1.0).");
         }
@@ -99,9 +99,11 @@ public abstract class Region extends FObj {
 
     /**
      * @param pageRefRect reference dimension of the page area.
+     * @param pageViewRectRect page view port dimensions.
      * @return the rectangle for the viewport area
      */
-    public abstract Rectangle getViewportRectangle(FODimension pageRefRect);
+    public abstract Rectangle getViewportRectangle(FODimension pageRefRect
+                                            , FODimension pageViewPortRect);
 
     /**
      * Returns the default region name (xsl-region-before, xsl-region-start,
index dc8fafd36ac2ab46dfb5ea06bede095aaade0846..68d6d066d6402ba3e2eab6433e27c6fcc8cfe7e6 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.Rectangle;
 // FOP
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 
 /**
  * The fo:region-after element.
@@ -40,16 +42,29 @@ public class RegionAfter extends RegionBA {
     /**
      * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
      */
-    public Rectangle getViewportRectangle (FODimension reldims) {
+    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.
+         */
         Rectangle vpRect;
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext neighbourContext;
         if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
-            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(), reldims.ipd, getExtent().getValue());
+            neighbourContext = pageWidthContext;
+            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext), reldims.ipd, getExtent().getValue(pageHeightContext));
         } else {
-            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(), getExtent().getValue(), reldims.ipd);
+            neighbourContext = pageHeightContext;
+            vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext), getExtent().getValue(pageWidthContext), reldims.ipd);
         }
         if (getPrecedence() == EN_FALSE) {
-            adjustIPD(vpRect, getWritingMode());
+            adjustIPD(vpRect, getWritingMode(), neighbourContext);
         }
         return vpRect;
     }
index 6d35dae20c581e0aea7507ab823d3d90d6101f1d..f732c721fc6fb908d14eb7b37876d8c02bb65f1c 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 
@@ -63,17 +64,18 @@ public abstract class RegionBA extends SideRegion {
      * and end regions if they are present.
      * @param vpRefRect viewport reference rectangle
      * @param wm writing mode
+     * @param siblingContext the context to use to resolve extent on siblings
      */
-    protected void adjustIPD(Rectangle vpRefRect, int wm) {
+    protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
         int offset = 0;
         RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START);
         if (start != null) {
-            offset = start.getExtent().getValue();
+            offset = start.getExtent().getValue(siblingContext);
             vpRefRect.translate(offset, 0);  // move (x, y) units
         }
         RegionEnd end = (RegionEnd) getSiblingRegion(FO_REGION_END);
         if (end != null) {
-            offset += end.getExtent().getValue();
+            offset += end.getExtent().getValue(siblingContext);
         }
         if (offset > 0) {
             if (wm == EN_LR_TB || wm == EN_RL_TB) {
index 19607f9b119266aa5c5499a23782fa86d2a5652c..c1f683c05ccbc9c0ea0d30259616c55745b23924 100644 (file)
@@ -23,6 +23,8 @@ import java.awt.Rectangle;
 
 // FOP
 import org.apache.fop.datatypes.FODimension;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.FONode;
 
 /**
@@ -46,21 +48,34 @@ public class RegionBefore extends RegionBA {
     /**
      * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
      */
-    public Rectangle getViewportRectangle (FODimension reldims) {
+    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.
+         */
         Rectangle vpRect;
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext neighbourContext;
         if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
-            vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue());
+            neighbourContext = pageWidthContext;
+            vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
         } else {
-            vpRect = new Rectangle(0, 0, getExtent().getValue(), reldims.ipd);
+            neighbourContext = pageHeightContext;
+            vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
         }
         if (getPrecedence() == EN_FALSE) {
-            adjustIPD(vpRect, getWritingMode());
+            adjustIPD(vpRect, getWritingMode(), neighbourContext);
         }
         return vpRect;
     }
index 00acca4daa0ad99f3290d87d09ee5fc580ce7c20..835802469ef224740eee8dfcaa61905b52321cca 100644 (file)
@@ -24,7 +24,9 @@ import java.awt.Rectangle;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -90,11 +92,24 @@ public class RegionBody extends Region {
     /**
      * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
      */
-    public Rectangle getViewportRectangle (FODimension reldims) {
-        int left = commonMarginBlock.marginLeft.getValue();
-        int right = commonMarginBlock.marginRight.getValue();
-        int top = commonMarginBlock.marginTop.getValue();
-        int bottom = commonMarginBlock.marginBottom.getValue();
+    public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
+        /* 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.
+         */
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.bpd);
+
+        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);
index e4aff17e645e621c2f3ae71f7dd2329e73e9402d..a097ec3759509d56b1012d8716d8a2700698092f 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.Rectangle;
 // FOP
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 
 /**
  * The fo:region-end element.
@@ -39,19 +41,31 @@ public class RegionEnd extends RegionSE {
     /**
      * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
      */
-    public Rectangle getViewportRectangle (FODimension reldims) {
+    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.
+         */
         Rectangle vpRect;
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext neighbourContext;
         if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
-            // Rectangle:  x , y (of top left point), width, height
-            vpRect = new Rectangle(reldims.ipd - getExtent().getValue(), 0,
-                    getExtent().getValue(), reldims.bpd);
+            neighbourContext = pageHeightContext;
+            vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
+                    getExtent().getValue(pageWidthContext), reldims.bpd);
         } else {
             // Rectangle:  x , y (of top left point), width, height
-            vpRect = new Rectangle(reldims.ipd - getExtent().getValue(), 0,
-                    reldims.bpd, getExtent().getValue());
+            neighbourContext = pageWidthContext;
+            vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
+                    reldims.bpd, getExtent().getValue(pageHeightContext));
         }
-        adjustIPD(vpRect, getWritingMode());
+        adjustIPD(vpRect, getWritingMode(), neighbourContext);
         return vpRect;
     }
 
index 9100c098156654401725ebd30a40c4af79964b18..4ab2ebd051db1d7554b5670a4a97491c6df9d129 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 
@@ -55,17 +56,18 @@ public abstract class RegionSE extends SideRegion {
      * diminish by extend of start and end if present.
      * @param vpRefRect viewport reference rectangle
      * @param wm writing mode
+     * @param siblingContext the context to use to resolve extent on siblings
      */
-    protected void adjustIPD(Rectangle vpRefRect, int wm) {
+    protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
         int offset = 0;
         RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE);
         if (before != null && before.getPrecedence() == EN_TRUE) {
-            offset = before.getExtent().getValue();
+            offset = before.getExtent().getValue(siblingContext);
             vpRefRect.translate(0, offset);
         }
         RegionAfter after = (RegionAfter) getSiblingRegion(FO_REGION_AFTER);
         if (after != null && after.getPrecedence() == EN_TRUE) {
-            offset += after.getExtent().getValue();
+            offset += after.getExtent().getValue(siblingContext);
         }
         if (offset > 0) {
             if (wm == EN_LR_TB || wm == EN_RL_TB) {
index 9668dceeb7b7e82eb745b4e8a1aead90e95c510b..2de7cc68f3669bfa0ac997ac65c1ee2a05d9ed9e 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.Rectangle;
 // FOP
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 
 /**
  * The fo:region-start element.
@@ -39,17 +41,30 @@ public class RegionStart extends RegionSE {
     /**
      * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
      */
-    public Rectangle getViewportRectangle (FODimension reldims) {
+    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.
+         */
         Rectangle vpRect;
+        SimplePercentBaseContext pageWidthContext 
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
+        SimplePercentBaseContext pageHeightContext
+            = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+        SimplePercentBaseContext neighbourContext;
         if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
-            vpRect = new Rectangle(0, 0, getExtent().getValue(), reldims.bpd);
+            neighbourContext = pageHeightContext;
+            vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
         } else {
-            vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue());
+            neighbourContext = pageWidthContext;
+            vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext));
         }
-        adjustIPD(vpRect, getWritingMode());
+        adjustIPD(vpRect, getWritingMode(), neighbourContext);
         return vpRect;
     }
 
index f60b37bcabacd599b09390283cce68b308d4bb26..ecdec78c851bd8f01d71342ca7ee01df4a4e0dec 100755 (executable)
@@ -20,6 +20,7 @@ package org.apache.fop.fo.properties;
 
 import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -223,6 +224,14 @@ public class CommonBorderPaddingBackground implements Cloneable {
         return this.borderInfo[side];
     }
     
+    /**
+     * Set padding.
+     * @param source the padding info to copy from
+     */
+    public void setPadding(CommonBorderPaddingBackground source) {
+        this.padding = source.padding;
+    }
+    
     /**
      * @return the background image as a preloaded FopImage, null if there is
      *     no background image.
@@ -247,20 +256,20 @@ public class CommonBorderPaddingBackground implements Cloneable {
         return getBorderWidth(AFTER, bDiscard);
     }
 
-    public int getPaddingStart(boolean bDiscard) {
-        return getPadding(START, bDiscard);
+    public int getPaddingStart(boolean bDiscard, PercentBaseContext context) {
+        return getPadding(START, bDiscard, context);
     }
 
-    public int getPaddingEnd(boolean bDiscard) {
-        return getPadding(END, bDiscard);
+    public int getPaddingEnd(boolean bDiscard, PercentBaseContext context) {
+        return getPadding(END, bDiscard, context);
     }
 
-    public int getPaddingBefore(boolean bDiscard) {
-        return getPadding(BEFORE, bDiscard);
+    public int getPaddingBefore(boolean bDiscard, PercentBaseContext context) {
+        return getPadding(BEFORE, bDiscard, context);
     }
 
-    public int getPaddingAfter(boolean bDiscard) {
-        return getPadding(AFTER, bDiscard);
+    public int getPaddingAfter(boolean bDiscard, PercentBaseContext context) {
+        return getPadding(AFTER, bDiscard, context);
     }
 
     public int getBorderWidth(int side, boolean bDiscard) {
@@ -290,11 +299,11 @@ public class CommonBorderPaddingBackground implements Cloneable {
         }
     }
 
-    public int getPadding(int side, boolean bDiscard) {
+    public int getPadding(int side, boolean bDiscard, PercentBaseContext context) {
         if ((padding[side] == null) || (bDiscard && padding[side].isDiscard())) {
             return 0;
         } else {
-            return padding[side].getLengthValue();
+            return padding[side].getLengthValue(context);
         }
     }
 
@@ -302,11 +311,12 @@ public class CommonBorderPaddingBackground implements Cloneable {
      * Return all the border and padding width in the inline progression 
      * dimension.
      * @param bDiscard the discard flag.
+     * @param context for percentage evaluation.
      * @return all the padding and border width.
      */
-    public int getIPPaddingAndBorder(boolean bDiscard) {
-        return getPaddingStart(bDiscard) 
-            + getPaddingEnd(bDiscard) 
+    public int getIPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
+        return getPaddingStart(bDiscard, context
+            + getPaddingEnd(bDiscard, context
             + getBorderStartWidth(bDiscard) 
             + getBorderEndWidth(bDiscard);        
     }
@@ -315,10 +325,11 @@ public class CommonBorderPaddingBackground implements Cloneable {
      * Return all the border and padding height in the block progression 
      * dimension.
      * @param bDiscard the discard flag.
+     * @param context for percentage evaluation
      * @return all the padding and border height.
      */
-    public int getBPPaddingAndBorder(boolean bDiscard) {
-        return getPaddingBefore(bDiscard) + getPaddingAfter(bDiscard) +
+    public int getBPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
+        return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context) +
                getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);        
     }
 
@@ -328,8 +339,8 @@ public class CommonBorderPaddingBackground implements Cloneable {
         getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n" +
         "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", " +
         getBorderColor(START) + ", " + getBorderColor(END) + ")\n" +
-        "Padding: (" + getPaddingBefore(false) + ", " + getPaddingAfter(false) + ", " +
-        getPaddingStart(false) + ", " + getPaddingEnd(false) + ")\n";
+        "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null) + ", " +
+        getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n";
     }
 
     /**
@@ -345,9 +356,12 @@ public class CommonBorderPaddingBackground implements Cloneable {
                 + getBorderStartWidth(false) + getBorderEndWidth(false)) > 0);
     }
 
-    /** @return true if padding is non-zero. */
-    public boolean hasPadding() {
-        return ((getPaddingBefore(false) + getPaddingAfter(false) 
-                + getPaddingStart(false) + getPaddingEnd(false)) > 0);
+    /** 
+     * @param context for percentage based evaluation.
+     * @return true if padding is non-zero. 
+     */
+    public boolean hasPadding(PercentBaseContext context) {
+        return ((getPaddingBefore(false, context) + getPaddingAfter(false, context) 
+                + getPaddingStart(false, context) + getPaddingEnd(false, context)) > 0);
     }
 }
index 77fbe53c1e942662af5459b73bba0501448ba4b4..c24c0c94144c10029bc57d8e3618f479d145ffa1 100755 (executable)
@@ -21,6 +21,7 @@ package org.apache.fop.fo.properties;
 // FOP
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
@@ -96,7 +97,7 @@ public class CommonFont {
      * @param fontInfo
      * @return a Font object.
      */
-    public Font getFontState(FontInfo fontInfo) {
+    public Font getFontState(FontInfo fontInfo, PercentBaseContext context) {
         if (fontState == null) {
             /**@todo this is ugly. need to improve. */
 
@@ -124,7 +125,7 @@ public class CommonFont {
             String fname = fontInfo.fontLookup(fontFamily, fontStyle,
                                                font_weight);
             FontMetrics metrics = fontInfo.getMetricsFor(fname);
-            fontState = new Font(fname, metrics, fontSize.getValue());
+            fontState = new Font(fname, metrics, fontSize.getValue(context));
         }
         return fontState;
     }
index d049d275a82f5442bfb9e2a29515e560763395f3..8875de05116038a6d41f7fe816537908347d8e25 100644 (file)
@@ -22,6 +22,7 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.RelativeNumericProperty;
 
 /**
  * Store all common margin properties for blocks.
index b14f12df3825e9d3fa2adcc664125628788efc12..0253e8a8152e39819fb75bf3adbfd481066699bc 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.fop.fo.properties;
 
 import org.apache.fop.datatypes.CompoundDatatype;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -122,6 +123,14 @@ public class CondLengthProperty extends Property implements CompoundDatatype {
         return this.length.getLength().getValue();
     }
 
+    /**
+     * Returns the computed length value.
+     * @return the length in millipoints
+     */
+    public int getLengthValue(PercentBaseContext context) {
+        return this.length.getLength().getValue(context);
+    }
+
     public String toString() {
         return "CondLength[" + (isDiscard() ? "discard, " : "") +
         length.getObject().toString() + "]";
index 2d45a1966f18d87526377ea12005b9618c2e3ff1..04efebaa6bc33e61afb2ba14414a6a72808ff656 100755 (executable)
@@ -18,6 +18,8 @@
  
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.datatypes.PercentBaseContext;
+
 /**
  * A length quantity in XSL which is specified as an enum, such as "auto"
  */
@@ -38,6 +40,7 @@ public class EnumLength extends LengthProperty {
     public boolean isAbsolute() {
         return false;
     }
+
     /**
      * Returns the length in 1/1000ths of a point (millipoints)
      * @return the length in millipoints
@@ -47,6 +50,16 @@ public class EnumLength extends LengthProperty {
         return 0;
     }
 
+    /**
+     * Returns the length in 1/1000ths of a point (millipoints)
+     * @param Evaluation context
+     * @return the length in millipoints
+     */
+    public int getValue(PercentBaseContext context) {
+        log.error("getValue() called on " + enumProperty + " length");
+        return 0;
+    }
+
     /**
      * Returns the value as numeric.
      * @return the length in millipoints
@@ -56,6 +69,16 @@ public class EnumLength extends LengthProperty {
         return 0;
     }
 
+    /**
+     * Returns the value as numeric.
+     * @param context Evaluation context
+     * @return the length in millipoints
+     */
+    public double getNumericValue(PercentBaseContext context) {
+        log.error("getNumericValue() called on " + enumProperty + " number");
+        return 0;
+    }
+
     /**
      * @see org.apache.fop.fo.properties.Property#getString()
      */
index cba009e57fcf69e8f5c7b6f44ef27139d12c35a0..347051990a445884d9aae47b8ecc80aa317791d5 100644 (file)
@@ -18,6 +18,8 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.datatypes.PercentBaseContext;
+
 /**
  * An absolute length quantity in XSL
  */
@@ -98,14 +100,34 @@ public class FixedLength extends LengthProperty {
         return millipoints;
     }
 
+    /**
+     * Returns the length in 1/1000ths of a point (millipoints)
+     * @param Evaluation context
+     * @return the length in millipoints
+     */
+    public int getValue(PercentBaseContext context) {
+        return millipoints;
+    }
+
     /**
      * Returns the value as numeric.
      * @return the length in millipoints
+     * @see Numeric#getNumericValue()
      */
     public double getNumericValue() {
         return millipoints;
     }
 
+    /**
+     * Return the value of this Numeric.
+     * @param context Evaluation context
+     * @return the length in millipoints
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) {
+        return millipoints;
+    }
+
     /**
      * Return true since FixedLength are always absolute.
      * @see org.apache.fop.datatypes.Numeric#isAbsolute()
index 83379dfa418f2c27542647667686b4408f7aa46a..3719c72d4b88ce7a4f7b228bd6439bea30399a8d 100644 (file)
 /* $Id: $ */
 
 package org.apache.fop.fo.properties;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.RelativeNumericProperty;
 
 /**
  * This subclass of LengthProperty.Maker handles the special treatment of 
index 732f99e14ca11c69c861503d5688c917cddda0ae..37e40028be299fa75bfd0759de1eedc764a811b1 100644 (file)
@@ -19,6 +19,7 @@
 package org.apache.fop.fo.properties;
 
 import org.apache.fop.datatypes.CompoundDatatype;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
@@ -90,11 +91,11 @@ public class LengthRangeProperty extends Property implements CompoundDatatype {
      */
     public Property getComponent(int cmpId) {
         if (cmpId == CP_MINIMUM) {
-            return getMinimum();
+            return getMinimum(null);
         } else if (cmpId == CP_OPTIMUM) {
-            return getOptimum();
+            return getOptimum(null);
         } else if (cmpId == CP_MAXIMUM) {
-            return getMaximum();
+            return getMaximum(null);
         } else {
             return null;    // SHOULDN'T HAPPEN
         }
@@ -146,15 +147,18 @@ public class LengthRangeProperty extends Property implements CompoundDatatype {
     }
     
     // Minimum is prioritaire, if explicit
-    private void checkConsistency() {
+    private void checkConsistency(PercentBaseContext context) {
         if (consistent) {
             return;
         }
+        if (context == null) {
+            return;
+        }
         // Make sure max >= min
         // Must also control if have any allowed enum values!
 
         if (!minimum.isAuto() && !maximum.isAuto() 
-                && minimum.getLength().getValue() > maximum.getLength().getValue()) {
+                && minimum.getLength().getValue(context) > maximum.getLength().getValue(context)) {
             if ((bfSet & MINSET) != 0) {
                 // if minimum is explicit, force max to min
                 if ((bfSet & MAXSET) != 0) {
@@ -168,7 +172,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype {
         }
         // Now make sure opt <= max and opt >= min
         if (!optimum.isAuto() && !maximum.isAuto() 
-                && optimum.getLength().getValue() > maximum.getLength().getValue()) {
+                && optimum.getLength().getValue(context) > maximum.getLength().getValue(context)) {
             if ((bfSet & OPTSET) != 0) {
                 if ((bfSet & MAXSET) != 0) {
                     // Warning: opt > max, resetting opt to max
@@ -182,7 +186,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype {
                 optimum = maximum;
             }
         } else if (!optimum.isAuto() && !minimum.isAuto() && 
-                optimum.getLength().getValue() < minimum.getLength().getValue()) {
+                optimum.getLength().getValue(context) < minimum.getLength().getValue(context)) {
             if ((bfSet & MINSET) != 0) {
                 // if minimum is explicit, force opt to min
                 if ((bfSet & OPTSET) != 0) {
@@ -198,34 +202,37 @@ public class LengthRangeProperty extends Property implements CompoundDatatype {
     }
 
     /**
+     * @param context Percentage evaluation context
      * @return minimum length
      */
-    public Property getMinimum() {
-        checkConsistency();
+    public Property getMinimum(PercentBaseContext context) {
+        checkConsistency(context);
         return this.minimum;
     }
 
     /**
+     * @param context Percentage evaluation context
      * @return maximum length
      */
-    public Property getMaximum() {
-        checkConsistency();
+    public Property getMaximum(PercentBaseContext context) {
+        checkConsistency(context);
         return this.maximum;
     }
 
     /**
+     * @param context Percentage evaluation context
      * @return optimum length
      */
-    public Property getOptimum() {
-        checkConsistency();
+    public Property getOptimum(PercentBaseContext context) {
+        checkConsistency(context);
         return this.optimum;
     }
 
     public String toString() {
         return "LengthRange[" +
-        "min:" + getMinimum().getObject() + 
-        ", max:" + getMaximum().getObject() + 
-        ", opt:" + getOptimum().getObject() + "]";
+        "min:" + getMinimum(null).getObject() + 
+        ", max:" + getMaximum(null).getObject() + 
+        ", opt:" + getOptimum(null).getObject() + "]";
     }
 
     /**
index e1fa1215acc07130f4b20e2af5b7dd865cbaa5d5..5c4507ae5a903caecf11e45326f19ed3f65f12e8 100644 (file)
 /* $Id$ */
 
 package org.apache.fop.fo.properties;
-
+import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.RelativeNumericProperty;
 
 /**
  * A maker which calculates the line-height property.
@@ -60,10 +63,13 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker {
         return null;
     }
 
+    /**
+     * @see SpaceProperty#convertProperty(Property, PropertyList, FObj)
+     */
     public Property convertProperty(Property p,
             PropertyList propertyList,
             FObj fo) throws PropertyException {
-        Numeric numval = p.getNumeric();
+        Numeric numval = p.getNumeric();    
         if (numval != null && numval.getDimension() == 0) {
             p = new PercentLength(numval.getNumericValue(), getPercentBase(fo,propertyList));
             Property spaceProp = super.convertProperty(p, propertyList, fo);
index a93e68b55216de3d2e5ab8fadfcaf623da8707b7..268066c570bf8935f4e13952300664acd7ea08b0 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -104,10 +105,30 @@ public class NumberProperty extends Property implements Numeric {
         return number.doubleValue();
     }
 
+    /**
+     * Return the value of this Numeric.
+     * @param context Evaluation context
+     * @return The value as a double.
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) {
+        return getNumericValue();
+    }
+
     public int getValue() {
         return number.intValue();
     }
 
+    /**
+     * Return the value
+     * @param context Evaluation context
+     * @return The value as an int.
+     * @see Numeric#getValue(Object)
+     */
+    public int getValue(PercentBaseContext context) {
+        return getValue();
+    }
+
     /**
      * Return true because all numbers are absolute.
      * @return true.
index 82c52adafe653efc72192d901e5f002813e8cdc4..ccad91d79f60fd4ea0a530075a4d43197f8d6daa 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.expr.PropertyException;
 
@@ -37,6 +38,8 @@ public class PercentLength extends LengthProperty {
      * {@link #factor} should be applied to compute the actual length
      */
     private PercentBase lbase = null;
+    
+    private double resolvedValue;
 
     /**
      * Main constructor. Construct an object based on a factor (the percent,
@@ -80,8 +83,19 @@ public class PercentLength extends LengthProperty {
      * @see org.apache.fop.datatypes.Numeric#getNumericValue()
      */
     public double getNumericValue() {
+        return getNumericValue(null);
+    }
+
+    /**
+     * Return the value of this Numeric.
+     * @param context Evaluation context
+     * @return the length in millipoints
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) {
         try {
-            return factor * lbase.getBaseLength();
+            resolvedValue = factor * lbase.getBaseLength(context);
+            return resolvedValue;
         } catch (PropertyException exc) {
             log.error(exc);
             return 0;
@@ -96,6 +110,14 @@ public class PercentLength extends LengthProperty {
         return (int) getNumericValue();
     }
 
+    /**
+     * Return the value of this numeric as a length in millipoints. 
+     * @param Evaluation context
+     */
+    public int getValue(PercentBaseContext context) {
+        return (int) getNumericValue(context);
+    }
+
     /**
      * @return the String equivalent of this
      */
index 51116fbafb9d7f7a757b47b043781ddcb96cebf4..6f0d86bfb6a688387876b49b9de82fac7ef99119 100644 (file)
@@ -308,7 +308,7 @@ public class PropertyMaker implements Cloneable {
      * what this is used for, or remove it from the signature.)
      * @return an object implementing the PercentBase interface.
      */
-    public PercentBase getPercentBase(FObj fo, PropertyList pl) {
+    public PercentBase getPercentBase(FObj fo, PropertyList pl) throws PropertyException {
         if (percentBase == -1)
             return null;
         return new LengthBase(fo, pl, percentBase);
index 2ef52a48f21dd66381539d1ec15ea11efc2987b8..45dce11a966df3f8a23a7fc1a5f5694452877b4f 100644 (file)
@@ -137,9 +137,9 @@ public class SpaceProperty extends LengthRangeProperty {
 
     public String toString() {
         return "Space[" +
-        "min:" + getMinimum().getObject() + 
-        ", max:" + getMaximum().getObject() + 
-        ", opt:" + getOptimum().getObject() + 
+        "min:" + getMinimum(null).getObject() + 
+        ", max:" + getMaximum(null).getObject() + 
+        ", opt:" + getOptimum(null).getObject() + 
         ", precedence:" + precedence.getObject() + 
         ", conditionality:" + conditionality.getObject() + "]";
     }
index 78e2eac5f90888cc1ad33e08c6dc595d80087898..a8cb201d377851789ad85fb2e264e01058f06fa9 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.FObj;
 
@@ -76,6 +77,16 @@ public class TableColLength extends LengthProperty {
         return tcolUnits * column.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue();
     }
 
+    /**
+     * Return the value of this Numeric.
+     * @param context Evaluation context
+     * @return the value
+     * @see Numeric#getNumericValue(Object)
+     */
+    public double getNumericValue(PercentBaseContext context) {
+        return getNumericValue();
+    }
+
     /**
      * Return the value as a length.
      * @see org.apache.fop.datatypes.Length#getValue()
@@ -84,6 +95,15 @@ public class TableColLength extends LengthProperty {
         return (int) (tcolUnits * column.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue());
     }
 
+    /**
+     * Returns the length in 1/1000ths of a point (millipoints)
+     * @param Evaluation context
+     * @return the length in millipoints
+     */
+    public int getValue(PercentBaseContext context) {
+        return getValue();
+    }
+
     /**
      * Convert this to a String
      * @return the string representation of this
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
new file mode 100644 (file)
index 0000000..ea8dab3
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.FObj;
+
+/**
+ * The base class for nearly all LayoutManagers.
+ * Provides the functionality for merging the {@link LayoutManager}
+ * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces
+ * into a common base calls for all higher LayoutManagers.
+ */
+public abstract class AbstractBaseLayoutManager 
+    implements LayoutManager, PercentBaseContext {
+    
+    protected boolean generatesReferenceArea = false;
+    protected boolean generatesBlockArea = false;
+    
+    protected FObj fobj = null;
+
+    /**
+     * logging instance
+     */
+    protected static Log log = LogFactory.getLog(LayoutManager.class);
+
+    /**
+     * Abstract base layout manager.
+     */
+    public AbstractBaseLayoutManager() {
+    }
+
+    /**
+     * Abstract base layout manager.
+     *
+     * @param fo the formatting object for this layout manager
+     */
+    public AbstractBaseLayoutManager(FObj fo) {
+        fobj = fo;
+        setGeneratesReferenceArea(fo.generatesReferenceAreas());
+        if (getGeneratesReferenceArea()) {
+            setGeneratesBlockArea(true);
+        }
+    }
+
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        if (fobj == getFObj()) {
+            switch (lengthBase) {
+            case LengthBase.CONTAINING_BLOCK_WIDTH:
+                return getAncestorBlockAreaIPD();
+            case LengthBase.CONTAINING_BLOCK_HEIGHT:
+                return getAncestorBlockAreaBPD();
+            case LengthBase.PARENT_AREA_WIDTH:
+                return getParentAreaIPD();
+            case LengthBase.CONTAINING_REFAREA_WIDTH:
+                return getReferenceAreaIPD();
+            default:
+                log.error("Unknown base type for LengthBase:" + lengthBase);
+                new Exception().printStackTrace();
+                return 0;
+            }
+        } else {
+            LayoutManager lm = getParent();
+            while (lm != null && fobj != lm.getFObj()) {
+                lm = lm.getParent();
+            }
+            if (lm != null) {
+                return lm.getBaseLength(lengthBase, fobj);
+            }
+        }
+        log.error("Cannot find LM to handle given FO for LengthBase.");
+        return 0;
+    }
+
+    /**
+     * Find the first ancestor area that is a block area
+     * and returns its IPD.
+     * @return the ipd of the ancestor block area
+     */
+    protected int getAncestorBlockAreaIPD() {
+        LayoutManager lm = getParent();
+        while (lm != null) {
+            if (lm.getGeneratesBlockArea() && !lm.getGeneratesLineArea()) {
+                return lm.getContentAreaIPD();
+            }
+            lm = lm.getParent();
+        }
+        if (lm == null) {
+            log.error("No parent LM found");
+        }
+        return 0;
+    }
+
+    /**
+     * Find the first ancestor area that is a block area
+     * and returns its BPD.
+     * @return the bpd of the ancestor block area
+     */
+    protected int getAncestorBlockAreaBPD() {
+        LayoutManager lm = getParent();
+        while (lm != null) {
+            if (lm.getGeneratesBlockArea() && !lm.getGeneratesLineArea()) {
+                return lm.getContentAreaBPD();
+            }
+            lm = lm.getParent();
+        }
+        if (lm == null) {
+            log.error("No parent LM found");
+        }
+        return 0;
+    }
+
+    /**
+     * Find the parent area and returns its IPD.
+     * @return the ipd of the parent area
+     */
+    protected int getParentAreaIPD() {
+        LayoutManager lm = getParent();
+        if (lm != null) {
+            return lm.getContentAreaIPD();
+        }
+        log.error("No parent LM found");
+        return 0;
+    }
+
+    /**
+     * Find the parent area and returns its BPD.
+     * @return the bpd of the parent area
+     */
+    protected int getParentAreaBPD() {
+        LayoutManager lm = getParent();
+        if (lm != null) {
+            return lm.getContentAreaBPD();
+        }
+        log.error("No parent LM found");
+        return 0;
+    }
+
+    /**
+     * Find the first ancestor area that is a reference area
+     * and returns its IPD.
+     * @return the ipd of the ancestor reference area
+     */
+    public int getReferenceAreaIPD() {
+        LayoutManager lm = getParent();
+        while (lm != null) {
+            if (lm.getGeneratesReferenceArea()) {
+                return lm.getContentAreaIPD();
+            }
+            lm = lm.getParent();
+        }
+        if (lm == null) {
+            log.error("No parent LM found");
+        }
+        return 0;
+    }
+
+    /**
+     * Find the first ancestor area that is a reference area
+     * and returns its BPD.
+     * @return the bpd of the ancestor reference area
+     */
+    protected int getReferenceAreaBPD() {
+        LayoutManager lm = getParent();
+        while (lm != null) {
+            if (lm.getGeneratesReferenceArea()) {
+                return lm.getContentAreaBPD();
+            }
+            lm = lm.getParent();
+        }
+        if (lm == null) {
+            log.error("No parent LM found");
+        }
+        return 0;
+    }
+
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     * @see LayoutManager#getContentAreaIPD
+     */
+    public int getContentAreaIPD() {
+        log.error("getContentAreaIPD called when it should have been overwritten");
+        return 0;
+    }
+   
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     * @see LayoutManager#getContentAreaBPD
+     */
+    public int getContentAreaBPD() {
+        log.error("getContentAreaBPD called when it should have been overwritten");
+        return 0;
+    }
+    
+    /**
+     * @see LayoutManager#getGeneratesReferenceArea
+     */
+    public boolean getGeneratesReferenceArea() {
+        return generatesReferenceArea;
+    }
+   
+    /**
+     * Lets implementing LM set the flag indicating if they
+     * generate reference areas.
+     * @param generatesReferenceArea if true the areas generates by this LM are 
+     * reference areas.
+     */
+    protected void setGeneratesReferenceArea(boolean generatesReferenceArea) {
+        this.generatesReferenceArea = generatesReferenceArea;
+    }
+   
+    /**
+     * @see LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return generatesBlockArea;
+    }
+   
+    /**
+     * Lets implementing LM set the flag indicating if they
+     * generate block areas.
+     * @param generatesBlockArea if true the areas generates by this LM are block areas.
+     */
+    protected void setGeneratesBlockArea(boolean generatesBlockArea) {
+        this.generatesBlockArea = generatesBlockArea;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea
+     */
+    public boolean getGeneratesLineArea() {
+        return false;
+    }
+    
+    public FObj getFObj() {
+        return fobj;
+    }
+   
+}
index cb33e9b0cdd7895d0dca6e275e1e38915a733b8b..1ad147f5327df18c6086291da489d632c176304f 100644 (file)
@@ -22,6 +22,8 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.PageViewport;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.RetrieveMarker;
 
@@ -37,7 +39,8 @@ import java.util.Map;
 /**
  * The base class for most LayoutManagers.
  */
-public abstract class AbstractLayoutManager implements LayoutManager, Constants {
+public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager 
+    implements Constants {
     protected LayoutManager parentLM = null;
     protected List childLMs = null;
     protected ListIterator fobjIter = null;
@@ -49,12 +52,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
     /** child LM and child LM iterator during getNextBreakPoss phase */
     protected LayoutManager curChildLM = null;
     protected ListIterator childLMiter = null;
-
-    /**
-     * logging instance
-     */
-    protected static Log log = LogFactory.getLog(LayoutManager.class);
-
+    
     /**
      * Abstract layout manager.
      */
@@ -67,6 +65,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
      * @param fo the formatting object for this layout manager
      */
     public AbstractLayoutManager(FObj fo) {
+        super(fo);
         if (fo == null) {
             throw new IllegalStateException("Null formatting object found.");
         }
@@ -83,6 +82,10 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
         return this.parentLM;
     }
 
+    public void initialize() {
+        // Empty
+    }
+
     /**
      * Return currently active child LayoutManager or null if
      * all children have finished layout.
@@ -95,6 +98,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
         }
         while (childLMiter.hasNext()) {
             curChildLM = (LayoutManager) childLMiter.next();
+            curChildLM.initialize();
             return curChildLM;
         }
         return null;
@@ -157,6 +161,9 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
     public void addAreas(PositionIterator posIter, LayoutContext context) {
     }
 
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
+     */
     public LinkedList getNextKnuthElements(LayoutContext context,
                                            int alignment) {
         log.warn("null implementation of getNextKnuthElements() called!");
@@ -283,4 +290,5 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
             addChildLM(lm);
         }
     }
+
 }
index a183732a38501087b5cd92e60afeb7302c85b8c3..2fe1c2d382ef905ae8d4c3f13f4bf828006f77f2 100644 (file)
@@ -74,45 +74,48 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
      */
     public BlockContainerLayoutManager(BlockContainer node) {
         super(node);
-        initialize();
     }
     
-    private void initialize() {
+    public void initialize() {
         abProps = getBlockContainerFO().getCommonAbsolutePosition();
         foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock()
-                    .spaceBefore).getSpace();
+                    .spaceBefore, this).getSpace();
         foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock()
-                    .spaceAfter).getSpace();
+                    .spaceAfter, this).getSpace();
 
         boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
         if (rotated) {
-            height = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength();
-            width = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength();
+            height = getBlockContainerFO().getInlineProgressionDimension()
+                            .getOptimum(this).getLength();
+            width = getBlockContainerFO().getBlockProgressionDimension()
+                            .getOptimum(this).getLength();
         } else {
-            height = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength();
-            width = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength();
+            height = getBlockContainerFO().getBlockProgressionDimension()
+                            .getOptimum(this).getLength();
+            width = getBlockContainerFO().getInlineProgressionDimension()
+                            .getOptimum(this).getLength();
         }
         
         bpUnit = 0; //layoutProps.blockProgressionUnit;
         if (bpUnit == 0) {
             // use optimum space values
             adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock()
-                .spaceBefore.getSpace().getOptimum().getLength().getValue();
+                .spaceBefore.getSpace().getOptimum(this).getLength().getValue(this);
             adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock()
-                .spaceAfter.getSpace().getOptimum().getLength().getValue();
+                .spaceAfter.getSpace().getOptimum(this).getLength().getValue(this);
         } else {
             // use minimum space values
             adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock()
-                .spaceBefore.getSpace().getMinimum().getLength().getValue();
+                .spaceBefore.getSpace().getMinimum(this).getLength().getValue(this);
             adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock()
-                .spaceAfter.getSpace().getMinimum().getLength().getValue();
+                .spaceAfter.getSpace().getMinimum(this).getLength().getValue(this);
         }
     }
 
     /** @return the content IPD */
     protected int getRotatedIPD() {
         return getBlockContainerFO().getInlineProgressionDimension()
-                .getOptimum().getLength().getValue();
+                .getOptimum(this).getLength().getValue(this);
     }
 
     private int getSpaceBefore() {
@@ -122,18 +125,18 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     private int getBPIndents() {
         int indents = 0;
         indents += getBlockContainerFO().getCommonMarginBlock()
-                    .spaceBefore.getOptimum().getLength().getValue();
+                    .spaceBefore.getOptimum(this).getLength().getValue(this);
         indents += getBlockContainerFO().getCommonMarginBlock()
-                    .spaceAfter.getOptimum().getLength().getValue();
+                    .spaceAfter.getOptimum(this).getLength().getValue(this);
         indents += getBlockContainerFO().getCommonBorderPaddingBackground()
-                    .getBPPaddingAndBorder(false);
+                    .getBPPaddingAndBorder(false, this);
         return indents;
     }
     
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
-        iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue();
+        iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this);
+        iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this);
         return iIndents;
     }
     
@@ -158,14 +161,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         int maxbpd = context.getStackLimit().opt;
         int allocBPD, allocIPD;
         if (height.getEnum() != EN_AUTO) {
-            allocBPD = height.getValue(); //this is the content-height
+            allocBPD = height.getValue(this); //this is the content-height
             allocBPD += getBPIndents();
         } else {
             allocBPD = maxbpd;
             autoHeight = true;
         }
         if (width.getEnum() != EN_AUTO) {
-            allocIPD = width.getValue(); //this is the content-width
+            allocIPD = width.getValue(this); //this is the content-width
             allocIPD += getIPIndents();
         } else {
             allocIPD = referenceIPD;
@@ -173,14 +176,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
 
         vpContentBPD = allocBPD - getBPIndents();
         vpContentIPD = allocIPD - getIPIndents();
-        
+        setContentAreaIPD(vpContentIPD);
         double contentRectOffsetX = 0;
-        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO()
+                .getCommonMarginBlock().startIndent.getValue(this);
         double contentRectOffsetY = 0;
         contentRectOffsetY += getBlockContainerFO()
                 .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
         contentRectOffsetY += getBlockContainerFO()
-                .getCommonBorderPaddingBackground().getPaddingBefore(false);
+                .getCommonBorderPaddingBackground().getPaddingBefore(false, this);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
@@ -337,7 +341,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         Point offset = getAbsOffset();
         int allocBPD, allocIPD;
         if (height.getEnum() != EN_AUTO) {
-            allocBPD = height.getValue(); //this is the content-height
+            allocBPD = height.getValue(this); //this is the content-height
             allocBPD += getBPIndents();
         } else {
             allocBPD = 0;
@@ -351,12 +355,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                 allocBPD = availHeight;
                 allocBPD -= offset.y;
                 if (abProps.bottom.getEnum() != EN_AUTO) {
-                    allocBPD -= abProps.bottom.getValue();
+                    allocBPD -= abProps.bottom.getValue(this);
                     if (allocBPD < 0) {
                         log.error("The current combination of top and bottom properties results"
                                 + " in a negative extent for the block-container. 'bottom' may be"
-                                + " at most " + (allocBPD + abProps.bottom.getValue()) + " mpt,"
-                                + " but was actually " + abProps.bottom.getValue() + " mpt."
+                                + " at most " + (allocBPD + abProps.bottom.getValue(this)) + " mpt,"
+                                + " but was actually " + abProps.bottom.getValue(this) + " mpt."
                                 + " The nominal available height is " + availHeight + " mpt.");
                         allocBPD = 0;
                     }
@@ -375,7 +379,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             }
         }
         if (width.getEnum() != EN_AUTO) {
-            allocIPD = width.getValue(); //this is the content-width
+            allocIPD = width.getValue(this); //this is the content-width
             allocIPD += getIPIndents();
         } else {
             int availWidth;
@@ -386,15 +390,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             }
             allocIPD = availWidth;
             if (abProps.left.getEnum() != EN_AUTO) {
-                allocIPD -= abProps.left.getValue();
+                allocIPD -= abProps.left.getValue(this);
             }
             if (abProps.right.getEnum() != EN_AUTO) {
-                allocIPD -= abProps.right.getValue();
+                allocIPD -= abProps.right.getValue(this);
                 if (allocIPD < 0) {
                     log.error("The current combination of left and right properties results"
                             + " in a negative extent for the block-container. 'right' may be"
-                            + " at most " + (allocIPD + abProps.right.getValue()) + " mpt,"
-                            + " but was actually " + abProps.right.getValue() + " mpt."
+                            + " at most " + (allocIPD + abProps.right.getValue(this)) + " mpt,"
+                            + " but was actually " + abProps.right.getValue(this) + " mpt."
                             + " The nominal available width is " + availWidth + " mpt.");
                     allocIPD = 0;
                 }
@@ -403,7 +407,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                     log.error("The current combination of left and right properties results"
                             + " in a negative extent for the block-container. 'left' may be"
                             + " at most " + allocIPD + " mpt,"
-                            + " but was actually " + abProps.left.getValue() + " mpt."
+                            + " but was actually " + abProps.left.getValue(this) + " mpt."
                             + " The nominal available width is " + availWidth + " mpt.");
                     allocIPD = 0;
                 }
@@ -414,13 +418,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         vpContentIPD = allocIPD - getIPIndents();
         
         double contentRectOffsetX = offset.getX();
-        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO()
+                .getCommonMarginBlock().startIndent.getValue(this);
         double contentRectOffsetY = offset.getY();
         contentRectOffsetY += getSpaceBefore();
         contentRectOffsetY += getBlockContainerFO()
                 .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
         contentRectOffsetY += getBlockContainerFO()
-                .getCommonBorderPaddingBackground().getPaddingBefore(false);
+                .getCommonBorderPaddingBackground().getPaddingBefore(false, this);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
@@ -589,10 +594,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         int x = 0;
         int y = 0;
         if (abProps.left.getEnum() != EN_AUTO) {
-            x = abProps.left.getValue();
+            x = abProps.left.getValue(this);
         }
         if (abProps.top.getEnum() != EN_AUTO) {
-            y = abProps.top.getValue();
+            y = abProps.top.getValue(this);
         }
         return new Point(x, y);
     }
@@ -730,9 +735,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                 // to reach a multiple of bpUnit
                 if (bSpaceBefore && bSpaceAfter) {
                     foBlockSpaceBefore = new SpaceVal(getBlockContainerFO()
-                                .getCommonMarginBlock().spaceBefore).getSpace();
+                                .getCommonMarginBlock().spaceBefore, this).getSpace();
                     foBlockSpaceAfter = new SpaceVal(getBlockContainerFO()
-                                .getCommonMarginBlock().spaceAfter).getSpace();
+                                .getCommonMarginBlock().spaceAfter, this).getSpace();
                     adjustedSpaceBefore = (neededUnits(splitLength
                             + foBlockSpaceBefore.min
                             + foBlockSpaceAfter.min)
@@ -818,12 +823,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
 
             TraitSetter.setProducerID(viewportBlockArea, getBlockContainerFO().getId());
             TraitSetter.addBorders(viewportBlockArea, 
-                    getBlockContainerFO().getCommonBorderPaddingBackground());
-            TraitSetter.addBackground(viewportBlockArea, 
-                    getBlockContainerFO().getCommonBorderPaddingBackground());
+                    getBlockContainerFO().getCommonBorderPaddingBackground(), this);
+            // TraitSetter.addBackground(viewportBlockArea, 
+            //        getBlockContainerFO().getCommonBorderPaddingBackground(),
+            //        this);
             TraitSetter.addMargins(viewportBlockArea, 
                     getBlockContainerFO().getCommonBorderPaddingBackground(),
-                    getBlockContainerFO().getCommonMarginBlock());
+                    getBlockContainerFO().getCommonMarginBlock(),
+                    this);
             
             viewportBlockArea.setCTM(absoluteCTM);
             viewportBlockArea.setClip(clip);
@@ -892,6 +899,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     protected void flush() {
         viewportBlockArea.addBlock(referenceArea, autoHeight);
 
+        TraitSetter.addBackground(viewportBlockArea, 
+                getBlockContainerFO().getCommonBorderPaddingBackground(),
+                this);
+        
         // Fake a 0 height for absolute positioned blocks.
         int saveBPD = viewportBlockArea.getBPD();
         if (viewportBlockArea.getPositioning() == Block.ABSOLUTE) {
@@ -952,5 +963,22 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     protected BlockContainer getBlockContainerFO() {
         return (BlockContainer) fobj;
     }    
+
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea
+     */
+    public boolean getGeneratesReferenceArea() {
+        return true;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return true;
+    }
+   
 }
 
index 46f2f68e45e32f5eeb4f82a32afe50f1993aef1a..0b9b2cd6c3bc2d791d4220d84fda2644d3ddb806 100644 (file)
 package org.apache.fop.layoutmgr;
 
 import java.util.LinkedList;
-import java.util.ListIterator;
 import java.util.List;
+import java.util.ListIterator;
 
-import org.apache.fop.fonts.Font;
-import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
-import org.apache.fop.layoutmgr.inline.LineLayoutManager;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.LineArea;
-import org.apache.fop.traits.SpaceVal;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fonts.Font;
+import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
+import org.apache.fop.layoutmgr.inline.LineLayoutManager;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.traits.SpaceVal;
 
 /**
  * LayoutManager for a block FO.
@@ -42,7 +43,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
     protected ListIterator proxyLMiter;
 
     private int lead = 12000;
-    private int lineHeight = 14000;
+    private Length lineHeight;
     private int follow = 2000;
     private int middleShift = 0;
 
@@ -56,29 +57,33 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
     public BlockLayoutManager(org.apache.fop.fo.flow.Block inBlock) {
         super(inBlock);
         proxyLMiter = new ProxyLMiter();
+    }
 
+    public void initialize() {
         Font fs = getBlockFO().getCommonFont().getFontState(
-                  getBlockFO().getFOEventHandler().getFontInfo());
+                  getBlockFO().getFOEventHandler().getFontInfo(), this);
         
         lead = fs.getAscender();
         follow = -fs.getDescender();
         middleShift = -fs.getXHeight() / 2;
-        lineHeight = getBlockFO().getLineHeight().getOptimum().getLength().getValue();
-        initialize();
-    }
-
-    private void initialize() {
-        foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
-        foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
+        lineHeight = getBlockFO().getLineHeight().getOptimum(this).getLength();
+        foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore, this)
+                            .getSpace();
+        foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter, this)
+                            .getSpace();
         bpUnit = 0; // non-standard extension
         if (bpUnit == 0) {
             // use optimum space values
-            adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
-            adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
+            adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace()
+                                        .getOptimum(this).getLength().getValue(this);
+            adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace()
+                                        .getOptimum(this).getLength().getValue(this);
         } else {
             // use minimum space values
-            adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
-            adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
+            adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace()
+                                        .getMinimum(this).getLength().getValue(this);
+            adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace()
+                                        .getMinimum(this).getLength().getValue(this);
         }
     }
 
@@ -92,15 +97,24 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
      */
     protected class ProxyLMiter extends LMiter {
 
+        /*
+         * Constructs a proxy iterator for Block LM.
+         */
         public ProxyLMiter() {
             super(BlockLayoutManager.this);
             listLMs = new java.util.ArrayList(10);
         }
 
+        /**
+         * @return true if there are more child lms
+         */
         public boolean hasNext() {
             return (curPos < listLMs.size()) ? true : createNextChildLMs(curPos);
         }
 
+        /**
+         * @return true if new child lms were added
+         */
         protected boolean createNextChildLMs(int pos) {
             List newLMs = createChildLMs(pos + 1 - listLMs.size());
             if (newLMs != null) {
@@ -156,8 +170,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue();
-        iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue();
+        iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue(this);
+        iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue(this);
         return iIndents;
     }
     
@@ -190,6 +204,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
                 || !getBlockFO().getKeepWithNext().getWithinColumn().isAuto();
     }
 
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext)
+     */
     public void addAreas(PositionIterator parentIter,
             LayoutContext layoutContext) {
         //System.out.println(" BLM.addAreas>");
@@ -315,8 +332,10 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             // add space before and / or after the paragraph
             // to reach a multiple of bpUnit
             if (bSpaceBefore && bSpaceAfter) {
-                foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
-                foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
+                foSpaceBefore = new SpaceVal(getBlockFO()
+                                    .getCommonMarginBlock().spaceBefore, this).getSpace();
+                foSpaceAfter = new SpaceVal(getBlockFO()
+                                    .getCommonMarginBlock().spaceAfter, this).getSpace();
                 adjustedSpaceBefore = (neededUnits(splitLength
                         + foSpaceBefore.min
                         + foSpaceAfter.min)
@@ -359,7 +378,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             childLM.addAreas(childPosIter, lc);
         }
 
-        //int bIndents = getBlockFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+        //int bIndents = getBlockFO().getCommonBorderPaddingBackground()
+        //                        .getBPPaddingAndBorder(false);
 
         if (markers != null) {
             getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
@@ -386,11 +406,16 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
      * its own area. This includes setting the content IPD and the maximum
      * BPD.
      * @param childArea area to get the parent area for
+     * @return the parent area
      */
     public Area getParentArea(Area childArea) {
         if (curBlockArea == null) {
             curBlockArea = new Block();
 
+            int contentIPD = referenceIPD - getIPIndents();
+            
+            curBlockArea.setIPD(contentIPD/*parentwidth*/);
+
             TraitSetter.addBreaks(curBlockArea, 
                     getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter());
 
@@ -401,10 +426,11 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             // set traits
             TraitSetter.setProducerID(curBlockArea, getBlockFO().getId());
             TraitSetter.addBorders(curBlockArea, 
-                    getBlockFO().getCommonBorderPaddingBackground());
+                    getBlockFO().getCommonBorderPaddingBackground(), this);
             TraitSetter.addMargins(curBlockArea,
                     getBlockFO().getCommonBorderPaddingBackground(), 
-                    getBlockFO().getCommonMarginBlock());
+                    getBlockFO().getCommonMarginBlock(),
+                    this);
 
             // Set up dimensions
             // Get reference IPD from parentArea
@@ -424,11 +450,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             parentwidth -= getIPIndents();
             */
 
-            int contentIPD = referenceIPD - getIPIndents();
-            
-            curBlockArea.setIPD(contentIPD/*parentwidth*/);
-            TraitSetter.addBackground(curBlockArea, 
-                    getBlockFO().getCommonBorderPaddingBackground());
             setCurrentArea(curBlockArea); // ??? for generic operations
         }
         return curBlockArea;
@@ -447,6 +468,19 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         }
     }
 
+    /**
+     * Force current area to be added to parent area.
+     * @see org.apache.fop.layoutmgr.BlockStackingLayoutManager#flush()
+     */
+    protected void flush() {
+        if (curBlockArea != null) {
+            TraitSetter.addBackground(curBlockArea, 
+                    getBlockFO().getCommonBorderPaddingBackground(),
+                    this);
+            super.flush();
+        }
+    }
+
     /**
      * @see org.apache.fop.layoutmgr.LayoutManager#resetPosition(org.apache.fop.layoutmgr.Position)
      */
@@ -462,9 +496,43 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
     /**
      * convenience method that returns the Block node
+     * @return the block node
      */
     protected org.apache.fop.fo.flow.Block getBlockFO() {
         return (org.apache.fop.fo.flow.Block) fobj;
     }
+    
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        if (curBlockArea != null) {
+            return curBlockArea.getIPD();
+        }
+        return super.getContentAreaIPD();
+    }
+   
+
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        if (curBlockArea != null) {
+            return curBlockArea.getBPD();
+        }
+        return -1;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return true;
+    }
+   
 }
 
index feec2f78365cc00f34c4eadb725bb420333bf5e2..822974e7b6deeee4ad84c33f21eaec96a2a77004 100644 (file)
@@ -62,29 +62,37 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     protected boolean bSpaceBeforeServed = false;
     /** Reference IPD available */
     protected int referenceIPD = 0;
-
-    /* holds the (one-time use) fo:block space-before
-       and -after properties.  Large fo:blocks are split
-       into multiple Area.Blocks to accomodate the subsequent
-       regions (pages) they are placed on.  space-before
-       is applied at the beginning of the first
-       Block and space-after at the end of the last Block
-       used in rendering the fo:block.
-    */
+    /**
+     * Holds the (one-time use) fo:block space-before
+     * and -after properties.  Large fo:blocks are split
+     * into multiple Area. Blocks to accomodate the subsequent
+     * regions (pages) they are placed on.  space-before
+     * is applied at the beginning of the first
+     * Block and space-after at the end of the last Block
+     * used in rendering the fo:block.
+     */
     protected MinOptMax foSpaceBefore = null;
+    /** see foSpaceBefore */
     protected MinOptMax foSpaceAfter = null;
 
     private int lastGeneratedPosition = -1;
     private int smallestPosNumberChecked = Integer.MAX_VALUE;
 
     private Position auxiliaryPosition;
+
+    private int contentAreaIPD = 0;
     
+    /**
+     * @param the fo this LM deals with
+     */
     public BlockStackingLayoutManager(FObj node) {
         super(node);
+        setGeneratesBlockArea(true);
         fobj = node;
     }
 
-    /** return current area being filled
+    /** 
+     * @return current area being filled
      */
     protected BlockParent getCurrentArea() {
         return this.parentArea;
@@ -93,6 +101,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
 
     /**
      * Set the current area being filled.
+     * @param parentArea the current area to be filled
      */
     protected void setCurrentArea(BlockParent parentArea) {
         this.parentArea = parentArea;
@@ -240,6 +249,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         return (int) Math.ceil((float)len / bpUnit);
     }
 
+    /**
+     * @see LayoutManager#getNextKnuthElements(LayoutContext, int)
+     */
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
         /* LF *///System.err.println("BLM.getNextKnuthElements> keep-together = "
               // + layoutProps.keepTogether.getType());
@@ -251,21 +263,21 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         BlockLevelLayoutManager prevLM = null; // previously active LM
 
         referenceIPD = context.getRefIPD();
+        
         int iIndents = 0;
         int bIndents = 0;
         if (fobj instanceof org.apache.fop.fo.flow.Block) {
             org.apache.fop.fo.flow.Block block = (org.apache.fop.fo.flow.Block)fobj;
-            iIndents = block.getCommonMarginBlock().startIndent.getValue() 
-                     + block.getCommonMarginBlock().endIndent.getValue();
-            bIndents = block.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+            iIndents = block.getCommonMarginBlock().startIndent.getValue(this
+                     + block.getCommonMarginBlock().endIndent.getValue(this);
+            bIndents = block.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, this);
         }
         int ipd = referenceIPD - iIndents;
 
         MinOptMax stackSize = new MinOptMax();
 
         // Set context for percentage property values.
-        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
-        fobj.setLayoutDimension(PercentBase.BLOCK_BPD, -1);
+        setContentAreaIPD(ipd);
 
         LinkedList returnedList = null;
         LinkedList contentList = new LinkedList();
@@ -437,6 +449,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         return returnList;
     }
 
+    /**
+     * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+     */
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
 /*LF*/  //System.out.println("  BLM.negotiateBPDAdjustment> " + adj);
 /*LF*/  //System.out.println("  lastElement e' " + (lastElement.isPenalty() 
@@ -517,6 +532,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         }
     }
 
+    /**
+     * @see BlockLevelLayoutManager#discardSpace(KnuthGlue)
+     */
     public void discardSpace(KnuthGlue spaceGlue) {
         //System.out.println("  BLM.discardSpace> " + spaceGlue.getPosition().getClass().getName());
         Position innerPosition = ((NonLeafPosition) spaceGlue.getPosition()).getPosition();
@@ -544,6 +562,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         }
     }
 
+    /**
+     * @see LayoutManager#getChangedKnuthElements(List, int)
+     */
     public LinkedList getChangedKnuthElements(List oldList, int alignment) {
 /*LF*/  //System.out.println("");
 /*LF*/  //System.out.println("  BLM.getChangedKnuthElements> inizio: oldList.size() = " 
@@ -775,7 +796,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for before border padding and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      */
     protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList/*, 
             Position returnPosition*/) {
@@ -791,7 +811,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         if (borderAndPadding != null) {
             //TODO Handle conditionality
             int bpBefore = borderAndPadding.getBorderBeforeWidth(false)
-                         + borderAndPadding.getPaddingBefore(false);
+                         + borderAndPadding.getPaddingBefore(false, this);
             if (bpBefore > 0) {
                 returnList.add(new KnuthBox(bpBefore, getAuxiliaryPosition(), true));
             }
@@ -801,7 +821,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for after border padding and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      */
     protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList/*, 
             Position returnPosition*/) {
@@ -817,7 +836,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         if (borderAndPadding != null) {
             //TODO Handle conditionality
             int bpAfter = borderAndPadding.getBorderAfterWidth(false)
-                        + borderAndPadding.getPaddingAfter(false);
+                        + borderAndPadding.getPaddingAfter(false, this);
             if (bpAfter > 0) {
                 returnList.add(new KnuthBox(bpAfter, getAuxiliaryPosition(), true));
             }
@@ -827,7 +846,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for break-before and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      * @return true if an element has been added due to a break-before.
      */
     protected boolean addKnuthElementsForBreakBefore(LinkedList returnList/*, 
@@ -856,7 +874,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for break-after and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      * @return true if an element has been added due to a break-after.
      */
     protected boolean addKnuthElementsForBreakAfter(LinkedList returnList/*, 
@@ -885,7 +902,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for space-before and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      * @param alignment vertical alignment
      */
     protected void addKnuthElementsForSpaceBefore(LinkedList returnList/*, 
@@ -907,8 +923,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         // append elements representing space-before
         if (bpUnit > 0
                 || spaceBefore != null
-                   && !(spaceBefore.getMinimum().getLength().getValue() == 0 
-                        && spaceBefore.getMaximum().getLength().getValue() == 0)) {
+                   && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 
+                        && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) {
             if (spaceBefore != null && !spaceBefore.getSpace().isDiscard()) {
                 // add elements to prevent the glue to be discarded
                 returnList.add(new KnuthBox(0, getAuxiliaryPosition(), false));
@@ -921,16 +937,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                         getAuxiliaryPosition(), true));
             } else /*if (alignment == EN_JUSTIFY)*/ {
                 returnList.add(new KnuthGlue(
-                        spaceBefore.getOptimum().getLength().getValue(),
-                        spaceBefore.getMaximum().getLength().getValue()
-                                - spaceBefore.getOptimum().getLength().getValue(),
-                        spaceBefore.getOptimum().getLength().getValue()
-                                - spaceBefore.getMinimum().getLength().getValue(),
+                        spaceBefore.getOptimum(this).getLength().getValue(this),
+                        spaceBefore.getMaximum(this).getLength().getValue(this)
+                                - spaceBefore.getOptimum(this).getLength().getValue(this),
+                        spaceBefore.getOptimum(this).getLength().getValue(this)
+                                - spaceBefore.getMinimum(this).getLength().getValue(this),
                         BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, 
                         getAuxiliaryPosition(), true));
             } /*else {
                 returnList.add(new KnuthGlue(
-                        spaceBefore.getOptimum().getLength().getValue(), 
+                        spaceBefore.getOptimum().getLength().getValue(this), 
                         0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT,
                         returnPosition, true));
             }*/
@@ -940,7 +956,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /**
      * Creates Knuth elements for space-after and adds them to the return list.
      * @param returnList return list to add the additional elements to
-     * @param returnPosition applicable return position
      * @param alignment vertical alignment
      */
     protected void addKnuthElementsForSpaceAfter(LinkedList returnList/*, Position returnPosition*/, 
@@ -962,8 +977,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         // append elements representing space-after
         if (bpUnit > 0
                 || spaceAfter != null
-                   && !(spaceAfter.getMinimum().getLength().getValue() == 0 
-                        && spaceAfter.getMaximum().getLength().getValue() == 0)) {
+                   && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 
+                        && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) {
             if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) {
                 returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
                         false, getAuxiliaryPosition(), false));
@@ -974,16 +989,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                         getAuxiliaryPosition(), true));
             } else /*if (alignment == EN_JUSTIFY)*/ {
                 returnList.add(new KnuthGlue(
-                        spaceAfter.getOptimum().getLength().getValue(),
-                        spaceAfter.getMaximum().getLength().getValue()
-                                - spaceAfter.getOptimum().getLength().getValue(),
-                        spaceAfter.getOptimum().getLength().getValue()
-                                - spaceAfter.getMinimum().getLength().getValue(),
+                        spaceAfter.getOptimum(this).getLength().getValue(this),
+                        spaceAfter.getMaximum(this).getLength().getValue(this)
+                                - spaceAfter.getOptimum(this).getLength().getValue(this),
+                        spaceAfter.getOptimum(this).getLength().getValue(this)
+                                - spaceAfter.getMinimum(this).getLength().getValue(this),
                         BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(),
                         (!spaceAfter.getSpace().isDiscard()) ? false : true));
             } /*else {
                 returnList.add(new KnuthGlue(
-                        spaceAfter.getOptimum().getLength().getValue(), 0, 0,
+                        spaceAfter.getOptimum().getLength().getValue(this), 0, 0,
                         BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, returnPosition,
                         (!spaceAfter.getSpace().isDiscard()) ? false : true));
             }*/
@@ -1378,5 +1393,25 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         }
     }
 
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return contentAreaIPD;
+    }
+   
+    protected void setContentAreaIPD(int contentAreaIPD) {
+        this.contentAreaIPD = contentAreaIPD;
+    }
+    
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        return -1;
+    }
+    
 }
 
index a400078c264011619f9d06a4837f7e3b636ed01d..70f4815326d0b6fc92a5ce517adb39adf4f8963d 100644 (file)
@@ -62,10 +62,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
         // set layout dimensions
         int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth();
         int flowBPD = (int) getCurrentPV().getBodyRegion().getBPD();
-        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
-        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
-        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD());
-        fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
 
         // currently active LM
         BlockLevelLayoutManager curLM;
@@ -338,5 +334,21 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
             reset(null);
         }
     }
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return getCurrentPV().getCurrentSpan().getColumnWidth();
+    }
+   
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        return (int) getCurrentPV().getBodyRegion().getBPD();
+    }
+    
 }
 
index 3d60532489dcc5aac1f464bb8863ccaa135d8218..33250110f6ae0fcd8ac4f93fa1243e09b88b5081 100644 (file)
@@ -22,11 +22,13 @@ import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.fop.area.Area;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.FObj;
 
 /**
  * The interface for all LayoutManagers.
  */
-public interface LayoutManager {
+public interface LayoutManager extends PercentBaseContext {
 
     /**
      * Set the parent layout manager.
@@ -42,6 +44,12 @@ public interface LayoutManager {
      */
     LayoutManager getParent();
 
+    /**
+     * initialize the layout manager. Allows each layout manager 
+     * to calculate often used values.
+     */
+    public void initialize();
+    
     /**
      * Get the active PageSequenceLayoutManager instance for this
      * layout process.
@@ -143,11 +151,46 @@ public interface LayoutManager {
      * of the node assigned to the LM, after changes have been applied
      *
      * @param oldList        the elements to replace
-     * @param flaggedPenalty the penalty value for hyphenated lines
      * @param alignment      the desired text alignment
      * @return               the updated list of KnuthElements
      */
     LinkedList getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/
                                        int alignment);
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    int getContentAreaIPD();
    
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    int getContentAreaBPD();
+   
+    /**
+     * Returns an indication if the layout manager generates a reference area.
+     * @return True if the layout manager generates a reference area
+     */
+    boolean getGeneratesReferenceArea();
+
+    /**
+     * Returns an indication if the layout manager generates a block area.
+     * @return True if the layout manager generates a block area
+     */
+    boolean getGeneratesBlockArea();
+
+    /**
+     * Returns an indication if the layout manager generates a line area.
+     * @return True if the layout manager generates a line area
+     */
+    boolean getGeneratesLineArea();
+    
+    /**
+     * Returns the fo this layout manager is associated with.
+     * @return The fo for this layout manager or null.
+     */
+    FObj getFObj();
+    
 }
index a17748e24d1be0b02a6432a06a573f41c85925b4..e99ec6853d13663c72ff9008c4e3556689c6d62f 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 import org.apache.fop.traits.MinOptMax;
@@ -31,18 +32,20 @@ public class MinOptMaxUtil {
      * Restricts a MinOptMax using the values from a LengthRangeProperty.
      * @param mom MinOptMax to restrict
      * @param lr restricting source
+     * @param context Percentage evaluation context
      */
-    public static void restrict(MinOptMax mom, LengthRangeProperty lr) {
+    public static void restrict(MinOptMax mom, LengthRangeProperty lr, 
+                                PercentBaseContext context) {
         if (lr.getEnum() != Constants.EN_AUTO) {
-            if (lr.getMinimum().getEnum() != Constants.EN_AUTO) {
-                int min = lr.getMinimum().getLength().getValue();
+            if (lr.getMinimum(context).getEnum() != Constants.EN_AUTO) {
+                int min = lr.getMinimum(context).getLength().getValue(context);
                 if (min > mom.min) {
                     mom.min = min;
                     fixAfterMinChanged(mom);
                 }
             }
-            if (lr.getMaximum().getEnum() != Constants.EN_AUTO) {
-                int max = lr.getMaximum().getLength().getValue();
+            if (lr.getMaximum(context).getEnum() != Constants.EN_AUTO) {
+                int max = lr.getMaximum(context).getLength().getValue(context);
                 if (max < mom.max) {
                     mom.max = max;
                     if (mom.max < mom.opt) {
@@ -51,8 +54,8 @@ public class MinOptMaxUtil {
                     }
                 }
             }
-            if (lr.getOptimum().getEnum() != Constants.EN_AUTO) {
-                int opt = lr.getOptimum().getLength().getValue();
+            if (lr.getOptimum(context).getEnum() != Constants.EN_AUTO) {
+                int opt = lr.getOptimum(context).getLength().getValue(context);
                 if (opt > mom.min) {
                     mom.opt = opt;
                     if (mom.opt > mom.max) {
@@ -63,6 +66,13 @@ public class MinOptMaxUtil {
         }
     }
 
+    /**
+     * Extend the minimum length to the given length.
+     * @param mom the min/opt/max trait
+     * @param len the new minimum length
+     * @param optToLen if set adjusts the optimum length to be the smaller of the
+     * minimum length and the given length
+     */
     public static void extendMinimum(MinOptMax mom, int len, boolean optToLen) {
         if (mom.min < len) {
             mom.min = len;
@@ -91,17 +101,18 @@ public class MinOptMaxUtil {
     /**
      * Converts a LengthRangeProperty to a MinOptMax.
      * @param prop LengthRangeProperty
+     * @param context Percentage evaluation context
      * @return the requested MinOptMax instance
      */
-    public static MinOptMax toMinOptMax(LengthRangeProperty prop) {
+    public static MinOptMax toMinOptMax(LengthRangeProperty prop, PercentBaseContext context) {
         MinOptMax mom = new MinOptMax(
-                (prop.getMinimum().isAuto() 
-                        ? 0 : prop.getMinimum().getLength().getValue()),
-                (prop.getOptimum().isAuto() 
-                        ? 0 : prop.getOptimum().getLength().getValue()),
-                (prop.getMinimum().isAuto() 
+                (prop.getMinimum(context).isAuto() 
+                        ? 0 : prop.getMinimum(context).getLength().getValue(context)),
+                (prop.getOptimum(context).isAuto() 
+                        ? 0 : prop.getOptimum(context).getLength().getValue(context)),
+                (prop.getMinimum(context).isAuto() 
                         ? Integer.MAX_VALUE 
-                        : prop.getMaximum().getLength().getValue()));
+                        : prop.getMaximum(context).getLength().getValue(context)));
         return mom;
     }
     
index c052bf94e28cb5a8086d4e5413e8219ad44d23de..57ceb82a068e37f0ad668938203a258100882aea 100644 (file)
@@ -243,6 +243,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
                             FootnoteBodyLayoutManager fblm 
                                 = (FootnoteBodyLayoutManager) footnoteBodyIterator.next();
                             fblm.setParent(childFLM);
+                            fblm.initialize();
                             ((KnuthBlockBox) element).addElementList(
                                     fblm.getNextKnuthElements(footnoteContext, alignment));
                         }
index 5412d80fc3c50f74d19797892dfe09734f9c30f9..37ab04395311273cdff6f24dc24b6575f5fef1cf 100644 (file)
@@ -42,6 +42,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
     private Block targetBlock;
     private SideRegion regionFO;
 
+    private int contentAreaIPD = 0;
+    private int contentAreaBPD = -1;
+
     /**
      * Creates a new StaticContentLayoutManager.
      * @param pslm PageSequenceLayoutManager this layout manager belongs to
@@ -53,9 +56,15 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
         super(node);
         setParent(pslm);
         regionFO = reg;
-        targetRegion = getCurrentPV().getRegionReference(regionFO.getNameId()); 
+        targetRegion = getCurrentPV().getRegionReference(regionFO.getNameId());
     }
 
+    /**
+     * Creates a new StaticContentLayoutManager.
+     * @param pslm PageSequenceLayoutManager this layout manager belongs to
+     * @param node static-content FO
+     * @param block the block to layout into
+     */
     public StaticContentLayoutManager(PageSequenceLayoutManager pslm, 
             StaticContent node, Block block) {
         super(node);
@@ -68,8 +77,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
      */
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
         // set layout dimensions
-        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD());
-        fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
+        setContentAreaIPD(context.getRefIPD());
+        setContentAreaBPD(context.getStackLimit().opt);
 
         //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. 
         // currently active LM
@@ -218,7 +227,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
     }
     
     /**
-     * convenience method that returns the Static Content node
+     * Convenience method that returns the Static Content node.
+     * @return the static content node
      */
     protected StaticContent getStaticContentFO() {
         return (StaticContent) fobj;
@@ -307,6 +317,31 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
         protected LayoutManager getCurrentChildLM() {
             return null; //TODO NYI
         }
-    }    
+    } 
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return contentAreaIPD;
+    }
+   
+    private void setContentAreaIPD(int contentAreaIPD) {
+        this.contentAreaIPD = contentAreaIPD;
+    }
+    
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        return contentAreaBPD;
+    }
+    
+    private void setContentAreaBPD(int contentAreaBPD) {
+        this.contentAreaBPD = contentAreaBPD;
+    }
+    
 }
 
index c1322d5703d8006f994bfcadbd0dc5a9011a540f..8e2c72a0f3fc7fb6879583d4ca2475924a7dd4a3 100644 (file)
@@ -23,6 +23,9 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
@@ -43,23 +46,25 @@ public class TraitSetter {
      * @param bpProps border and padding properties
      * @param bNotFirst True if the area is not the first area
      * @param bNotLast True if the area is not the last area
+     * @param context Property evaluation context
      */
     public static void setBorderPaddingTraits(Area area,
-            CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast) {
+            CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast,
+            PercentBaseContext context) {
         int iBP;
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst);
+        iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst, context);
         if (iBP > 0) {
             area.addTrait(Trait.PADDING_START, new Integer(iBP));
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast);
+        iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, context);
         if (iBP > 0) {
             area.addTrait(Trait.PADDING_END, new Integer(iBP));
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
         if (iBP > 0) {
             area.addTrait(Trait.PADDING_BEFORE, new Integer(iBP));
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
         if (iBP > 0) {
             area.addTrait(Trait.PADDING_AFTER, new Integer(iBP));
         }
@@ -106,8 +111,10 @@ public class TraitSetter {
      * add the borders to the area.
      * @param area the area to set the traits on.
      * @param bordProps border properties
+     * @param context Property evaluation context
      */
-    public static void addBorders(Area area, CommonBorderPaddingBackground bordProps) {
+    public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
+                                PercentBaseContext context) {
         BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
         if (bps != null) {
             area.addTrait(Trait.BORDER_BEFORE, bps);
@@ -125,7 +132,7 @@ public class TraitSetter {
             area.addTrait(Trait.BORDER_END, bps);
         }
 
-        addPadding(area, bordProps);
+        addPadding(area, bordProps, context);
     }
 
     /**
@@ -136,10 +143,12 @@ public class TraitSetter {
      * @param bordProps border properties
      * @param outer 4 boolean values indicating if the side represents the 
      *     table's outer border. Order: before, after, start, end
+     * @param context Property evaluation context
      */
     public static void addCollapsingBorders(Area area, 
             CommonBorderPaddingBackground bordProps,
-            boolean[] outer) {
+            boolean[] outer,
+            PercentBaseContext context) {
         BorderProps bps = getCollapsingBorderProps(bordProps, 
                 CommonBorderPaddingBackground.BEFORE, outer[0]);
         if (bps != null) {
@@ -161,26 +170,27 @@ public class TraitSetter {
             area.addTrait(Trait.BORDER_END, bps);
         }
 
-        addPadding(area, bordProps);
+        addPadding(area, bordProps, context);
     }
 
-    private static void addPadding(Area area, CommonBorderPaddingBackground bordProps) {
-        int padding = bordProps.getPadding(CommonBorderPaddingBackground.START, false);
+    private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, 
+                                PercentBaseContext context) {
+        int padding = bordProps.getPadding(CommonBorderPaddingBackground.START, false, context);
         if (padding != 0) {
             area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding));
         }
 
-        padding = bordProps.getPadding(CommonBorderPaddingBackground.END, false);
+        padding = bordProps.getPadding(CommonBorderPaddingBackground.END, false, context);
         if (padding != 0) {
             area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding));
         }
 
-        padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
         if (padding != 0) {
             area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding));
         }
 
-        padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
         if (padding != 0) {
             area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding));
         }
@@ -221,8 +231,11 @@ public class TraitSetter {
      * Note: The area's IPD and BPD must be set before calling this method.
      * @param area the area to set the traits on
      * @param backProps the background properties
+     * @param context Property evaluation context
      */
-    public static void addBackground(Area area, CommonBorderPaddingBackground backProps) {
+    public static void addBackground(Area area, 
+                                     CommonBorderPaddingBackground backProps,
+                                     PercentBaseContext context) {
         if (!backProps.hasBackground()) {
             return;
         }
@@ -236,43 +249,42 @@ public class TraitSetter {
             if (backProps.backgroundPositionHorizontal != null) {
                 if (back.getRepeat() == Constants.EN_NOREPEAT 
                         || back.getRepeat() == Constants.EN_REPEATY) {
-                    if (backProps.backgroundPositionHorizontal instanceof PercentLength) {
-                        if (area.getIPD() > 0) {
-                            int width = area.getIPD();
-                            width += backProps.getPaddingStart(false);
-                            width += backProps.getPaddingEnd(false);
-                            back.setHoriz((int)((width - back.getFopImage().getIntrinsicWidth()) 
-                                * ((PercentLength)backProps.backgroundPositionHorizontal).value()));
-                        } else {
-                            //TODO Area IPD has to be set for this to work
-                            log.warn("Horizontal background image positioning ignored"
-                                    + " because the IPD was not set on the area."
-                                    + " (Yes, it's a bug in FOP)");
-                        }
+                    if (area.getIPD() > 0) {
+                        int width = area.getIPD();
+                        width += backProps.getPaddingStart(false, context);
+                        width += backProps.getPaddingEnd(false, context);
+                        back.setHoriz(backProps.backgroundPositionHorizontal.getValue(
+                                new SimplePercentBaseContext(context, 
+                                                             LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL,
+                                                             (width - back.getFopImage().getIntrinsicWidth())
+                                                            )
+                            ));
                     } else {
-                        back.setHoriz(backProps.backgroundPositionHorizontal.getValue());
+                        //TODO Area IPD has to be set for this to work
+                        log.warn("Horizontal background image positioning ignored"
+                                + " because the IPD was not set on the area."
+                                + " (Yes, it's a bug in FOP)");
                     }
                 }
             }
             if (backProps.backgroundPositionVertical != null) {
                 if (back.getRepeat() == Constants.EN_NOREPEAT 
                         || back.getRepeat() == Constants.EN_REPEATX) {
-                    if (backProps.backgroundPositionVertical instanceof PercentLength) {
-                        if (area.getBPD() > 0) {
-                            int height = area.getBPD();
-                            height += backProps.getPaddingBefore(false);
-                            height += backProps.getPaddingAfter(false);
-                            back.setVertical(
-                                (int)((height - back.getFopImage().getIntrinsicHeight()) 
-                                * ((PercentLength)backProps.backgroundPositionVertical).value()));
-                        } else {
-                            //TODO Area BPD has to be set for this to work
-                            log.warn("Vertical background image positioning ignored"
-                                    + " because the BPD was not set on the area."
-                                    + " (Yes, it's a bug in FOP)");
-                        }
+                    if (area.getBPD() > 0) {
+                        int height = area.getBPD();
+                        height += backProps.getPaddingBefore(false, context);
+                        height += backProps.getPaddingAfter(false, context);
+                        back.setVertical(backProps.backgroundPositionVertical.getValue(
+                                new SimplePercentBaseContext(context, 
+                                                             LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL,
+                                                             (height - back.getFopImage().getIntrinsicHeight())
+                                                            )
+                            ));
                     } else {
-                        back.setVertical(backProps.backgroundPositionVertical.getValue());
+                        //TODO Area BPD has to be set for this to work
+                        log.warn("Vertical background image positioning ignored"
+                                + " because the BPD was not set on the area."
+                                + " (Yes, it's a bug in FOP)");
                     }
                 }
             }
@@ -288,29 +300,31 @@ public class TraitSetter {
      * @param area the area to set the traits on.
      * @param bpProps the border, padding and background properties
      * @param marginProps the margin properties.
+     * @param context the context for evaluation of percentages
      */
     public static void addMargins(Area area,
                                   CommonBorderPaddingBackground bpProps,
-                                  CommonMarginBlock marginProps) {
-        int startIndent = marginProps.startIndent.getValue();
+                                  CommonMarginBlock marginProps,
+                                  PercentBaseContext context) {
+        int startIndent = marginProps.startIndent.getValue(context);
         if (startIndent != 0) {
             area.addTrait(Trait.START_INDENT, new Integer(startIndent));
         }
         
-        int spaceStart = marginProps.startIndent.getValue()
+        int spaceStart = marginProps.startIndent.getValue(context)
                             - bpProps.getBorderStartWidth(false)
-                            - bpProps.getPaddingStart(false);
+                            - bpProps.getPaddingStart(false, context);
         if (spaceStart != 0) {
             area.addTrait(Trait.SPACE_START, new Integer(spaceStart));
         }
 
-        int endIndent = marginProps.endIndent.getValue();
+        int endIndent = marginProps.endIndent.getValue(context);
         if (endIndent != 0) {
             area.addTrait(Trait.END_INDENT, new Integer(endIndent));
         }
-        int spaceEnd = marginProps.endIndent.getValue()
+        int spaceEnd = marginProps.endIndent.getValue(context)
                             - bpProps.getBorderEndWidth(false)
-                            - bpProps.getPaddingEnd(false);
+                            - bpProps.getPaddingEnd(false, context);
         if (spaceEnd != 0) {
             area.addTrait(Trait.SPACE_END, new Integer(spaceEnd));
         }
index 6a60f420522cf04638c17d96d5a9130a3d1f8756..bc6a0d44aebe2213eea72dde1452294d1aeed8b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ public class BidiLayoutManager extends LeafNodeLayoutManager {
 
     public BidiLayoutManager(BidiOverride node, InlineLayoutManager cLM) {
         super(node);
+        setParent(cLM);
         children = new ArrayList();
 /*
         for (int count = cLM.size() - 1; count >= 0; count--) {
index b278c0f2bf569e051450f0f9695e796a0835f296..c15ee02c48630688caef96327f8a9e150027ef6f 100644 (file)
@@ -54,10 +54,14 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
     public CharacterLayoutManager(Character node) {
         super(node);
         fobj = node;
-        InlineArea inline = getCharacterInlineArea(node);
+    }
+    
+    public void initialize() {
+        InlineArea inline = getCharacterInlineArea(fobj);
         setCurrentArea(inline);
+        
         setAlignment(fobj.getVerticalAlign());
-        fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
+        fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
 
         SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing());
         letterSpaceIPD = ls.getSpace();
index d55208a20f47d27c6d2b224bbf34b10f69e7d9e5..6c094f6a36481e89493492bb0e0c88adf956e76c 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr.inline;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.pagination.Title;
+import org.apache.fop.layoutmgr.AbstractBaseLayoutManager;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthPossPosIter;
 import org.apache.fop.layoutmgr.LayoutContext;
@@ -41,24 +42,21 @@ import org.apache.fop.traits.MinOptMax;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Block;
 
 /**
  * Content Layout Manager.
  * For use with objects that contain inline areas such as
  * leader use-content and title.
  */
-public class ContentLayoutManager implements InlineLevelLayoutManager {
+public class ContentLayoutManager extends AbstractBaseLayoutManager
+        implements InlineLevelLayoutManager {
     private FOUserAgent userAgent;
     private Area holder;
     private int stackSize;
     private LayoutManager parentLM;
     private InlineLevelLayoutManager childLM = null;
 
-    /**
-     * logging instance
-     */
-    protected static Log log = LogFactory.getLog(LayoutManager.class);
-
     /**
      * Constructs a new ContentLayoutManager
      *
@@ -88,6 +86,10 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
         fillArea(lm);
     }
 
+    public void initialize() {
+        // Empty
+    }
+
     public void fillArea(LayoutManager curLM) {
 
         int ipd = 1000000;
@@ -311,5 +313,45 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
     public PageSequenceLayoutManager getPSLM() {
         return parentLM.getPSLM();
     }
+
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return holder.getIPD();
+    }
+   
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        return holder.getBPD();
+    }
+    
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea
+     */
+    public boolean getGeneratesReferenceArea() {
+        return false;
+    }
+
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return getGeneratesLineArea() || holder instanceof Block;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea
+     */
+    public boolean getGeneratesLineArea() {
+        return holder instanceof LineArea;
+    }
+   
 }
 
index cc5dd8ca7a17a0cc0cee7f37f912040ed1119215..b31b5ea04029775f4d37a9cc944c9e4a0e51083b 100644 (file)
@@ -20,14 +20,18 @@ package org.apache.fop.layoutmgr.inline;
 
 // Java
 import java.awt.geom.Rectangle2D;
+import java.util.LinkedList;
 
 // FOP
 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;
 
 /**
@@ -57,11 +61,6 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
     public ExternalGraphicLayoutManager(ExternalGraphic node) {
         super(node);
         fobj = node;
-        setup();
-        InlineArea area = getExternalGraphicInlineArea();
-        setCurrentArea(area);
-        setAlignment(fobj.getVerticalAlign());
-        setLead(viewHeight);
     }
 
     /**
@@ -71,22 +70,22 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
      */
     private void setup() {
         // assume lr-tb for now and just use the .optimum value of the range
-        Length ipd = fobj.getInlineProgressionDimension().getOptimum().getLength();
+        Length ipd = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
         if (ipd.getEnum() != EN_AUTO) {
-            viewWidth = ipd.getValue();
+            viewWidth = ipd.getValue(this);
         } else {
             ipd = fobj.getWidth();
             if (ipd.getEnum() != EN_AUTO) {
-                viewWidth = ipd.getValue();
+                viewWidth = ipd.getValue(this);
             }
         }
-        Length bpd = fobj.getBlockProgressionDimension().getOptimum().getLength();
+        Length bpd = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
         if (bpd.getEnum() != EN_AUTO) {
-            viewHeight = bpd.getValue();
+            viewHeight = bpd.getValue(this);
         } else {
             bpd = fobj.getHeight();
             if (bpd.getEnum() != EN_AUTO) {
-                viewHeight = bpd.getValue();
+                viewHeight = bpd.getValue(this);
             }
         }
 
@@ -99,7 +98,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
                     cheight = viewHeight;
                 }
             } else {
-                cheight = ch.getValue();
+                cheight = ch.getValue(this);
             }
         }
         Length cw = fobj.getContentWidth();
@@ -109,7 +108,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
                     cwidth = viewWidth;
                 }
             } else {
-                cwidth = cw.getValue();
+                cwidth = cw.getValue(this);
             }
         }
 
@@ -189,10 +188,10 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
         CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
         
         //Determine extra BPD from borders etc.
-        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
         beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
                                              false);
-        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
         afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
         
         yoffset += beforeBPD;
@@ -201,10 +200,10 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
         
         //Determine extra IPD from borders etc.
         int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false/*bNotFirst*/);
+                false/*bNotFirst*/, this);
         startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
                  false/*bNotFirst*/);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this);
         endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
         
         xoffset += startIPD;
@@ -214,6 +213,19 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
         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.
@@ -232,8 +244,8 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
          vp.setOffset(0);
 
          // Common Border, Padding, and Background Properties
-         TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground());
-         TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground());
+         TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this);
+         TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this);
 
          return vp;
      }
@@ -242,5 +254,38 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
     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
+     */
+    protected int getIntrinsicHeight() {
+        return fobj.getIntrinsicHeight();
+    }
+
 }
 
index 21267f7c59c8dd378b941ef639df4e907fb14429..44d8fc8ed6e46ef6d1cb40cc7b0eaa701babfd09 100644 (file)
@@ -44,7 +44,9 @@ public class FootnoteLayoutManager extends AbstractLayoutManager
     public FootnoteLayoutManager(Footnote node) {
         super(node);
         footnote = node;
-
+    }
+    
+    public void initialize() {
         // create an InlineStackingLM handling the fo:inline child of fo:footnote
         citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
 
@@ -61,7 +63,9 @@ public class FootnoteLayoutManager extends AbstractLayoutManager
 
         // set the citationLM parent to be this LM's parent
         citationLM.setParent(getParent());
+        citationLM.initialize();
         bodyLM.setParent(this);
+        bodyLM.initialize();
 
         // get Knuth elements representing the footnote citation
         LinkedList returnedList = new LinkedList();
index 72b8c7badee52f5016d5d72095b68d876b5f1059..3463e38831133c47b385925cf0efb56e62f35d39 100755 (executable)
@@ -67,31 +67,30 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
     public InlineLayoutManager(InlineLevel node) {
         super(node);
         fobj = node;
-        initialize();
     }
     
     private Inline getInlineFO() {
         return (Inline)fobj;
     }
     
-    private void initialize() {
+    public void initialize() {
         inlineProps = fobj.getCommonMarginInline();
         borderProps = fobj.getCommonBorderPaddingBackground();
 
-        int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
         iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
                                              false);
-        iPad += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        iPad += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
         iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
         extraBPD = new MinOptMax(iPad);
     }
 
     protected MinOptMax getExtraIPD(boolean bNotFirst, boolean bNotLast) {
         int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                                           bNotFirst);
+                                           bNotFirst, this);
         iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
                                             bNotFirst);
-        iBP += borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast);
+        iBP += borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, this);
         iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast);
         return new MinOptMax(iBP);
     }
@@ -99,14 +98,14 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
 
     protected boolean hasLeadingFence(boolean bNotFirst) {
         int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                                           bNotFirst);
+                                           bNotFirst, this);
         iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
                                             bNotFirst);
         return (iBP > 0);
     }
 
     protected boolean hasTrailingFence(boolean bNotLast) {
-        int iBP = borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast);
+        int iBP = borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, this);
         iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast);
         return (iBP > 0);
     }
@@ -138,11 +137,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         
         // Add border and padding to current area and set flags (FIRST, LAST ...)
         TraitSetter.setBorderPaddingTraits(getCurrentArea(),
-                                           borderProps, bNotFirst, bNotLast);
+                                           borderProps, bNotFirst, bNotLast, this);
 
         if (borderProps != null) {
-            TraitSetter.addBorders(getCurrentArea(), borderProps);
-            TraitSetter.addBackground(getCurrentArea(), borderProps);
+            TraitSetter.addBorders(getCurrentArea(), borderProps, this);
+            TraitSetter.addBackground(getCurrentArea(), borderProps, this);
         }
     }
 
@@ -166,7 +165,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
             // not be the first area created by this inline
             childLC = new LayoutContext(lc);
             if (getSpaceStart() != null) {
-                lc.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart()));
+                lc.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
             }
 
             // Check for "fence"
@@ -308,8 +307,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
      *
      * @param parentIter Iterator over Position information returned
      * by this LayoutManager.
-     * @param dSpaceAdjust Factor controlling how much extra space to add
-     * in order to justify the line.
+     * @param context layout context.
      */
     public void addAreas(PositionIterator parentIter,
                          LayoutContext context) {
@@ -331,7 +329,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         }
 
         if (getSpaceStart() != null) {
-            context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart()));
+            context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
         }
 
         // "unwrap" the NonLeafPositions stored in parentIter
@@ -391,11 +389,12 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         }
         // Add own trailing space to parent context (or set on area?)
         if (context.getTrailingSpace() != null  && getSpaceEnd() != null) {
-            context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd()));
+            context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd(), this));
         }
-        setTraits(bAreaCreated, !bIsLast);
         
         parentLM.addChildArea(getCurrentArea());
+        setTraits(bAreaCreated, !bIsLast);
+
         context.setFlags(LayoutContext.LAST_AREA, bIsLast);
         bAreaCreated = true;
     }
index e0d06dcb5721cf381fdadd9d38b83754db2f6388..c7dea09c84aae4ff7fe139fb9c6f48cc5aee1d27 100644 (file)
@@ -20,15 +20,19 @@ 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.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
@@ -40,14 +44,11 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
     /**
      * Constructor
      * @param node the formatting object that creates this area
+     * @param parent the parent layout manager
      */
     public InstreamForeignObjectLM(InstreamForeignObject node) {
         super(node);
         fobj = node;
-        Viewport areaCurrent = getInlineArea();
-        setCurrentArea(areaCurrent);
-        setAlignment(node.getVerticalAlign());
-        setLead(areaCurrent.getBPD());
     }
 
     /**
@@ -73,29 +74,29 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         int ipd = -1;
         boolean bpdauto = false;
         if (hasLH) {
-            bpd = fobj.getLineHeight().getValue();
+            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().getLength();
+            len = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
             if (len.getEnum() != EN_AUTO) {
-                bpd = len.getValue();
+                bpd = len.getValue(this);
             } else {
                 len = fobj.getHeight();
                 if (len.getEnum() != EN_AUTO) {
-                    bpd = len.getValue();
+                    bpd = len.getValue(this);
                 }
             }
         }
 
-        len = fobj.getInlineProgressionDimension().getOptimum().getLength();
+        len = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
         if (len.getEnum() != EN_AUTO) {
-            ipd = len.getValue();
+            ipd = len.getValue(this);
         } else {
             len = fobj.getWidth();
             if (len.getEnum() != EN_AUTO) {
-                ipd = len.getValue();
+                ipd = len.getValue(this);
             }
         }
 
@@ -110,7 +111,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
                     cwidth = ipd;
                 }
             } else {
-                cwidth = len.getValue();
+                cwidth = len.getValue(this);
             }
         }
         len = fobj.getContentHeight();
@@ -120,7 +121,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
                     cwidth = bpd;
                 }
             } else {
-                cheight = len.getValue();
+                cheight = len.getValue(this);
             }
         }
 
@@ -172,10 +173,10 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
         
         //Determine extra BPD from borders etc.
-        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
         beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
                                              false);
-        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
         afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
         
         yoffset += beforeBPD;
@@ -184,10 +185,10 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         
         //Determine extra IPD from borders etc.
         int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false/*bNotFirst*/);
+                false/*bNotFirst*/, this);
         startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
                  false/*bNotFirst*/);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this);
         endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
         
         xoffset += startIPD;
@@ -212,17 +213,62 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         vp.setOffset(0);
 
         // Common Border, Padding, and Background Properties
-        TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground());
-        TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground());
+        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());
     }
+
+    // --------- 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 7d87ea8fd960e0c00cf3679004ac3917669101a6..26a58bf68ebf29e09e73ea68a5ffc1db72562b67 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.fop.area.inline.FilledArea;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.flow.Leader;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.layoutmgr.KnuthElement;
@@ -40,6 +39,8 @@ import org.apache.fop.traits.MinOptMax;
 
 import java.util.List;
 import java.util.LinkedList;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager.AreaInfo;
 
 /**
  * LayoutManager for the fo:leader formatting object
@@ -50,6 +51,8 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
     
     private LinkedList contentList = null;
     private ContentLayoutManager clm = null;
+    
+    private int contentAreaIPD = 0;
 
     /**
      * Constructor
@@ -60,7 +63,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
     public LeaderLayoutManager(Leader node) {
         super(node);
         fobj = node;
-        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
+    }
+    
+    public void initialize() {
+        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
         // the property leader-alignment does not affect vertical positioning
         // (see section 7.21.1 in the XSL Recommendation)
         // setAlignment(node.getLeaderAlignment());
@@ -77,10 +83,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
 
     private MinOptMax getLeaderAllocIPD(int ipd) {
         // length of the leader
-        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
-        int opt = fobj.getLeaderLength().getOptimum().getLength().getValue();
-        int min = fobj.getLeaderLength().getMinimum().getLength().getValue();
-        int max = fobj.getLeaderLength().getMaximum().getLength().getValue();
+        setContentAreaIPD(ipd);
+        int opt = fobj.getLeaderLength().getOptimum(this).getLength().getValue(this);
+        int min = fobj.getLeaderLength().getMinimum(this).getLength().getValue(this);
+        int max = fobj.getLeaderLength().getMaximum(this).getLength().getValue(this);
         return new MinOptMax(min, opt, max);
     }
 
@@ -91,10 +97,12 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             org.apache.fop.area.inline.Leader leader = 
                 new org.apache.fop.area.inline.Leader();
             leader.setRuleStyle(fobj.getRuleStyle());
-            leader.setRuleThickness(fobj.getRuleThickness().getValue());
+            leader.setRuleThickness(fobj.getRuleThickness().getValue(this));
+            leader.setBPD(fobj.getRuleThickness().getValue(this));
             leaderArea = leader;
         } else if (fobj.getLeaderPattern() == EN_SPACE) {
             leaderArea = new Space();
+            leaderArea.setBPD(font.getAscender());
         } else if (fobj.getLeaderPattern() == EN_DOTS) {
             TextArea t = new TextArea();
             char dot = '.'; // userAgent.getLeaderDotCharacter();
@@ -105,10 +113,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             t.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
             int width = font.getCharWidth(dot);
             Space spacer = null;
-            if (fobj.getLeaderPatternWidth().getValue() > width) {
+            if (fobj.getLeaderPatternWidth().getValue(this) > width) {
                 spacer = new Space();
-                spacer.setIPD(fobj.getLeaderPatternWidth().getValue() - width);
-                width = fobj.getLeaderPatternWidth().getValue();
+                spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
+                width = fobj.getLeaderPatternWidth().getValue(this);
             }
             FilledArea fa = new FilledArea();
             fa.setUnitWidth(width);
@@ -142,10 +150,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             contentList = clm.getNextKnuthElements(new LayoutContext(0), 0);
             int width = clm.getStackingSize();
             Space spacer = null;
-            if (fobj.getLeaderPatternWidth().getValue() > width) {
+            if (fobj.getLeaderPatternWidth().getValue(this) > width) {
                 spacer = new Space();
-                spacer.setIPD(fobj.getLeaderPatternWidth().getValue() - width);
-                width = fobj.getLeaderPatternWidth().getValue();
+                spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
+                width = fobj.getLeaderPatternWidth().getValue(this);
             }
             fa.setUnitWidth(width);
             if (spacer != null) {
@@ -334,4 +342,24 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
     protected void addId() {
         getPSLM().addIDToPage(fobj.getId());
     }
+
+    /**
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        return getParent().getBaseLength(lengthBase, getParent().getFObj());
+    }
+
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return contentAreaIPD;
+    }
+   
+    private void setContentAreaIPD(int contentAreaIPD) {
+        this.contentAreaIPD = contentAreaIPD;
+    }
+    
 }
index eb669be69a5e15f1ea8b98ffd8d1469cb438dccd..c58d9ce7c1a813c3ef3233b93d6f615f84638aa2 100644 (file)
@@ -68,7 +68,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
 
     private Block fobj; 
     
-    private void initialize() {
+    public void initialize() {
         bTextAlignment = fobj.getTextAlign();
         bTextAlignmentLast = fobj.getTextAlignLast();
         textIndent = fobj.getTextIndent();
@@ -139,7 +139,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
     private CommonHyphenation hyphProps;
     //private LayoutProps layoutProps;
 
-    private int lineHeight;
+    private Length lineHeight;
     private int lead;
     private int follow;
     // offset of the middle baseline with respect to the main baseline
@@ -222,8 +222,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
             // add the element representing text indentation
             // at the beginning of the first paragraph
             if (knuthParagraphs.size() == 0
-                        && fobj.getTextIndent().getValue() != 0) {
-                this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(), 0, 0, 0,
+                        && fobj.getTextIndent().getValue(layoutManager) != 0) {
+                this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(layoutManager), 0, 0, 0,
                                       null, false));
                 ignoreAtStart ++;
             }
@@ -575,7 +575,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
      * @param l the default lead, from top to baseline
      * @param f the default follow, from baseline to bottom
      */
-    public LineLayoutManager(Block block, int lh, int l, int f, int ms) {
+    public LineLayoutManager(Block block, Length lh, int l, int f, int ms) {
         super(block);
         fobj = block;
         // the child FObj are owned by the parent BlockLM
@@ -585,7 +585,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         lead = l;
         follow = f;
         middleShift = ms;
-        initialize(); // Normally done when started by parent!
     }
 
     /** @see org.apache.fop.layoutmgr.LayoutManager */
@@ -601,7 +600,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         int iPrevLineEnd = vecInlineBreaks.size();
 
         if (iPrevLineEnd == 0 && bTextAlignment == EN_START) {
-            availIPD.subtract(new MinOptMax(textIndent.getValue()));
+            availIPD.subtract(new MinOptMax(textIndent.getValue(this)));
         }
 
         //PHASE 1: Create Knuth elements
@@ -741,7 +740,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                         if (lastPar == null) { 
                             lastPar = new Paragraph(this, 
                                                     bTextAlignment, bTextAlignmentLast, 
-                                                    textIndent.getValue());
+                                                    textIndent.getValue(this));
                             lastPar.startParagraph(availIPD.opt);
                             if (log.isTraceEnabled()) {
                                 trace.append(" [");
@@ -881,7 +880,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                 ? difference / 2
                 : (textAlign == EN_END) ? difference : 0;
             indent += (line == 1 && knuthParagraphs.indexOf(par) == 0)
-                ? textIndent.getValue() : 0;
+                ? textIndent.getValue(this) : 0;
             double ratio = (textAlign == EN_JUSTIFY)
                 ? knuthPara.getAdjustRatio(i) : 0;
 
@@ -1012,8 +1011,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         int iBPcount = 0;
         LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment,
                 bTextAlignment, bTextAlignmentLast,
-                                        textIndent.getValue(), currPar.lineFiller.opt,
-                                        lineHeight, lead, follow, middleShift,
+                                        textIndent.getValue(this), currPar.lineFiller.opt,
+                                        lineHeight.getValue(this), lead, follow, middleShift,
                                         (knuthParagraphs.indexOf(currPar) == 0),
                                         this);
    
@@ -1324,6 +1323,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         return false;
     }
 
+    /**
+     * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+     */
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
         LeafPosition pos = (LeafPosition)lastElement.getPosition();
         int totalAdj = adj;
@@ -1774,5 +1776,21 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         }
     }
 
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return true;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea
+     */
+    public boolean getGeneratesLineArea() {
+        return true;
+    }
+   
 }
 
index bd075f45dcbdf01da463509a68b90fd3c0fe6fdd..7ed3cf8f762f82079b80032e62f14678f61a786e 100644 (file)
@@ -51,7 +51,10 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
     public PageNumberCitationLayoutManager(PageNumberCitation node) {
         super(node);
         fobj = node;
-        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
+    }
+    
+    public void initialize() {
+        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
     }
 
     public InlineArea get(LayoutContext context) {
index 17c40aece95b74b09d73c07aebe3c939f9540246..2a89d4ab582d1de9c3e01631eece352100263f18 100644 (file)
@@ -43,7 +43,10 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager {
     public PageNumberLayoutManager(PageNumber node) {
         super(node);
         fobj = node;
-        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
+    }
+    
+    public void initialize() {
+        font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
     }
 
     public InlineArea get(LayoutContext context) {
index 77d560df167ebf3c79a06142cecc715826c03eef..adf4514d84f838d2e7cbc80e4c92b4a1a4ede893 100644 (file)
@@ -132,7 +132,6 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
     private int total = 0;
     private int middle = 0;
     private int verticalAlignment = EN_BASELINE;
-
     /**
      * Create a Text layout manager.
      *
@@ -147,8 +146,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
             node.endIndex - node.startIndex);
 
         vecAreaInfo = new java.util.ArrayList();
-
-        fs = foText.getCommonFont().getFontState(foText.getFOEventHandler().getFontInfo());
+    }
+    
+    public void initialize() {
+        fs = foText.getCommonFont().getFontState(foText.getFOEventHandler().getFontInfo(), this);
         
         // With CID fonts, space isn't neccesary currentFontState.width(32)
         spaceCharIPD = fs.getCharWidth(' ');
index fedc04f2eb0a539672a1fde03ca90257d1d99ed7..f3f37d6e37224e24438bdd709eb77782563fa3a6 100644 (file)
@@ -1,55 +1,56 @@
-/*\r
- * Copyright 2005 The Apache Software Foundation.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/* $Id$ */\r
-\r
-package org.apache.fop.layoutmgr.inline;\r
-\r
-import org.apache.fop.area.inline.InlineArea;\r
-import org.apache.fop.fo.flow.Wrapper;\r
-import org.apache.fop.layoutmgr.LayoutContext;\r
-\r
-/**\r
- * This is the layout manager for the fo:wrapper formatting object.\r
- */\r
-public class WrapperLayoutManager extends LeafNodeLayoutManager {\r
-    \r
-    private Wrapper fobj;\r
-\r
-    /**\r
-     * Creates a new LM for fo:wrapper.\r
-     * @param node the fo:wrapper\r
-     */\r
-    public WrapperLayoutManager(Wrapper node) {\r
-        super(node);\r
-        fobj = node;\r
-    }\r
-\r
-    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager */\r
-    public InlineArea get(LayoutContext context) {\r
-        //Create a zero-width, zero-height dummy area so this node can \r
-        //participate in the ID handling. Otherwise, addId() wouldn't \r
-        //be called.\r
-        InlineArea area = new InlineArea();\r
-        return area;\r
-    }\r
-    \r
-    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */\r
-    protected void addId() {\r
-        getPSLM().addIDToPage(fobj.getId());\r
-    }\r
-    \r
-}\r
+/*
+ * 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 org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.fo.flow.Wrapper;
+import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.LayoutManager;
+
+/**
+ * This is the layout manager for the fo:wrapper formatting object.
+ */
+public class WrapperLayoutManager extends LeafNodeLayoutManager {
+    
+    private Wrapper fobj;
+
+    /**
+     * Creates a new LM for fo:wrapper.
+     * @param node the fo:wrapper
+     */
+    public WrapperLayoutManager(Wrapper node) {
+        super(node);
+        fobj = node;
+    }
+
+    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager */
+    public InlineArea get(LayoutContext context) {
+        //Create a zero-width, zero-height dummy area so this node can 
+        //participate in the ID handling. Otherwise, addId() wouldn't 
+        //be called.
+        InlineArea area = new InlineArea();
+        return area;
+    }
+    
+    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
+    protected void addId() {
+        getPSLM().addIDToPage(fobj.getId());
+    }
+    
+}
index 4c10482418eb184fe3d2fd259a9451d30c8edd4e..f21275acf4fa0b6b774dad133a900ba62275d396 100644 (file)
@@ -42,6 +42,7 @@ import java.util.List;
  * the list block area..
  */
 public class ListBlockLayoutManager extends BlockStackingLayoutManager {
+
     private Block curBlockArea;
 
     //TODO space-before|after: handle space-resolution rules
@@ -72,10 +73,10 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
     /**
      * Create a new list block layout manager.
      * @param node list-block to create the layout manager for
+     * @param parent the parent layout manager
      */
     public ListBlockLayoutManager(ListBlock node) {
         super(node);
-        initialize();
     }
 
     /**
@@ -86,15 +87,15 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
         return (ListBlock)fobj;
     }
 
-    private void initialize() {
-        foSpaceBefore = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
-        foSpaceAfter = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
+    public void initialize() {
+        foSpaceBefore = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceBefore, this).getSpace();
+        foSpaceAfter = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceAfter, this).getSpace();
     }
 
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue();
-        iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue();
+        iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue(this);
+        iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue(this);
         return iIndents;
     }
     
@@ -180,6 +181,11 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
             getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
         }
 
+        // We are done with this area add the background
+        TraitSetter.addBackground(curBlockArea, 
+                getListBlockFO().getCommonBorderPaddingBackground(),
+                this);
+
         flush();
 
         // if adjusted space after
@@ -212,18 +218,17 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
             // set traits
             TraitSetter.setProducerID(curBlockArea, getListBlockFO().getId());
             TraitSetter.addBorders(curBlockArea, 
-                    getListBlockFO().getCommonBorderPaddingBackground());
+            getListBlockFO().getCommonBorderPaddingBackground(), this);
             TraitSetter.addMargins(curBlockArea,
                     getListBlockFO().getCommonBorderPaddingBackground(), 
-                    getListBlockFO().getCommonMarginBlock());
+                    getListBlockFO().getCommonMarginBlock(),
+                    this);
             TraitSetter.addBreaks(curBlockArea, 
                     getListBlockFO().getBreakBefore(), 
                     getListBlockFO().getBreakAfter());
             
             int contentIPD = referenceIPD - getIPIndents();
             curBlockArea.setIPD(contentIPD);
-            TraitSetter.addBackground(curBlockArea, 
-                    getListBlockFO().getCommonBorderPaddingBackground());
             
             setCurrentArea(curBlockArea);
         }
index e0ea656dd7a52501fba52fcd83019a7229827aee..f8408807a563a352975e44cac899a4cac0df203f 100644 (file)
@@ -57,7 +57,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
     private LinkedList bodyList = null;
 
     private int listItemHeight;
-
+    
     //TODO space-before|after: handle space-resolution rules
     
     private boolean keepWithNextPendingOnLabel;
@@ -122,7 +122,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         super(node);
         setLabel(node.getLabel());
         setBody(node.getBody());
-        initialize();
     }
 
     /**
@@ -151,15 +150,15 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         body.setParent(this);
     }
 
-    private void initialize() {
-        foSpaceBefore = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceBefore).getSpace();
-        foSpaceAfter = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceAfter).getSpace();
+    public void initialize() {
+        foSpaceBefore = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceBefore, this).getSpace();
+        foSpaceAfter = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceAfter, this).getSpace();
     }
 
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue();
-        iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue();
+        iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue(this);
+        iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue(this);
         return iIndents;
     }
     
@@ -178,6 +177,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         // label
         childLC = new LayoutContext(0);
         childLC.setRefIPD(context.getRefIPD());
+        label.initialize();
         labelList = label.getNextKnuthElements(childLC, alignment);
         if (childLC.isKeepWithPreviousPending()) {
             context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
@@ -187,6 +187,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         // body
         childLC = new LayoutContext(0);
         childLC.setRefIPD(context.getRefIPD());
+        body.initialize();
         bodyList = body.getNextKnuthElements(childLC, alignment);
         if (childLC.isKeepWithPreviousPending()) {
             context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
@@ -504,6 +505,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
             getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
         }
 
+        // We are done with this area add the background
+        TraitSetter.addBackground(curBlockArea, 
+                getListItemFO().getCommonBorderPaddingBackground(),
+                this);
+
         flush();
 
         // if adjusted space after
@@ -545,12 +551,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
             // set traits
             TraitSetter.setProducerID(curBlockArea, getListItemFO().getId());
             TraitSetter.addBorders(curBlockArea, 
-                    getListItemFO().getCommonBorderPaddingBackground());
-            TraitSetter.addBackground(curBlockArea, 
-                    getListItemFO().getCommonBorderPaddingBackground());
+                    getListItemFO().getCommonBorderPaddingBackground(), this);
             TraitSetter.addMargins(curBlockArea,
                     getListItemFO().getCommonBorderPaddingBackground(), 
-                    getListItemFO().getCommonMarginBlock());
+                    getListItemFO().getCommonMarginBlock(), this);
             TraitSetter.addBreaks(curBlockArea, 
                     getListItemFO().getBreakBefore(), 
                     getListItemFO().getBreakAfter());
index c732763e742b00553bb585f8ff142846a8a37675..188b9f6abc79ab24804e930089ab05c08700a457 100644 (file)
@@ -24,6 +24,7 @@ import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.datatypes.PercentBaseContext;
 
 import org.apache.fop.fo.flow.Table;
 import org.apache.fop.fo.flow.TableColumn;
@@ -127,12 +128,13 @@ public class ColumnSetup {
 
     /**
      * @param col column index (1 is first column)
+     * @param context the context for percentage based calculations
      * @return the X offset of the requested column
      */
-    public int getXOffset(int col) {
+    public int getXOffset(int col, PercentBaseContext context) {
         int xoffset = 0;
         for (int i = 1; i < col; i++) {
-            xoffset += getColumn(i).getColumnWidth().getValue();
+            xoffset += getColumn(i).getColumnWidth().getValue(context);
         }
         return xoffset;
     }
index db381bf87304f8b6a945a4cccd8e9f169ebee396..48aeeae17c52e8a6add567ee33d0e167e7d104e5 100644 (file)
@@ -245,6 +245,9 @@ public class GridUnit {
         this.effBorders.setBorderInfo(
                 borderModel.determineWinner(this, other, 
                         side, resFlags), side);
+        if (cell != null) {
+            this.effBorders.setPadding(this.cell.getCommonBorderPaddingBackground());
+        }
     }
     
     /**
index 21d042b8e64dc6217ab83f6f8a5f2047a83ef33e..9caba174d64484877582ab2ede788a2f1bd746a0 100644 (file)
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.fop.fo.flow.TableCell;
 import org.apache.fop.fo.flow.TableColumn;
+import org.apache.fop.layoutmgr.LayoutManager;
 
 /**
  * This class represents a primary grid unit of a spanned cell.
@@ -131,11 +132,11 @@ public class PrimaryGridUnit extends GridUnit {
 
     /** @return true if cell/row has an explicit BPD/height */
     public boolean hasBPD() {
-        if (!getCell().getBlockProgressionDimension().getOptimum().isAuto()) {
+        if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) {
             return true;
         }
         if (getRow() != null 
-                && !getRow().getBlockProgressionDimension().getOptimum().isAuto()) {
+                && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) {
             return true;
         }
         return false;
index a304a0dd428224c8ecc41eed039e061694860546..4fda7ab982f659a7dffaaf767f4cf666baba9139 100644 (file)
@@ -37,6 +37,7 @@ import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -71,11 +72,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         super(node);
         fobj = node;
         this.gridUnit = pgu;
-        initialize();
     }
 
     /** @return the table-cell FO */
-    public TableCell getFObj() {
+    public TableCell getTableCell() {
         return this.fobj;
     }
     
@@ -83,15 +83,15 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         return fobj.isSeparateBorderModel();
     }
     
-    private void initialize() {
+    public void initialize() {
         borderAndPaddingBPD = 0;
         borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
         borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderAfterWidth(false);
         if (!isSeparateBorderModel()) {
             borderAndPaddingBPD /= 2;
         }
-        borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false);
-        borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false);
+        borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false, this);
+        borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false, this);
     }
     
     /**
@@ -116,8 +116,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         if (!isSeparateBorderModel()) {
             iIndents /= 2;
         }
-        iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false);
-        iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false);
+        iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this);
+        iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false, this);
         return iIndents;
     }
     
@@ -132,7 +132,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         cellIPD -= getIPIndents();
         if (isSeparateBorderModel()) {
             int borderSep = fobj.getBorderSeparation().getLengthPair()
-                    .getIPD().getLength().getValue();
+                    .getIPD().getLength().getValue(this);
             cellIPD -= borderSep;
         }
 
@@ -298,8 +298,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         }
         CommonBorderPaddingBackground cbpb 
             = gu.getCell().getCommonBorderPaddingBackground(); 
-        bpd -= cbpb.getPaddingBefore(false);
-        bpd -= cbpb.getPaddingAfter(false);
+        bpd -= cbpb.getPaddingBefore(false, this);
+        bpd -= cbpb.getPaddingAfter(false, this);
         return bpd;
     }
     
@@ -317,7 +317,11 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
 
         getPSLM().addIDToPage(fobj.getId());
 
-        if (!isSeparateBorderModel()) {
+        if (isSeparateBorderModel()) {
+            if (!emptyCell || fobj.showEmptyCells()) {
+                TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this);
+            }
+        } else {
             boolean[] outer = new boolean[] {
                     gridUnit.getFlag(GridUnit.FIRST_IN_TABLE), 
                     gridUnit.getFlag(GridUnit.LAST_IN_TABLE),
@@ -326,7 +330,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
             if (!gridUnit.hasSpanning()) {
                 //Can set the borders directly if there's no span
                 TraitSetter.addCollapsingBorders(curBlockArea, 
-                        gridUnit.getBorders(), outer);
+                        gridUnit.getBorders(), outer, this);
             } else {
                 int dy = yoffset;
                 for (int y = 0; y < gridUnit.getRows().size(); y++) {
@@ -356,7 +360,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
                         }
                         block.setBPD(bpd);
                         lastRowHeight = rowHeight;
-                        int ipd = gu.getColumn().getColumnWidth().getValue();
+                        int ipd = gu.getColumn().getColumnWidth().getValue(this);
                         int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; 
                         ipd -= borderStartWidth;
                         ipd -= gu.getBorders().getBorderEndWidth(false) / 2;
@@ -368,9 +372,9 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
                                 += gu.getBorders().getBorderBeforeWidth(false) / 2;
                         }
                         block.setYOffset(dy - halfCollapsingBorderHeight);
-                        TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer);
+                        TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer, this);
                         parentLM.addChildArea(block);
-                        dx += gu.getColumn().getColumnWidth().getValue();
+                        dx += gu.getColumn().getColumnWidth().getValue(this);
                     }
                     dy += lastRowHeight;
                 }
@@ -396,13 +400,17 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
         
         curBlockArea.setBPD(contentBPD);
 
+        // Add background after we know the BPD
         if (isSeparateBorderModel()) {
             if (!emptyCell || fobj.showEmptyCells()) {
-                TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
-                TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+                TraitSetter.addBackground(curBlockArea,
+                                          fobj.getCommonBorderPaddingBackground(),
+                                          this);
             }
         } else {
-            TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+            TraitSetter.addBackground(curBlockArea,
+                                      fobj.getCommonBorderPaddingBackground(),
+                                      this);
         }
         
         flush();
@@ -434,12 +442,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
             if (!isSeparateBorderModel()) {
                 indent /= 2;
             }
-            indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false);
+            indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this);
             // set position
             int halfBorderSep = 0;
             if (isSeparateBorderModel()) {
                 halfBorderSep = fobj.getBorderSeparation().getLengthPair()
-                        .getIPD().getLength().getValue() / 2;
+                        .getIPD().getLength().getValue(this) / 2;
             }
             int borderAdjust = 0;
             if (!isSeparateBorderModel()) {
@@ -534,6 +542,43 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement
             || !fobj.getKeepWithNext().getWithinColumn().isAuto();
             */
     }
+    
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return cellIPD;
+    }
+   
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        if (curBlockArea != null) {
+            return curBlockArea.getBPD();
+        } else {
+            log.error("getContentAreaBPD called on unknown BPD");
+            return -1;
+        }
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea
+     */
+    public boolean getGeneratesReferenceArea() {
+        return true;
+    }
+   
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea
+     */
+    public boolean getGeneratesBlockArea() {
+        return true;
+    }
 
 }
 
index df32b143b3239a6f9e18a8ce8992b826b32fb937..529ec8e41f156d9575383d9103ac4654ef9f648a 100644 (file)
@@ -28,7 +28,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.Table;
 import org.apache.fop.fo.flow.TableBody;
 import org.apache.fop.fo.flow.TableRow;
@@ -51,7 +53,7 @@ import org.apache.fop.traits.MinOptMax;
 /**
  * Layout manager for table contents, particularly managing the creation of combined element lists.
  */
-public class TableContentLayoutManager {
+public class TableContentLayoutManager implements PercentBaseContext {
 
     /** Logger **/
     private static Log log = LogFactory.getLog(TableContentLayoutManager.class);
@@ -415,7 +417,7 @@ public class TableContentLayoutManager {
                     PrimaryGridUnit primary = gu.getPrimary();
                     
                     if (gu.isPrimary()) {
-                        primary.getCellLM().setParent(tableLM);
+                        primary.getCellLM().setParent(getTableLM());
                      
                         //Determine the table-row if any
                         if (tableRow == null && primary.getRow() != null) {
@@ -423,11 +425,11 @@ public class TableContentLayoutManager {
                             
                             //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
                             LengthRangeProperty bpd = tableRow.getBlockProgressionDimension();
-                            if (!bpd.getMinimum().isAuto()) {
+                            if (!bpd.getMinimum(getTableLM()).isAuto()) {
                                 minContentHeight = Math.max(minContentHeight, 
-                                        bpd.getMinimum().getLength().getValue());
+                                        bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
                             }
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, getTableLM());
                             
                         }
 
@@ -438,7 +440,7 @@ public class TableContentLayoutManager {
                                         + primary.getCell().getNumberColumnsSpanned();
                                 i++) {
                             spanWidth += getTableLM().getColumns().getColumn(i + 1)
-                                .getColumnWidth().getValue();
+                                .getColumnWidth().getValue(getTableLM());
                         }
                         LayoutContext childLC = new LayoutContext(0);
                         childLC.setStackLimit(context.getStackLimit()); //necessary?
@@ -487,17 +489,17 @@ public class TableContentLayoutManager {
                     if (gu.isLastGridUnitRowSpan()) {
                         int effCellContentHeight = minContentHeight;
                         LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
-                        if (!bpd.getMinimum().isAuto()) {
+                        if (!bpd.getMinimum(getTableLM()).isAuto()) {
                             effCellContentHeight = Math.max(effCellContentHeight,
-                                    bpd.getMinimum().getLength().getValue());
+                                    bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
                         }
-                        if (!bpd.getOptimum().isAuto()) {
+                        if (!bpd.getOptimum(getTableLM()).isAuto()) {
                             effCellContentHeight = Math.max(effCellContentHeight,
-                                    bpd.getOptimum().getLength().getValue());
+                                    bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()));
                         }
                         if (gu.getRowSpanIndex() == 0) {
                             //TODO ATM only non-row-spanned cells are taken for this
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
                         }
                         effCellContentHeight = Math.max(effCellContentHeight, 
                                 primary.getContentLength());
@@ -514,8 +516,8 @@ public class TableContentLayoutManager {
                                 effCellContentHeight);
                         CommonBorderPaddingBackground cbpb 
                             = primary.getCell().getCommonBorderPaddingBackground(); 
-                        padding += cbpb.getPaddingBefore(false);
-                        padding += cbpb.getPaddingAfter(false);
+                        padding += cbpb.getPaddingBefore(false, primary.getCellLM());
+                        padding += cbpb.getPaddingAfter(false, primary.getCellLM());
                         int effRowHeight = effCellContentHeight + padding + borderWidths;
                         for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) {
                             effRowHeight -= rowHeights[rgi - previous - 1].opt;
@@ -566,7 +568,7 @@ public class TableContentLayoutManager {
      */
     protected int getXOffsetOfGridUnit(GridUnit gu) {
         int col = gu.getStartCol();
-        return startXOffset + getTableLM().getColumns().getXOffset(col + 1);
+        return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM());
     }
     
     /**
@@ -792,36 +794,41 @@ public class TableContentLayoutManager {
                             gridUnits[i].getElements(), start[i], end[i]);
                     partLength[i] = len;
                     log.debug("len of part: " + len);
+
                     if (start[i] == 0) {
                         LengthRangeProperty bpd = gridUnits[i].getCell()
                                 .getBlockProgressionDimension();
-                        if (!bpd.getMinimum().isAuto()) {
-                            if (bpd.getMinimum().getLength().getValue() > 0) {
-                                len = Math.max(len, bpd.getMinimum().getLength().getValue());
+                        if (!bpd.getMinimum(getTableLM()).isAuto()) {
+                            if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
+                                len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
                             }
                         }
-                        if (!bpd.getOptimum().isAuto()) {
-                            if (bpd.getOptimum().getLength().getValue() > 0) {
-                                len = Math.max(len, bpd.getOptimum().getLength().getValue());
+                        if (!bpd.getOptimum(getTableLM()).isAuto()) {
+                            if (bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
+                                len = Math.max(len, bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()));
                             }
                         }
                         if (gridUnits[i].getRow() != null) {
                             bpd = gridUnits[i].getRow().getBlockProgressionDimension();
-                            if (!bpd.getMinimum().isAuto()) {
-                                if (bpd.getMinimum().getLength().getValue() > 0) {
-                                    len = Math.max(len, bpd.getMinimum().getLength().getValue());
+                            if (!bpd.getMinimum(getTableLM()).isAuto()) {
+                                if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) {
+                                    len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()));
                                 }
                             }
                         }
                     }
                     
+                    // Add the padding if any
+                    len += gridUnits[i].getBorders()
+                                    .getPaddingBefore(false, gridUnits[i].getCellLM());
+                    len += gridUnits[i].getBorders()
+                                    .getPaddingAfter(false, gridUnits[i].getCellLM());
+
                     //Now add the borders to the contentLength
                     if (isSeparateBorderModel()) {
                         len += gridUnits[i].getBorders().getBorderBeforeWidth(false);
                         len += gridUnits[i].getBorders().getBorderAfterWidth(false);
                     }
-                    len += gridUnits[i].getBorders().getPaddingBefore(false);
-                    len += gridUnits[i].getBorders().getPaddingAfter(false);
                     int startRow = Math.max(gridUnits[i].getStartRow(), firstRow[bt]);
                     Integer storedOffset = (Integer)rowOffsets[bt].get(new Integer(startRow));
                     int effYOffset;
@@ -906,7 +913,6 @@ public class TableContentLayoutManager {
             Block block = new Block();
             block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
             block.setPositioning(Block.ABSOLUTE);
-            TraitSetter.addBackground(block, row.getCommonBorderPaddingBackground());
             return block;
         }
     }
@@ -927,6 +933,7 @@ public class TableContentLayoutManager {
             rowBackground.setXOffset(this.startXOffset);
             rowBackground.setYOffset(yoffset);
             getTableLM().addChildArea(rowBackground);
+            TraitSetter.addBackground(rowBackground, row.getCommonBorderPaddingBackground(), getTableLM());
         }
     }
     
@@ -1125,4 +1132,13 @@ public class TableContentLayoutManager {
         }
     }
     
+    // --------- Property Resolution related functions --------- //
+    
+    /**
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, fobj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        return tableLM.getBaseLength(lengthBase, fobj);
+    }
+
 }
index ee3a5bdba62d048c27039388f99aca7ad294ff85..713d0179a3a09df5067849a7b8d102af7454ec28 100644 (file)
@@ -39,6 +39,8 @@ import org.apache.fop.traits.SpaceVal;
 
 import java.util.Iterator;
 import java.util.LinkedList;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.fo.FObj;
 
 /**
  * LayoutManager for a table FO.
@@ -58,13 +60,13 @@ public class TableLayoutManager extends BlockStackingLayoutManager
     private Block curBlockArea;
 
     private int referenceIPD;
+    private int referenceBPD;
     private boolean autoLayout = true;
 
     //TODO space-before|after: handle space-resolution rules
     private MinOptMax spaceBefore;
     private MinOptMax spaceAfter;
     
-    
     /**
      * Create a new table layout manager.
      * @param node the table FO
@@ -73,7 +75,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         super(node);
         fobj = node;
         this.columns = new ColumnSetup(node);
-        initialize();
     }
 
     /** @return the table FO */
@@ -88,20 +89,20 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         return this.columns;
     }
     
-    private void initialize() {
-        spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
-        spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
+    public void initialize() {
+        spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore, this).getSpace();
+        spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter, this).getSpace();
         
         if (!fobj.isAutoLayout() 
-                && fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
+                && fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) {
             autoLayout = false;
         }
     }
 
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += fobj.getCommonMarginBlock().startIndent.getValue();
-        iIndents += fobj.getCommonMarginBlock().endIndent.getValue();
+        iIndents += fobj.getCommonMarginBlock().startIndent.getValue(this);
+        iIndents += fobj.getCommonMarginBlock().endIndent.getValue(this);
         return iIndents;
     }
     
@@ -120,9 +121,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager
             }
         }
 
+        referenceBPD = context.getStackLimit().opt;
         referenceIPD = context.getRefIPD();
-        if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
-            referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue();
+
+        if (fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) {
+            referenceIPD = fobj.getInlineProgressionDimension().getOptimum(this).getLength().getValue(this);
         } else if( !fobj.isAutoLayout() ) {
             log.info("table-layout=\"fixed\" and width=\"auto\", but auto-layout not supported " + 
                      "=> assuming width=\"100%\"");
@@ -141,11 +144,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager
             stackSize.add(spaceBefore);
         }
 
-        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
-        fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
-        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
-        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
-
         // either works out table of column widths or if proportional-column-width function
         // is used works out total factor, so that value of single unit can be computed.
         int sumCols = 0;
@@ -153,7 +151,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         for (Iterator i = columns.iterator(); i.hasNext(); ) {
             TableColumn column = (TableColumn) i.next();
             Length width = column.getColumnWidth();
-            sumCols += width.getValue();
+            sumCols += width.getValue(this);
             if (width instanceof TableColLength) {
                 factors += ((TableColLength) width).getTableUnits();
             }
@@ -284,7 +282,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         addBlockSpacing(adjust, spaceBefore);
         spaceBefore = null;
 
-        int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue();
+        int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue(this);
         
         // add column, body then row areas
 
@@ -301,12 +299,15 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         curBlockArea.setBPD(tableHeight);
 
         if (fobj.isSeparateBorderModel()) {
-            TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
+            TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this);
         }
-        TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+        TraitSetter.addBackground(curBlockArea, 
+                fobj.getCommonBorderPaddingBackground(),
+                this);
         TraitSetter.addMargins(curBlockArea,
                 fobj.getCommonBorderPaddingBackground(), 
-                fobj.getCommonMarginBlock());
+                fobj.getCommonMarginBlock(),
+                this);
         TraitSetter.addBreaks(curBlockArea, 
                 fobj.getBreakBefore(), fobj.getBreakAfter());
 
@@ -413,5 +414,41 @@ public class TableLayoutManager extends BlockStackingLayoutManager
                 || !fobj.getKeepWithNext().getWithinColumn().isAuto();
     }
 
+    // --------- Property Resolution related functions --------- //
+
+    /**
+     * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
+     */
+    public int getBaseLength(int lengthBase, FObj fobj) {
+        // Special handler for TableColumn width specifications
+        if (fobj instanceof TableColumn && fobj.getParent() == getFObj()) {
+            switch (lengthBase) {
+            case LengthBase.CONTAINING_BLOCK_WIDTH:
+                return getContentAreaIPD();
+            default:
+                log.error("Unknown base type for LengthBase.");
+                return 0;
+            }
+        } else {
+            return super.getBaseLength(lengthBase, fobj);
+        }
+    }
+    
+    /**
+     * Returns the IPD of the content area
+     * @return the IPD of the content area
+     */
+    public int getContentAreaIPD() {
+        return referenceIPD;
+    }
+   
+    /**
+     * Returns the BPD of the content area
+     * @return the BPD of the content area
+     */
+    public int getContentAreaBPD() {
+        return referenceBPD;
+    }
+    
 }
 
index 272afdf18d2800853747447e354c96a473b66ac1..f7a381a3e877ff44a81d259cb9d2482c0df9d3c8 100644 (file)
@@ -202,8 +202,8 @@ public class TableStepper {
             } else {
                 borderBefore[column] = pgu.getBorders().getBorderBeforeWidth(false) / 2;
             }
-            paddingBefore[column] = pgu.getBorders().getPaddingBefore(false);
-            paddingAfter[column] = pgu.getBorders().getPaddingAfter(false);
+            paddingBefore[column] = pgu.getBorders().getPaddingBefore(false, pgu.getCellLM());
+            paddingAfter[column] = pgu.getBorders().getPaddingAfter(false, pgu.getCellLM());
             start[column] = 0;
             end[column] = -1;
             widths[column] = 0;
@@ -301,8 +301,8 @@ public class TableStepper {
                     = getTableLM().getTable().getCommonBorderPaddingBackground(); 
                 effPenaltyLen += borders.getBorderBeforeWidth(false); 
                 effPenaltyLen += borders.getBorderAfterWidth(false); 
-                effPenaltyLen += borders.getPaddingBefore(false); 
-                effPenaltyLen += borders.getPaddingAfter(false); 
+                effPenaltyLen += borders.getPaddingBefore(false, getTableLM()); 
+                effPenaltyLen += borders.getPaddingAfter(false, getTableLM()); 
             }
             TableContentPosition tcpos = new TableContentPosition(getTableLM(), 
                     gridUnitParts, getActiveRow());
index 0f1a92a17af70d3da7081f8a2e601c389c4b1dc5..68d1a687182b52355f92580e7d5a57a6cc576258 100644 (file)
@@ -142,34 +142,34 @@ public class TableAttributesConverter {
         //TODO Make this configurable
         if (reproduceMSWordBug) {
             //MS Word has a bug where padding left and top are exchanged
-            padding = border.getPaddingStart(false);
+            padding = border.getPaddingStart(false, null); // TODO do we need a real context here?
             if (padding != 0) {
                 attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding);
                 attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/);
             }
-            padding = border.getPaddingBefore(false);
+            padding = border.getPaddingBefore(false, null); // TODO do we need a real context here?
             if (padding != 0) {
                 attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding);
                 attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/);
             }
         } else {
-            padding = border.getPaddingStart(false);
+            padding = border.getPaddingStart(false, null); // TODO do we need a real context here?
             if (padding != 0) {
                 attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding);
                 attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/);
             }
-            padding = border.getPaddingBefore(false);
+            padding = border.getPaddingBefore(false, null); // TODO do we need a real context here?
             if (padding != 0) {
                 attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding);
                 attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/);
             }
         }
-        padding = border.getPaddingEnd(false);
+        padding = border.getPaddingEnd(false, null);  // TODO do we need a real context here?
         if (padding != 0) {
             attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_RIGHT, padding);
             attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_RIGHT, 3 /*=twips*/);
         }
-        padding = border.getPaddingAfter(false);
+        padding = border.getPaddingAfter(false, null); // TODO do we need a real context here?
         if (padding != 0) {
             attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, padding);
             attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, 3 /*=twips*/);
index 7de406c156071355de5c9397c7a2cd7832b5d454..39a91ef9193856423ed7abe67e395c48c7e28e89 100644 (file)
@@ -186,9 +186,9 @@ class TextAttributesConverter {
 
     private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) {
         rtfAttr.setTwips(RtfText.SPACE_BEFORE, 
-                cmb.spaceBefore.getOptimum().getLength());
+                cmb.spaceBefore.getOptimum(null).getLength());
         rtfAttr.setTwips(RtfText.SPACE_AFTER, 
-                cmb.spaceAfter.getOptimum().getLength());
+                cmb.spaceAfter.getOptimum(null).getLength());
         rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
         rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
     }
index 5dfbab90f3bf2507eccf3e524a1deedee77ed427..4c9cdf5bc7e680eb28e1bed270672268c516bbcd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
  
 package org.apache.fop.traits;
 
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.SpaceProperty;
@@ -37,11 +38,12 @@ public class SpaceVal {
     /**
      * Constructor for SpaceVal objects based on Space objects.
      * @param spaceprop Space object to use
+     * @param context Percentage evaluation context
      */
-    public SpaceVal(SpaceProperty spaceprop) {
-        space = new MinOptMax(spaceprop.getMinimum().getLength().getValue(),
-                              spaceprop.getOptimum().getLength().getValue(),
-                              spaceprop.getMaximum().getLength().getValue());
+    public SpaceVal(SpaceProperty spaceprop, PercentBaseContext context) {
+        space = new MinOptMax(spaceprop.getMinimum(context).getLength().getValue(context),
+                              spaceprop.getOptimum(context).getLength().getValue(context),
+                              spaceprop.getMaximum(context).getLength().getValue(context));
         bConditional = 
                 (spaceprop.getConditionality().getEnum() == Constants.EN_DISCARD);
         Property precProp = spaceprop.getPrecedence();
@@ -69,7 +71,9 @@ public class SpaceVal {
         this.iPrecedence = iPrecedence;
     }
 
-    static public SpaceVal makeWordSpacing(Property wordSpacing, SpaceVal letterSpacing, Font fs) {
+    static public SpaceVal makeWordSpacing(Property wordSpacing, 
+                                           SpaceVal letterSpacing, 
+                                           Font fs) {
         if (wordSpacing.getEnum() == Constants.EN_NORMAL) {
             // give word spaces the possibility to shrink by a third,
             // and stretch by a half;
@@ -80,7 +84,7 @@ public class SpaceVal {
                      (space, MinOptMax.multiply(letterSpacing.getSpace(), 2)),
                      true, true, 0);
         } else {
-            return new SpaceVal(wordSpacing.getSpace());
+            return new SpaceVal(wordSpacing.getSpace(), null);
         }        
     }
 
@@ -89,7 +93,7 @@ public class SpaceVal {
             // letter spaces are set to zero (or use different values?)
             return new SpaceVal(new MinOptMax(0), true, true, 0);
         } else {
-            return new SpaceVal(letterSpacing.getSpace());
+            return new SpaceVal(letterSpacing.getSpace(), null);
         }
     }
 
index f3fb7ee547a24300949c05f0168521f0ca6c5060..1d96f163d1ba85aaef0b6ebe9a5fdc298eec869e 100644 (file)
@@ -118,6 +118,7 @@ public class LayoutEngineTestSuite {
                 final LayoutEngineTester tester, final File f) {
         suite.addTest(new LayoutEngineTestCase(f.getName()) {
             public void runTest() throws Exception {
+                org.apache.commons.logging.LogFactory.getLog(this.getClass()).info("Starting " + f.getName());
                 prepare(tester, f);
                 testMain();
             }
index 752b94bedd3560ce05700e093d9fe7c56a7f65fe..450c6c90ea12b540ca517de94ea1724c7bc9727b 100644 (file)
@@ -1,16 +1,8 @@
-background-image-list1.xml
-background-image-list2.xml
+background-image6.xml
 background-image-table2.xml
-background-image-table3.xml
-background-image-table4.xml
 background-image-table5.xml
-background-image3.xml
-background-image5.xml
-background-image6.xml
-background-image7.xml
 block-container4a.xml
-external-graphic1.xml
-external-graphic2.xml
+font-stretch.xml
 external-graphic4.xml
 inline-block2.xml
 inline-container1.xml
@@ -19,11 +11,11 @@ keep-with-previous2.xml
 keep-with-previous3.xml
 keep-with-previous4.xml
 keep-with-previous5.xml
-leader-dots.xml
-leader-rule.xml
-leader-space.xml
+leader-alignment.xml
+leader-use-content.xml
 letter-spacing3.xml
 list4a.xml
+margin-region3.xml
 multi-column3.xml
 multi-column4.xml
 normal-breaking4.xml
index 091be019e20a17504f0cfe756890ae45b93c0e8b..e4b81b117477ca77602244f41bdf9acf59692526 100644 (file)
 <testcase>
   <info>
     <p>
-      This test checks background image on lists (list-item).
+      This test checks background image on lists (list-block).
     </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: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">
           <fo:region-body/>
@@ -33,7 +33,7 @@
       </fo:layout-master-set>
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
-          <fo:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+          <fo:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in" background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
             <fo:list-item>
               <fo:list-item-label end-indent="label-end()">
                 <fo:block>label 1</fo:block>
@@ -62,7 +62,7 @@
               <fo:list-item-label end-indent="label-end()">
                 <fo:block>label 3</fo:block>
               </fo:list-item-label>
-              <fo:list-item-body start-indent="body-start()" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+              <fo:list-item-body start-indent="body-start()">
                 <fo:block>
                   body 3: The whole list should have a centered background.
                   The whole list should have a centered background.
               </fo:list-item-body>
             </fo:list-item>
           </fo:list-block>
-          <fo:block></fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="360000" xpath="//flow/block/@ipd"/>
+    <eval expected="172800" xpath="//flow/block/@bpd"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=156960,vertical=63360" xpath="//flow/block/@background"/>
   </checks>
 </testcase>
index 687e278b48322df9bf4a080f2711c9d5ab2f0100..9fa6ee7f3910ad6ce7055b536dced2119f2e92c0 100644 (file)
@@ -25,7 +25,7 @@
     <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: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">
           <fo:region-body/>
@@ -34,7 +34,7 @@
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in">
-            <fo:list-item background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+            <fo:list-item background-repeat="no-repeat" background-color="yellow"  background-position-horizontal="center" background-position-vertical="center" background-image="##img">
               <fo:list-item-label end-indent="label-end()">
                 <fo:block>label 1</fo:block>
               </fo:list-item-label>
               <fo:list-item-label end-indent="label-end()">
                 <fo:block>label 3</fo:block>
               </fo:list-item-label>
-              <fo:list-item-body start-indent="body-start()" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+              <fo:list-item-body start-indent="body-start()">
                 <fo:block>
-                  body 3: The whole list should have a centered background.
-                  The whole list should have a centered background.
-                  The whole list should have a centered background.
+                  body 3: We should have no background on this list item.
+                  We should have no background on this list item.
+                  We should have no background on this list item.
                 </fo:block>
               </fo:list-item-body>
             </fo:list-item>
           </fo:list-block>
-          <fo:block></fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="360000" xpath="//flow/block/block/@ipd"/>
+    <eval expected="72000" xpath="//flow/block/block/@bpd"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=156960,vertical=12960" xpath="//flow/block/block/@background"/>
   </checks>
 </testcase>
index c6b597a947c3a447239e84f941158c1ca6e171de..2a8f1984caed008631504f5b519870fe3998dfac 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a table.
+      This test checks background image on a fo:table.
     </p>
   </info>
   <variables>
@@ -33,7 +33,7 @@
       </fo:layout-master-set>
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
-          <fo:table background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+          <fo:table background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
             <fo:table-column column-number="1" />
             <fo:table-column column-number="2" />
             <fo:table-column column-number="3" />
               </fo:table-row>
             </fo:table-body>
           </fo:table>
-          <fo:block>Table with centered background</fo:block>
+          <fo:block>Table with centered background image</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=156960,vertical=12960" xpath="//flow/block[1]/@background"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=156960,vertical=12960" xpath="//flow/block[1]/@background"/>
   </checks>
 </testcase>
index be87ea653146d02cc8e39ced28cdc6f95782b5a9..d212685cde7ee39d18df49b683a282588dbd704d 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a table.
+      This test checks background image on a fo:table-body.
     </p>
   </info>
   <variables>
@@ -50,7 +50,7 @@
                 </fo:table-cell>
               </fo:table-row>
             </fo:table-header>
-            <fo:table-body background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+            <fo:table-body background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
               <fo:table-row>
                 <fo:table-cell>
                   <fo:block>Row 1 Col 1</fo:block>
               </fo:table-row>
             </fo:table-body>
           </fo:table>
-          <fo:block>Table with centered body background</fo:block>
+          <fo:block>Table with centered background image on body</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+  <!-- backgrounds on table-body are not supported at the time this test
+  was written. Therefore no checks! -->
   </checks>
 </testcase>
index c6d5e7de011289e3e8052530d2691729a85213cd..2f05e343a7e87764d18aae1b2a268e625e22c49e 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a table.
+      This test checks background image on a fo:table-row.
     </p>
   </info>
   <variables>
@@ -51,7 +51,7 @@
               </fo:table-row>
             </fo:table-header>
             <fo:table-body>
-              <fo:table-row background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+              <fo:table-row height="1in" background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
                 <fo:table-cell>
                   <fo:block>Row 1 Col 1</fo:block>
                 </fo:table-cell>
                   <fo:block>Row 2 Col 3</fo:block>
                 </fo:table-cell>
               </fo:table-row>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
             </fo:table-body>
           </fo:table>
-          <fo:block>Table with centered row 1 background</fo:block>
+          <fo:block>Table with centered background image on row 1</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="360000" xpath="//flow/block/block[4]/@ipd"/>
+    <eval expected="72000" xpath="//flow/block/block[4]/@bpd"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=156960,vertical=12960" xpath="//flow/block/block[4]/@background"/>
   </checks>
 </testcase>
index 4c5e7c691b22353cf7458d633c2baa570a5b4286..b36bba6ce1b901d13d1fc7d70aa4a273fff2b396 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a table.
+      This test checks background image on a fo:table-cell.
     </p>
   </info>
   <variables>
             <fo:table-column column-number="1" />
             <fo:table-column column-number="2" />
             <fo:table-column column-number="3" />
-            <fo:table-header>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Header Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Header Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Header Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
-            </fo:table-header>
             <fo:table-body>
               <fo:table-row>
-                <fo:table-cell background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+                <fo:table-cell>
                   <fo:block>Row 1 Col 1</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
                 </fo:table-cell>
               </fo:table-row>
               <fo:table-row>
-                <fo:table-cell>
+                <fo:table-cell background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+                  <fo:block>Row 2 Col 1</fo:block>
+                  <fo:block>Row 2 Col 1</fo:block>
+                  <fo:block>Row 2 Col 1</fo:block>
+                  <fo:block>Row 2 Col 1</fo:block>
                   <fo:block>Row 2 Col 1</fo:block>
                 </fo:table-cell>
-                <fo:table-cell>
+                <fo:table-cell padding="5pt" display-align="center" background-color="blue" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
                   <fo:block>Row 2 Col 2</fo:block>
                 </fo:table-cell>
-                <fo:table-cell>
+                <fo:table-cell display-align="center" background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
                   <fo:block>Row 2 Col 3</fo:block>
                 </fo:table-cell>
               </fo:table-row>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 3 Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 4 Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
             </fo:table-body>
           </fo:table>
-          <fo:block>Table with centered row 1 col 1 background</fo:block>
+          <fo:block>Table with centered background images on row 2 col 1, and 3</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <!-- first cell in row 2 -->
+    <eval expected="120000" xpath="//flow/block/block[4]/@ipd"/>
+    <eval expected="72000" xpath="//flow/block/block[4]/@bpd"/>
+    <eval expected="72000" xpath="//flow/block/block[4]/@bpda"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=36960,vertical=12960" xpath="//flow/block/block[4]/@background"/>
+    <!-- second cell in row 2 -->
+    <eval expected="110000" xpath="//flow/block/block[5]/@ipd"/>
+    <eval expected="62000" xpath="//flow/block/block[5]/@bpd"/>
+    <eval expected="72000" xpath="//flow/block/block[5]/@bpda"/>
+    <eval expected="color=#0000ff,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=36960,vertical=12960" xpath="//flow/block/block[5]/@background"/>
+    <!-- second cell in row 2 -->
+    <eval expected="120000" xpath="//flow/block/block[6]/@ipd"/>
+    <eval expected="72000" xpath="//flow/block/block[6]/@bpd"/>
+    <eval expected="72000" xpath="//flow/block/block[6]/@bpda"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=36960,vertical=12960" xpath="//flow/block/block[6]/@background"/>
   </checks>
 </testcase>
index b4bd72372d94697f214b898bddbe7c02ebf2bc00..1101b3f950e98ec0d10c093bc6e8e369310eba1e 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a table.
+      This test checks background image on a fo:table-header and footer.
     </p>
   </info>
   <variables>
@@ -37,7 +37,7 @@
             <fo:table-column column-number="1" />
             <fo:table-column column-number="2" />
             <fo:table-column column-number="3" />
-            <fo:table-header background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+            <fo:table-header background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
               <fo:table-row>
                 <fo:table-cell>
                   <fo:block>Header Col 1</fo:block>
                 </fo:table-cell>
               </fo:table-row>
             </fo:table-header>
-            <fo:table-body>
+            <fo:table-footer background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
               <fo:table-row>
                 <fo:table-cell>
-                  <fo:block>Row 1 Col 1</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 1 Col 2</fo:block>
-                </fo:table-cell>
-                <fo:table-cell>
-                  <fo:block>Row 1 Col 3</fo:block>
-                </fo:table-cell>
-              </fo:table-row>
-              <fo:table-row>
-                <fo:table-cell>
-                  <fo:block>Row 2 Col 1</fo:block>
+                  <fo:block>Footer Col 1</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 2 Col 2</fo:block>
+                  <fo:block>Footer Col 2</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 2 Col 3</fo:block>
+                  <fo:block>Footer Col 3</fo:block>
                 </fo:table-cell>
               </fo:table-row>
-              <fo:table-row>
+            </fo:table-footer>
+            <fo:table-body background-color="blue">
+              <fo:table-row height="4in" background-color="blue">
                 <fo:table-cell>
-                  <fo:block>Row 3 Col 1</fo:block>
+                  <fo:block>Row 1 Col 1</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 3 Col 2</fo:block>
+                  <fo:block>Row 1 Col 2</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 3 Col 3</fo:block>
+                  <fo:block>Row 1 Col 3</fo:block>
                 </fo:table-cell>
               </fo:table-row>
-              <fo:table-row>
+              <fo:table-row height="4in" background-color="blue">
                 <fo:table-cell>
-                  <fo:block>Row 4 Col 1</fo:block>
+                  <fo:block>Row 2 Col 1</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 4 Col 2</fo:block>
+                  <fo:block>Row 2 Col 2</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
-                  <fo:block>Row 4 Col 3</fo:block>
+                  <fo:block>Row 2 Col 3</fo:block>
                 </fo:table-cell>
               </fo:table-row>
             </fo:table-body>
           </fo:table>
-          <fo:block>Table with centered header background</fo:block>
+          <fo:block>Table with centered background image in header and footer</fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+  <!-- backgrounds on table-header/footer are not supported at the time this test
+  was written. Therefore no checks! -->
   </checks>
 </testcase>
index 2b3bbeb0aeb2e8c4e9c9233d66840de2799695eb..2ed43b0ce7a608f9d57a90e871a7a5f0e8d2c6fa 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background images.
+      This test checks background images in block-containers.
     </p>
   </info>
   <variables>
index 2f480ac037fefd8e83fa320c1e2a1bf32f33988a..ec99b964610eb18fa67c3af4fb0145b3e754da65 100644 (file)
       </fo:layout-master-set>
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
-          <fo:block-container height="100%" width="100%" background-color="yellow">
-          <fo:block background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
-             normal block<fo:block/>
-             normal block
-          </fo:block>
+          <fo:block-container height="50%" width="50%" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+            <fo:block background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">
+              normal block<fo:block/>
+              normal block
+            </fo:block>
           </fo:block-container>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <eval expected="color=#ffff00" xpath="//flow/block[1]/@background"/>
-    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
+    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/>
+    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/>
+    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
   </checks>
 </testcase>
index 353f36fb977b312f6d86d59f5d6d7783d6f5fd62..92f3c31f32d6b69aa5d643717bd7fda7083b57cb 100644 (file)
@@ -18,7 +18,7 @@
 <testcase>
   <info>
     <p>
-      This test checks background image on a fo:basic-link.
+      This test checks background image on a fo:inline.
     </p>
   </info>
   <variables>
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:block>
-            Why is <fo:inline font-size="96pt" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img" background-color="lightgray">FOP</fo:inline> so cool?
+            Why is <fo:inline font-size="96pt" background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">FOP</fo:inline> so cool?
           </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="197376" xpath="//flow/block/lineArea/inlineparent/@ipd"/>
+    <eval expected="92100" xpath="//flow/block/lineArea/inlineparent/@bpd"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=75648,vertical=23010" xpath="//flow/block/lineArea/inlineparent/@background"/>
   </checks>
 </testcase>
index 0e8d0d210db79edd8614d4e6f4639998ee72a033..ce3c7bdd62b1656bd507cf379e1484a6b02273ac 100644 (file)
       <fo:page-sequence master-reference="normal" white-space-collapse="true">
         <fo:flow flow-name="xsl-region-body">
           <fo:block>
-            Why is <fo:basic-link external-destination="http://xmlgraphics.apache.org/fop" font-size="96pt" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">FOP</fo:basic-link> so cool?
+            Why is <fo:basic-link external-destination="http://xmlgraphics.apache.org/fop" font-size="96pt" background-color="yellow" background-repeat="no-repeat" background-position-horizontal="center" background-position-vertical="center" background-image="##img">FOP</fo:basic-link> so cool?
           </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="197376" xpath="//flow/block/lineArea/inlineparent/@ipd"/>
+    <eval expected="92100" xpath="//flow/block/lineArea/inlineparent/@bpd"/>
+    <eval expected="color=#ffff00,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=75648,vertical=23010" xpath="//flow/block/lineArea/inlineparent/@background"/>
   </checks>
 </testcase>
index 76c839ee29cf5faeccd96fc9fe068a252ca079b2..736ade4b7ae42f01224624bacd98fe2c8a2f9561 100644 (file)
@@ -41,7 +41,7 @@
   </fo>
   <checks>
     <eval expected="360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@ipd"/>
-    <eval expected="50214" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@bpd"/>
+    <eval expected="51864" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@bpd"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@ipda"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@bpd"/>
index a6203e7f764ccbfa4e5f5f1778608fe0f364e36e..ae099e6d62062f4e877c72f2b098823949190e2b 100644 (file)
   <checks>
     <!-- first image -->
     <eval expected="360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@ipd"/>
-    <eval expected="44134" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@bpd"/>
+    <eval expected="45784" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@bpd"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@ipda"/>
     <eval expected="40000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@bpd"/>
     <eval expected="40000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/viewport/@bpda"/>
-    <!-- first image -->
+    <!-- second image -->
     <eval expected="360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/@ipd"/>
-    <eval expected="50214" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/@bpd"/>
+    <eval expected="51864" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/@bpd"/>
     <eval expected="40000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/lineArea/viewport/@ipd"/>
     <eval expected="40000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/lineArea/viewport/@ipda"/>
     <eval expected="46080" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[4]/lineArea/viewport/@bpd"/>
index 3b091a8c07570c716f297a54cdceb1969c4e5dc2..eec2e7b704274f760dcd04e3ca2e4db4120bce94 100644 (file)
@@ -1,52 +1,49 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-  Copyright 2005 The Apache Software Foundation\r
-\r
-  Licensed under the Apache License, Version 2.0 (the "License");\r
-  you may not use this file except in compliance with the License.\r
-  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-  Unless required by applicable law or agreed to in writing, software\r
-  distributed under the License is distributed on an "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-  See the License for the specific language governing permissions and\r
-  limitations under the License.\r
--->\r
-<!-- $Id$ -->\r
-<testcase>\r
-  <info>\r
-    <p>\r
-      This test checks external-graphics. An oversized image is to be squeezed into page using min/opt/max values.\r
-    </p>\r
-  </info>\r
-  <fo>\r
-    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">\r
-      <fo:layout-master-set>\r
-        <fo:simple-page-master master-name="normal" page-width="21cm" page-height="29.7cm" margin="2cm">\r
-          <fo:region-body background-color="yellow"/>\r
-        </fo:simple-page-master>\r
-      </fo:layout-master-set>\r
-      <fo:page-sequence master-reference="normal" white-space-collapse="true">\r
-        <fo:flow flow-name="xsl-region-body">\r
-          <fo:block font-size="8pt">This first block is only to force an infinite loop if the image is not scaled down.</fo:block>\r
-          <!-- TODO If you remove the above block, the image is placed on the page although it's too big. No warnings. -->\r
-          <fo:block>\r
-            <fo:external-graphic src="../../resources/images/big-image.png" \r
-                inline-progression-dimension.maximum="100%" block-progression-dimension.maximum="100%"\r
-                content-width="scale-to-fit" content-height="scale-to-fit" overflow="hidden"/>\r
-          </fo:block>\r
-          <fo:block>EOF</fo:block>\r
-        </fo:flow>\r
-      </fo:page-sequence>\r
-    </fo:root>\r
-  </fo>\r
-  <checks>\r
-    <eval expected="0 0 595275 841889" xpath="//pageViewport/@bounds"/>\r
-    <eval expected="481891" xpath="//regionBody/@ipda"/>\r
-    <eval expected="728505" xpath="//regionBody/@bpda"/>\r
-    <eval expected="481891" xpath="//flow/block[2]/lineArea/viewport/@ipda"/>\r
-    <eval expected="728505" xpath="//flow/block[2]/lineArea/viewport/@bpda + //flow/block[1]/@bpda"/>\r
-  </checks>\r
-</testcase>\r
+<?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 external-graphics with relative content-height
+    </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>plain external-graphic</fo:block>
+          <fo:block>
+            <fo:external-graphic src="../../resources/images/bgimg300dpi.jpg" content-height="200%" content-width="200%" />EOG
+          </fo:block>
+          <fo:block>EOF</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="360000" xpath="//flow/block[2]/@ipd"/>
+    <eval expected="92160" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
+    <eval expected="92160" xpath="//flow/block[2]/lineArea/viewport/@ipda"/>
+    <eval expected="92160" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
+    <eval expected="92160" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/font-stretch.xml b/test/layoutengine/testcases/font-stretch.xml
new file mode 100644 (file)
index 0000000..07d7ab7
--- /dev/null
@@ -0,0 +1,55 @@
+<?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 font stretches.
+    </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="210mm" page-height="297mm">
+          <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 font-family="serif">font-family="serif" font-stretch not given</fo:block>
+          <fo:block font-family="serif" font-stretch="ultra-condensed">font-family="serif" font-stretch="ultra-condensed"
+            <fo:block font-family="serif" font-stretch="narrower">font-family="serif" font-stretch="narrower"</fo:block>
+          </fo:block>  
+          <fo:block font-family="serif" font-stretch="extra-condensed">font-family="serif" font-stretch="extra-condensed"</fo:block>
+          <fo:block font-family="serif" font-stretch="condensed">font-family="serif" font-stretch="condensed"</fo:block>
+          <fo:block font-family="serif" font-stretch="semi-condensed">font-family="serif" font-stretch="semi-condensed"</fo:block>
+          <fo:block font-family="serif" font-stretch="normal">font-family="serif" font-stretch="normal"</fo:block>
+          <fo:block font-family="serif" font-stretch="semi-expanded">font-family="serif" font-stretch="semi-expanded"</fo:block>
+          <fo:block font-family="serif" font-stretch="expanded">font-family="serif" font-stretch="expanded"</fo:block>
+          <fo:block font-family="serif" font-stretch="extra-expanded">font-family="serif" font-stretch="extra-expanded"</fo:block>
+          <fo:block font-family="serif" font-stretch="ultra-expanded">font-family="serif" font-stretch="ultra-expanded"
+            <fo:block font-family="serif" font-stretch="wider">font-family="serif" font-stretch="wider"</fo:block>
+          </fo:block>
+          <fo:block font-family="serif" font-stretch="narrower">font-family="serif" font-stretch="narrower"</fo:block>
+          <fo:block font-family="serif" font-stretch="wider">font-family="serif" font-stretch="wider"</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/leader-alignment.xml b/test/layoutengine/testcases/leader-alignment.xml
new file mode 100644 (file)
index 0000000..c8257ab
--- /dev/null
@@ -0,0 +1,67 @@
+<?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 leaders
+    </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="6in">
+          <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 margin="0pt" padding-left="10mm">
+                margin="0pt" padding-left="10mm"
+          </fo:block>
+          <fo:block padding-left="10mm">
+                padding-left="10mm"
+          </fo:block>
+          <fo:block>
+            <fo:leader leader-length.minimum="12pt"
+              leader-length.optimum="80pt"
+              leader-length.maximum="100%" leader-pattern="dots" leader-alignment="page"/>
+              leader-alignment="page"
+          </fo:block>
+          <fo:block margin="0pt" padding-left="10mm">
+            <fo:leader leader-length.minimum="12pt"
+              leader-length.optimum="80pt"
+              leader-length.maximum="100%" leader-pattern="dots" leader-alignment="page"/>
+              leader-alignment="page"
+          </fo:block>
+          <fo:block margin="0pt" padding-left="5mm">
+            <fo:leader leader-length.minimum="12pt"
+              leader-length.optimum="80pt"
+              leader-length.maximum="100%" leader-pattern="dots" leader-alignment="reference-area"/>
+              leader-alignment="reference-area"
+            <fo:leader leader-length.minimum="12pt"
+              leader-length.optimum="80pt"
+              leader-length.maximum="100%" leader-pattern="dots" leader-alignment="reference-area"/>
+              leader-alignment="reference-area" Leader-pattern is aligned as if it began on the current reference-area's content-rectangle start-edge.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+  </checks>
+</testcase>
index 52b7c67b9ed244267009bf424d9d2efd361f13a6..d5ac49b92db8588f3cd18e869a740681ec2f557c 100644 (file)
             <fo:leader leader-pattern="dots" leader-length="20mm" leader-pattern-width="5mm"/>
                  leader-length="20mm" leader-pattern-width="5mm"
           </fo:block>
+          <fo:block>
+            <fo:leader leader-pattern="dots" leader-length="20%" leader-pattern-width="5mm"/>
+                 leader-length="20%" leader-pattern-width="5mm"
+          </fo:block>
           <fo:block>
             <fo:leader leader-pattern="dots" leader-pattern-width="1pt"/>
                 leader-pattern-width="1pt"
           </fo:block>
           <fo:block>
-            <fo:leader leader-pattern="dots" leader-pattern-width="5%"/>
-                leader-pattern-width="5%"
+            <fo:leader leader-pattern="dots" leader-length="20%" leader-pattern-width="5%"/>
+                leader-length="20%" leader-pattern-width="5%"
           </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="14400" xpath="//flow/block[1]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[1]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[1]/lineArea/inlineparent/@ipd"/>
+    <eval expected="3" xpath="count(//flow/block[1]/lineArea/inlineparent/text)"/>
+    <eval expected="14400" xpath="//flow/block[2]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[2]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[2]/lineArea/inlineparent/@ipd"/>
+    <eval expected="3" xpath="count(//flow/block[2]/lineArea/inlineparent/text)"/>
+    <eval expected="14400" xpath="//flow/block[3]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[3]/lineArea/@ipd"/>
+    <eval expected="56692" xpath="//flow/block[3]/lineArea/inlineparent/@ipd"/>
+    <eval expected="4" xpath="count(//flow/block[3]/lineArea/inlineparent/text)"/>
+    <eval expected="4" xpath="count(//flow/block[3]/lineArea/inlineparent/space)"/>
+    <eval expected="14400" xpath="//flow/block[4]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[4]/lineArea/@ipd"/>
+    <eval expected="72000" xpath="//flow/block[4]/lineArea/inlineparent/@ipd"/>
+    <eval expected="5" xpath="count(//flow/block[4]/lineArea/inlineparent/text)"/>
+    <eval expected="5" xpath="count(//flow/block[4]/lineArea/inlineparent/space)"/>
+    <eval expected="14400" xpath="//flow/block[5]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[5]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[5]/lineArea/inlineparent/@ipd"/>
+    <eval expected="3" xpath="count(//flow/block[5]/lineArea/inlineparent/text)"/>
+    <eval expected="14400" xpath="//flow/block[6]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[6]/lineArea/@ipd"/>
+    <eval expected="72000" xpath="//flow/block[6]/lineArea/inlineparent/@ipd"/>
+    <eval expected="4" xpath="count(//flow/block[6]/lineArea/inlineparent/text)"/>
+    <eval expected="4" xpath="count(//flow/block[6]/lineArea/inlineparent/space)"/>
   </checks>
 </testcase>
index ee5b774507766b7cedd639392b6f1071a4af39b2..4e65823fa5304b99f6182a5e6b19feaeabf253f7 100644 (file)
     </fo:root>
   </fo>
   <checks>
+    <eval expected="14400" xpath="//flow/block[1]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[1]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[1]/lineArea/leader/@ipd"/>
+    <eval expected="solid" xpath="//flow/block[1]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[1]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[2]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[2]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[2]/lineArea/leader/@ipd"/>
+    <eval expected="--NYI--" xpath="//flow/block[2]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[2]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[3]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[3]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[3]/lineArea/leader/@ipd"/>
+    <eval expected="dotted" xpath="//flow/block[3]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[3]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[4]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[4]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[4]/lineArea/leader/@ipd"/>
+    <eval expected="dashed" xpath="//flow/block[4]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[4]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[5]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[5]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[5]/lineArea/leader/@ipd"/>
+    <eval expected="solid" xpath="//flow/block[5]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[5]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[6]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[6]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[6]/lineArea/leader/@ipd"/>
+    <eval expected="double" xpath="//flow/block[6]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[6]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[7]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[7]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[7]/lineArea/leader/@ipd"/>
+    <eval expected="groove" xpath="//flow/block[7]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[7]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[8]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[8]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[8]/lineArea/leader/@ipd"/>
+    <eval expected="ridge" xpath="//flow/block[8]/lineArea/leader/@ruleStyle"/>
+    <eval expected="1000" xpath="//flow/block[8]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[9]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[9]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[9]/lineArea/leader/@ipd"/>
+    <eval expected="dotted" xpath="//flow/block[9]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[9]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[10]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[10]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[10]/lineArea/leader/@ipd"/>
+    <eval expected="dashed" xpath="//flow/block[10]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[10]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[11]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[11]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[11]/lineArea/leader/@ipd"/>
+    <eval expected="solid" xpath="//flow/block[11]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[11]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[12]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[12]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[12]/lineArea/leader/@ipd"/>
+    <eval expected="double" xpath="//flow/block[12]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[12]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[13]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[13]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[13]/lineArea/leader/@ipd"/>
+    <eval expected="groove" xpath="//flow/block[13]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[13]/lineArea/leader/@ruleThickness"/>
+    <eval expected="14400" xpath="//flow/block[14]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[14]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[14]/lineArea/leader/@ipd"/>
+    <eval expected="ridge" xpath="//flow/block[14]/lineArea/leader/@ruleStyle"/>
+    <eval expected="3000" xpath="//flow/block[14]/lineArea/leader/@ruleThickness"/>
+    <!-- No checks for the "alignment-baseline=..." section as this property is currently
+     not supported -->
   </checks>
 </testcase>
index 2f8e3fa815c61c6e7c7fccb8d7d75cdb53427f41..e82dfa680c54465955ca2b013933186852af086a 100644 (file)
                Default space pattern
           </fo:block>
           <fo:block>
-            <fo:leader leader-pattern="space" leader-pattern-width="use-font-metrics"/>
-                leader-pattern-width="use-font-metrics"
+            <fo:leader leader-pattern="space" leader-length="0.5in"/>
+               leader-length="0.5in"
           </fo:block>
           <fo:block>
-            <fo:leader leader-pattern="space" leader-length="20mm" leader-pattern-width="5mm"/>
-                 leader-length="20mm" leader-pattern-width="5mm"
-          </fo:block>
-          <fo:block>
-            <fo:leader leader-pattern="space" leader-pattern-width="1pt"/>
-                leader-pattern-width="1pt"
-          </fo:block>
-          <fo:block>
-            <fo:leader leader-pattern="space" leader-pattern-width="5%"/>
-                leader-pattern-width="5%"
+            <fo:leader leader-pattern="space" leader-length="5%"/>
+               leader-length="5%"
           </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
+    <eval expected="14400" xpath="//flow/block[1]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[1]/lineArea/@ipd"/>
+    <eval expected="12000" xpath="//flow/block[1]/lineArea/space/@ipd"/>
+    <eval expected="14400" xpath="//flow/block[2]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[2]/lineArea/@ipd"/>
+    <eval expected="36000" xpath="//flow/block[2]/lineArea/space/@ipd"/>
+    <eval expected="14400" xpath="//flow/block[3]/lineArea/@bpd"/>
+    <eval expected="360000" xpath="//flow/block[3]/lineArea/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[3]/lineArea/space/@ipd"/>
   </checks>
 </testcase>
diff --git a/test/layoutengine/testcases/leader-use-content.xml b/test/layoutengine/testcases/leader-use-content.xml
new file mode 100644 (file)
index 0000000..00b0d97
--- /dev/null
@@ -0,0 +1,59 @@
+<?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 leaders with leader-pattern="use-content"
+    </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>
+            <fo:leader leader-pattern="use-content"/>
+               Default dots pattern
+          </fo:block>
+          <fo:block>
+            <fo:leader leader-pattern="use-content" leader-pattern-width="use-font-metrics"/>
+                leader-pattern-width="use-font-metrics"
+          </fo:block>
+          <fo:block>
+            <fo:leader leader-pattern="use-content" leader-length="20mm" leader-pattern-width="5mm"/>
+                 leader-length="20mm" leader-pattern-width="5mm"
+          </fo:block>
+          <fo:block>
+            <fo:leader leader-pattern="use-content" leader-pattern-width="1pt"/>
+                leader-pattern-width="1pt"
+          </fo:block>
+          <fo:block>
+            <fo:leader leader-pattern="use-content" leader-pattern-width="5%"/>
+                leader-pattern-width="5%"
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/line-height.xml b/test/layoutengine/testcases/line-height.xml
new file mode 100644 (file)
index 0000000..5908e14
--- /dev/null
@@ -0,0 +1,74 @@
+<?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 line height and its special inheritance behaviour
+    </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 line-height="normal" background-color="yellow">line-height="normal"
+            <fo:block font-size="larger" margin-left="10pt" background-color="blue">font-size="larger" - line height grows</fo:block>
+            <fo:block font-size="smaller" margin-left="10pt" background-color="red">font-size="smaller" - line height shrinks</fo:block>
+          </fo:block>
+          <fo:block line-height="150%" background-color="yellow">line-height="150%"
+            <fo:block font-size="larger" margin-left="10pt" background-color="blue">font-size="larger" - line height same as above</fo:block>
+            <fo:block font-size="smaller" margin-left="10pt" background-color="red">font-size="smaller" - line height same as above</fo:block>
+          </fo:block>
+          <fo:block line-height="20pt" background-color="yellow">line-height="20pt"
+            <fo:block font-size="larger" margin-left="10pt" background-color="blue">font-size="larger" - line height same as above</fo:block>
+            <fo:block font-size="smaller" margin-left="10pt" background-color="red">font-size="smaller" - line height same as above</fo:block>
+          </fo:block>
+          <fo:block line-height="1.5" background-color="yellow">line-height="1.5"
+            <fo:block font-size="larger" margin-left="10pt" background-color="blue">font-size="larger" - line height grows</fo:block>
+            <fo:block font-size="smaller" margin-left="10pt" background-color="red">font-size="smaller" - line height shrinks</fo:block>
+          </fo:block>
+          <fo:block line-height="150% - 5pt" background-color="yellow">line-height="150% - 5pt"
+            <fo:block font-size="larger" margin-left="10pt" background-color="blue">font-size="larger" - line height same as above</fo:block>
+            <fo:block font-size="smaller" margin-left="10pt" background-color="red">font-size="smaller" - line height same as above</fo:block>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="14400" xpath="//flow/block[1]/lineArea/@bpd"/>
+    <eval expected="17280" xpath="//flow/block[1]/block[1]/lineArea/@bpd"/>
+    <eval expected="12000" xpath="//flow/block[1]/block[2]/lineArea/@bpd"/>
+    <eval expected="18000" xpath="//flow/block[2]/lineArea/@bpd"/>
+    <eval expected="18000" xpath="//flow/block[2]/block[1]/lineArea/@bpd"/>
+    <eval expected="18000" xpath="//flow/block[2]/block[2]/lineArea/@bpd"/>
+    <eval expected="20000" xpath="//flow/block[3]/lineArea/@bpd"/>
+    <eval expected="20000" xpath="//flow/block[3]/block[1]/lineArea/@bpd"/>
+    <eval expected="20000" xpath="//flow/block[3]/block[2]/lineArea/@bpd"/>
+    <eval expected="18000" xpath="//flow/block[4]/lineArea/@bpd"/>
+    <eval expected="21600" xpath="//flow/block[4]/block[1]/lineArea/@bpd"/>
+    <eval expected="15000" xpath="//flow/block[4]/block[2]/lineArea/@bpd"/>
+    <eval expected="13000" xpath="//flow/block[5]/lineArea/@bpd"/>
+    <eval expected="13000" xpath="//flow/block[5]/block[1]/lineArea/@bpd"/>
+    <eval expected="13000" xpath="//flow/block[5]/block[2]/lineArea/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/margin-block1.xml b/test/layoutengine/testcases/margin-block1.xml
new file mode 100644 (file)
index 0000000..f3f9b53
--- /dev/null
@@ -0,0 +1,63 @@
+<?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 margin percentages on fo:block.
+    </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 margin="5%" background-color="yellow">
+            <fo:block margin="5%" background-color="blue">
+               margin="5%" - should have the slightly smaller margin than the enclosing block
+            </fo:block>
+          </fo:block>
+          <fo:block>Yellow block has margin="5%" - 18pt margin based on 5in page width</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="0" xpath="//flow/block[1]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[1]/@bpd"/>
+    <eval expected="324000" xpath="//flow/block[2]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[2]/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@end-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@space-start"/>
+    <eval expected="18000" xpath="//flow/block[2]/@space-end"/>
+    <eval expected="0" xpath="//flow/block[2]/block[1]/@ipd"/>
+    <eval expected="16200" xpath="//flow/block[2]/block[1]/@bpd"/>
+    <eval expected="291600" xpath="//flow/block[2]/block[2]/@ipd"/>
+    <eval expected="34200" xpath="//flow/block[2]/block[2]/@start-indent"/>
+    <eval expected="34200" xpath="//flow/block[2]/block[2]/@end-indent"/>
+    <eval expected="34200" xpath="//flow/block[2]/block[2]/@space-start"/>
+    <eval expected="34200" xpath="//flow/block[2]/block[2]/@space-end"/>
+    <eval expected="0" xpath="//flow/block[2]/block[3]/@ipd"/>
+    <eval expected="16200" xpath="//flow/block[2]/block[3]/@bpd"/>
+    <eval expected="0" xpath="//flow/block[3]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[3]/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/margin-block2.xml b/test/layoutengine/testcases/margin-block2.xml
new file mode 100644 (file)
index 0000000..da022fb
--- /dev/null
@@ -0,0 +1,63 @@
+<?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 margin percentages on fo:block with explict inheritance.
+    </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 margin="5%" background-color="yellow">
+            <fo:block margin="inherit" background-color="blue">
+               margin="inherit" - should have the same margin as the enclosing block
+            </fo:block>
+          </fo:block>
+          <fo:block>Yellow block has margin="5%" - 18pt margin based on 5in page width</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="0" xpath="//flow/block[1]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[1]/@bpd"/>
+    <eval expected="324000" xpath="//flow/block[2]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[2]/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@end-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@space-start"/>
+    <eval expected="18000" xpath="//flow/block[2]/@space-end"/>
+    <eval expected="0" xpath="//flow/block[2]/block[1]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[2]/block[1]/@bpd"/>
+    <eval expected="288000" xpath="//flow/block[2]/block[2]/@ipd"/>
+    <eval expected="36000" xpath="//flow/block[2]/block[2]/@start-indent"/>
+    <eval expected="36000" xpath="//flow/block[2]/block[2]/@end-indent"/>
+    <eval expected="36000" xpath="//flow/block[2]/block[2]/@space-start"/>
+    <eval expected="36000" xpath="//flow/block[2]/block[2]/@space-end"/>
+    <eval expected="0" xpath="//flow/block[2]/block[3]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[2]/block[3]/@bpd"/>
+    <eval expected="0" xpath="//flow/block[3]/@ipd"/>
+    <eval expected="18000" xpath="//flow/block[3]/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/margin-region1.xml b/test/layoutengine/testcases/margin-region1.xml
new file mode 100644 (file)
index 0000000..b1a7341
--- /dev/null
@@ -0,0 +1,106 @@
+<?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%">
+          <fo:region-body margin="5%" background-color="yellow" />
+          <fo:region-before extent="5%" 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="5%" 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% margins on all regions and the page master.
+            The page size is 5in x 3in. This gives top and bottom margins of 0.25in and
+            left and right margins 0.15in.
+          </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="18000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 194400 18000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="10800 36000 10800 288000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="194400 36000 10800 288000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <!-- 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"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="172800" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 36000 172800 288000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="172800" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/margin-region2.xml b/test/layoutengine/testcases/margin-region2.xml
new file mode 100644 (file)
index 0000000..fa05f77
--- /dev/null
@@ -0,0 +1,107 @@
+<?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="5%" background-color="yellow" />
+          <fo:region-before extent="5%" 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="5%" 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% margins on all regions and the page master with a
+            landscape reference orientation.
+            The page size is 5in x 3in. This gives top and bottom margins of 0.25in and
+            left and right margins 0.15in.
+          </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="18000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 18000 324000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="28800 331200 158400 10800" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="28800 18000 158400 10800" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <!-- region after -->
+    <eval expected="color=#008000" xpath="//page/regionViewport[4]/@background"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/@bpd"/>
+    <eval expected="187200 18000 18000 324000" xpath="//page/regionViewport[4]/@rect"/>
+    <eval expected="324000" xpath="//page/regionViewport[4]/regionAfter/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[4]/regionAfter/@bpd"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="302400" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="28800 28800 158400 302400" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="302400" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="158400" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/margin-region3.xml b/test/layoutengine/testcases/margin-region3.xml
new file mode 100644 (file)
index 0000000..a486145
--- /dev/null
@@ -0,0 +1,109 @@
+<?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 regions (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%" writing-mode="rl">
+          <fo:region-body margin-top="5%" margin-bottom="5%" margin-left="5%" margin-right="10%" background-color="yellow" />
+          <fo:region-before extent="5%" background-color="blue" precedence="true" />
+          <fo:region-after extent="5%" background-color="green" precedence="true" />
+          <fo:region-start extent="10%" background-color="red" />
+          <fo:region-end extent="5%" 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% margins on all regions and the page master.
+            The page size is 5in x 3in. This gives top and bottom margins of 0.25in and
+            left and right margins 0.15in.
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- The values in these checks are currently not correct. However, there is also a bug
+    in the rl writing mode causing a swap of left and right margin. Both should be fixed at
+    the same time. -->
+    <!-- region before -->
+    <eval expected="color=#0000ff" xpath="//page/regionViewport[1]/@background"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[1]/@bpd"/>
+    <eval expected="10800 18000 194400 18000" xpath="//page/regionViewport[1]/@rect"/>
+    <eval expected="194400" xpath="//page/regionViewport[1]/regionBefore/@ipd"/>
+    <eval expected="18000" xpath="//page/regionViewport[1]/regionBefore/@bpd"/>
+    <!-- region start -->
+    <eval expected="color=#ff0000" xpath="//page/regionViewport[2]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[2]/@bpd"/>
+    <eval expected="10800 36000 10800 288000" xpath="//page/regionViewport[2]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[2]/regionStart/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[2]/regionStart/@bpd"/>
+    <!-- region end -->
+    <eval expected="color=#ffa500" xpath="//page/regionViewport[3]/@background"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[3]/@bpd"/>
+    <eval expected="194400 36000 10800 288000" xpath="//page/regionViewport[3]/@rect"/>
+    <eval expected="10800" xpath="//page/regionViewport[3]/regionEnd/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[3]/regionEnd/@bpd"/>
+    <!-- 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"/>
+    <!-- region body -->
+    <eval expected="color=#ffff00" xpath="//page/regionViewport[5]/@background"/>
+    <eval expected="172800" xpath="//page/regionViewport[5]/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[5]/@bpd"/>
+    <eval expected="21600 36000 172800 288000" xpath="//page/regionViewport[5]/@rect"/>
+    <eval expected="172800" xpath="//page/regionViewport[5]/regionBody/@ipd"/>
+    <eval expected="288000" xpath="//page/regionViewport[5]/regionBody/@bpd"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-block-container1.xml b/test/layoutengine/testcases/padding-block-container1.xml
new file mode 100644 (file)
index 0000000..ca76d9a
--- /dev/null
@@ -0,0 +1,53 @@
+<?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 padding on block containers.
+    </p>
+  </info>
+  <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">
+          <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 width="2in" height="1in" background-color="yellow" padding="5%">
+             <fo:block>margin not specified padding="5%" on this 2x1in yellow container</fo:block>
+          </fo:block-container>
+          <fo:block-container width="2in" height="1in" margin="0pt" background-color="blue" padding="5%">
+             <fo:block>margin="0pt" padding="5%" on this 2x1in blue container</fo:block>
+          </fo:block-container>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block[1]/@bap"/>
+    <eval expected="-18000" xpath="//flow/block[1]/@space-start"/>
+    <eval expected="-18000" xpath="//flow/block[1]/@space-end"/>
+    <eval expected="color=#ffff00" xpath="//flow/block[1]/@background"/>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block[2]/@bap"/>
+    <eval expected="18000" xpath="//flow/block[2]/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@end-indent"/>
+    <eval expected="color=#0000ff" xpath="//flow/block[2]/@background"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-block1.xml b/test/layoutengine/testcases/padding-block1.xml
new file mode 100644 (file)
index 0000000..45856b7
--- /dev/null
@@ -0,0 +1,53 @@
+<?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 padding on blocks.
+    </p>
+  </info>
+  <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">
+          <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="yellow" padding="5%">
+             margin not specified padding="5%"
+          </fo:block>
+          <fo:block margin="0pt" background-color="yellow" padding="5%">
+             margin="0pt" padding="5%"
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block[1]/@bap"/>
+    <eval expected="-18000" xpath="//flow/block[1]/@space-start"/>
+    <eval expected="-18000" xpath="//flow/block[1]/@space-end"/>
+    <eval expected="color=#ffff00" xpath="//flow/block[1]/@background"/>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block[2]/@bap"/>
+    <eval expected="18000" xpath="//flow/block[2]/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block[2]/@end-indent"/>
+    <eval expected="color=#ffff00" xpath="//flow/block[2]/@background"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-list1.xml b/test/layoutengine/testcases/padding-list1.xml
new file mode 100644 (file)
index 0000000..2b49e5d
--- /dev/null
@@ -0,0 +1,75 @@
+<?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 padding on lists (list-block).
+    </p>
+  </info>
+  <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">
+          <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:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in" margin="0pt" padding="5%" background-color="yellow">
+            <fo:list-item background-color="white">
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 1</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 1: The whole list should have a 5% padding shown in yellow.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+            <fo:list-item background-color="white">
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 2</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 2: The whole list should have a 5% padding shown in yellow.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+            <fo:list-item background-color="white">
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 3</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 3: The whole list should have a 5% padding shown in yellow.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+          </fo:list-block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block/@bap"/>
+    <eval expected="18000" xpath="//flow/block/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block/@end-indent"/>
+    <eval expected="color=#ffff00" xpath="//flow/block/@background"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-list2.xml b/test/layoutengine/testcases/padding-list2.xml
new file mode 100644 (file)
index 0000000..1c56ac9
--- /dev/null
@@ -0,0 +1,78 @@
+<?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 padding widths on lists (list-item).
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <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">
+          <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:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in">
+            <fo:list-item margin="0pt" padding="5%" background-color="yellow">
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 1</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 1: We should have 5% padding around this whole yellow list item.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+            <fo:list-item>
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 2</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 2: We should have no padding around this whole list item.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+            <fo:list-item>
+              <fo:list-item-label end-indent="label-end()">
+                <fo:block>label 3</fo:block>
+              </fo:list-item-label>
+              <fo:list-item-body start-indent="body-start()">
+                <fo:block>
+                  body 3: We should have no padding around this whole list item.
+                </fo:block>
+              </fo:list-item-body>
+            </fo:list-item>
+          </fo:list-block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="18000 18000 18000 18000" xpath="//flow/block/block/@bap"/>
+    <eval expected="18000" xpath="//flow/block/block/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block/block/@end-indent"/>
+    <eval expected="color=#ffff00" xpath="//flow/block/block/@background"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-table1.xml b/test/layoutengine/testcases/padding-table1.xml
new file mode 100644 (file)
index 0000000..73345c4
--- /dev/null
@@ -0,0 +1,74 @@
+<?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 padding on a fo:table.
+    </p>
+  </info>
+  <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">
+          <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:table margin="0pt" padding="5%" background-color="yellow" border-collapse="separate">
+            <fo:table-column column-number="1" />
+            <fo:table-column column-number="2" />
+            <fo:table-column column-number="3" />
+            <fo:table-header>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block>Header Col 1</fo:block>
+                </fo:table-cell>
+                <fo:table-cell>
+                  <fo:block>Header Col 2</fo:block>
+                </fo:table-cell>
+                <fo:table-cell>
+                  <fo:block>Header Col 3</fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-header>
+            <fo:table-body>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block>Row 1 Col 1</fo:block>
+                </fo:table-cell>
+                <fo:table-cell>
+                  <fo:block>Row 1 Col 2</fo:block>
+                </fo:table-cell>
+                <fo:table-cell>
+                  <fo:block>Row 1 Col 3</fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-body>
+          </fo:table>
+          <fo:block>Table on yellow background with 5% padding</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="18000" xpath="//flow/block/@start-indent"/>
+    <eval expected="18000" xpath="//flow/block/@end-indent"/>
+    <eval expected="color=#ffff00" xpath="//flow/block/@background"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/padding-table2.xml b/test/layoutengine/testcases/padding-table2.xml
new file mode 100644 (file)
index 0000000..b7178c9
--- /dev/null
@@ -0,0 +1,64 @@
+<?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 padding on a fo:table-cell.
+    </p>
+  </info>
+  <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">
+          <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:table>
+            <fo:table-column column-number="1" />
+            <fo:table-column column-number="2" />
+            <fo:table-column column-number="3" />
+            <fo:table-body>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block>Row 1 Col 1</fo:block>
+                </fo:table-cell>
+                <fo:table-cell margin="0pt" padding="2%" background-color="yellow">
+                  <fo:block>Row 1 Col 2</fo:block>
+                </fo:table-cell>
+                <fo:table-cell>
+                  <fo:block>Row 1 Col 3</fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-body>
+          </fo:table>
+          <fo:block>Table a yellow cell having 2% padding.</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="7200 7200 7200 7200" xpath="//flow/block/block[2]/@bap"/>
+    <eval expected="color=#ffff00" xpath="//flow/block/block[2]/@background"/>
+    <eval expected="7200" xpath="//flow/block/block[2]/block/@start-indent"/>
+    <eval expected="7200" xpath="//flow/block/block[2]/block/@end-indent"/>
+    <eval expected="7200" xpath="//flow/block/block[2]/block/@space-start"/>
+    <eval expected="7200" xpath="//flow/block/block[2]/block/@space-end"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/table3.xml b/test/layoutengine/testcases/table3.xml
new file mode 100644 (file)
index 0000000..d791e96
--- /dev/null
@@ -0,0 +1,79 @@
+<?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 basic tables with percentages in cells.
+    </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:table table-layout="fixed" width="100%">
+            <fo:table-column column-width="2in"/>
+            <fo:table-column column-width="3in"/>
+            <fo:table-body>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block margin="10%">cell1</fo:block>
+                </fo:table-cell>
+                <fo:table-cell background-color="yellow">
+                  <fo:block margin-left="5%" margin-right="5%">cell2</fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-body>
+          </fo:table>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- table dimensions -->
+    <eval expected="360000" xpath="//flow/block[1]/@ipd"/>
+    <eval expected="43200" xpath="//flow/block[1]/@bpd"/>
+    
+    <!-- cell 1 -->
+    <true xpath="//flow/block[1]/block[1]/@is-reference-area"/>
+    <eval expected="144000" xpath="//flow/block[1]/block[1]/@ipd"/>
+    <eval expected="43200" xpath="//flow/block[1]/block[1]/@bpd"/>
+    <eval expected="115200" xpath="//flow/block[1]/block[1]/block[2]/@ipd"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[1]/block[2]/@bpd"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[1]/block[2]/@start-indent"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[1]/block[2]/@space-start"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[1]/block[2]/@end-indent"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[1]/block[2]/@space-end"/>
+
+    <!-- cell 2 -->
+    <true xpath="//flow/block[1]/block[2]/@is-reference-area"/>
+    <eval expected="144000" xpath="//flow/block[1]/block[2]/@left-offset"/>
+    <eval expected="216000" xpath="//flow/block[1]/block[2]/@ipd"/>
+    <eval expected="43200" xpath="//flow/block[1]/block[2]/@bpd"/>
+    <eval expected="194400" xpath="//flow/block[1]/block[2]/block[1]/@ipd"/>
+    <eval expected="14400" xpath="//flow/block[1]/block[2]/block[1]/@bpd"/>
+    <eval expected="10800" xpath="//flow/block[1]/block[2]/block[1]/@start-indent"/>
+    <eval expected="10800" xpath="//flow/block[1]/block[2]/block[1]/@space-start"/>
+    <eval expected="10800" xpath="//flow/block[1]/block[2]/block[1]/@end-indent"/>
+    <eval expected="10800" xpath="//flow/block[1]/block[2]/block[1]/@space-end"/>
+  </checks>
+</testcase>