From 692a69774d19362a7c39f7df56bd60b88aef9b4d Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 26 Sep 2001 12:00:43 +0000 Subject: [PATCH] catches exception when building svg git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194486 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/render/awt/AWTRenderer.java | 8 +++++++- src/org/apache/fop/render/pdf/PDFRenderer.java | 8 +++++++- src/org/apache/fop/render/ps/PSRenderer.java | 12 ++++++++++-- src/org/apache/fop/svg/SVGElement.java | 14 +++++++------- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index b623a9b64..98118ed36 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -699,7 +699,13 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(userAgent); GraphicsNode root; - root = builder.build(ctx, doc); + try { + root = builder.build(ctx, doc); + } catch (Exception e) { + log.error("svg graphic could not be built: " + + e.getMessage(), e); + return; + } float w = (float)ctx.getDocumentSize().getWidth() * 1000f; float h = (float)ctx.getDocumentSize().getHeight() * 1000f; diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index b7bdc61f5..ec9da0725 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -409,7 +409,13 @@ public class PDFRenderer extends PrintRenderer { GraphicsNode root; - root = builder.build(ctx, doc); + try { + root = builder.build(ctx, doc); + } catch (Exception e) { + log.error("svg graphic could not be built: " + + e.getMessage(), e); + return; + } // get the 'width' and 'height' attributes of the SVG document float w = (float)ctx.getDocumentSize().getWidth() * 1000f; float h = (float)ctx.getDocumentSize().getHeight() * 1000f; diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 1bcf315d9..d380f54ef 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -295,13 +295,21 @@ public class PSRenderer extends AbstractRenderer { int y = this.currentYPosition; Document doc = area.getSVGDocument(); - UserAgent userAgent = new org.apache.fop.svg.SVGUserAgent(new AffineTransform()); + org.apache.fop.svg.SVGUserAgent userAgent + = new org.apache.fop.svg.SVGUserAgent(new AffineTransform()); + userAgent.setLogger(log); GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(userAgent); GraphicsNode root; - root = builder.build(ctx, doc); + try { + root = builder.build(ctx, doc); + } catch (Exception e) { + log.error("svg graphic could not be built: " + + e.getMessage(), e); + return; + } // get the 'width' and 'height' attributes of the SVG document float w = (float)ctx.getDocumentSize().getWidth() * 1000f; float h = (float)ctx.getDocumentSize().getHeight() * 1000f; diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java index 730a984e4..65ba2effe 100644 --- a/src/org/apache/fop/svg/SVGElement.java +++ b/src/org/apache/fop/svg/SVGElement.java @@ -138,6 +138,13 @@ public class SVGElement extends SVGObj { }; ((SVGOMDocument)doc).setSVGContext(dc); + try { + String baseDir = Configuration.getStringValue("baseDir"); + ((SVGOMDocument)doc).setURLObject(new URL(baseDir)); + } catch (Exception e) { + log.error("Could not set base URL for svg", e); + } + Element e = ((SVGDocument)doc).getRootElement(); String s; SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform()); @@ -185,13 +192,6 @@ public class SVGElement extends SVGObj { element = doc.getDocumentElement(); - try { - String baseDir = Configuration.getStringValue("baseDir"); - ((SVGOMDocument)doc).setURLObject(new URL(baseDir)); - } catch (Exception e) { - // cannot use log yet - //log.error("Could not set base URL for svg", e); - } buildTopLevel(doc, element); } -- 2.39.5