import java.awt.geom.Point2D;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
* @see org.apache.fop.fo.FONode#processNode
*/
public void processNode(String elementName, Locator locator,
- Attributes attlist) throws SAXParseException {
- super.processNode(elementName, locator, attlist);
+ Attributes attlist, PropertyList propertyList)
+ throws SAXParseException
+ {
+ super.processNode(elementName, locator, attlist, propertyList);
createBasicDocument();
}
* @param attlist Collection of attributes passed to us from the parser.
* @throws SAXParseException for errors or inconsistencies in the attributes
*/
- public void processNode(String elementName, Locator locator, Attributes attlist) throws SAXParseException {
+ public void processNode(String elementName, Locator locator,
+ Attributes attlist, PropertyList parent) throws SAXParseException {
System.out.println("name = " + elementName);
}
* @param locator location in fo source file.
*/
protected void addCharacters(char data[], int start, int length,
+ PropertyList pList,
Locator locator) throws SAXParseException {
// ignore
}
*/
protected FONode currentFObj = null;
+ /**
+ * Current propertyList for the node being handled.
+ */
+ protected PropertyList currentPropertyList;
+
/**
* The class that handles formatting and rendering to a stream
* (mark-fop@inomial.com)
public void characters(char[] data, int start, int length)
throws SAXParseException {
if (currentFObj != null) {
- currentFObj.addCharacters(data, start, start + length, locator);
+ currentFObj.addCharacters(data, start, start + length, currentPropertyList, locator);
}
}
/* the node found in the FO document */
FONode foNode;
+ PropertyList propertyList;
// Check to ensure first node encountered is an fo:root
if (rootFObj == null) {
try {
foNode = fobjMaker.make(currentFObj);
- foNode.processNode(localName, locator, attlist);
+ propertyList = foNode.createPropertyList(currentPropertyList, foEventHandler);
+ foNode.processNode(localName, locator, attlist, propertyList);
+ foNode.startOfNode();
} catch (IllegalArgumentException e) {
throw new SAXException(e);
}
}
currentFObj = foNode;
+ if (propertyList != null) {
+ currentPropertyList = propertyList;
+ }
}
/**
throw e;
}
+ if (currentPropertyList.getFObj() == currentFObj) {
+ currentPropertyList = currentPropertyList.getParentPropertyList();
+ }
currentFObj = currentFObj.getParent();
}
rootFObj = null;
foEventHandler = null;
}
-
}
// code stolen from org.apache.batik.util and modified slightly
* @see org.apache.fop.fo.FONode#processNode
*/
public void processNode(String elementName, Locator locator,
- Attributes attlist) throws SAXParseException {
+ Attributes attlist, PropertyList pList) throws SAXParseException {
setLocator(locator);
- addProperties(attlist);
+ propertyList.addAttributesToList(attlist);
+ propertyList.setWritingMode();
+ bind(propertyList);
+ propMgr = new PropertyManager(propertyList);
}
/**
*/
protected PropertyList createPropertyList(PropertyList parent, FOEventHandler foEventHandler) throws SAXParseException {
//return foEventHandler.getPropertyListMaker().make(this, parent);
- return null;
+ propertyList = new StaticPropertyList(this, parent);
+ return propertyList;
}
/**
}
}
- /**
- * Set properties for this FO based on node attributes
- * @param attlist Collection of attributes passed to us from the parser.
- */
- protected void addProperties(Attributes attlist) throws SAXParseException {
- FObj parentFO = findNearestAncestorFObj();
- PropertyList parentPL = null;
-
- if (parentFO != null) {
- parentPL = parentFO.getPropertiesForNamespace(FO_URI);
- }
-
- propertyList = new PropertyList(this, parentPL, FO_URI);
- propertyList.addAttributesToList(attlist);
- propMgr = new PropertyManager(propertyList);
- setWritingMode();
-
- // if this FO can have a PR_ID, make sure it is unique
- if (PropertySets.canHaveId(getNameId())) {
- setupID();
- }
- }
-
- /**
- * 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
- * fo and sets the id attribute of this object.
- */
- private void setupID() throws SAXParseException {
- String str = getPropString(PR_ID);
- if (str != null && !str.equals("")) {
- Set idrefs = getFOEventHandler().getIDReferences();
- if (!idrefs.contains(str)) {
- idrefs.add(str);
- } else {
- throw new SAXParseException("Property id \"" + str +
- "\" previously used; id values must be unique" +
- " in document.", locator);
- }
- }
- }
-
/**
* Returns Out Of Line FO Descendant indicator.
* @return true if Out of Line FO or Out Of Line descendant, false otherwise
return (FObj) par;
}
- /**
- * Find nearest ancestor which generates Reference Areas.
- *
- * @param includeSelf Set to true to consider the current FObj as an
- * "ancestor". Set to false to only return a true ancestor.
- * @param returnRoot Supposing a condition where no appropriate ancestor
- * FObj is found, setting returnRoot to true will return the FObj with no
- * parent (presumably the root FO). Otherwise, null will be returned.
- * Note that this will override a false setting for includeSelf, and return
- * the current node if it is the root FO. Setting returnRoot to true should
- * always return a valid FObj.
- * @return FObj of the nearest ancestor that generates Reference Areas
- * and fits the parameters.
- */
- private FObj findNearestAncestorGeneratingRAs(boolean includeSelf,
- boolean returnRoot) {
- FObj p = this;
- if (includeSelf && p.generatesReferenceAreas()) {
- return p;
- }
- FObj parent = p.findNearestAncestorFObj();
- if (parent == null && returnRoot) {
- return p;
- }
- do {
- p = parent;
- parent = p.findNearestAncestorFObj();
- } while (parent != null && !p.generatesReferenceAreas());
- if (p.generatesReferenceAreas()) {
- return p;
- }
- // if we got here, it is because parent is null
- if (returnRoot) {
- return p;
- } else {
- return null;
- }
- }
-
- /**
- * For a given namespace, determine whether the properties of this object
- * match that namespace.
- * @param nameSpaceURI the namespace URI to be tested against
- * @return this.propertyList, if the namespaces match; otherwise, null
- */
- public PropertyList getPropertiesForNamespace(String nameSpaceURI) {
- if (this.propertyList == null) {
- return null;
- }
- if (!nameSpaceURI.equals(this.propertyList.getNameSpace())) {
- return null;
- }
- return this.propertyList;
- }
-
/* This section is the implemenation of the property context. */
/**
return false;
}
- /**
- * Set writing mode for this FO.
- * Use that from the nearest ancestor, including self, which generates
- * reference areas, or from root FO if no ancestor found.
- */
- protected void setWritingMode() {
- FObj p = findNearestAncestorGeneratingRAs(true, true);
- this.propertyList.setWritingMode(
- p.getPropEnum(PR_WRITING_MODE));
- }
-
/**
* @see org.apache.fop.fo.FONode#getChildNodes()
*/
* @see XMLObj#addCharacters
*/
protected void addCharacters(char data[], int start, int length,
- Locator locator) {
+ PropertyList pList, Locator locator) {
if (doc == null) {
createBasicDocument();
}
- super.addCharacters(data, start, length, locator);
+ super.addCharacters(data, start, length, pList, locator);
}
}
* @see org.apache.fop.fo.FONode#processNode
*/
public void processNode(String elementName, Locator locator,
- Attributes attlist) throws SAXParseException {
+ Attributes attlist, PropertyList propertyList) throws SAXParseException {
setLocator(locator);
name = elementName;
attr = attlist;
* @param locator location in fo source file.
*/
protected void addCharacters(char data[], int start, int length,
- Locator locator) {
+ PropertyList pList, Locator locator) {
String str = new String(data, start, length - start);
org.w3c.dom.Text text = doc.createTextNode(str);
element.appendChild(text);
// FOP
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.svg.SVGOMElement;
* @see org.apache.fop.fo.FONode#processNode
*/
public void processNode(String elementName, Locator locator,
- Attributes attlist) throws SAXParseException {
- super.processNode(elementName, locator, attlist);
+ Attributes attlist, PropertyList propertyList) throws SAXParseException {
+ super.processNode(elementName, locator, attlist, propertyList);
init();
}