diff options
39 files changed, 262 insertions, 326 deletions
diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java index 29ef8a2ea..aa9ed297b 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java @@ -56,10 +56,11 @@ public class MathMLElement extends MathMLObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FONode#processNode */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + public void processNode(String elementName, Locator locator, + Attributes attlist) throws FOPException { + super.processNode(elementName, locator, attlist); createBasicDocument(); } diff --git a/examples/plan/src/org/apache/fop/plan/PlanElement.java b/examples/plan/src/org/apache/fop/plan/PlanElement.java index 8a6956d6d..071647611 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElement.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElement.java @@ -44,10 +44,11 @@ public class PlanElement extends PlanObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FONode#processNode */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + public void processNode(String elementName, Locator locator, + Attributes attlist) throws FOPException { + super.processNode(elementName, locator, attlist); createBasicDocument(); } diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index c86871253..b9a5cb213 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -229,7 +229,6 @@ public class Driver { throw new IllegalStateException("Driver already initialized"); } treeBuilder = new FOTreeBuilder(); - treeBuilder.setUserAgent(getUserAgent()); } /** @@ -511,7 +510,6 @@ public class Driver { foInputHandler.setLogger(getLogger()); - treeBuilder.setUserAgent(getUserAgent()); treeBuilder.setFOInputHandler(foInputHandler); treeBuilder.setFOTreeControl(currentDocument); diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 70f709ab5..7d293ad77 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -37,8 +37,10 @@ import org.apache.fop.apps.FOUserAgent; * */ public abstract class FONode { + /** Parent FO node */ protected FONode parent; + /** Name of the node */ protected String name; @@ -51,22 +53,14 @@ public abstract class FONode { } /** - * Sets the name of the node. - * @param str the name + * Returns the user agent for the node. + * @return FOUserAgent */ - public void setName(String str) { - name = str; + public FOUserAgent getUserAgent() { + return getFOTreeControl().getDriver().getUserAgent(); } /** - * Sets the name of the node. - * @param str the name - */ - public void setLocation(Locator locator) { - // do nothing by default - } - - /** * Returns the logger for the node. * @return the logger */ @@ -75,19 +69,16 @@ public abstract class FONode { } /** - * Returns the user agent for the node. - * @return FOUserAgent - */ - public FOUserAgent getUserAgent() { - return getFOTreeControl().getDriver().getUserAgent(); - } - - /** - * Do something with the attributes for this element + * Initialize the node with its name, location information, and attributes + * The attributes must be used immediately as the sax attributes + * will be altered for the next element. + * @param elementName element name (e.g., "fo:block") + * @param locator Locator object (ignored by default) * @param attlist Collection of attributes passed to us from the parser. * @throws FOPException for errors or inconsistencies in the attributes - */ - public void handleAttrs(Attributes attlist) throws FOPException { + */ + public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException { + this.name = elementName; } /** diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 014d51cc4..59a16095a 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -32,7 +32,6 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.ElementMapping.Maker; import org.apache.fop.fo.pagination.Root; import org.xml.sax.Attributes; @@ -65,14 +64,14 @@ public class FOTreeBuilder extends DefaultHandler { protected Set namespaces = new java.util.HashSet(); /** - * Current formatting object being handled + * The root of the formatting object tree */ - protected FONode currentFObj = null; + protected Root rootFObj = null; /** - * The root of the formatting object tree + * Current formatting object being handled */ - protected Root rootFObj = null; + protected FONode currentFObj = null; /** * The class that handles formatting and rendering to a stream @@ -80,12 +79,10 @@ public class FOTreeBuilder extends DefaultHandler { */ private FOInputHandler foInputHandler; - private FOUserAgent userAgent; - /** The FOTreeControl object managing the FO Tree that is being built */ private FOTreeControl foTreeControl; - /** The SAX locator object maneging the line and column counters */ + /** The SAX locator object managing the line and column counters */ private Locator locator; /** @@ -95,22 +92,6 @@ public class FOTreeBuilder extends DefaultHandler { setupDefaultMappings(); } - private Log getLogger() { - return log; - } - - /** - * Sets the user agent - * @param ua the user agent - */ - public void setUserAgent(FOUserAgent ua) { - userAgent = ua; - } - - private FOUserAgent getUserAgent() { - return userAgent; - } - /** * Sets the FO Tree Control for this object * @param fotc FOTreeControl instance @@ -146,7 +127,7 @@ public class FOTreeBuilder extends DefaultHandler { try { addElementMapping(str); } catch (IllegalArgumentException e) { - getLogger().warn("Error while adding element mapping", e); + log.warn("Error while adding element mapping", e); } } @@ -209,23 +190,13 @@ public class FOTreeBuilder extends DefaultHandler { } /** - * SAX Handler for the end of an element - * @see org.xml.sax.ContentHandler#endElement(String, String, String) - */ - public void endElement(String uri, String localName, String rawName) - throws SAXException { - currentFObj.end(); - currentFObj = currentFObj.getParent(); - } - - /** * SAX Handler for the start of the document * @see org.xml.sax.ContentHandler#startDocument() */ public void startDocument() throws SAXException { rootFObj = null; // allows FOTreeBuilder to be reused - if (getLogger().isDebugEnabled()) { - getLogger().debug("Building formatting object tree"); + if (log.isDebugEnabled()) { + log.debug("Building formatting object tree"); } foInputHandler.startDocument(); } @@ -237,8 +208,8 @@ public class FOTreeBuilder extends DefaultHandler { public void endDocument() throws SAXException { rootFObj = null; currentFObj = null; - if (getLogger().isDebugEnabled()) { - getLogger().debug("Parsing of document complete"); + if (log.isDebugEnabled()) { + log.debug("Parsing of document complete"); } foInputHandler.endDocument(); } @@ -249,8 +220,9 @@ public class FOTreeBuilder extends DefaultHandler { */ public void startElement(String namespaceURI, String localName, String rawName, Attributes attlist) throws SAXException { - /* the formatting object started */ - FONode fobj; + + /* the node found in the FO document */ + FONode foNode; /* the maker for the formatting object started */ ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName); @@ -258,27 +230,35 @@ public class FOTreeBuilder extends DefaultHandler { // System.out.println("found a " + fobjMaker.toString()); try { - fobj = fobjMaker.make(currentFObj); - fobj.setName(localName); - fobj.setLocation(locator); - fobj.handleAttrs(attlist); + foNode = fobjMaker.make(currentFObj); + foNode.processNode(localName, locator, attlist); } catch (FOPException e) { throw new SAXException(e); } if (rootFObj == null) { - if (!fobj.getName().equals("fo:root")) { + if (!foNode.getName().equals("fo:root")) { throw new SAXException(new FOPException("Root element must" + " be fo:root, not " - + fobj.getName())); + + foNode.getName())); } - rootFObj = (Root)fobj; + rootFObj = (Root) foNode; rootFObj.setFOTreeControl(foTreeControl); } else { - currentFObj.addChild(fobj); + currentFObj.addChild(foNode); } - currentFObj = fobj; + currentFObj = foNode; + } + + /** + * SAX Handler for the end of an element + * @see org.xml.sax.ContentHandler#endElement(String, String, String) + */ + public void endElement(String uri, String localName, String rawName) + throws SAXException { + currentFObj.end(); + currentFObj = currentFObj.getParent(); } /** @@ -299,8 +279,8 @@ public class FOTreeBuilder extends DefaultHandler { } if (fobjMaker == null) { - if (getLogger().isWarnEnabled()) { - getLogger().warn("Unknown formatting object " + namespaceURI + "^" + localName); + if (log.isWarnEnabled()) { + log.warn("Unknown formatting object " + namespaceURI + "^" + localName); } if (namespaces.contains(namespaceURI.intern())) { // fall back @@ -350,7 +330,7 @@ class Service { } String serviceFile = "META-INF/services/" + cls.getName(); - // getLogger().debug("File: " + serviceFile); + // log.debug("File: " + serviceFile); List lst = (List)providerMap.get(serviceFile); if (lst != null) { @@ -370,7 +350,7 @@ class Service { while (e.hasMoreElements()) { try { java.net.URL u = (java.net.URL)e.nextElement(); - //getLogger().debug("URL: " + u); + //log.debug("URL: " + u); InputStream is = u.openStream(); Reader r = new InputStreamReader(is, "UTF-8"); @@ -393,7 +373,7 @@ class Service { line = br.readLine(); continue; } - // getLogger().debug("Line: " + line); + // log.debug("Line: " + line); // Try and load the class // Object obj = cl.loadClass(line).newInstance(); diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index db2bc953d..c1cc9891e 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -69,6 +69,15 @@ public class FObj extends FONode implements Constants { */ protected Map layoutDimension = null; + /** Marks input file containing this object **/ + public String systemId; + + /** Marks line number of this object in the input file **/ + public int line; + + /** Marks column number of this object in the input file **/ + public int column; + /** * Create a new formatting object. * All formatting object classes extend this class. @@ -88,39 +97,27 @@ public class FObj extends FONode implements Constants { } } - /** Marks input file containing this object **/ - public String systemId; - /** Marks line number of this object in the input file **/ - public int line; - /** Marks column number of this object in the input file **/ - public int column; - /** - * 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 + * @see org.apache.fop.fo.FONode#processNode */ - public void setName(String str) { - name = "fo:" + str; - } + public void processNode(String elementName, Locator locator, + Attributes attlist) throws FOPException { + name = "fo:" + elementName; - public void setLocation(Locator locator) { if (locator != null) { line = locator.getLineNumber(); column = locator.getColumnNumber(); systemId = locator.getSystemId(); } + + addProperties(attlist); } - + /** - * Handle the attributes for this element. - * The attributes must be used immediately as the sax attributes - * will be altered for the next element. + * Set properties for this FO based on node attributes * @param attlist Collection of attributes passed to us from the parser. - * @throws FOPException for invalid FO data */ - public void handleAttrs(Attributes attlist) throws FOPException { + protected void addProperties(Attributes attlist) throws FOPException { FObj parentFO = findNearestAncestorFObj(); PropertyList parentPropertyList = null; if (parentFO != null) { @@ -135,6 +132,24 @@ public class FObj extends FONode implements Constants { } /** + * 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; + } + + public void setLocation(Locator locator) { + if (locator != null) { + line = locator.getLineNumber(); + column = locator.getColumnNumber(); + systemId = locator.getSystemId(); + } + } + + /** * Find the nearest parent, grandparent, etc. FONode that is also an FObj * @return FObj the nearest ancestor FONode that is an FObj */ diff --git a/src/java/org/apache/fop/fo/XMLElement.java b/src/java/org/apache/fop/fo/XMLElement.java index 50cabbbb8..2d5b84b00 100644 --- a/src/java/org/apache/fop/fo/XMLElement.java +++ b/src/java/org/apache/fop/fo/XMLElement.java @@ -20,6 +20,7 @@ package org.apache.fop.fo; // XML import org.xml.sax.Attributes; +import org.xml.sax.Locator; // FOP import org.apache.fop.apps.FOPException; @@ -41,13 +42,11 @@ public class XMLElement extends XMLObj { } /** - * Process the attributes for this element. - * @param attlist the attribute list for this element returned by the SAX - * parser - * @throws FOPException for invalid attributes + * @see org.apache.fop.fo.FONode#processNode */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + public void processNode(String elementName, Locator locator, + Attributes attlist) throws FOPException { + super.processNode(elementName, locator, attlist); init(); } diff --git a/src/java/org/apache/fop/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index 574b8c9fa..91baef3fe 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.java @@ -39,8 +39,10 @@ public abstract class XMLObj extends FONode { // temp reference for attributes private Attributes attr = null; + /** DOM element representing this node */ protected Element element; + /** DOM document containing this node */ protected Document doc; @@ -53,18 +55,10 @@ public abstract class XMLObj extends FONode { } /** - * @param str name of the element - */ - public void setName(String str) { - name = str; - } - - /** - * Store the attributes for this element - * @param attlist Collection of attributes passed to us from the parser. - * @throws FOPException for errors in the attributes + * @see org.apache.fop.fo.FONode#processNode */ - public void handleAttrs(Attributes attlist) throws FOPException { + public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException { + name = elementName; attr = attlist; } diff --git a/src/java/org/apache/fop/fo/extensions/Outline.java b/src/java/org/apache/fop/fo/extensions/Outline.java index c9282a1f4..548ee0c05 100644 --- a/src/java/org/apache/fop/fo/extensions/Outline.java +++ b/src/java/org/apache/fop/fo/extensions/Outline.java @@ -48,13 +48,12 @@ public class Outline extends ExtensionObj { } /** - * The attribues on the outline object are the internal and external + * The attributes on the outline object are the internal and external * destination. One of these is required. * - * @param attlist the attribute list - * @throws FOPException a fop exception if there is an error + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { + protected void addProperties(Attributes attlist) throws FOPException { internalDestination = attlist.getValue("internal-destination"); externalDestination = diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java index 693a25628..812e83a82 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java @@ -30,6 +30,7 @@ import org.apache.batik.dom.util.XMLSupport; import org.w3c.dom.Element; import org.w3c.dom.svg.SVGDocument; import org.xml.sax.Attributes; +import org.xml.sax.Locator; import org.apache.batik.bridge.UnitProcessor; import org.apache.batik.util.SVGConstants; @@ -58,12 +59,11 @@ public class SVGElement extends SVGObj { } /** - * Handle the xml attributes from SAX. - * @param attlist the attribute list - * @throws FOPException not thrown from here + * @see org.apache.fop.fo.FONode#processNode */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + public void processNode(String elementName, Locator locator, + Attributes attlist) throws FOPException { + super.processNode(elementName, locator, attlist); init(); } diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 9fa3c2997..a541ac27f 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -49,6 +49,14 @@ public class BasicLink extends Inline { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().startLink(this); + } + public void setup() { String destination; int linkType; @@ -130,15 +138,6 @@ public class BasicLink extends Inline { } /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().startLink(this); - } - - /** * @see org.apache.fop.fo.FONode#end */ public void end() { diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 72d651b8d..bd99ced06 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -96,10 +96,10 @@ public class Block extends FObjMixed { } /** - * @see org.apache.fop.fo.FObj#handleAttrs + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); this.span = this.propertyList.get(PR_SPAN).getEnum(); this.wsTreatment = this.propertyList.get(PR_WHITE_SPACE_TREATMENT).getEnum(); diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 4964bd128..1d8e8e90f 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -57,10 +57,10 @@ public class BlockContainer extends FObj { } /** - * @see org.apache.fop.fo.FObj#handleAttrs + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); this.span = this.propertyList.get(PR_SPAN).getEnum(); setupID(); } diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 9ff80787e..842be7641 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -59,6 +59,14 @@ public class ExternalGraphic extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().image(this); + } + + /** * Setup this image. * This gets the sizes for the image and the dimensions and clipping. */ @@ -234,12 +242,4 @@ public class ExternalGraphic extends FObj { return placement; } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().image(this); - } } diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index ffb45c465..136e15363 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -44,6 +44,14 @@ public class Footnote extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().startFootnote(this); + } + + /** * @param child child FONode to be added to this object */ public void addChild(FONode child) { @@ -69,18 +77,8 @@ public class Footnote extends FObj { fotv.serveFootnote(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().startFootnote(this); - } - protected void end() { super.end(); - getFOTreeControl().getFOInputHandler().endFootnote(this); } } diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index 562f26759..162a1bcec 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java @@ -47,19 +47,18 @@ public class FootnoteBody extends FObj { super(parent); } - public void acceptVisitor(FOTreeVisitor fotv) { - fotv.serveFootnoteBody(this); - } - /** - * @see org.apache.fop.fo.FObj#handleAttrs + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); getFOTreeControl().getFOInputHandler().startFootnoteBody(this); } + public void acceptVisitor(FOTreeVisitor fotv) { + fotv.serveFootnoteBody(this); + } + protected void end() { super.end(); diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 1d99bceb4..1441e0396 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -56,10 +56,10 @@ public class Inline extends FObjMixed { } /** - * @see org.apache.fop.fo.FObj#handleAttrs + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (parent.getName().equals("fo:flow")) { throw new FOPException("inline formatting objects cannot" diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index eb2901344..2889034d0 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java @@ -45,10 +45,10 @@ public class InlineContainer extends FObj { } /** - * @see org.apache.fop.fo.FObj#handleAttrs + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); // Common Border, Padding, and Background Properties CommonBorderAndPadding bap = propMgr.getBorderAndPadding(); CommonBackground bProps = propMgr.getBackgroundProps(); diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index 11ee08e44..b0fd8c4b6 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -59,6 +59,14 @@ public class ListBlock extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().startList(this); + } + private void setup() throws FOPException { // Common Accessibility Properties @@ -128,15 +136,6 @@ public class ListBlock extends FObj { fotv.serveListBlock(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().startList(this); - } - protected void end() { super.end(); diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index c3f8c0b83..69f2a9c29 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -59,6 +59,14 @@ public class ListItem extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().startListItem(this); + } + private void setup() { // Common Accessibility Properties @@ -138,18 +146,8 @@ public class ListItem extends FObj { fotv.serveListItem(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().startListItem(this); - } - protected void end() { super.end(); - getFOTreeControl().getFOInputHandler().endListItem(this); } } diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index 666f3a089..c04dece44 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java @@ -41,6 +41,14 @@ public class ListItemLabel extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + getFOTreeControl().getFOInputHandler().startListLabel(); + } + private void setup() { // Common Accessibility Properties @@ -75,15 +83,6 @@ public class ListItemLabel extends FObj { fotv.serveListItemLabel(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - getFOTreeControl().getFOInputHandler().startListLabel(); - } - protected void end() { super.end(); diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index f6ff69af4..81e681650 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -46,16 +46,10 @@ public class Marker extends FObjMixed { } /** - * Handle the attributes for this marker. - * This gets the marker-class-name and attempts to add itself - * to the parent formatting object. - * - * @param attlist the attribute list - * @throws FOPException if there is an exception + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); this.markerClassName = this.propertyList.get(PR_MARKER_CLASS_NAME).getString(); } diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 1d758436b..b092cf75c 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -55,6 +55,15 @@ public class PageNumber extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + setup(); + getFOTreeControl().getFOInputHandler().startPageNumber(this); + } + public void setup() { // Common Accessibility Properties @@ -119,17 +128,6 @@ public class PageNumber extends FObj { fotv.servePageNumber(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - setup(); - - getFOTreeControl().getFOInputHandler().startPageNumber(this); - } - protected void end() { getFOTreeControl().getFOInputHandler().endPageNumber(this); } diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java index a18e01e05..826a6faf9 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java @@ -46,12 +46,10 @@ public class RetrieveMarker extends FObjMixed { } /** - * Handle the attributes for the retrieve-marker. - * - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); this.retrieveClassName = this.propertyList.get(PR_RETRIEVE_CLASS_NAME).getString(); this.retrievePosition = diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index b0ce8d664..8c81cf796 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -76,6 +76,15 @@ public class Table extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + setupID(); + getFOTreeControl().getFOInputHandler().startTable(this); + } + + /** * Overrides FObj. * @param child FONode child object to be added */ @@ -193,17 +202,6 @@ public class Table extends FObj { fotv.serveTable(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - setupID(); - - getFOTreeControl().getFOInputHandler().startTable(this); - } - protected void end() { getFOTreeControl().getFOInputHandler().endTable(this); } diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index addc5ad95..23b02e2ec 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -51,6 +51,15 @@ public class TableBody extends FObj { super(parent); } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + setupID(); + getFOTreeControl().getFOInputHandler().startBody(this); + } + private void setup() throws FOPException { // Common Accessibility Properties CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); @@ -94,17 +103,6 @@ public class TableBody extends FObj { fotv.serveTableBody(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - setupID(); - - getFOTreeControl().getFOInputHandler().startBody(this); - } - protected void end() { getFOTreeControl().getFOInputHandler().endBody(this); } diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index f58a6f12f..a63eedd79 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -118,14 +118,11 @@ public class TableCell extends FObj { } /** - * Overriden from FObj. - * @param attlist Collection of attributes passed to us from the parser. - * @throws FOPException for FO errors + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); doSetup(); // init some basic property values - getFOTreeControl().getFOInputHandler().startCell(this); } diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java index 7003bc4d7..067aec266 100644 --- a/src/java/org/apache/fop/fo/flow/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/TableColumn.java @@ -55,6 +55,15 @@ public class TableColumn extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + initialize(); // init some basic property values + getFOTreeControl().getFOInputHandler().startColumn(this); + } + + /** * @return Length object containing column width */ public Length getColumnWidth() { @@ -114,18 +123,6 @@ public class TableColumn extends FObj { fotv.serveTableColumn(this); } - /** - * Overriden from FObj. - * @param attlist Collection of attributes passed to us from the parser. - * @throws FOPException for FO errors - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - initialize(); // init some basic property values - - getFOTreeControl().getFOInputHandler().startColumn(this); - } - protected void end() { getFOTreeControl().getFOInputHandler().endColumn(this); } diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index b470ebe60..fabde75a0 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -63,6 +63,15 @@ public class TableRow extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); + setupID(); + getFOTreeControl().getFOInputHandler().startRow(this); + } + + /** * @return keepWithPrevious */ public KeepValue getKeepWithPrevious() { @@ -135,17 +144,6 @@ public class TableRow extends FObj { fotv.serveTableRow(this); } - /** - * @see org.apache.fop.fo.FObj#handleAttrs - */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - - setupID(); - - getFOTreeControl().getFOInputHandler().startRow(this); - } - protected void end() { getFOTreeControl().getFOInputHandler().endRow(this); } diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index acbcc8a0a..b98276462 100644 --- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -53,10 +53,10 @@ public class ConditionalPageMasterReference extends FObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (getProperty(PR_MASTER_REFERENCE) != null) { setMasterName(getProperty(PR_MASTER_REFERENCE).getString()); } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 670bcc736..e46eb8201 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -63,12 +63,10 @@ public class Flow extends FObj { } /** - * @see org.apache.fop.fo.FObj#handleAttrs - * @param attlist Collection of attributes passed to us from the parser. - * @throws FOPException if parent is not a page-sequence object + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (parent.getName().equals("fo:page-sequence")) { this.pageSequence = (PageSequence) parent; } else { diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 4ad02daab..afa039b4a 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -53,10 +53,10 @@ public class LayoutMasterSet extends FObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (parent.getName().equals("fo:root")) { Root root = (Root)parent; diff --git a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java index 302ae987e..409bb92c2 100644 --- a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java @@ -44,10 +44,10 @@ public abstract class PageMasterReference extends FObj } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (getProperty(PR_MASTER_REFERENCE) != null) { this.masterName = getProperty(PR_MASTER_REFERENCE).getString(); } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index c89967b3c..5bc84706f 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -130,16 +130,10 @@ public class PageSequence extends FObj { } /** - * Handle the attributes for this xml element. - * For the page sequence this gets all the appropriate properties - * for dealing with the page sequence. - * - * @param attlist the attribute list - * @throws FOPException if there is an error with the properties + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (parent.getName().equals("fo:root")) { this.root = (Root)parent; // this.root.addPageSequence(this); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index e3a21337a..199ff0fb3 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -59,13 +59,11 @@ public class PageSequenceMaster extends FObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); subSequenceSpecifiers = new java.util.ArrayList(); - if (parent.getName().equals("fo:layout-master-set")) { this.layoutMasterSet = (LayoutMasterSet)parent; masterName = this.propertyList.get(Constants.PR_MASTER_NAME).getString(); diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index bccd5402f..1540682a5 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -62,10 +62,10 @@ public abstract class Region extends FObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); // regions may have name, or default if (null == this.propertyList.get(PR_REGION_NAME)) { diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 67dba300f..2d1f54819 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -58,11 +58,10 @@ public class RepeatablePageMasterAlternatives extends FObj } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); conditionalPageMasterRefs = new ArrayList(); if (parent.getName().equals("fo:page-sequence-master")) { diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index c012a21c1..c75be5b16 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -49,11 +49,10 @@ public class RepeatablePageMasterReference extends PageMasterReference } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); String mr = getProperty(PR_MAXIMUM_REPEATS).getString(); if (mr.equals("no-limit")) { this.maximumRepeats = INFINITE; diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index 542a91261..73b484652 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -53,10 +53,10 @@ public class SimplePageMaster extends FObj { } /** - * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + * @see org.apache.fop.fo.FObj#addProperties */ - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); + protected void addProperties(Attributes attlist) throws FOPException { + super.addProperties(attlist); if (parent.getName().equals("fo:layout-master-set")) { LayoutMasterSet layoutMasterSet = (LayoutMasterSet)parent; |