*/
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 **/
*/
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);
}
/**
*/
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);
}
/**
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. */
/**
}
}
- /**
- * 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.
return markers;
}
- /**
- * lets layout managers access FO properties via PropertyManager
- * @return the property manager for this FO
- */
- public PropertyManager getPropertyManager() {
- return this.propMgr;
- }
-
/**
* This is a hook for an FOTreeVisitor subclass to be able to access
* this object.
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;
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.
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};
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;
}
/**
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;
Property p;
EnumProperty ep;
RtfColorTable colorTable = RtfColorTable.getInstance();
-
+ PropertyList propList = fobj.getPropertyList();
+
+
RtfAttributes attrib = null;
attrib = new RtfAttributes();
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
}
// 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) {
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,