aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-12-08 11:30:11 +0000
committerJeremias Maerki <jeremias@apache.org>2008-12-08 11:30:11 +0000
commit607aeaa986fbf0ecbc55684dad0b3286613f56dd (patch)
tree2bcf43c318379e749e489ded328ed5e8995769fe /src/java/org/apache
parentf455ebac165a6b9fd8c0f58e6ddc999b7e08c3e5 (diff)
downloadxmlgraphics-fop-607aeaa986fbf0ecbc55684dad0b3286613f56dd.tar.gz
xmlgraphics-fop-607aeaa986fbf0ecbc55684dad0b3286613f56dd.zip
Batik's DOMUtilities.deepCloneDocument() doesn't propagate the document URI which makes relative image URIs fail. Fixes one of our unit tests.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@724310 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/image/loader/batik/BatikUtil.java19
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java3
-rw-r--r--src/java/org/apache/fop/render/AbstractGenericSVGHandler.java4
-rw-r--r--src/java/org/apache/fop/render/afp/AFPSVGHandler.java4
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java4
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFSVGHandler.java4
-rw-r--r--src/java/org/apache/fop/render/ps/PSSVGHandler.java4
7 files changed, 30 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
index 558c3b043..20a7bf767 100644
--- a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
+++ b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
@@ -19,6 +19,11 @@
package org.apache.fop.image.loader.batik;
+import org.w3c.dom.Document;
+
+import org.apache.batik.dom.AbstractDocument;
+import org.apache.batik.dom.util.DOMUtilities;
+
/**
* Helper utilities for Apache Batik.
*/
@@ -38,4 +43,18 @@ public class BatikUtil {
return false;
}
+ /**
+ * Clones an SVG DOM document. This is used for making SVG production thread-safe when the
+ * SVG document is cached and re-used.
+ * @param doc the SVG DOM to be cloned
+ * @return the cloned SVG DOM
+ */
+ public static Document cloneSVGDocument(Document doc) {
+ Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ if (clonedDoc instanceof AbstractDocument) {
+ ((AbstractDocument)clonedDoc).setDocumentURI(((AbstractDocument)doc).getDocumentURI());
+ }
+ return clonedDoc;
+ }
+
}
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
index 8d9399a3c..2bb521dc9 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
@@ -29,7 +29,6 @@ import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -83,7 +82,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
Document doc = svg.getDocument();
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
//Build the GVT tree
final GraphicsNode root;
diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
index 35876a728..731f0bae2 100644
--- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
+++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
@@ -30,7 +30,6 @@ import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
@@ -39,6 +38,7 @@ import org.apache.xmlgraphics.util.QName;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
import org.apache.fop.svg.SVGEventProducer;
@@ -138,7 +138,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
//Build the GVT tree
final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);
diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
index ca64d6bc2..161217a54 100644
--- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
@@ -28,7 +28,6 @@ import org.w3c.dom.Document;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.xmlgraphics.image.loader.ImageManager;
@@ -46,6 +45,7 @@ import org.apache.fop.afp.AFPUnitConverter;
import org.apache.fop.afp.svg.AFPBridgeContext;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
@@ -113,7 +113,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
// Build the SVG DOM and provide the painter with it
GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
index 2d16b120d..99502096c 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
@@ -27,11 +27,11 @@ import org.w3c.dom.Document;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
@@ -135,7 +135,7 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
GraphicsNode root;
try {
diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
index 0bf9bd95b..41f48df55 100644
--- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
@@ -31,7 +31,6 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.util.SVGConstants;
import org.apache.commons.logging.Log;
@@ -39,6 +38,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFPage;
import org.apache.fop.pdf.PDFPaintingState;
@@ -182,7 +182,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
GraphicsNode root;
try {
diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
index 646cd3823..7171efb4e 100644
--- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
@@ -29,7 +29,6 @@ import org.w3c.dom.Document;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,6 +37,7 @@ import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
@@ -273,7 +273,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
//to it.
- Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+ Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
GraphicsNode root;
try {