aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-03-18 12:30:46 +0000
committerKeiron Liddle <keiron@apache.org>2002-03-18 12:30:46 +0000
commit40e4612f21555a6bf6d8b2ee4dea73d73f06c72a (patch)
tree3ecf9f781d8f42357a762d281bd0530ef1981c5c /src/org/apache/fop
parent68384a39b8517bcda2be21e1b663499966490aca (diff)
downloadxmlgraphics-fop-40e4612f21555a6bf6d8b2ee4dea73d73f06c72a.tar.gz
xmlgraphics-fop-40e4612f21555a6bf6d8b2ee4dea73d73f06c72a.zip
made it easier to add xml handlers
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194708 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r--src/org/apache/fop/apps/Driver.java11
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java5
-rw-r--r--src/org/apache/fop/render/pdf/PDFXMLHandler.java28
3 files changed, 31 insertions, 13 deletions
diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java
index 02d27a6ae..3fd180185 100644
--- a/src/org/apache/fop/apps/Driver.java
+++ b/src/org/apache/fop/apps/Driver.java
@@ -173,6 +173,7 @@ public class Driver {
* the system resources that FOP will use
*/
private Logger log;
+ private FOUserAgent userAgent = null;
public static final String getParserClassName() {
String parserClassName = null;
@@ -192,6 +193,7 @@ public class Driver {
public Driver() {
_stream = null;
_treeBuilder = new FOTreeBuilder();
+ _treeBuilder.setUserAgent(getUserAgent());
setupDefaultMappings();
}
@@ -202,12 +204,15 @@ public class Driver {
}
public void setUserAgent(FOUserAgent agent) {
+ userAgent = agent;
}
private FOUserAgent getUserAgent() {
- FOUserAgent ua = new FOUserAgent();
- ua.setLogger(log);
- return ua;
+ if(userAgent == null) {
+ userAgent = new FOUserAgent();
+ userAgent.setLogger(log);
+ }
+ return userAgent;
}
public void setLogger(Logger logger) {
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index 3d548073a..a446693ee 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -83,6 +83,11 @@ public class FOTreeBuilder extends DefaultHandler {
userAgent = ua;
}
+ public FOUserAgent getUserAgent() {
+ return userAgent;
+ }
+
+
public void setStreamRenderer(StreamRenderer streamRenderer) {
this.streamRenderer = streamRenderer;
}
diff --git a/src/org/apache/fop/render/pdf/PDFXMLHandler.java b/src/org/apache/fop/render/pdf/PDFXMLHandler.java
index 6d983203c..da936ec4c 100644
--- a/src/org/apache/fop/render/pdf/PDFXMLHandler.java
+++ b/src/org/apache/fop/render/pdf/PDFXMLHandler.java
@@ -59,7 +59,17 @@ public static final String PDF_YPOS = "ypos";
public void handleXML(RendererContext context, Document doc,
String ns) throws Exception {
- PDFDocument pdfDoc = (PDFDocument) context.getProperty(PDF_DOCUMENT);
+ PDFInfo pdfi = getPDFInfo(context);
+
+ String svg = "http://www.w3.org/2000/svg";
+ if (svg.equals(ns)) {
+ SVGHandler svghandler = new SVGHandler();
+ svghandler.renderSVGDocument(context, doc, pdfi);
+ } else {
+ }
+ }
+
+ public static PDFInfo getPDFInfo(RendererContext context) {
PDFInfo pdfi = new PDFInfo();
pdfi.pdfDoc = (PDFDocument)context.getProperty(PDF_DOCUMENT);
pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM);
@@ -70,18 +80,12 @@ public static final String PDF_YPOS = "ypos";
pdfi.currentFontSize = ((Integer)context.getProperty(PDF_FONT_SIZE)).intValue();
pdfi.currentXPosition = ((Integer)context.getProperty(PDF_XPOS)).intValue();
pdfi.currentYPosition = ((Integer)context.getProperty(PDF_YPOS)).intValue();
-
- String svg = "http://www.w3.org/2000/svg";
- if (svg.equals(ns)) {
- SVGHandler svghandler = new SVGHandler();
- svghandler.renderSVGDocument(context, doc, pdfi);
- } else {
- }
+ return pdfi;
}
- class PDFInfo {
+ public static class PDFInfo {
PDFDocument pdfDoc;
- PDFStream currentStream;
+ public PDFStream currentStream;
int x;
int y;
FontState fs;
@@ -91,6 +95,10 @@ public static final String PDF_YPOS = "ypos";
int currentYPosition;
}
+ /**
+ * This method is placed in an inner class so that we don't get class
+ * loading errors if batik is not present.
+ */
protected class SVGHandler {
protected void renderSVGDocument(RendererContext context, Document doc, PDFInfo pdfInfo) {
float sx = 1, sy = 1;