aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/fo')
-rw-r--r--src/java/org/apache/fop/fo/FOPropertyMapping.java14
-rw-r--r--src/java/org/apache/fop/fo/FObj.java49
-rw-r--r--src/java/org/apache/fop/fo/PropertyManager.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/ExternalGraphic.java20
-rw-r--r--src/java/org/apache/fop/fo/flow/TableColumn.java32
5 files changed, 75 insertions, 42 deletions
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index 7703121e8..761c00cc4 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -304,6 +304,7 @@ public class FOPropertyMapping implements Constants {
genericPadding = new LengthProperty.Maker(0);
genericPadding.setInherited(false);
genericPadding.setDefault("0pt");
+ genericPadding.setPercentBase(LengthBase.BLOCK_WIDTH);
genericPadding.addShorthand(s_generics[PR_PADDING]);
// GenericCondBorderWidth
@@ -1189,6 +1190,7 @@ public class FOPropertyMapping implements Constants {
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-top", m);
// margin-bottom
@@ -1196,6 +1198,7 @@ public class FOPropertyMapping implements Constants {
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-bottom", m);
// margin-left
@@ -1203,6 +1206,7 @@ public class FOPropertyMapping implements Constants {
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-left", m);
// margin-right
@@ -1210,6 +1214,7 @@ public class FOPropertyMapping implements Constants {
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-right", m);
// space-before
@@ -1343,6 +1348,7 @@ public class FOPropertyMapping implements Constants {
// block-progression-dimension
m = new LengthRangeProperty.Maker(PR_BLOCK_PROGRESSION_DIMENSION);
m.setInherited(false);
+ m.setPercentBase(LengthBase.BLOCK_HEIGHT);
l = new LengthProperty.Maker(CP_MINIMUM);
l.setDefault("auto");
@@ -1372,6 +1378,7 @@ public class FOPropertyMapping implements Constants {
{PR_MAX_HEIGHT, PR_MAX_HEIGHT, PR_MAX_WIDTH, }
});
pdim.setRelative(true);
+ m.setCorresponding(pdim);
addPropertyMaker("block-progression-dimension", m);
// content-height
@@ -1398,6 +1405,7 @@ public class FOPropertyMapping implements Constants {
// inline-progression-dimension
m = new LengthRangeProperty.Maker(PR_INLINE_PROGRESSION_DIMENSION);
m.setInherited(false);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
l = new LengthProperty.Maker(CP_MINIMUM);
l.setDefault("auto");
@@ -1427,6 +1435,7 @@ public class FOPropertyMapping implements Constants {
{PR_MIN_WIDTH, PR_MIN_WIDTH, PR_MIN_HEIGHT, },
{PR_MAX_WIDTH, PR_MAX_WIDTH, PR_MAX_HEIGHT, }
});
+ m.setCorresponding(pdim);
addPropertyMaker("inline-progression-dimension", m);
// max-height
@@ -1471,7 +1480,7 @@ public class FOPropertyMapping implements Constants {
l = new LengthProperty.Maker(PR_WIDTH);
l.setInherited(false);
l.setAutoOk(true);
- l.setPercentBase(LengthBase.CONTAINING_BOX);
+ l.setPercentBase(LengthBase.BLOCK_WIDTH);
l.setDefault("auto");
addPropertyMaker("width", l);
}
@@ -1580,6 +1589,7 @@ public class FOPropertyMapping implements Constants {
m = new LengthProperty.Maker(PR_TEXT_INDENT);
m.setInherited(false);
m.setDefault("0pt");
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("text-indent", m);
// white-space-collapse
@@ -2222,6 +2232,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);
addPropertyMaker("column-width", m);
// empty-cells
@@ -2476,6 +2487,7 @@ public class FOPropertyMapping implements Constants {
m.setInherited(false);
m.setDefault("");
m.setDatatypeParser(new BoxPropShorthandParser());
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin", m);
// padding
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index 6d61dce3b..df057eab1 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -97,6 +97,11 @@ public class FObj extends FONode implements Constants {
protected Map markers = null;
/**
+ * Dynamic layout dimension. Used to resolve relative lengths.
+ */
+ protected Map layoutDimension = null;
+
+ /**
* Create a new formatting object.
* All formatting object classes extend this class.
*
@@ -237,6 +242,50 @@ public class FObj extends FONode implements Constants {
return new PropertyManager(propertyList);
}
+ /* This section is the implemenation of the property context. */
+
+ /**
+ * Assign the size of a layout dimension to the key.
+ * @param key the Layout dimension, from PercentBase.
+ * @param dimension The layout length.
+ */
+ public void setLayoutDimension(Integer key, int dimension) {
+ if (layoutDimension == null){
+ layoutDimension = new HashMap();
+ }
+ layoutDimension.put(key, new Integer(dimension));
+ }
+
+ /**
+ * Assign the size of a layout dimension to the key.
+ * @param key the Layout dimension, from PercentBase.
+ * @param dimension The layout length.
+ */
+ public void setLayoutDimension(Integer key, float dimension) {
+ if (layoutDimension == null){
+ layoutDimension = new HashMap();
+ }
+ layoutDimension.put(key, new Float(dimension));
+ }
+
+ /**
+ * Return the size associated with the key.
+ * @param key The layout dimension key.
+ * @return the length.
+ */
+ public Number getLayoutDimension(Integer key) {
+ if (layoutDimension != null) {
+ Number result = (Number) layoutDimension.get(key);
+ if (result != null) {
+ return result;
+ }
+ }
+ if (parent != null) {
+ return ((FObj) parent).getLayoutDimension(key);
+ }
+ return new Integer(0);
+ }
+
/**
* Add the child to this object.
*
diff --git a/src/java/org/apache/fop/fo/PropertyManager.java b/src/java/org/apache/fop/fo/PropertyManager.java
index 4c25add9e..50a9e6c17 100644
--- a/src/java/org/apache/fop/fo/PropertyManager.java
+++ b/src/java/org/apache/fop/fo/PropertyManager.java
@@ -465,7 +465,7 @@ public class PropertyManager implements Constants {
*/
public BlockProps getBlockProps() {
BlockProps props = new BlockProps();
- props.firstIndent = this.propertyList.get(PR_TEXT_INDENT).getLength().getValue();
+ props.firstIndent = this.propertyList.get(PR_TEXT_INDENT).getLength();
props.lastIndent = 0;
/*this.propertyList.get("last-line-end-indent").getLength().mvalue(); */
props.textAlign = this.propertyList.get(PR_TEXT_ALIGN).getEnum();
diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
index 3e51896be..903e3d360 100644
--- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -51,18 +51,16 @@
package org.apache.fop.fo.flow;
// XML
-import org.xml.sax.Attributes;
+import java.awt.geom.Rectangle2D;
-// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
-import org.apache.fop.fo.properties.LengthProperty;
-import org.apache.fop.image.ImageFactory;
+import org.apache.fop.fo.FObj;
import org.apache.fop.image.FopImage;
-// Java
-import java.awt.geom.Rectangle2D;
+import org.apache.fop.image.ImageFactory;
+import org.xml.sax.Attributes;
/**
* External graphic formatting object.
@@ -104,7 +102,7 @@ public class ExternalGraphic extends FObj {
url = ImageFactory.getURL(url);
// assume lr-tb for now and just use the .optimum value of the range
- LengthProperty ipd = propertyList.get(PR_INLINE_PROGRESSION_DIMENSION).
+ Length ipd = propertyList.get(PR_INLINE_PROGRESSION_DIMENSION).
getLengthRange().getOptimum().getLength();
if (!ipd.isAuto()) {
viewWidth = ipd.getValue();
@@ -114,7 +112,7 @@ public class ExternalGraphic extends FObj {
viewWidth = ipd.getValue();
}
}
- LengthProperty bpd = propertyList.get(PR_BLOCK_PROGRESSION_DIMENSION | CP_OPTIMUM).getLength();
+ Length bpd = propertyList.get(PR_BLOCK_PROGRESSION_DIMENSION | CP_OPTIMUM).getLength();
if (!bpd.isAuto()) {
viewHeight = bpd.getValue();
} else {
@@ -129,7 +127,7 @@ public class ExternalGraphic extends FObj {
int cwidth = -1;
int cheight = -1;
- LengthProperty ch = propertyList.get(PR_CONTENT_HEIGHT).getLength();
+ Length ch = propertyList.get(PR_CONTENT_HEIGHT).getLength();
if (!ch.isAuto()) {
/*if (ch.scaleToFit()) {
if (viewHeight != -1) {
@@ -138,7 +136,7 @@ public class ExternalGraphic extends FObj {
} else {*/
cheight = ch.getValue();
}
- LengthProperty cw = propertyList.get(PR_CONTENT_WIDTH).getLength();
+ Length cw = propertyList.get(PR_CONTENT_WIDTH).getLength();
if (!cw.isAuto()) {
/*if (cw.scaleToFit()) {
if (viewWidth != -1) {
diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java
index 76a960771..39a19c61d 100644
--- a/src/java/org/apache/fop/fo/flow/TableColumn.java
+++ b/src/java/org/apache/fop/fo/flow/TableColumn.java
@@ -63,7 +63,6 @@ import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.Property;
/**
* Class modelling the fo:table-column object. See Sec. 6.7.4 of the XSL-FO
@@ -73,8 +72,7 @@ public class TableColumn extends FObj {
private ColorType backgroundColor;
- private Length columnWidthPropVal;
- private int columnWidth;
+ private Length columnWidth;
private int columnOffset;
private int numColumnsRepeated;
private int iColumnNumber;
@@ -91,27 +89,11 @@ public class TableColumn extends FObj {
/**
* @return Length object containing column width
*/
- public Length getColumnWidthAsLength() {
- return columnWidthPropVal;
- }
-
- /**
- * @return the column width (in millipoints ??)
- */
- public int getColumnWidth() {
+ public Length getColumnWidth() {
return columnWidth;
}
/**
- * Set the column width value, overriding the value from the column-width
- * Property.
- * @param columnWidth the column width value in base units (millipoints ??)
- */
- public void setColumnWidth(int columnWidth) {
- this.columnWidth = columnWidth;
- }
-
- /**
* @return column number
*/
public int getColumnNumber() {
@@ -146,15 +128,7 @@ public class TableColumn extends FObj {
this.backgroundColor =
this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
- Property prop = this.propertyList.get(PR_COLUMN_WIDTH);
- if (prop != null) {
- columnWidthPropVal = propertyList.get(PR_COLUMN_WIDTH).getLength();
-
- // This won't include resolved table-units or % values yet.
- columnWidth = columnWidthPropVal.getValue();
- } else {
- columnWidth = 300000;
- }
+ columnWidth = this.propertyList.get(PR_COLUMN_WIDTH).getLength();
// initialize id
setupID();