diff options
author | Glen Mazza <gmazza@apache.org> | 2004-05-22 21:44:38 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-05-22 21:44:38 +0000 |
commit | 63afbbbd99eced56126e226e117f33652d8067b4 (patch) | |
tree | 5034fc18f721ed36ca773f5c0555a0ec3cba2d82 /src/java/org/apache/fop/fo | |
parent | 579ea70d54fbd5a82bc0afe59686c57dae37bc6c (diff) | |
download | xmlgraphics-fop-63afbbbd99eced56126e226e117f33652d8067b4.tar.gz xmlgraphics-fop-63afbbbd99eced56126e226e117f33652d8067b4.zip |
PR:
Obtained from:
Submitted by:
Reviewed by:
Made propertyList member variable of fo.FObj protected (instead of public).
Property value queries routed through FObj instead of PropertyList.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo')
8 files changed, 87 insertions, 41 deletions
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index c1cc9891e..cec89be12 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -42,7 +42,7 @@ public class FObj extends FONode implements Constants { /** * Formatting properties for this fo element. */ - public PropertyList propertyList; + protected PropertyList propertyList; /** * Property manager for handling some common properties. @@ -292,10 +292,51 @@ public class FObj extends FONode implements Constants { * @return the property */ public Property getProperty(int propId) { - return (propertyList.get(propId)); + return propertyList.get(propId); } /** + * Return the "nearest" specified value for the given property. + * Implements the from-nearest-specified-value function. + * @param propertyName The name of the property whose value is desired. + * @return The computed value if the property is explicitly set on some + * ancestor of the current FO, else the initial value. + */ + public Property getNearestSpecifiedProperty(int propId) { + return propertyList.getNearestSpecified(propId); + } + + /** + * Return the value explicitly specified on this FO. + * @param propertyName The name of the property whose value is desired. + * It may be a compound name, such as space-before.optimum. + * @return The value if the property is explicitly set, otherwise null. + */ + public Property getExplicitProperty(int propId) { + return propertyList.getExplicit(propId); + } + + /** + * Uses the stored writingMode. + * @param absdir an absolute direction (top, bottom, left, right) + * @return the corresponding writing model relative direction name + * for the flow object. + */ + public int getWritingMode(int lrtb, int rltb, int tbrl) { + return propertyList.getWritingMode(lrtb, rltb, tbrl); + } + + + /** + * Uses the stored writingMode. + * @param relativeWritingMode relative direction (start, end, before, after) + * @return the corresponding absolute direction name for the flow object. + */ + public String getAbsoluteWritingMode(int relativeWritingMode) { + return propertyList.getAbsoluteWritingMode(relativeWritingMode); + } + + /** * Setup the id for this formatting object. * Most formatting objects can have an id that can be referenced. * This methods checks that the id isn't already used by another diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index 373dca8be..d5421c085 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -33,9 +33,11 @@ import org.apache.fop.fo.properties.PropertyMaker; public class PropertyList extends HashMap { // writing-mode values - private byte[] wmtable = null; + private byte[] writingModeTable = null; + // writing-mode index private int writingMode; + private static boolean[] inheritableProperty; // absolute directions and dimensions @@ -66,11 +68,11 @@ public class PropertyList extends HashMap { /** constant for dimension "inline-progression-dimension" */ public static final int INLINEPROGDIM = 5; - private static final String[] ABS_NAMES = new String[] { + private static final String[] ABS_WM_NAMES = new String[] { "left", "right", "top", "bottom", "height", "width" }; - private static final String[] REL_NAMES = new String[] { + private static final String[] REL_WM_NAMES = new String[] { "start", "end", "before", "after", "block-progression-dimension", "inline-progression-dimension" }; @@ -307,16 +309,25 @@ public class PropertyList extends HashMap { } /** + * Set the writing mode traits for the FO with this property list. + * @param writingMode the writing-mode property to be set for this object + */ + public void setWritingMode(int writingMode) { + this.writingMode = writingMode; + this.writingModeTable = (byte[])WRITING_MODE_TABLES.get(new Integer(writingMode)); + } + + /** * Uses the stored writingMode. * @param absdir an absolute direction (top, bottom, left, right) * @return the corresponding writing model relative direction name * for the flow object. */ - public int wmMap(int lrtb, int rltb, int tbrl) { + public int getWritingMode(int lrtb, int rltb, int tbrl) { switch (writingMode) { - case Constants.WritingMode.LR_TB: return lrtb; - case Constants.WritingMode.RL_TB: return rltb; - case Constants.WritingMode.TB_RL: return tbrl; + case Constants.WritingMode.LR_TB: return lrtb; + case Constants.WritingMode.RL_TB: return rltb; + case Constants.WritingMode.TB_RL: return tbrl; } return -1; } @@ -324,14 +335,14 @@ public class PropertyList extends HashMap { /** * Uses the stored writingMode. - * @param reldir a writing mode relative direction (start, end, before, after) + * @param relativeWritingMode relative direction (start, end, before, after) * @return the corresponding absolute direction name for the flow object. */ - public String wmRelToAbs(int reldir) { - if (wmtable != null) { - for (int i = 0; i < wmtable.length; i++) { - if (wmtable[i] == reldir) { - return ABS_NAMES[i]; + public String getAbsoluteWritingMode(int relativeWritingMode) { + if (writingModeTable != null) { + for (int i = 0; i < writingModeTable.length; i++) { + if (writingModeTable[i] == relativeWritingMode) { + return ABS_WM_NAMES[i]; } } } @@ -339,15 +350,6 @@ public class PropertyList extends HashMap { } /** - * Set the writing mode traits for the FO with this property list. - * @param writingMode the writing-mode property to be set for this object - */ - public void setWritingMode(int writingMode) { - this.writingMode = writingMode; - this.wmtable = (byte[])WRITING_MODE_TABLES.get(new Integer(writingMode)); - } - - /** * * @param attributes Collection of attributes passed to us from the parser. * @throws FOPException If an error occurs while building the PropertyList diff --git a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java index 23ad8d6df..f58b17718 100644 --- a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java +++ b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java @@ -58,7 +58,7 @@ public class BodyStartFunction extends FunctionBase { } Numeric startIndent = - ((ListItem)item).propertyList.get(Constants.PR_START_INDENT).getNumeric(); + ((ListItem)item).getProperty(Constants.PR_START_INDENT).getNumeric(); return (Property) NumericOp.addition(distance, startIndent); } diff --git a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java index 06c9d8327..5e88418e2 100644 --- a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java @@ -63,7 +63,7 @@ public class LabelEndFunction extends FunctionBase { if (item == null) { throw new PropertyException("label-end() called from outside an fo:list-item"); } - Length startIndent = ((ListItem)item).propertyList.get(Constants.PR_START_INDENT).getLength(); + Length startIndent = ((ListItem)item).getProperty(Constants.PR_START_INDENT).getLength(); // Should be CONTAINING_REFAREA but that doesn't work LengthBase base = new LengthBase((ListItem)item, pInfo.getPropertyList(), diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 6de00eb60..cb7de1642 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -79,7 +79,7 @@ public class RegionBody extends Region { private int getRelMargin(int reldir, int relPropId) { FObj parent = (FObj) getParent(); String sPropName = "margin-" - + parent.propertyList.wmRelToAbs(reldir); + + parent.getAbsoluteWritingMode(reldir); int propId = FOPropertyMapping.getPropertyId(sPropName); Property prop = propertyList.getExplicitOrShorthand(propId); if (prop == null) { diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java index ee202e9ff..9d0292668 100644 --- a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java @@ -69,19 +69,21 @@ public class CorrespondingPropertyMaker { * direction has been specified in the input properties */ public boolean isCorrespondingForced(PropertyList propertyList) { + if (!relative) { return false; } - PropertyList pList; - if (useParent) { - pList = propertyList.getParentFObj().propertyList; + + PropertyList pList = (useParent) ? propertyList.getParentPropertyList() : + propertyList; + + int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); + + if (pList.getExplicit(correspondingId) != null) { + return true; } else { - pList = propertyList; + return false; } - int correspondingId = pList.wmMap(lr_tb, rl_tb, tb_rl); - if (propertyList.getExplicit(correspondingId) != null) - return true; - return false; } /** @@ -104,7 +106,7 @@ public class CorrespondingPropertyMaker { } else { pList = propertyList; } - int correspondingId = pList.wmMap(lr_tb, rl_tb, tb_rl); + int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); Property p = propertyList.getExplicitOrShorthand(correspondingId); if (p != null) { diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index 43c04ce56..c228f256c 100644 --- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java @@ -58,7 +58,7 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { } // Based on min-[width|height] - int wmcorr = propertyList.wmMap(extraCorresponding[0][0], + int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0], extraCorresponding[0][1], extraCorresponding[0][2]); Property subprop = propertyList.getExplicitOrShorthand(wmcorr); @@ -67,7 +67,7 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { } // Based on max-[width|height] - wmcorr = propertyList.wmMap(extraCorresponding[1][0], + wmcorr = propertyList.getWritingMode(extraCorresponding[1][0], extraCorresponding[1][1], extraCorresponding[1][2]); subprop = propertyList.getExplicitOrShorthand(wmcorr); diff --git a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java index 3ed94be69..cd04c0ebf 100644 --- a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java @@ -70,7 +70,8 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { */ public Property compute(PropertyList propertyList) throws FOPException { // TODO: bckfnn reenable - if (propertyList.getExplicitOrShorthand(propertyList.wmMap(lr_tb, rl_tb, tb_rl)) == null) { + if (propertyList.getExplicitOrShorthand( + propertyList.getWritingMode(lr_tb, rl_tb, tb_rl)) == null) { return null; } // Calculate the values as described in 5.3.2. @@ -82,7 +83,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { v = v.add(propertyList.getInherited(propName).getNumeric()); } */ - v = NumericOp.addition(v, propertyList.get(propertyList.wmMap(lr_tb, rl_tb, tb_rl)).getNumeric()); + v = NumericOp.addition(v, propertyList.get(propertyList.getWritingMode(lr_tb, rl_tb, tb_rl)).getNumeric()); v = NumericOp.addition(v, getCorresponding(paddingCorresponding, propertyList).getNumeric()); v = NumericOp.addition(v, getCorresponding(borderWidthCorresponding, propertyList).getNumeric()); return (Property) v; @@ -94,7 +95,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { } private Property getCorresponding(int[] corresponding, PropertyList propertyList) { - int wmcorr = propertyList.wmMap(corresponding[0], corresponding[1], corresponding[2]); + int wmcorr = propertyList.getWritingMode(corresponding[0], corresponding[1], corresponding[2]); return propertyList.get(wmcorr); } } |