]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
added namespace separation of properties
authorKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 05:34:11 +0000 (05:34 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 05:34:11 +0000 (05:34 +0000)
also added all the currently supported svg properties

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193484 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/FOTreeBuilder.java
src/org/apache/fop/fo/PropertyList.java
src/org/apache/fop/fo/PropertyListBuilder.java
src/org/apache/fop/fo/XTFOTreeBuilder.java

index 42a3098a15df6734c7a3d60a3f6f2befdce9cd7d..0d30be9a1ade7f62da92de4f4803d8b7c3cb08e7 100644 (file)
@@ -223,7 +223,7 @@ public class FOTreeBuilder extends DefaultHandler {
        }
        
        try {
-               PropertyList list = this.propertyListBuilder.makeList(attlist,  
+               PropertyList list = this.propertyListBuilder.makeList(fullName, attlist,  
                     (currentFObj == null) ? null : currentFObj.properties);
            fobj = fobjMaker.make(currentFObj, list);
        } catch (FOPException e) {
index cd9a2566e082fc1ba47bc863199bdaceb90198da..690a201cac655d23bf8caef02eea9a695017a464 100644 (file)
@@ -58,9 +58,11 @@ import org.apache.fop.apps.FOPException;
 public class PropertyList extends Hashtable {
   private PropertyListBuilder builder;
   private PropertyList parentPropertyList = null;
+  String namespace = "";
 
-  public PropertyList(PropertyList parentPropertyList) {
+  public PropertyList(PropertyList parentPropertyList, String space) {
     this.parentPropertyList = parentPropertyList;
+    this.namespace = space;
   }
 
   public Property get(String propertyName) {
@@ -89,4 +91,9 @@ public class PropertyList extends Hashtable {
   public void setBuilder(PropertyListBuilder builder) {
     this.builder = builder;
   }
+
+       public String getNameSpace()
+       {
+               return namespace;
+       }
 }
index f5f457d82606d86ce831e4699e2a16f792e0392d..a8692781fffdf9df19572715ea59722e555b4c26 100644 (file)
@@ -54,6 +54,7 @@ package org.apache.fop.fo;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.svg.*;
+import org.apache.fop.datatypes.*;
 
 import org.apache.fop.apps.FOPException;
 
@@ -64,6 +65,8 @@ import java.util.Hashtable;
 public class PropertyListBuilder {
     
     private Hashtable propertyTable;
+       private Hashtable spaceTable;
+       private Hashtable elementTable;
 
     public PropertyListBuilder() {
        this.propertyTable = new Hashtable();
@@ -112,15 +115,13 @@ public class PropertyListBuilder {
        propertyTable.put("padding-right",PaddingRight.maker());
        propertyTable.put("external-destination",ExternalDestination.maker());
         propertyTable.put("internal-destination",InternalDestination.maker());
-       propertyTable.put("height",SVGLength.maker());
-       propertyTable.put("width",SVGLength.maker());
-       propertyTable.put("x",SVGLength.maker());
-       propertyTable.put("y",SVGLength.maker());
-       propertyTable.put("x1",SVGLength.maker());
-       propertyTable.put("x2",SVGLength.maker());
-       propertyTable.put("y1",SVGLength.maker());
-       propertyTable.put("y2",SVGLength.maker());
-        
+       propertyTable.put("x",SVGLengthProperty.maker());
+       propertyTable.put("y",SVGLengthProperty.maker());
+       propertyTable.put("x1",SVGLengthProperty.maker());
+       propertyTable.put("x2",SVGLengthProperty.maker());
+       propertyTable.put("y1",SVGLengthProperty.maker());
+       propertyTable.put("y2",SVGLengthProperty.maker());
+
        propertyTable.put("border-after-color",BorderAfterColor.maker());
        propertyTable.put("border-after-style",BorderAfterStyle.maker());
        propertyTable.put("border-after-width",BorderAfterWidth.maker());
@@ -172,7 +173,48 @@ public class PropertyListBuilder {
        propertyTable.put("odd-or-even",OddOrEven.maker());
        propertyTable.put("blank-or-not-blank",BlankOrNotBlank.maker());
 
-    }
+               // should split up name space properties into separate files
+               spaceTable = new Hashtable();
+               Hashtable table = new Hashtable();
+               table.put("height",SVGLengthProperty.maker());
+               table.put("width",SVGLengthProperty.maker());
+               spaceTable.put("http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd", table);
+
+               propertyTable.put("rx",SVGLengthProperty.maker());
+               propertyTable.put("ry",SVGLengthProperty.maker());
+               propertyTable.put("dx",SVGLengthProperty.maker());
+               propertyTable.put("dy",SVGLengthProperty.maker());
+               propertyTable.put("cx",SVGLengthProperty.maker());
+               propertyTable.put("cy",SVGLengthProperty.maker());
+               propertyTable.put("r",SVGLengthProperty.maker());
+               propertyTable.put("fx",SVGLengthProperty.maker());
+               propertyTable.put("fy",SVGLengthProperty.maker());
+               propertyTable.put("refX",SVGLengthProperty.maker());
+               propertyTable.put("refY",SVGLengthProperty.maker());
+               propertyTable.put("markerWidth",SVGLengthProperty.maker());
+               propertyTable.put("markerHeight",SVGLengthProperty.maker());
+               propertyTable.put("offset",SVGLengthProperty.maker());
+
+/*             propertyTable.put("orient",SVGOrient.maker());*/
+               propertyTable.put("xlink:href",HRef.maker());
+               propertyTable.put("style",SVGStyle.maker());
+               propertyTable.put("transform",SVGTransform.maker());
+               propertyTable.put("d",SVGD.maker());
+               propertyTable.put("points",SVGPoints.maker());
+//             propertyTable.put("viewBox",SVGBox.maker());
+
+//             propertyTable.put("id", SVGStringProperty.maker());
+
+               elementTable = new Hashtable();
+               table = new Hashtable();
+               table.put("x",SVGLengthListProperty.maker());
+               table.put("y",SVGLengthListProperty.maker());
+               table.put("dx",SVGLengthListProperty.maker());
+               table.put("dy",SVGLengthListProperty.maker());
+//             table.put("id",SVGStringProperty.maker());
+               elementTable.put("http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd^tref", table);
+               elementTable.put("http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd^tspan", table);
+       }
 
     public Property computeProperty(PropertyList propertyList, String propertyName) {
        
@@ -200,14 +242,36 @@ public class PropertyListBuilder {
        return b;
     }
     
-    public PropertyList makeList(Attributes attributes, PropertyList parentPropertyList) throws FOPException {
-       
-       PropertyList p = new PropertyList(parentPropertyList);
+    public PropertyList makeList(String elementName, Attributes attributes, PropertyList parentPropertyList) throws FOPException {
+       int index = elementName.indexOf("^");
+       String space = "http://www.w3.org/TR/1999/XSL/Format";
+    Hashtable sptable = null;
+       if(index != -1) {
+               space = elementName.substring(0, index);
+               sptable = (Hashtable)spaceTable.get(space);
+       }
+
+       PropertyList par = null;
+       if(parentPropertyList != null && space.equals(parentPropertyList.getNameSpace())) {
+               par = parentPropertyList;
+       }
+       PropertyList p = new PropertyList(par, space);
        p.setBuilder(this);
-       
+    Hashtable table;
+    table = (Hashtable)elementTable.get(elementName);
        for (int i = 0; i < attributes.getLength(); i++) {
            String attributeName = attributes.getRawName(i);
-           Property.Maker propertyMaker = (Property.Maker)propertyTable.get(attributeName);
+           Property.Maker propertyMaker = null;
+           if(sptable != null) {
+               propertyMaker = (Property.Maker)sptable.get(attributeName);
+           }
+           if(propertyMaker == null) {
+               if(table != null) {
+                       propertyMaker = (Property.Maker)table.get(attributeName);
+                   }
+           }
+           if(propertyMaker == null)
+                   propertyMaker = (Property.Maker)propertyTable.get(attributeName);
            if (propertyMaker != null) {
                p.put(attributeName,propertyMaker.make(p,attributes.getValue(i)));
            } else {
index 81fd0a42192b9ba9a63236995314315aef1e5a19..84623ebd6c7c14253bf21dfc2f0b4ba445c2b3de 100644 (file)
@@ -223,7 +223,7 @@ public class XTFOTreeBuilder extends HandlerBase {
        }
        
        try {
-               PropertyList list = this.propertyListBuilder.makeList(attlist,  
+               PropertyList list = this.propertyListBuilder.makeList(fullName, attlist,  
                     (currentFObj == null) ? null : currentFObj.properties);
            fobj = fobjMaker.make(currentFObj, list);
        } catch (FOPException e) {