gmazza 2004/05/23 10:00:00 Modified: src/java/org/apache/fop/fo FObj.java PropertyManager.java src/java/org/apache/fop/fo/pagination RegionBody.java src/java/org/apache/fop/fo/properties PropertyMaker.java src/java/org/apache/fop/render/rtf TableAttributesConverter.java Log: Reverted part of yesterday's work to make FObj simpler, added more commenting in FObj. Revision Changes Path 1.40 +52 -106 xml-fop/src/java/org/apache/fop/fo/FObj.java Index: FObj.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- FObj.java 22 May 2004 21:44:37 -0000 1.39 +++ FObj.java 23 May 2004 17:00:00 -0000 1.40 @@ -37,36 +37,25 @@ */ public class FObj extends FONode implements Constants { private static final String FO_URI = "http://www.w3.org/1999/XSL/Format"; + public static PropertyMaker[] propertyListTable = null; - /** - * Formatting properties for this fo element. - */ + /** Formatting properties for this fo element. */ protected PropertyList propertyList; - /** - * Property manager for handling some common properties. - */ + /** Property manager for providing refined properties/traits. */ protected PropertyManager propMgr; - /** - * Id of this fo element of null if no id. - */ + /** Id of this fo element of null if no id. */ protected String id = null; - /** - * The children of this node. - */ + /** The children of this node. */ public ArrayList children = null; - /** - * Markers added to this element. - */ + /** Markers added to this element. */ protected Map markers = null; - /** - * Dynamic layout dimension. Used to resolve relative lengths. - */ + /** Dynamic layout dimension. Used to resolve relative lengths. */ protected Map layoutDimension = null; /** Marks input file containing this object **/ @@ -102,15 +91,30 @@ */ public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException { - name = "fo:" + elementName; + setName(elementName); + setLocation(locator); + addProperties(attlist); + } + /** + * Set the name of this element. + * The prepends "fo:" to the name to indicate it is in the fo namespace. + * @param str the xml element name + */ + public void setName(String str) { + name = "fo:" + str; + } + + /** + * Set the location information for this element + * @param locator the org.xml.sax.Locator object + */ + public void setLocation(Locator locator) { if (locator != null) { line = locator.getLineNumber(); column = locator.getColumnNumber(); systemId = locator.getSystemId(); } - - addProperties(attlist); } /** @@ -119,34 +123,44 @@ */ protected void addProperties(Attributes attlist) throws FOPException { FObj parentFO = findNearestAncestorFObj(); - PropertyList parentPropertyList = null; + PropertyList parentPL = null; + if (parentFO != null) { - parentPropertyList = parentFO.getPropertiesForNamespace(FO_URI); + parentPL = parentFO.getPropertiesForNamespace(FO_URI); } - propertyList = new PropertyList(this, parentPropertyList, FO_URI, - name); + propertyList = new PropertyList(this, parentPL, FO_URI, name); propertyList.addAttributesToList(attlist); - this.propMgr = makePropertyManager(propertyList); + propMgr = new PropertyManager(propertyList); setWritingMode(); } /** - * Set the name of this element. - * The prepends "fo:" to the name to indicate it is in the fo namespace. - * - * @param str the xml element name + * Return the PropertyManager object for this FO. PropertyManager + * tends to hold the traits for this FO, and is primarily used in layout. + * @return the property manager for this FO */ - public void setName(String str) { - name = "fo:" + str; + public PropertyManager getPropertyManager() { + return propMgr; } - public void setLocation(Locator locator) { - if (locator != null) { - line = locator.getLineNumber(); - column = locator.getColumnNumber(); - systemId = locator.getSystemId(); - } + /** + * Return the property list object for this FO. PropertyList tends + * to hold the base, pre-trait properties for this FO, either explicitly + * declared in the input XML or from inherited values. + */ + public PropertyList getPropertyList() { + return propertyList; + } + + /** + * Helper method to quickly obtain the value of a property + * for this FO, without querying for the propertyList first. + * @param name - the name of the desired property to obtain + * @return the property + */ + public Property getProperty(int propId) { + return propertyList.get(propId); } /** @@ -216,15 +230,6 @@ return this.propertyList; } - /** - * @param propertyList the collection of Property objects to be managed - * @return a PropertyManager for the Property objects - */ - protected PropertyManager makePropertyManager( - PropertyList propertyList) { - return new PropertyManager(propertyList); - } - /* This section is the implemenation of the property context. */ /** @@ -286,57 +291,6 @@ } /** - * lets outside sources access the property list - * first used by PageNumberCitation to find the "id" property - * @param name - the name of the desired property to obtain - * @return the property - */ - public Property getProperty(int 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 @@ -484,14 +438,6 @@ */ public Map getMarkers() { return markers; - } - - /** - * lets layout managers access FO properties via PropertyManager - * @return the property manager for this FO - */ - public PropertyManager getPropertyManager() { - return this.propMgr; } /** 1.26 +7 -5 xml-fop/src/java/org/apache/fop/fo/PropertyManager.java Index: PropertyManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyManager.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- PropertyManager.java 22 Apr 2004 21:38:39 -0000 1.25 +++ PropertyManager.java 23 May 2004 17:00:00 -0000 1.26 @@ -19,6 +19,7 @@ package org.apache.fop.fo; // FOP +import org.apache.fop.apps.FOPException; import org.apache.fop.fonts.Font; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.CommonBorderAndPadding; @@ -35,6 +36,7 @@ import org.apache.fop.traits.LayoutProps; // keep, break, span, space? import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fo.properties.CommonHyphenation; +import org.xml.sax.Attributes; /** * Helper class for managing groups of properties. @@ -47,6 +49,7 @@ private CommonBorderAndPadding borderAndPadding = null; private CommonHyphenation hyphProps = null; private TextInfo textInfo = null; + private static final String NONE = "none"; private static final int[] SA_BEFORE = new int[] { PR_BORDER_BEFORE_COLOR, PR_BORDER_BEFORE_STYLE, PR_BORDER_BEFORE_WIDTH, PR_PADDING_BEFORE}; @@ -57,14 +60,13 @@ private static final int[] SA_END = new int[]{ PR_BORDER_END_COLOR, PR_BORDER_END_STYLE, PR_BORDER_END_WIDTH, PR_PADDING_END}; - private static final String NONE = "none"; - /** * Main constructor - * @param pList property list + * @param propList list of properties for the FO, initialized + * from the attributes in the input source document */ - public PropertyManager(PropertyList pList) { - this.propertyList = pList; + public PropertyManager(PropertyList propList) { + propertyList = propList; } /** 1.20 +1 -1 xml-fop/src/java/org/apache/fop/fo/pagination/RegionBody.java Index: RegionBody.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/RegionBody.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- RegionBody.java 22 May 2004 21:44:37 -0000 1.19 +++ RegionBody.java 23 May 2004 17:00:00 -0000 1.20 @@ -79,7 +79,7 @@ private int getRelMargin(int reldir, int relPropId) { FObj parent = (FObj) getParent(); String sPropName = "margin-" - + parent.getAbsoluteWritingMode(reldir); + + parent.getPropertyList().getAbsoluteWritingMode(reldir); int propId = FOPropertyMapping.getPropertyId(sPropName); Property prop = propertyList.getExplicitOrShorthand(propId); if (prop == null) { 1.4 +3 -3 xml-fop/src/java/org/apache/fop/fo/properties/PropertyMaker.java Index: PropertyMaker.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/PropertyMaker.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PropertyMaker.java 27 Feb 2004 17:45:45 -0000 1.3 +++ PropertyMaker.java 23 May 2004 17:00:00 -0000 1.4 @@ -372,7 +372,7 @@ * @return The initialized Property object. * @throws FOPException for invalid or inconsistent FO input */ - public Property make(PropertyList propertyList, String value, + public Property make(PropertyList propertyList, String value, FObj fo) throws FOPException { try { Property newProp = null; @@ -383,7 +383,7 @@ newProp = checkEnumValues(value); } if (newProp == null) { - /* Check for keyword shorthand values to be substituted. */ + // Check for keyword shorthand values to be substituted. pvalue = checkValueKeywords(value); // Override parsePropertyValue in each subclass of Property.Maker Property p = PropertyParser.parse(pvalue, 1.15 +13 -8 xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java Index: TableAttributesConverter.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- TableAttributesConverter.java 22 May 2004 21:44:38 -0000 1.14 +++ TableAttributesConverter.java 23 May 2004 17:00:00 -0000 1.15 @@ -34,6 +34,7 @@ import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; import org.apache.fop.datatypes.ColorType; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; @@ -115,7 +116,9 @@ Property p; EnumProperty ep; RtfColorTable colorTable = RtfColorTable.getInstance(); - + PropertyList propList = fobj.getPropertyList(); + + RtfAttributes attrib = null; attrib = new RtfAttributes(); @@ -123,7 +126,8 @@ boolean isBorderPresent = false; // Cell background color - if ((p = fobj.getNearestSpecifiedProperty(Constants.PR_BACKGROUND_COLOR)) != null) { + if ((p = propList.getNearestSpecified( + Constants.PR_BACKGROUND_COLOR)) != null) { ColorType color = p.getColorType(); if (color != null) { if (color.getAlpha() != 0 @@ -141,7 +145,7 @@ } // Cell borders : - if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_COLOR)) != null) { + if ((p = propList.getExplicit(Constants.PR_BORDER_COLOR)) != null) { ListProperty listprop = (ListProperty) p; ColorType color = null; if (listprop.getList().get(0) instanceof NCnameProperty) { @@ -155,28 +159,29 @@ colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), (int)color.getBlue()).intValue()); } - if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_TOP_COLOR)) != null) { + if ((p = propList.getExplicit( + Constants.PR_BORDER_TOP_COLOR)) != null) { ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), (int)color.getBlue()).intValue()); } - if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_BOTTOM_COLOR)) != null) { + if ((p = propList.getExplicit(Constants.PR_BORDER_BOTTOM_COLOR)) != null) { ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), (int)color.getBlue()).intValue()); } - if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_LEFT_COLOR)) != null) { + if ((p = propList.getExplicit(Constants.PR_BORDER_LEFT_COLOR)) != null) { ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR, colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(), (int)color.getBlue()).intValue()); } - if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_RIGHT_COLOR)) != null) { + if ((p = propList.getExplicit(Constants.PR_BORDER_RIGHT_COLOR)) != null) { ColorType color = p.getColorType(); attrib.set( BorderAttributesConverter.BORDER_COLOR,
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]