xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r640395 [1/2] - in /xmlgraphics/fop/branches/Temp_ProcessingFeedback: ./ src/java/META-INF/services/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/events/ src/java/org/apache/fop/events/model/ src/java/org/apache/fop/fo/ src/java/or...
Date Mon, 24 Mar 2008 12:39:22 GMT
Author: jeremias
Date: Mon Mar 24 05:39:13 2008
New Revision: 640395

URL: http://svn.apache.org/viewvc?rev=640395&view=rev
Log:
Moved the creation of the fallback LoggingEventListener to FOUserAgent so event before the startDocument() SAX event arrive in the log.
Dynamic discovery of event models. Renderers and extensions can register renderer-specific event models.
Switched the most important parts of the renderers to events (maybe not everything is converted).

Added:
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/PSEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/PSEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/rtf/RTFEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/rtf/RTFEventProducer.xml   (with props)
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/events/FOPTestEventModelFactory.java   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/build.xml
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/DefaultEventBroadcaster.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/Event.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOTreeBuilder.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/AbstractRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLGenerator.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/PSRenderer.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/PSSVGHandler.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/ResourceHandler.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/rtf/RTFHandler.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/events/BasicEventTestCase.java

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/build.xml?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/build.xml (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/build.xml Mon Mar 24 05:39:13 2008
@@ -424,6 +424,51 @@
         translationfile="${src.java.dir}/org/apache/fop/events/EventFormatter.xml">
       <fileset dir="${src.java.dir}">
         <include name="**/*.java"/>
+        <exclude name="org/apache/fop/render/*/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <fixcrlf file="${src.java.dir}/org/apache/fop/events/EventFormatter.xml" tab="remove" tablength="2"/>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/afp/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/afp/AFPEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/afp/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <fixcrlf file="${src.java.dir}/org/apache/fop/render/afp/AFPEventFormatter.xml" tab="remove" tablength="2"/>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/bitmap/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/bitmap/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/pcl/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/pcl/PCLEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/pcl/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/pdf/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/pdf/PDFEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/pdf/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/ps/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/ps/PSEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/ps/**/*.java"/>
+      </fileset>
+    </eventResourceGenerator>
+    <eventResourceGenerator
+      modelfile="${build.gensrc.dir}/org/apache/fop/render/rtf/event-model.xml"
+      translationfile="${src.java.dir}/org/apache/fop/render/rtf/RTFEventProducer.xml">
+      <fileset dir="${src.java.dir}">
+        <include name="org/apache/fop/render/rtf/**/*.java"/>
       </fileset>
     </eventResourceGenerator>
   </target>
@@ -764,6 +809,7 @@
     </eventResourceGenerator>
     <copy todir="${build.dir}/test-classes">
       <fileset dir="${basedir}/test/java">
+        <include name="META-INF/**"/>
         <include name="**/*.xml"/>
       </fileset>
       <fileset dir="${build.dir}/test-gensrc">

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory Mon Mar 24 05:39:13 2008
@@ -0,0 +1,7 @@
+org.apache.fop.events.FOPEventModelFactory
+org.apache.fop.render.afp.AFPEventProducer$EventModelFactory
+org.apache.fop.render.bitmap.BitmapRendererEventProducer$EventModelFactory
+org.apache.fop.render.pcl.PCLEventProducer$EventModelFactory
+org.apache.fop.render.pdf.PDFEventProducer$EventModelFactory
+org.apache.fop.render.ps.PSEventProducer$EventModelFactory
+org.apache.fop.render.rtf.RTFEventProducer$EventModelFactory

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java Mon Mar 24 05:39:13 2008
@@ -39,8 +39,9 @@
 import org.apache.fop.events.DefaultEventBroadcaster;
 import org.apache.fop.events.Event;
 import org.apache.fop.events.EventBroadcaster;
-import org.apache.fop.events.EventListener;
+import org.apache.fop.events.EventProducer;
 import org.apache.fop.events.FOPEventListenerProxy;
+import org.apache.fop.events.LoggingEventListener;
 import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererFactory;
@@ -548,7 +549,7 @@
 
     private class FOPEventBroadcaster extends DefaultEventBroadcaster {
 
-        private EventListener rootListener;
+        private FOPEventListenerProxy rootListener;
         
         public FOPEventBroadcaster() {
             this.rootListener = new FOPEventListenerProxy(
@@ -558,6 +559,18 @@
         /** {@inheritDoc} */
         public void broadcastEvent(Event event) {
             rootListener.processEvent(event);
+        }
+
+        /** {@inheritDoc} */
+        protected EventProducer createProxyFor(Class clazz) {
+            if (!this.listeners.hasEventListeners()) {
+                //Backwards-compatibility: Make sure at least the LoggingEventListener is plugged
+                //in so no events are just silently swallowed.
+                addEventListener(
+                        new LoggingEventListener(LogFactory.getLog(FOUserAgent.class)));
+                
+            }
+            return super.createProxyFor(clazz);
         }
         
     }

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/DefaultEventBroadcaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/DefaultEventBroadcaster.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/DefaultEventBroadcaster.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/DefaultEventBroadcaster.java Mon Mar 24 05:39:13 2008
@@ -19,22 +19,18 @@
 
 package org.apache.fop.events;
 
-import java.io.InputStream;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.MissingResourceException;
 
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.commons.io.IOUtils;
+import org.apache.xmlgraphics.util.Service;
 
 import org.apache.fop.events.model.EventMethodModel;
 import org.apache.fop.events.model.EventModel;
-import org.apache.fop.events.model.EventModelParser;
+import org.apache.fop.events.model.EventModelFactory;
 import org.apache.fop.events.model.EventProducerModel;
 import org.apache.fop.events.model.EventSeverity;
 
@@ -67,37 +63,25 @@
         this.listeners.processEvent(event);
     }
 
-    private static final String EVENT_MODEL_FILENAME = "event-model.xml";
-    private static EventModel eventModel;
+    private static List/*<EventModel>*/ eventModels = new java.util.ArrayList();
     private Map proxies = new java.util.HashMap();
     
     static {
-        loadModel(DefaultEventBroadcaster.class, EVENT_MODEL_FILENAME);
+        Iterator iter = Service.providers(EventModelFactory.class, true);
+        while (iter.hasNext()) {
+            EventModelFactory factory = (EventModelFactory)iter.next();
+            addEventModel(factory.createEventModel());
+        }
     }
 
     /**
-     * Loads an event model overriding any previously loaded event model.
-     * @param resourceBaseClass base class to use for loading resources
-     * @param resourceName the resource name pointing to the event model to be loaded
+     * Adds a new {@link EventModel} to the list of registered event models.
+     * @param eventModel the event model instance
      */
-    public static void loadModel(Class resourceBaseClass, String resourceName) {
-        InputStream in = resourceBaseClass.getResourceAsStream(resourceName);
-        if (in == null) {
-            throw new MissingResourceException(
-                    "File " + resourceName + " not found",
-                    DefaultEventBroadcaster.class.getName(), ""); 
-        }
-        try {
-            eventModel = EventModelParser.parse(new StreamSource(in));
-        } catch (TransformerException e) {
-            throw new MissingResourceException(
-                    "Error reading " + resourceName + ": " + e.getMessage(),
-                    DefaultEventBroadcaster.class.getName(), ""); 
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
+    public static void addEventModel(EventModel eventModel) {
+        eventModels.add(eventModel);
     }
-
+    
     /** {@inheritDoc} */
     public EventProducer getEventProducerFor(Class clazz) {
         if (!EventProducer.class.isAssignableFrom(clazz)) {
@@ -114,8 +98,25 @@
         return producer;
     }
     
-    private EventProducer createProxyFor(Class clazz) {
-        final EventProducerModel producerModel = eventModel.getProducer(clazz);
+    private EventProducerModel getEventProducerModel(Class clazz) {
+        for (int i = 0, c = eventModels.size(); i < c; i++) {
+            EventModel eventModel = (EventModel)eventModels.get(i);
+            EventProducerModel producerModel = eventModel.getProducer(clazz);
+            if (producerModel != null) {
+                return producerModel;
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * Creates a dynamic proxy for the given EventProducer interface that will handle the
+     * conversion of the method call into the broadcasting of an event instance.
+     * @param clazz a descendant interface of EventProducer
+     * @return the EventProducer instance
+     */
+    protected EventProducer createProxyFor(Class clazz) {
+        final EventProducerModel producerModel = getEventProducerModel(clazz);
         if (producerModel == null) {
             throw new IllegalStateException("Event model doesn't contain the definition for "
                     + clazz.getName());

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/Event.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/Event.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/Event.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/Event.java Mon Mar 24 05:39:13 2008
@@ -58,6 +58,19 @@
     }
     
     /**
+     * Returns the event group identifier.
+     * @return the event group identifier (or null if there is no group identifier)
+     */
+    public String getEventGroupID() {
+        int pos = this.eventID.lastIndexOf('.');
+        if (pos > 0) {
+            return this.eventID.substring(0, pos);
+        } else {
+            return null;
+        }
+    }
+    
+    /**
      * Returns the severity level.
      * @return the severity level
      */

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java Mon Mar 24 05:39:13 2008
@@ -21,10 +21,14 @@
 
 import java.util.Locale;
 import java.util.Map;
+import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.util.XMLResourceBundle;
 import org.apache.fop.util.text.AdvancedMessageFormat;
 import org.apache.fop.util.text.AdvancedMessageFormat.Part;
@@ -33,22 +37,66 @@
 /**
  * Converts events into human-readable, localized messages.
  */
-public class EventFormatter {
+public final class EventFormatter {
 
     private static final Pattern INCLUDES_PATTERN = Pattern.compile("\\{\\{.+\\}\\}");
     
     private static ResourceBundle defaultBundle = XMLResourceBundle.getXMLBundle(
             EventFormatter.class.getName(), EventFormatter.class.getClassLoader());
     
+    private static Log log = LogFactory.getLog(EventFormatter.class);
+    
+    private EventFormatter() {
+        //utility class
+    }
+    
+    /**
+     * Formats an event using the default locale.
+     * @param event the event
+     * @return the formatted message
+     */
     public static String format(Event event) {
-        return format(event, defaultBundle);
+        ResourceBundle bundle = null;
+        String groupID = event.getEventGroupID();
+        if (groupID != null) {
+            try {
+                 bundle = XMLResourceBundle.getXMLBundle(
+                        groupID,
+                        EventFormatter.class.getClassLoader());
+            } catch (MissingResourceException mre) {
+                log.trace("No XMLResourceBundle for " + groupID + " available.");
+            }
+        }
+        if (bundle == null) {
+            bundle = defaultBundle;
+        }
+        return format(event, bundle);
     }
     
+    /**
+     * Formats an event using a given locale.
+     * @param event the event
+     * @param locale the locale
+     * @return the formatted message
+     */
     public static String format(Event event, Locale locale) {
-        ResourceBundle bundle = XMLResourceBundle.getXMLBundle(
-                EventFormatter.class.getName(),
-                locale,
-                EventFormatter.class.getClassLoader());
+        ResourceBundle bundle = null;
+        String groupID = event.getEventGroupID();
+        if (groupID != null) {
+            try {
+                 bundle = XMLResourceBundle.getXMLBundle(
+                        groupID, locale,
+                        EventFormatter.class.getClassLoader());
+            } catch (MissingResourceException mre) {
+                log.trace("No XMLResourceBundle for " + groupID + " available.");
+            }
+        }
+        if (bundle == null) {
+            bundle = XMLResourceBundle.getXMLBundle(
+                    EventFormatter.class.getName(),
+                    locale,
+                    EventFormatter.class.getClassLoader());
+        }
         return format(event, bundle);
     }
 
@@ -84,6 +132,13 @@
         return replacements;
     }
 
+    /**
+     * Formats the event using a given pattern. The pattern needs to be compatible with
+     * {@link AdvancedMessageFormat}.
+     * @param event the event
+     * @param pattern the pattern (compatible with {@link AdvancedMessageFormat})
+     * @return the formatted message
+     */
     public static String format(Event event, String pattern) {
         AdvancedMessageFormat format = new AdvancedMessageFormat(pattern);
         Map params = new java.util.HashMap(event.getParams());

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml Mon Mar 24 05:39:13 2008
@@ -22,6 +22,9 @@
   <message key="rule.retrieveMarkerDescendatOfStaticContent">An fo:retrieve-marker is permitted only as the descendant of an fo:static-content.</message>
   <message key="rule.bidiOverrideContent">An fo:bidi-override that is a descendant of an fo:leader or of the fo:inline child of an fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container.</message>
   <message key="rule.inlineContent">An fo:inline that is a descendant of an fo:leader or fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container.</message>
+  <message key="rule.childOfSPM">The element must be a child of fo:simple-page-master.</message>
+  <message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
+  <message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated,lookup}]{{locator}}</message>
@@ -59,11 +62,14 @@
   <message key="org.apache.fop.fo.flow.table.TableEventProducer.paddingNotApplicable">padding-* properties are not applicable to {elementName}, but a non-zero value for padding was found.{{locator}}</message>
   <message key="org.apache.fop.fo.flow.table.TableEventProducer.cellOverlap">{elementName} overlaps in column {column}.<!-- no locator here, exception will be wrapped --></message>
   <message key="org.apache.fop.fo.flow.table.TableEventProducer.breakIgnoredDueToRowSpanning">{breakBefore,if,break-before,break-after} ignored on {elementName} because of row spanning in progress (See XSL 1.1, {breakBefore,if,7.20.2,7.20.1}){{locator}}</message>
-  <message key="org.apache.fop.events.ResourceEventProducer.imageNotFound">Image not found. URI: {uri}{{locator}}</message>
+  <message key="org.apache.fop.events.ResourceEventProducer.imageNotFound">Image not found.[ URI: {uri}.]{{locator}}</message>
   <message key="org.apache.fop.events.ResourceEventProducer.imageError">Image not available.[ URI: {uri}.] Reason:[ {reason}][ {e}]{{locator}}</message>
-  <message key="org.apache.fop.events.ResourceEventProducer.imageIOError">I/O error while loading image.  URI: {uri}. Reason: {ioe}{{locator}}</message>
+  <message key="org.apache.fop.events.ResourceEventProducer.imageIOError">I/O error while loading image.[ URI: {uri}.][ Reason: {ioe}]{{locator}}</message>
   <message key="org.apache.fop.events.ResourceEventProducer.ifoNoIntrinsicSize">The intrinsic dimensions of an instream-foreign-object could not be determined.{{locator}}</message>
   <message key="org.apache.fop.events.ResourceEventProducer.uriError">Error while handling URI: {uri}. Reason: {e}{{locator}}</message>
+  <message key="org.apache.fop.events.ResourceEventProducer.foreignXMLProcessingError">Some XML content will be ignored. Could not render XML in namespace "{namespaceURI}".[ Reason: {e}]</message>
+  <message key="org.apache.fop.events.ResourceEventProducer.foreignXMLNoHandler">Some XML content will be ignored. No handler defined for XML with namespace "{namespaceURI}".</message>
+  <message key="org.apache.fop.events.ResourceEventProducer.imageWritingError">Error while writing an image to the target file.[ Reason: {e}]</message>
   <message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.leaderWithoutContent">fo:leader is set to "use-content" but has no content.{{locator}}</message>
   <message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.lineOverflows">Line {line} of a paragraph overflows the available area by {overflowLength,choice,50000#{overflowLength} millipoints|50000&lt;more than 50 points}.{{locator}}</message>
   <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.rowTooTall">The contents of table-row {row} are taller than they should be (there is a block-progression-dimension or height constraint on the indicated row). Due to its contents the row grows to {effCellBPD} millipoints, but the row shouldn't get any taller than {maxCellBPD} millipoints.{{locator}}</message>
@@ -81,4 +87,5 @@
   <message key="org.apache.fop.svg.SVGEventProducer.info">SVG info: {message}</message>
   <message key="org.apache.fop.svg.SVGEventProducer.svgNotBuilt">SVG graphic could not be built. Reason: {e}</message>
   <message key="org.apache.fop.svg.SVGEventProducer.svgRenderingError">SVG graphic could not be rendered. Reason: {e}</message>
+  <message key="org.apache.fop.render.RendererEventProducer.ioError">I/O error while writing to target file.[ Reason: {ioe}]</message>
 </catalogue>

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.events;
+
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Factory for FOP's main event model.
+ */
+public class FOPEventModelFactory extends AbstractEventModelFactory {
+
+    private static final String EVENT_MODEL_FILENAME = "event-model.xml";
+
+    /** {@inheritDoc} */
+    public EventModel createEventModel() {
+        return loadModel(getClass(), EVENT_MODEL_FILENAME);
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventModelFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java Mon Mar 24 05:39:13 2008
@@ -22,6 +22,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import org.w3c.dom.Document;
+
 import org.xml.sax.Locator;
 
 import org.apache.xmlgraphics.image.loader.ImageException;
@@ -68,7 +70,7 @@
     void imageError(Object source, String uri, ImageException e, Locator loc);
     
     /**
-     * I/O error while processing image.
+     * I/O error while loading an image.
      * @param source the event source
      * @param uri the original URI of the image
      * @param ioe the I/O exception
@@ -78,6 +80,14 @@
     void imageIOError(Object source, String uri, IOException ioe, Locator loc);
 
     /**
+     * Error while writing/serializing an image to an output format.
+     * @param source the event source
+     * @param e the original exception
+     * @event.severity ERROR
+     */
+    void imageWritingError(Object source, Exception e);
+
+    /**
      * Error while handling a URI.
      * @param source the event source
      * @param uri the original URI of the image
@@ -94,4 +104,24 @@
      * @event.severity ERROR
      */
     void ifoNoIntrinsicSize(Object source, Locator loc);
+    
+    /**
+     * Error processing foreign XML content.
+     * @param source the event source
+     * @param doc the foreign XML
+     * @param namespaceURI the namespace URI of the foreign XML
+     * @param e the original exception
+     * @event.severity ERROR
+     */
+    void foreignXMLProcessingError(Object source, Document doc, String namespaceURI, Exception e);
+
+    /**
+     * No handler for foreign XML content.
+     * @param source the event source
+     * @param doc the foreign XML
+     * @param namespaceURI the namespace URI of the foreign XML
+     * @event.severity ERROR
+     */
+    void foreignXMLNoHandler(Object source, Document doc, String namespaceURI);
+    
 }

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.events.model;
+
+import java.io.InputStream;
+import java.util.MissingResourceException;
+
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.events.DefaultEventBroadcaster;
+
+/**
+ * This interface is used to instantiate (load, parse) event models.
+ */
+public abstract class AbstractEventModelFactory implements EventModelFactory {
+
+    /**
+     * Loads an event model and returns its instance.
+     * @param resourceBaseClass base class to use for loading resources
+     * @param resourceName the resource name pointing to the event model to be loaded
+     * @return the newly loaded event model.
+     */
+    public EventModel loadModel(Class resourceBaseClass, String resourceName) {
+        InputStream in = resourceBaseClass.getResourceAsStream(resourceName);
+        if (in == null) {
+            throw new MissingResourceException(
+                    "File " + resourceName + " not found",
+                    DefaultEventBroadcaster.class.getName(), ""); 
+        }
+        try {
+            return EventModelParser.parse(new StreamSource(in));
+        } catch (TransformerException e) {
+            throw new MissingResourceException(
+                    "Error reading " + resourceName + ": " + e.getMessage(),
+                    DefaultEventBroadcaster.class.getName(), ""); 
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.events.model;
+
+/**
+ * This interface is used to instantiate (load, parse) event models.
+ */
+public interface EventModelFactory {
+
+    /**
+     * Creates a new EventModel instance.
+     * @return the new EventModel instance
+     */
+    EventModel createEventModel();
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/model/EventModelFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOTreeBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOTreeBuilder.java Mon Mar 24 05:39:13 2008
@@ -35,8 +35,6 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.area.AreaTreeHandler;
-import org.apache.fop.events.EventBroadcaster;
-import org.apache.fop.events.LoggingEventListener;
 import org.apache.fop.fo.ElementMapping.Maker;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fo.pagination.Root;
@@ -131,14 +129,6 @@
         if (used) {
             throw new IllegalStateException("FOTreeBuilder (and the Fop class) cannot be reused."
                     + " Please instantiate a new instance.");
-        }
-        
-        //Backwards-compatibility: Make sure at least the LoggingEventListener is plugged in
-        //so no events are just silently swallowed.
-        EventBroadcaster broadcaster = userAgent.getEventBroadcaster(); 
-        if (!broadcaster.hasEventListeners()) {
-            broadcaster.addEventListener(
-                    new LoggingEventListener(LogFactory.getLog(FOUserAgent.class)));
         }
         
         used = true;

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Mon Mar 24 05:39:13 2008
@@ -44,6 +44,7 @@
 
     //Additional value
     private Point2D intrinsicDimensions;
+    private boolean instrisicSizeDetermined;
     
     private Length intrinsicAlignmentAdjust;
     
@@ -93,7 +94,7 @@
 
     /** Preloads the image so the intrinsic size is available. */
     private void prepareIntrinsicSize() {
-        if (intrinsicDimensions == null) {
+        if (!this.instrisicSizeDetermined) {
             XMLObj child = (XMLObj) firstChild;
             Point2D csize = new Point2D.Float(-1, -1);
             intrinsicDimensions = child.getDimension(csize);
@@ -103,6 +104,7 @@
                 eventProducer.ifoNoIntrinsicSize(this, getLocator());
             }
             intrinsicAlignmentAdjust = child.getIntrinsicAlignmentAdjust();
+            this.instrisicSizeDetermined = true;
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/AbstractRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/AbstractRenderer.java Mon Mar 24 05:39:13 2008
@@ -67,6 +67,7 @@
 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.fonts.FontInfo;
 
@@ -797,10 +798,11 @@
                     = new XMLHandlerConfigurator(userAgent);
                 configurator.configure(ctx, namespace);
                 handler.handleXML(ctx, doc, namespace);
-            } catch (Throwable t) {
+            } catch (Exception e) {
                 // could not handle document
-                log.error("Some XML content will be ignored. "
-                        + "Could not render XML", t);
+                ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                        ctx.getUserAgent().getEventBroadcaster());
+                eventProducer.foreignXMLProcessingError(this, doc, namespace, e);
             }
         } else {
             if (warnedXMLHandlers == null) {
@@ -809,8 +811,9 @@
             if (!warnedXMLHandlers.contains(namespace)) {
                 // no handler found for document
                 warnedXMLHandlers.add(namespace);
-                log.warn("Some XML content will be ignored. "
-                        + "No handler defined for XML: " + namespace);
+                ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                        ctx.getUserAgent().getEventBroadcaster());
+                eventProducer.foreignXMLNoHandler(this, doc, namespace);
             }
         }
     }

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.render;
+
+import java.io.IOException;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for rendering-specific events.
+ */
+public interface RendererEventProducer extends EventProducer {
+
+    /** Factory class for the event producer. */
+    class Factory {
+        
+        /**
+         * Creates a new event producer.
+         * @param broadcaster the event broadcaster to use
+         * @return the new event producer
+         */
+        public static RendererEventProducer create(EventBroadcaster broadcaster) {
+            return (RendererEventProducer)broadcaster.getEventProducerFor(
+                    RendererEventProducer.class);
+        }
+    }
+
+    /**
+     * I/O error while writing target file.
+     * @param source the event source
+     * @param ioe the original I/O error
+     * @event.severity ERROR
+     */
+    void ioError(Object source, IOException ioe);
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/RendererEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,63 @@
+/*
+ * 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.render.afp;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for AFP-specific events.
+ */
+public interface AFPEventProducer extends EventProducer {
+
+    /** Factory class for the event producer. */
+    class Factory {
+        
+        /**
+         * Creates a new event producer.
+         * @param broadcaster the event broadcaster to use
+         * @return the new event producer
+         */
+        public static AFPEventProducer create(EventBroadcaster broadcaster) {
+            return (AFPEventProducer)broadcaster.getEventProducerFor(
+                    AFPEventProducer.class);
+        }
+    }
+
+    /** Event model factory for AFP. */
+    public static class EventModelFactory extends AbstractEventModelFactory {
+
+        /** {@inheritDoc} */
+        public EventModel createEventModel() {
+            return loadModel(getClass(), "event-model.xml");
+        }
+        
+    }
+    
+    /**
+     * Warn about using default font setup.
+     * @param source the event source
+     * @event.severity WARN
+     */
+    void warnDefaultFontSetup(Object source);
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml Mon Mar 24 05:39:13 2008
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message key="org.apache.fop.render.afp.AFPEventProducer.warnDefaultFontSetup">No AFP fonts configured. Using default setup.</message>
+</catalogue>

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/afp/AFPRenderer.java Mon Mar 24 05:39:13 2008
@@ -70,6 +70,7 @@
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.FontInfo;
@@ -291,7 +292,9 @@
                 }
             }
         } else {
-            log.warn("No AFP fonts configured - using default setup");
+            AFPEventProducer eventProducer = AFPEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.warnDefaultFontSetup(this);
         }
         if (this.fontInfo.fontLookup("sans-serif", "normal", 400) == null) {
             CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZH200  ",
@@ -909,7 +912,7 @@
         RendererContext context;
         context = super.createRendererContext(x, y, width, height, foreignAttributes);
         context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
-                new Boolean(!this.colorImages));
+                Boolean.valueOf(!this.colorImages));
         return context;
     }
 
@@ -1014,13 +1017,17 @@
                 }
 
             } catch (ImageException ie) {
-                log.error("Error while processing image: "
-                        + (info != null ? info.toString() : uri), ie);
+                ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
             } catch (FileNotFoundException fe) {
-                log.error(fe.getMessage());
+                ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
             } catch (IOException ioe) {
-                log.error("I/O error while processing image: "
-                        + (info != null ? info.toString() : uri), ioe);
+                ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
             }
             
             /*
@@ -1195,7 +1202,9 @@
                         image.getWidth(), image.getHeight(), this.bitsPerPixel);
             }
         } catch (IOException ioe) {
-            log.error("Error while serializing bitmap: " + ioe.getMessage(), ioe);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageWritingError(this, ioe);
         }
     }
 
@@ -1305,8 +1314,9 @@
         } catch (Throwable ex) {
             encoding = AFPConstants.EBCIDIC_ENCODING;
             log.warn(
-                "renderText():: Error getting encoding for font "
-                + " - using default encoding "
+                "renderText():: Error getting encoding for font '"
+                + tf.getFullName()
+                + "' - using default encoding "
                 + encoding);
         }
 

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.render.bitmap;
+
+import java.io.IOException;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the bitmap renderers.
+ */
+public interface BitmapRendererEventProducer extends EventProducer {
+
+    /** Factory class for the event producer. */
+    class Factory {
+        
+        /**
+         * Creates a new event producer.
+         * @param broadcaster the event broadcaster to use
+         * @return the new event producer
+         */
+        public static BitmapRendererEventProducer create(EventBroadcaster broadcaster) {
+            return (BitmapRendererEventProducer)broadcaster.getEventProducerFor(
+                    BitmapRendererEventProducer.class);
+        }
+    }
+
+    /** Event model factory for this event producer. */
+    public static class EventModelFactory extends AbstractEventModelFactory {
+
+        /** {@inheritDoc} */
+        public EventModel createEventModel() {
+            return loadModel(getClass(), "event-model.xml");
+        }
+        
+    }
+    
+    /**
+     * No filename information available. Stopping early after the first page.
+     * @param source the event source
+     * @event.severity WARN
+     */
+    void stoppingAfterFirstPageNoFilename(Object source);
+    
+    /**
+     * Image writer does not support multiple images. Only the first page has been produced.
+     * @param source the event source
+     * @event.severity WARN
+     */
+    void stoppingAfterFirstPageNoMultiWriter(Object source);
+    
+    /**
+     * No ImageWriter found.
+     * @param source the event source
+     * @param mime the target MIME type
+     * @throws IOException the I/O error provoked by the method call
+     * @event.severity FATAL
+     */
+    void noImageWriterFound(Object source, String mime) throws IOException;
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml Mon Mar 24 05:39:13 2008
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message key="org.apache.fop.render.bitmap.BitmapRendererEventProducer.stoppingAfterFirstPageNoFilename">No filename information available. Stopping early after the first page.</message>
+  <message key="org.apache.fop.render.bitmap.BitmapRendererEventProducer.stoppingAfterFirstPageNoMultiWriter">Image writer does not support multiple images. Only the first page has been produced.</message>
+  <message key="org.apache.fop.render.bitmap.BitmapRendererEventProducer.noImageWriterFound">Could not get an ImageWriter to produce "{mime}". The most likely explanation for this is a class loading problem.</message>
+</catalogue>

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/PNGRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/PNGRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/PNGRenderer.java Mon Mar 24 05:39:13 2008
@@ -23,12 +23,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.commons.io.IOUtils;
+
 import org.apache.xmlgraphics.image.writer.ImageWriter;
 import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
 
-import org.apache.commons.io.IOUtils;
-
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.java2d.Java2DRenderer;
@@ -74,8 +74,10 @@
 
             OutputStream os = getCurrentOutputStream(i);
             if (os == null) {
-                log.warn("No filename information available."
-                        + " Stopping early after the first page.");
+                BitmapRendererEventProducer eventProducer
+                    = BitmapRendererEventProducer.Factory.create(
+                            getUserAgent().getEventBroadcaster());
+                eventProducer.stoppingAfterFirstPageNoFilename(this);
                 break;
             }
             try {
@@ -104,9 +106,10 @@
         // Encode PNG image
         ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
         if (writer == null) {
-            throw new IOException("Could not get an ImageWriter to produce " 
-                    + getMimeType() + ". The most likely explanation for this is a class"
-                    + " loading problem.");
+            BitmapRendererEventProducer eventProducer
+                = BitmapRendererEventProducer.Factory.create(
+                        getUserAgent().getEventBroadcaster());
+            eventProducer.noImageWriterFound(this, getMimeType());
         }
         if (log.isDebugEnabled()) {
             log.debug("Writing image using " + writer.getClass().getName());

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Mon Mar 24 05:39:13 2008
@@ -129,7 +129,10 @@
         // Creates writer
         ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
         if (writer == null) {
-            throw new NullPointerException("No ImageWriter for " + getMimeType() + " available!");
+            BitmapRendererEventProducer eventProducer
+                = BitmapRendererEventProducer.Factory.create(
+                        getUserAgent().getEventBroadcaster());
+            eventProducer.noImageWriterFound(this, getMimeType());
         }
         if (writer.supportsMultiImageWriter()) {
             MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
@@ -145,8 +148,10 @@
         } else {
             writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams);
             if (pageImagesItr.hasNext()) {
-                log.error("Image encoder does not support multiple images. Only the first page"
-                        + " has been produced.");
+                BitmapRendererEventProducer eventProducer
+                    = BitmapRendererEventProducer.Factory.create(
+                            getUserAgent().getEventBroadcaster());
+                eventProducer.stoppingAfterFirstPageNoFilename(this);
             }
         }
 

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Mon Mar 24 05:39:13 2008
@@ -66,6 +66,7 @@
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
@@ -930,13 +931,17 @@
                         pos, foreignAttributes);
             }
         } catch (ImageException ie) {
-            log.error("Error while processing image: "
-                    + (info != null ? info.toString() : uri), ie);
-        } catch (FileNotFoundException fnfe) {
-            log.error(fnfe.getMessage());
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+        } catch (FileNotFoundException fe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
         } catch (IOException ioe) {
-            log.error("I/O error while processing image: "
-                    + (info != null ? info.toString() : uri), ioe);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java Mon Mar 24 05:39:13 2008
@@ -25,14 +25,14 @@
 
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.XMLHandler;
+import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
 
 /**
@@ -40,7 +40,8 @@
  * This handler handles XML for foreign objects when rendering to Java2D.
  * The properties from the Java2D renderer are subject to change.
  */
-public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConstants {
+public class Java2DSVGHandler extends AbstractGenericSVGHandler
+            implements Java2DRendererContextConstants {
 
     /** logging instance */
     private static Log log = LogFactory.getLog(Java2DSVGHandler.class);
@@ -52,16 +53,6 @@
         //nop
     }
 
-    /** {@inheritDoc} */
-    public void handleXML(RendererContext context, 
-                Document doc, String ns) throws Exception {
-        Java2DInfo pdfi = getJava2DInfo(context);
-
-        if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
-            renderSVGDocument(context, doc, pdfi);
-        }
-    }
-
     /**
      * Get the pdf information from the render context.
      *
@@ -104,18 +95,14 @@
         }
     }
     
-    /**
-     * Render the svg document.
-     * @param context the renderer context
-     * @param doc the svg document
-     * @param info the pdf information of the current context
-     */
+    /** {@inheritDoc} */
     protected void renderSVGDocument(RendererContext context,
-                                     Document doc,
-                                     Java2DInfo info) {
+                                     Document doc) {
+        Java2DInfo info = getJava2DInfo(context);
+        if (log.isDebugEnabled()) {
+            log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")");
+        }
 
-        log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")");
-        
         int x = info.currentXPosition;
         int y = info.currentYPosition;
         
@@ -128,7 +115,9 @@
         try {
             root = builder.build(ctx, doc);
         } catch (Exception e) {
-            log.error("SVG graphic could not be built: " + e.getMessage(), e);
+            SVGEventProducer eventProducer = SVGEventProducer.Factory.create(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
             return;
         }
         
@@ -155,7 +144,9 @@
         try {
             root.paint(info.state.getGraph());
         } catch (Exception e) {
-            log.error("Error while painting SVG", e);
+            SVGEventProducer eventProducer = SVGEventProducer.Factory.create(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
         }
         
         info.state.getGraph().setTransform(origTransform);
@@ -166,9 +157,4 @@
         return (renderer instanceof Java2DRenderer);
     }
 
-
-    /** {@inheritDoc} */
-    public String getNamespace() {
-        return SVGDOMImplementation.SVG_NAMESPACE_URI;
-    }
 }

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.render.pcl;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the PCL renderer.
+ */
+public interface PCLEventProducer extends EventProducer {
+
+    /** Factory class for the event producer. */
+    class Factory {
+        
+        /**
+         * Creates a new event producer.
+         * @param broadcaster the event broadcaster to use
+         * @return the new event producer
+         */
+        public static PCLEventProducer create(EventBroadcaster broadcaster) {
+            return (PCLEventProducer)broadcaster.getEventProducerFor(
+                    PCLEventProducer.class);
+        }
+    }
+
+    /** Event model factory for this event producer. */
+    public static class EventModelFactory extends AbstractEventModelFactory {
+
+        /** {@inheritDoc} */
+        public EventModel createEventModel() {
+            return loadModel(getClass(), "event-model.xml");
+        }
+        
+    }
+    
+    /**
+     * Paper type could not be determined. Falling back to another.
+     * @param source the event source
+     * @param pageWidth the page width (in millipoints)
+     * @param pageHeight the page height (in millipoints)
+     * @param fallbackPaper the paper type that will be used instead
+     * @event.severity WARN
+     */
+    void paperTypeUnavailable(Object source, long pageWidth, long pageHeight, String fallbackPaper);
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml Mon Mar 24 05:39:13 2008
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message key="org.apache.fop.render.pcl.PCLEventProducer.paperTypeUnavailable">Paper type ({pageWidth} x {pageHeight} mpt) could not be determined. Falling back to: {fallbackPaper}</message>
+</catalogue>

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLGenerator.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLGenerator.java Mon Mar 24 05:39:13 2008
@@ -43,9 +43,11 @@
 import java.util.Locale;
 
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.fop.util.UnitConv;
+
 import org.apache.xmlgraphics.image.GraphicsUtil;
 
+import org.apache.fop.util.UnitConv;
+
 /**
  * This class provides methods for generating PCL print files.
  */
@@ -355,16 +357,16 @@
         if (usePCLShades 
                 || Color.black.equals(col)
                 || Color.white.equals(col)) {
-            writeCommand("*c" + formatDouble4(w / 100) + "h" 
-                              + formatDouble4(h / 100) + "V");
+            writeCommand("*c" + formatDouble4(w / 100.0) + "h" 
+                              + formatDouble4(h / 100.0) + "V");
             int lineshade = convertToPCLShade(col);
             writeCommand("*c" + lineshade + "G");
             writeCommand("*c2P"); //Shaded fill
         } else {
             defineGrayscalePattern(col, 32, DITHER_MATRIX_4X4);
 
-            writeCommand("*c" + formatDouble4(w / 100) + "h" 
-                              + formatDouble4(h / 100) + "V");
+            writeCommand("*c" + formatDouble4(w / 100.0) + "h" 
+                              + formatDouble4(h / 100.0) + "V");
             writeCommand("*c32G");
             writeCommand("*c4P"); //User-defined pattern
         }

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=640395&r1=640394&r2=640395&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pcl/PCLRenderer.java Mon Mar 24 05:39:13 2008
@@ -78,6 +78,7 @@
 import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
@@ -86,6 +87,7 @@
 import org.apache.fop.render.PrintRenderer;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.RendererContextConstants;
+import org.apache.fop.render.RendererEventProducer;
 import org.apache.fop.render.java2d.FontMetricsMapper;
 import org.apache.fop.render.java2d.FontSetup;
 import org.apache.fop.render.java2d.Java2DRenderer;
@@ -208,7 +210,9 @@
      */
     protected void handleIOTrouble(IOException ioe) {
         if (!ioTrouble) {
-            log.error("Error while writing to target file", ioe);
+            RendererEventProducer eventProducer = RendererEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.ioError(this, ioe);
             ioTrouble = true;
         }
     }
@@ -417,11 +421,15 @@
         
         if (this.currentPageDefinition == null) {
             this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition();
-            log.warn("Paper type could not be determined. Falling back to: " 
-                    + this.currentPageDefinition.getName());
+            PCLEventProducer eventProducer = PCLEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.paperTypeUnavailable(this, pagewidth, pageheight,
+                    this.currentPageDefinition.getName());
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
+            log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
         }
-        log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
-        log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
         if (this.currentPageDefinition.isLandscapeFormat()) {
             gen.writeCommand("&l1O"); //Orientation
         } else {
@@ -1107,12 +1115,17 @@
             }
 
         } catch (ImageException ie) {
-            log.error("Error while processing image: "
-                    + (info != null ? info.toString() : uri), ie);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
         } catch (FileNotFoundException fe) {
-            log.error(fe.getMessage());
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
         } catch (IOException ioe) {
-            handleIOTrouble(ioe);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java Mon Mar 24 05:39:13 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.render.pdf;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the PDF renderer.
+ */
+public interface PDFEventProducer extends EventProducer {
+
+    /** Factory class for the event producer. */
+    class Factory {
+        
+        /**
+         * Creates a new event producer.
+         * @param broadcaster the event broadcaster to use
+         * @return the new event producer
+         */
+        public static PDFEventProducer create(EventBroadcaster broadcaster) {
+            return (PDFEventProducer)broadcaster.getEventProducerFor(
+                    PDFEventProducer.class);
+        }
+    }
+
+    /** Event model factory for this event producer. */
+    public static class EventModelFactory extends AbstractEventModelFactory {
+
+        /** {@inheritDoc} */
+        public EventModel createEventModel() {
+            return loadModel(getClass(), "event-model.xml");
+        }
+        
+    }
+    
+    /**
+     * Some link targets haven't been fully resolved.
+     * @param source the event source
+     * @param count the number of unresolved links
+     * @event.severity WARN
+     */
+    void nonFullyResolvedLinkTargets(Object source, int count);
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml?rev=640395&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml Mon Mar 24 05:39:13 2008
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message key="org.apache.fop.render.pdf.PDFEventProducer.nonFullyResolvedLinkTargets">{count} link target{count,equals,1,,s} could not be fully resolved and now point{count,equals,1,,s} to the top of the page or {count,equals,1,is,are} dysfunctional.</message>
+</catalogue>

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Id



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


Mime
View raw message