From b758fac13e887dba43e6ba9256e798abb68dd984 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Wed, 4 Aug 2004 22:21:04 +0000 Subject: [PATCH] PR: Obtained from: Submitted by: Reviewed by: Start of conversion of AddLMVisitor to FObj.AddLayoutManager(): removed acceptVisitor() methods from FO's that don't need LM's (e.g., those FO's not yet implemented or those that don't return areas anyway). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197854 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FObj.java | 10 +- .../apache/fop/fo/ToBeImplementedElement.java | 12 -- src/java/org/apache/fop/fo/Unknown.java | 12 -- src/java/org/apache/fop/fo/UnknownXMLObj.java | 11 -- src/java/org/apache/fop/fo/XMLElement.java | 13 -- src/java/org/apache/fop/fo/XMLObj.java | 13 -- .../fop/fo/extensions/svg/SVGElement.java | 6 - .../apache/fop/fo/extensions/svg/SVGObj.java | 6 - src/java/org/apache/fop/fo/flow/Float.java | 5 - .../fop/fo/flow/InitialPropertySet.java | 5 - .../org/apache/fop/fo/flow/MultiCase.java | 5 - .../apache/fop/fo/flow/MultiProperties.java | 5 - .../apache/fop/fo/flow/MultiPropertySet.java | 5 - .../org/apache/fop/fo/flow/MultiSwitch.java | 5 - .../org/apache/fop/fo/flow/MultiToggle.java | 5 - .../apache/fop/fo/flow/TableAndCaption.java | 6 - .../org/apache/fop/fo/flow/TableCaption.java | 5 - .../apache/fop/layoutmgr/AddLMVisitor.java | 172 +++--------------- 18 files changed, 32 insertions(+), 269 deletions(-) diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 3d8c69b1b..3d785d399 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -21,6 +21,7 @@ package org.apache.fop.fo; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; @@ -433,6 +434,14 @@ public class FObj extends FONode implements Constants { return markers; } + /** + * Return a LayoutManager responsible for laying out this FObj's content. + * Must override in subclasses if their content can be laid out. + * @param list the list to which the layout manager(s) should be added + */ + public void addLayoutManager(List list) { + } + /** * This is a hook for the AddLMVisitor class to be able to access * this object. @@ -442,7 +451,6 @@ public class FObj extends FONode implements Constants { aLMV.serveFObj(this); } - /* * Return a string representation of the fo element. * Deactivated in order to see precise ID of each fo element created diff --git a/src/java/org/apache/fop/fo/ToBeImplementedElement.java b/src/java/org/apache/fop/fo/ToBeImplementedElement.java index 7c77741f4..d445fe1e4 100644 --- a/src/java/org/apache/fop/fo/ToBeImplementedElement.java +++ b/src/java/org/apache/fop/fo/ToBeImplementedElement.java @@ -18,8 +18,6 @@ package org.apache.fop.fo; -import org.apache.fop.layoutmgr.AddLMVisitor; - /** * This class is a placeholder for elements that have not been implemented. */ @@ -31,14 +29,4 @@ public class ToBeImplementedElement extends FObj { protected ToBeImplementedElement(FONode parent) { super(parent); } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveToBeImplementedElement(this); - } - } diff --git a/src/java/org/apache/fop/fo/Unknown.java b/src/java/org/apache/fop/fo/Unknown.java index 2a8edee8c..e3d063a86 100644 --- a/src/java/org/apache/fop/fo/Unknown.java +++ b/src/java/org/apache/fop/fo/Unknown.java @@ -18,8 +18,6 @@ package org.apache.fop.fo; -import org.apache.fop.layoutmgr.AddLMVisitor; - /** * Class for handling an unknown element, for example one from an unsupported * namespace. @@ -53,14 +51,4 @@ public class Unknown extends FONode { private void setup() { getLogger().debug("Layout Unknown element"); } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveUnknown(this); - } - } diff --git a/src/java/org/apache/fop/fo/UnknownXMLObj.java b/src/java/org/apache/fop/fo/UnknownXMLObj.java index a64759b87..e768973c3 100644 --- a/src/java/org/apache/fop/fo/UnknownXMLObj.java +++ b/src/java/org/apache/fop/fo/UnknownXMLObj.java @@ -19,7 +19,6 @@ package org.apache.fop.fo; import org.xml.sax.Locator; -import org.apache.fop.layoutmgr.AddLMVisitor; /** * Class for handling generic XML from a namespace not recognized by FOP @@ -89,15 +88,5 @@ public class UnknownXMLObj extends XMLObj { } super.addCharacters(data, start, length, locator); } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveUnknownXMLObj(this); - } - } diff --git a/src/java/org/apache/fop/fo/XMLElement.java b/src/java/org/apache/fop/fo/XMLElement.java index accd4f45a..4f9431c3e 100644 --- a/src/java/org/apache/fop/fo/XMLElement.java +++ b/src/java/org/apache/fop/fo/XMLElement.java @@ -23,9 +23,6 @@ import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXParseException; -// FOP -import org.apache.fop.layoutmgr.AddLMVisitor; - /** * class representing svg:svg pseudo flow object. */ @@ -62,14 +59,4 @@ public class XMLElement extends XMLObj { public String getNameSpace() { return namespace; } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveXMLElement(this); - } - } diff --git a/src/java/org/apache/fop/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index f48d2077f..b87ae8dcd 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.java @@ -29,9 +29,6 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; import javax.xml.parsers.DocumentBuilderFactory; -// FOP -import org.apache.fop.layoutmgr.AddLMVisitor; - /** * Abstract class modelling generic, non-XSL-FO XML objects. Such objects are * stored in a DOM. @@ -209,15 +206,5 @@ public abstract class XMLObj extends FONode { org.w3c.dom.Text text = doc.createTextNode(str); element.appendChild(text); } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveXMLObj(this); - } - } 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 1575bacc7..67923a7af 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.extensions.svg; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.svg.SVGOMElement; @@ -282,10 +281,5 @@ public class SVGElement extends SVGObj { return 100; } } - - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveSVGElement(this); - } - } diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java b/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java index bf932df6d..0d300b9a4 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.extensions.svg; import org.apache.fop.fo.FONode; import org.apache.fop.fo.XMLObj; -import org.apache.fop.layoutmgr.AddLMVisitor; /** * Class for SVG element objects. @@ -43,10 +42,5 @@ public class SVGObj extends XMLObj { public String getNameSpace() { return "http://www.w3.org/2000/svg"; } - - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveSVGObj(this); - } - } diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index e92503262..a428e86ca 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.java @@ -21,7 +21,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.ToBeImplementedElement; -import org.apache.fop.layoutmgr.AddLMVisitor; /** * fo:float element. @@ -42,10 +41,6 @@ public class Float extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFloat(this); - } - public String getName() { return "fo:float"; } diff --git a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java index 9bc17ff6b..2972491ca 100644 --- a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java +++ b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java @@ -25,7 +25,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; @@ -86,10 +85,6 @@ public class InitialPropertySet extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveInitialPropertySet(this); - } - public String getName() { return "fo:initial-property-set"; } diff --git a/src/java/org/apache/fop/fo/flow/MultiCase.java b/src/java/org/apache/fop/fo/flow/MultiCase.java index 52cdb0daa..efac25394 100644 --- a/src/java/org/apache/fop/fo/flow/MultiCase.java +++ b/src/java/org/apache/fop/fo/flow/MultiCase.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; @@ -49,10 +48,6 @@ public class MultiCase extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveMultiCase(this); - } - public String getName() { return "fo:multi-case"; } diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java index 86df3e4cf..a2a2c04e5 100644 --- a/src/java/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; @@ -46,10 +45,6 @@ public class MultiProperties extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveMultiProperties(this); - } - public String getName() { return "fo:multi-properties"; } diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java index cc971388d..05edd6e01 100644 --- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java @@ -25,7 +25,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; /** @@ -55,10 +54,6 @@ public class MultiPropertySet extends ToBeImplementedElement { // this.propertyList.get("active-state"); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveMultiPropertySet(this); - } - public String getName() { return "fo:multi-property-set"; } diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java index 0ce8d34ba..61420201a 100644 --- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; @@ -47,10 +46,6 @@ public class MultiSwitch extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveMultiSwitch(this); - } - public String getName() { return "fo:multi-switch"; } diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java index f0abecde6..06e129c26 100644 --- a/src/java/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; @@ -47,10 +46,6 @@ public class MultiToggle extends ToBeImplementedElement { } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveMultiToggle(this); - } - public String getName() { return "fo:multi-toggle"; } diff --git a/src/java/org/apache/fop/fo/flow/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/TableAndCaption.java index a903d358d..b87b23c8c 100644 --- a/src/java/org/apache/fop/fo/flow/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/TableAndCaption.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; @@ -82,13 +81,8 @@ public class TableAndCaption extends ToBeImplementedElement { return true; } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableAndCaption(this); - } - public String getName() { return "fo:table-and-caption"; } - } diff --git a/src/java/org/apache/fop/fo/flow/TableCaption.java b/src/java/org/apache/fop/fo/flow/TableCaption.java index 2b29caef5..ec8cacfe4 100644 --- a/src/java/org/apache/fop/fo/flow/TableCaption.java +++ b/src/java/org/apache/fop/fo/flow/TableCaption.java @@ -20,7 +20,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; @@ -75,10 +74,6 @@ public class TableCaption extends ToBeImplementedElement { return true; } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableCaption(this); - } - public String getName() { return "fo:table-caption"; } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 3b30e81c6..372c62d49 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -47,26 +47,19 @@ import org.apache.fop.fo.FObj; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.TextInfo; import org.apache.fop.fo.ToBeImplementedElement; -import org.apache.fop.fo.Unknown; -import org.apache.fop.fo.UnknownXMLObj; -import org.apache.fop.fo.XMLElement; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.extensions.ExtensionObj; import org.apache.fop.fo.extensions.Label; import org.apache.fop.fo.extensions.Outline; -import org.apache.fop.fo.extensions.svg.SVGElement; -import org.apache.fop.fo.extensions.svg.SVGObj; import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.BidiOverride; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; import org.apache.fop.fo.flow.Character; import org.apache.fop.fo.flow.ExternalGraphic; -import org.apache.fop.fo.flow.Float; import org.apache.fop.fo.flow.Footnote; import org.apache.fop.fo.flow.FootnoteBody; -import org.apache.fop.fo.flow.InitialPropertySet; import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.InlineContainer; import org.apache.fop.fo.flow.InstreamForeignObject; @@ -76,18 +69,12 @@ import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.Marker; -import org.apache.fop.fo.flow.MultiCase; -import org.apache.fop.fo.flow.MultiProperties; -import org.apache.fop.fo.flow.MultiPropertySet; -import org.apache.fop.fo.flow.MultiSwitch; -import org.apache.fop.fo.flow.MultiToggle; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.RetrieveMarker; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableAndCaption; import org.apache.fop.fo.flow.TableBody; -import org.apache.fop.fo.flow.TableCaption; import org.apache.fop.fo.flow.TableCell; import org.apache.fop.fo.flow.TableColumn; import org.apache.fop.fo.flow.TableFooter; @@ -174,6 +161,19 @@ public class AddLMVisitor { return saveLMList; } + /** + * @param node FONode object to process + */ + public void serveFONode(FONode node) { + } + + /** + * @param node FObj object to process + */ + public void serveFObj(FObj node) { + serveFONode((FONode)node); + } + public void serveFOText(FOText foText) { if (foText.endIndex - foText.startIndex > 0) { currentLMList.add(new TextLayoutManager(foText)); @@ -798,18 +798,18 @@ public class AddLMVisitor { } /** - * @param node FONode object to process - */ - public void serveFONode(FONode node) { - } - - /** - * @param node FObj object to process + * @param node Wrapper object to process */ - public void serveFObj(FObj node) { - serveFONode((FONode)node); + public void serveWrapper(Wrapper node) { + ListIterator baseIter; + baseIter = node.getChildNodes(); + if (baseIter == null) return; + while (baseIter.hasNext()) { + FObj child = (FObj) baseIter.next(); + child.acceptVisitor(this); + } } - + /** * @param node ColorProfile object to process */ @@ -880,19 +880,6 @@ public class AddLMVisitor { serveFObjMixed((FObjMixed)node); } - /** - * @param node Wrapper object to process - */ - public void serveWrapper(Wrapper node) { - ListIterator baseIter; - baseIter = node.getChildNodes(); - if (baseIter == null) return; - while (baseIter.hasNext()) { - FObj child = (FObj) baseIter.next(); - child.acceptVisitor(this); - } - } - /** * @param node FootnoteBody object to process */ @@ -1053,117 +1040,4 @@ public class AddLMVisitor { public void serveTableColumn(TableColumn node) { serveFObj((FObj)node); } - - /** - * @param node ToBeImplementedElement object to process - */ - public void serveToBeImplementedElement(ToBeImplementedElement node) { - serveFObj((FObj)node); - } - - /** - * @param node Float object to process - */ - public void serveFloat(Float node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node InitialPropertySet object to process - */ - public void serveInitialPropertySet(InitialPropertySet node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node MultiCase object to process - */ - public void serveMultiCase(MultiCase node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node MultiProperties object to process - */ - public void serveMultiProperties(MultiProperties node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node MultiPropertySet object to process - */ - public void serveMultiPropertySet(MultiPropertySet node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node MultiSwitch object to process - */ - public void serveMultiSwitch(MultiSwitch node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node MultiToggle object to process - */ - public void serveMultiToggle(MultiToggle node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node TableAndCaption object to process - */ - public void serveTableAndCaption(TableAndCaption node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node TableCaption object to process - */ - public void serveTableCaption(TableCaption node) { - serveToBeImplementedElement((ToBeImplementedElement)node); - } - - /** - * @param node Unknown object to process - */ - public void serveUnknown(Unknown node) { - serveFONode((FONode)node); - } - - /** - * @param node XMLObj object to process - */ - public void serveXMLObj(XMLObj node) { - serveFONode((FONode)node); - } - - /** - * @param node SVGObj object to process - */ - public void serveSVGObj(SVGObj node) { - serveXMLObj((XMLObj)node); - } - - /** - * @param node SVGElement object to process - */ - public void serveSVGElement(SVGElement node) { - serveSVGObj((SVGObj)node); - } - - /** - * @param node UnknownXMLObj object to process - */ - public void serveUnknownXMLObj(UnknownXMLObj node) { - serveXMLObj((XMLObj)node); - } - - /** - * @param node XMLElement object to process - */ - public void serveXMLElement(XMLElement node) { - serveXMLObj((XMLObj)node); - } - } -- 2.39.5