You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by bc...@apache.org on 2005/08/31 22:30:49 UTC
svn commit: r265577 [2/5] - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/area/ src/java/org/apache/fop/datatypes/
src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/expr/
src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/pagination/...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java Wed Aug 31 13:29:33 2005
@@ -19,9 +19,10 @@
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 @@
return 255f;
}
- public int getBaseLength() {
+ public int getBaseLength(PercentBaseContext context) {
return 0;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java Wed Aug 31 13:29:33 2005
@@ -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 @@
/**
* 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 @@
* @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);
}
/**
@@ -168,6 +180,19 @@
public int getValue() {
try {
return (int) getNumericValue();
+ } catch (PropertyException exc) {
+ log.error(exc);
+ }
+ 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);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/ExternalGraphic.java Wed Aug 31 13:29:33 2005
@@ -280,19 +280,6 @@
}
/**
- * @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()
*/
public int getIntrinsicWidth() {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Wed Aug 31 13:29:33 2005
@@ -285,17 +285,6 @@
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.
*/
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java Wed Aug 31 13:29:33 2005
@@ -132,11 +132,13 @@
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");
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCell.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCell.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCell.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCell.java Wed Aug 31 13:29:33 2005
@@ -188,95 +188,97 @@
* 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.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java Wed Aug 31 13:29:33 2005
@@ -81,8 +81,8 @@
}
}
- 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 @@
/**
* @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,
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java Wed Aug 31 13:29:33 2005
@@ -24,6 +24,8 @@
// 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 @@
/**
* @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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBA.java Wed Aug 31 13:29:33 2005
@@ -22,6 +22,7 @@
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 @@
* 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) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBefore.java Wed Aug 31 13:29:33 2005
@@ -23,6 +23,8 @@
// 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 @@
/**
* @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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java Wed Aug 31 13:29:33 2005
@@ -24,7 +24,9 @@
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 @@
/**
* @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);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java Wed Aug 31 13:29:33 2005
@@ -24,6 +24,8 @@
// 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 @@
/**
* @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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionSE.java Wed Aug 31 13:29:33 2005
@@ -22,6 +22,7 @@
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 @@
* 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) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java Wed Aug 31 13:29:33 2005
@@ -24,6 +24,8 @@
// 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 @@
/**
* @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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java Wed Aug 31 13:29:33 2005
@@ -20,6 +20,7 @@
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;
@@ -224,6 +225,14 @@
}
/**
+ * 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 @@
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 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 @@
* 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 @@
* 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 @@
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 @@
+ 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);
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java Wed Aug 31 13:29:33 2005
@@ -21,6 +21,7 @@
// 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 @@
* @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 @@
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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java Wed Aug 31 13:29:33 2005
@@ -22,6 +22,7 @@
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.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CondLengthProperty.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CondLengthProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CondLengthProperty.java Wed Aug 31 13:29:33 2005
@@ -20,6 +20,7 @@
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;
@@ -120,6 +121,14 @@
*/
public int getLengthValue() {
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() {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/EnumLength.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/EnumLength.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/EnumLength.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/EnumLength.java Wed Aug 31 13:29:33 2005
@@ -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 boolean isAbsolute() {
return false;
}
+
/**
* Returns the length in 1/1000ths of a point (millipoints)
* @return the length in millipoints
@@ -48,10 +51,30 @@
}
/**
+ * 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
*/
public double getNumericValue() {
+ log.error("getNumericValue() called on " + enumProperty + " number");
+ 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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java Wed Aug 31 13:29:33 2005
@@ -18,6 +18,8 @@
package org.apache.fop.fo.properties;
+import org.apache.fop.datatypes.PercentBaseContext;
+
/**
* An absolute length quantity in XSL
*/
@@ -99,10 +101,30 @@
}
/**
+ * 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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java Wed Aug 31 13:29:33 2005
@@ -17,10 +17,14 @@
/* $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
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java Wed Aug 31 13:29:33 2005
@@ -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 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 @@
}
// 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 @@
}
// 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 @@
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 @@
}
/**
+ * @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() + "]";
}
/**
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java Wed Aug 31 13:29:33 2005
@@ -17,11 +17,14 @@
/* $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 @@
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);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java Wed Aug 31 13:29:33 2005
@@ -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,8 +105,28 @@
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();
}
/**
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PercentLength.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PercentLength.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PercentLength.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PercentLength.java Wed Aug 31 13:29:33 2005
@@ -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 @@
* {@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 @@
* @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;
@@ -94,6 +108,14 @@
*/
public int getValue() {
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);
}
/**
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyMaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyMaker.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PropertyMaker.java Wed Aug 31 13:29:33 2005
@@ -308,7 +308,7 @@
* 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);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/SpaceProperty.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/SpaceProperty.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/SpaceProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/SpaceProperty.java Wed Aug 31 13:29:33 2005
@@ -137,9 +137,9 @@
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() + "]";
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/TableColLength.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/TableColLength.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/TableColLength.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/TableColLength.java Wed Aug 31 13:29:33 2005
@@ -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;
@@ -77,11 +78,30 @@
}
/**
+ * 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()
*/
public int getValue() {
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();
}
/**
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java?rev=265577&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java Wed Aug 31 13:29:33 2005
@@ -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;
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Wed Aug 31 13:29:33 2005
@@ -22,6 +22,8 @@
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 @@
/**
* 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 @@
/** 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 @@
* @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 @@
return this.parentLM;
}
+ public void initialize() {
+ // Empty
+ }
+
/**
* Return currently active child LayoutManager or null if
* all children have finished layout.
@@ -95,6 +98,7 @@
}
while (childLMiter.hasNext()) {
curChildLM = (LayoutManager) childLMiter.next();
+ curChildLM.initialize();
return curChildLM;
}
return null;
@@ -157,6 +161,9 @@
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 @@
addChildLM(lm);
}
}
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=265577&r1=265576&r2=265577&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Wed Aug 31 13:29:33 2005
@@ -74,45 +74,48 @@
*/
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
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 @@
}
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org