aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-03-10 07:55:20 +0000
committerJeremias Maerki <jeremias@apache.org>2009-03-10 07:55:20 +0000
commit090c6205eeedae7990499540c879a8f00773b978 (patch)
tree2820d1f090e7fd8889cc3eae832df364b3d0b5fc /src/java/org
parentefcd8b9100f7dcc85d7a8d8f3d0fe7f919192e99 (diff)
downloadxmlgraphics-fop-090c6205eeedae7990499540c879a8f00773b978.tar.gz
xmlgraphics-fop-090c6205eeedae7990499540c879a8f00773b978.zip
AreaTreeParser redirecting image loading exceptions to event subsystem.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@752010 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
index 8a6198cb6..ec47d2083 100644
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ b/src/java/org/apache/fop/area/AreaTreeParser.java
@@ -21,6 +21,8 @@ package org.apache.fop.area;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.nio.CharBuffer;
import java.util.List;
import java.util.Map;
@@ -41,6 +43,7 @@ import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
@@ -48,6 +51,7 @@ import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
@@ -68,6 +72,7 @@ import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.WordArea;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fo.expr.PropertyException;
@@ -149,6 +154,7 @@ public class AreaTreeParser {
private Stack delegateStack = new Stack();
private ContentHandler delegate;
private DOMImplementation domImplementation;
+ private Locator locator;
public Handler(AreaTreeModel treeModel, FOUserAgent userAgent,
@@ -224,6 +230,15 @@ public class AreaTreeParser {
}
/** {@inheritDoc} */
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ private Locator getLocator() {
+ return this.locator;
+ }
+
+ /** {@inheritDoc} */
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (delegate != null) {
@@ -1056,8 +1071,21 @@ public class AreaTreeParser {
= userAgent.getImageSessionContext();
ImageInfo info = manager.getImageInfo(uri, sessionContext);
bkg.setImageInfo(info);
- } catch (Exception e) {
- log.error("Background image not available: " + uri, e);
+ } catch (ImageException e) {
+ ResourceEventProducer eventProducer
+ = ResourceEventProducer.Provider.get(
+ this.userAgent.getEventBroadcaster());
+ eventProducer.imageError(this, uri, e, getLocator());
+ } catch (FileNotFoundException fnfe) {
+ ResourceEventProducer eventProducer
+ = ResourceEventProducer.Provider.get(
+ this.userAgent.getEventBroadcaster());
+ eventProducer.imageNotFound(this, uri, fnfe, getLocator());
+ } catch (IOException ioe) {
+ ResourceEventProducer eventProducer
+ = ResourceEventProducer.Provider.get(
+ this.userAgent.getEventBroadcaster());
+ eventProducer.imageIOError(this, uri, ioe, getLocator());
}
String repeat = attributes.getValue("bkg-repeat");