diff options
Diffstat (limited to 'src/org/apache/fop/svg/SVGObj.java')
-rw-r--r-- | src/org/apache/fop/svg/SVGObj.java | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/org/apache/fop/svg/SVGObj.java b/src/org/apache/fop/svg/SVGObj.java index c41b58cef..c5d53ad6f 100644 --- a/src/org/apache/fop/svg/SVGObj.java +++ b/src/org/apache/fop/svg/SVGObj.java @@ -57,9 +57,12 @@ import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -import org.apache.fop.dom.svg.*; +import org.apache.batik.dom.svg.*; -import org.w3c.dom.svg.SVGElement; +import org.w3c.dom.svg.*; +import org.w3c.dom.*; + +import java.util.*; /** * Since SVG objects are not layed out then this class checks @@ -68,6 +71,8 @@ import org.w3c.dom.svg.SVGElement; */ public abstract class SVGObj extends FObj implements GraphicsCreator { + String tagName = ""; + String[] props = {}; /** * * @param parent the parent formatting object @@ -77,10 +82,42 @@ public abstract class SVGObj extends FObj implements GraphicsCreator { super(parent, propertyList); } - public SVGElement createGraphic() - { - return null; - } + protected static Hashtable ns = new Hashtable(); + + public void addGraphic(Document doc, Element parent) { + Element element = doc.createElementNS("http://www.w3.org/2000/svg", tagName); +// Element element = doc.createElement(tagName); + for(int count = 0; count < props.length; count++) { + if(this.properties.get(props[count]) != null) { + String rf = this.properties.get(props[count]).getString(); + if(rf != null) { + if(props[count].indexOf(":") == -1) { + element.setAttribute(props[count], rf); + } else { + String pref = props[count].substring(0, props[count].indexOf(":")); +System.out.println(pref); + if(pref.equals("xmlns")) { + ns.put(props[count].substring(props[count].indexOf(":") + 1), rf); +System.out.println(ns); + } + ns.put("xlink", "http://www.w3.org/1999/xlink"); + element.setAttributeNS((String)ns.get(pref), props[count], rf); + } + } + } + } + parent.appendChild(element); + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + Object child = children.elementAt(i); + if (child instanceof GraphicsCreator) { + ((GraphicsCreator)child).addGraphic(doc, element); + } else if (child instanceof String) { + org.w3c.dom.Text text = doc.createTextNode((String)child); + element.appendChild(text); + } + } + } /** * layout this formatting object. @@ -90,11 +127,11 @@ public abstract class SVGObj extends FObj implements GraphicsCreator { */ public Status layout(Area area) throws FOPException { - if (area instanceof SVGArea) { - } else { +// if (area instanceof SVGArea) { +// } else { /* otherwise generate a warning */ System.err.println("WARNING: " + this.name + " outside svg:svg"); - } +// } /* return status */ return new Status(Status.OK); |