You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/11/21 17:08:00 UTC

svn commit: r719616 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/extensions/svg/ src/java/org/apache/fop/svg/

Author: jeremias
Date: Fri Nov 21 08:07:58 2008
New Revision: 719616

URL: http://svn.apache.org/viewvc?rev=719616&view=rev
Log:
Added support for SVG 1.2 inside fo:instream-foreign-object. The code just used the basic SVGDOMImplementation for SVG 1.1. Now it delegates the DOM building to Batik code instead of to a normal DOM builder.

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLObj.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLObj.java?rev=719616&r1=719615&r2=719616&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLObj.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/XMLObj.java Fri Nov 21 08:07:58 2008
@@ -217,6 +217,7 @@
     /** {@inheritDoc} */
     public void notifyObjectBuilt(Object obj) {
         this.doc = (Document)obj;
+        this.element = this.doc.getDocumentElement();
     }
 
 }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java?rev=719616&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java Fri Nov 21 08:07:58 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.extensions.svg;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.util.XMLResourceDescriptor;
+
+import org.apache.fop.svg.FOPSAXSVGDocumentFactory;
+import org.apache.fop.util.ContentHandlerFactory;
+
+/**
+ * ContentHandlerFactory which constructs ContentHandlers that build SVG DOM Documents.
+ */
+public class SVGDOMContentHandlerFactory implements ContentHandlerFactory {
+
+    /**
+     * Default Constructor.
+     */
+    public SVGDOMContentHandlerFactory() {
+        //nop
+    }
+
+    /** {@inheritDoc} */
+    public String[] getSupportedNamespaces() {
+        return new String[] {SVGDOMImplementation.SVG_NAMESPACE_URI};
+    }
+
+    /** {@inheritDoc} */
+    public ContentHandler createContentHandler() throws SAXException {
+        return new Handler();
+    }
+
+    private static class Handler extends FOPSAXSVGDocumentFactory
+                implements ContentHandlerFactory.ObjectSource {
+
+        private ObjectBuiltListener obListener;
+
+        public Handler() throws SAXException {
+            super(XMLResourceDescriptor.getXMLParserClassName());
+        }
+
+        /** {@inheritDoc} */
+        public Object getObject() {
+            return getDocument();
+        }
+
+        /** {@inheritDoc} */
+        public void setObjectBuiltListener(ObjectBuiltListener listener) {
+            this.obListener = listener;
+        }
+
+        /** {@inheritDoc} */
+        public void endDocument() throws SAXException {
+            super.endDocument();
+            if (obListener != null) {
+                obListener.notifyObjectBuilt(getObject());
+            }
+        }
+
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java?rev=719616&r1=719615&r2=719616&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java Fri Nov 21 08:07:58 2008
@@ -20,35 +20,28 @@
 package org.apache.fop.fo.extensions.svg;
 
 // FOP
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.PropertyList;
-import org.apache.fop.util.ContentHandlerFactory;
-import org.apache.fop.util.DOMBuilderContentHandlerFactory;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.net.URL;
 
-import org.apache.batik.dom.svg.SVGOMDocument;
-import org.apache.batik.dom.svg.SVGOMElement;
-import org.apache.batik.dom.svg.SVGContext;
-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;
-
-import org.w3c.dom.DOMImplementation;
 
+import org.apache.batik.bridge.UnitProcessor;
+import org.apache.batik.dom.svg.SVGContext;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.dom.util.XMLSupport;
+import org.apache.batik.util.SVGConstants;
 
-import java.net.URL;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.util.ContentHandlerFactory;
 
 /**
- * class representing the SVG root element
- * for constructing an svg document.
+ * Class representing the SVG root element
+ * for constructing an SVG document.
  */
 public class SVGElement extends SVGObj {
 
@@ -61,21 +54,9 @@
         super(parent);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public ContentHandlerFactory getContentHandlerFactory() {
-        return new DOMBuilderContentHandlerFactory(getNamespaceURI(),
-                SVGDOMImplementation.getDOMImplementation());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void processNode(String elementName, Locator locator,
-                            Attributes attlist, PropertyList propertyList) throws FOPException {
-        super.processNode(elementName, locator, attlist, propertyList);
-        init();
+        return new SVGDOMContentHandlerFactory();
     }
 
     /**
@@ -170,16 +151,6 @@
         return p2d;
     }
 
-    private void init() {
-        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-        doc = impl.createDocument(svgNS, "svg", null);
-
-        element = doc.getDocumentElement();
-
-        buildTopLevel(doc, element);
-    }
-
     /**
      * Get the size of the SVG root element.
      * @param size the font size

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java?rev=719616&r1=719615&r2=719616&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java Fri Nov 21 08:07:58 2008
@@ -21,6 +21,8 @@
 
 import java.io.IOException;
 
+import org.w3c.dom.Document;
+
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -71,4 +73,13 @@
         return super.resolveEntity(publicId, systemId);
     }
 
+    /**
+     * Returns the document built up by handling the incoming SAX events. This method will not
+     * return any instance for the first SAX events have been received.
+     * @return the DOM document
+     */
+    public Document getDocument() {
+        return this.document;
+    }
+
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=719616&r1=719615&r2=719616&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Fri Nov 21 08:07:58 2008
@@ -53,6 +53,9 @@
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Images" dev="JM" type="add">
+        Added support for SVG 1.2 functionality inside fo:instream-foreign-object.
+      </action>
       <action context="Layout" dev="AD" type="fix" fixes-bug="46240">
         Fixed a bug when combining break-before with a span change.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org