You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/04/14 15:06:05 UTC

svn commit: r647787 [5/5] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ examples/embedding/java/embedding/events/ lib/build/ src/codegen/java/ src/codegen/java/org/ src/codegen/java/org/apache/ src/codegen/java/org/apache/fop/ src/codegen/ja...

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Mon Apr 14 06:05:52 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.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+        } catch (FileNotFoundException fe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    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.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java Mon Apr 14 06:05:52 2008
@@ -23,26 +23,25 @@
 
 import org.w3c.dom.Document;
 
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.XMLHandler;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.svg.SVGUserAgent;
-
-// Commons-Logging
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.gvt.GraphicsNode;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.gvt.GraphicsNode;
+import org.apache.fop.render.AbstractGenericSVGHandler;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererContext;
+import org.apache.fop.svg.SVGEventProducer;
+import org.apache.fop.svg.SVGUserAgent;
 
 /**
  * Java2D XML handler for SVG (uses Apache Batik).
  * 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);
@@ -54,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.
      *
@@ -106,23 +95,18 @@
         }
     }
     
-    /**
-     * 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;
         
-        float ptom = context.getUserAgent().getSourcePixelUnitToMillimeter();
-        SVGUserAgent ua = new SVGUserAgent(ptom, new AffineTransform());
+        SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
         
         GVTBuilder builder = new GVTBuilder();
         BridgeContext ctx = new BridgeContext(ua);
@@ -131,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.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
             return;
         }
         
@@ -158,7 +144,9 @@
         try {
             root.paint(info.state.getGraph());
         } catch (Exception e) {
-            log.error("Error while painting SVG", e);
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
         }
         
         info.state.getGraph().setTransform(origTransform);
@@ -169,9 +157,4 @@
         return (renderer instanceof Java2DRenderer);
     }
 
-
-    /** {@inheritDoc} */
-    public String getNamespace() {
-        return SVGDOMImplementation.SVG_NAMESPACE_URI;
-    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLGenerator.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLGenerator.java Mon Apr 14 06:05:52 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_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRenderer.java Mon Apr 14 06:05:52 2008
@@ -58,6 +58,7 @@
 import org.apache.xmlgraphics.image.loader.util.ImageUtil;
 import org.apache.xmlgraphics.java2d.GraphicContext;
 import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.util.QName;
 
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.MimeConstants;
@@ -77,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;
@@ -85,12 +87,12 @@
 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;
 import org.apache.fop.render.pcl.extensions.PCLElementMapping;
 import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.QName;
 import org.apache.fop.util.UnitConv;
 
 /* Note:
@@ -208,7 +210,9 @@
      */
     protected void handleIOTrouble(IOException ioe) {
         if (!ioTrouble) {
-            log.error("Error while writing to target file", ioe);
+            RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+                    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.Provider.get(
+                    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.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
         } catch (FileNotFoundException fe) {
-            log.error(fe.getMessage());
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
         } catch (IOException ioe) {
-            handleIOTrouble(ioe);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRendererContext.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRendererContext.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRendererContext.java Mon Apr 14 06:05:52 2008
@@ -19,9 +19,10 @@
 
 package org.apache.fop.render.pcl;
 
+import org.apache.xmlgraphics.util.QName;
+
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.render.RendererContext;
-import org.apache.fop.util.QName;
 
 /**
  * Wrapper on the RendererContext to access the information structure for drawing 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java Mon Apr 14 06:05:52 2008
@@ -73,6 +73,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.fo.extensions.xmp.XMPMetadata;
@@ -490,13 +491,10 @@
                 PDFGoTo gt = (PDFGoTo) unfinishedGoTos.get(0);
                 finishIDGoTo(gt, defaultPos);
             }
-            boolean one = count == 1;
-            String pl = one ? ""    : "s";
-            String ww = one ? "was" : "were";
-            String ia = one ? "is"  : "are";
-            log.warn("" + count + " link target" + pl + " could not be fully resolved and "
-                        + ww + " now point to the top of the page or "
-                        + ia + " dysfunctional.");  // dysfunctional if pageref is null
+            PDFEventProducer eventProducer = PDFEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.nonFullyResolvedLinkTargets(this, count);
+            // dysfunctional if pageref is null
         }
     }
 
@@ -555,16 +553,17 @@
 
     private void renderDestination(DestinationData dd) {
         String targetID = dd.getIDRef();
-        if (targetID != null && targetID.length() > 0) {
-            PageViewport pv = dd.getPageViewport();
-            if (pv == null) {
-                log.warn("Unresolved destination item received: " + dd.getIDRef());
-            }
+        if (targetID == null || targetID.length() == 0) {
+            throw new IllegalArgumentException("DestinationData must contain a ID reference");
+        }
+        PageViewport pv = dd.getPageViewport();
+        if (pv != null) {
             PDFGoTo gt = getPDFGoToForID(targetID, pv.getKey());
             pdfDoc.getFactory().makeDestination(
                     dd.getIDRef(), gt.makeReference());
         } else {
-            log.warn("DestinationData item with null or empty IDRef received.");
+            //Warning already issued by AreaTreeHandler (debug level is sufficient)
+            log.debug("Unresolved destination item received: " + dd.getIDRef());
         }
     }
 
@@ -584,22 +583,22 @@
         PDFOutline pdfOutline = null;
 
         String targetID = bookmarkItem.getIDRef();
-        if (targetID != null && targetID.length() > 0) {
-            PageViewport pv = bookmarkItem.getPageViewport();
-            if (pv != null) {
-                String pvKey = pv.getKey();
-                PDFGoTo gt = getPDFGoToForID(targetID, pvKey);
-                // create outline object:
-                PDFOutline parent = parentBookmarkItem != null
-                    ? parentBookmarkItem
-                    : pdfDoc.getOutlineRoot();
-                pdfOutline = pdfDoc.getFactory().makeOutline(parent,
-                        bookmarkItem.getBookmarkTitle(), gt, bookmarkItem.showChildItems());
-            } else {
-                log.warn("Bookmark with IDRef \"" + targetID + "\" has a null PageViewport.");
-            }
+        if (targetID == null || targetID.length() == 0) {
+            throw new IllegalArgumentException("DestinationData must contain a ID reference");
+        }
+        PageViewport pv = bookmarkItem.getPageViewport();
+        if (pv != null) {
+            String pvKey = pv.getKey();
+            PDFGoTo gt = getPDFGoToForID(targetID, pvKey);
+            // create outline object:
+            PDFOutline parent = parentBookmarkItem != null
+                ? parentBookmarkItem
+                : pdfDoc.getOutlineRoot();
+            pdfOutline = pdfDoc.getFactory().makeOutline(parent,
+                    bookmarkItem.getBookmarkTitle(), gt, bookmarkItem.showChildItems());
         } else {
-            log.warn("Bookmark item with null or empty IDRef received.");
+            //Warning already issued by AreaTreeHandler (debug level is sufficient)
+            log.debug("Bookmark with IDRef \"" + targetID + "\" has a null PageViewport.");
         }
 
         for (int i = 0; i < bookmarkItem.getCount(); i++) {
@@ -1368,15 +1367,8 @@
                 if (annotsAllowed) {
                     action = getPDFGoToForID(idRef, pvKey);
                 }
-            } else if (pvKeyOK) {
-                log.warn("Internal link trait with PageViewport key " + pvKey 
-                         + " contains no ID reference.");
-            } else if (idRefOK) {
-                log.warn("Internal link trait with ID reference " + idRef 
-                         + " contains no PageViewport key.");
             } else {
-                log.warn("Internal link trait received with neither PageViewport key"
-                         + " nor ID reference.");
+                //Warnings already issued by AreaTreeHandler
             }
         }
 
@@ -1671,7 +1663,9 @@
                             x, y, posInt.width, posInt.height, foreignAttributes);
                     handler.generateImage(context, img, origin, posInt);
                 } catch (IOException ioe) {
-                    log.error("I/O error while handling image: " + info, ioe);
+                    ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                            getUserAgent().getEventBroadcaster());
+                    eventProducer.imageWritingError(this, ioe);
                     return;
                 }
             } else {
@@ -1680,13 +1674,17 @@
                             + info + " (" + img.getClass().getName() + ")");
             }
         } 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.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+        } catch (FileNotFoundException fe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    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.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
 
         // output new data
@@ -1811,18 +1809,34 @@
         return MIME_TYPE;
     }
     
+    /**
+     * Sets the PDF/A mode for the PDF renderer.
+     * @param mode the PDF/A mode
+     */
     public void setAMode(PDFAMode mode) {
         this.pdfAMode = mode;
     }
 
+    /**
+     * Sets the PDF/X mode for the PDF renderer.
+     * @param mode the PDF/X mode
+     */
     public void setXMode(PDFXMode mode) {
         this.pdfXMode = mode;        
     }
 
+    /**
+     * Sets the output color profile for the PDF renderer.
+     * @param outputProfileURI the URI to the output color profile
+     */
     public void setOutputProfileURI(String outputProfileURI) {
         this.outputProfileURI = outputProfileURI;
     }
 
+    /**
+     * Sets the filter map to be used by the PDF renderer.
+     * @param filterMap the filter map
+     */
     public void setFilterMap(Map filterMap) {
         this.filterMap = filterMap;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java Mon Apr 14 06:05:52 2008
@@ -36,6 +36,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.util.QName;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.FontInfo;
@@ -51,8 +53,8 @@
 import org.apache.fop.svg.PDFAElementBridge;
 import org.apache.fop.svg.PDFBridgeContext;
 import org.apache.fop.svg.PDFGraphics2D;
+import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
-import org.apache.fop.util.QName;
 
 /**
  * PDF XML handler for SVG (uses Apache Batik).
@@ -144,8 +146,9 @@
             try {
                 super.renderSVGDocument(context, doc);
             } catch (IOException ioe) {
-                log.error("I/O error while rendering SVG graphic: "
-                                       + ioe.getMessage(), ioe);
+                SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                        context.getUserAgent().getEventBroadcaster());
+                eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
             }
             return;
         }
@@ -153,15 +156,13 @@
         int yOffset = pdfInfo.currentYPosition;
 
         FOUserAgent userAgent = context.getUserAgent(); 
-        log.debug("Generating SVG at " 
-                + userAgent.getTargetResolution()
-                + "dpi.");
         final float deviceResolution = userAgent.getTargetResolution();
-        log.debug("Generating SVG at " + deviceResolution + "dpi.");
-        log.debug("Generating SVG at " + deviceResolution + "dpi.");
+        if (log.isDebugEnabled()) {
+            log.debug("Generating SVG at " + deviceResolution + "dpi.");
+        }
         
         final float uaResolution = userAgent.getSourceResolution();
-        SVGUserAgent ua = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
+        SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());
 
         //Scale for higher resolution on-the-fly images from Batik
         double s = uaResolution / deviceResolution;
@@ -188,8 +189,9 @@
             root = builder.build(ctx, doc);
             builder = null;
         } catch (Exception e) {
-            log.error("svg graphic could not be built: "
-                                   + e.getMessage(), e);
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
             return;
         }
         // get the 'width' and 'height' attributes of the SVG document
@@ -261,8 +263,9 @@
             root.paint(graphics);
             pdfInfo.currentStream.add(graphics.getString());
         } catch (Exception e) {
-            log.error("svg graphic could not be rendered: "
-                                   + e.getMessage(), e);
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
         }
         pdfInfo.pdfState.pop();
         renderer.restoreGraphicsState();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java Mon Apr 14 06:05:52 2008
@@ -85,6 +85,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.Font;
@@ -95,6 +96,7 @@
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.ImageAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererEventProducer;
 import org.apache.fop.render.ps.extensions.PSCommentAfter;
 import org.apache.fop.render.ps.extensions.PSCommentBefore;
 import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
@@ -296,7 +298,9 @@
      */
     protected void handleIOTrouble(IOException ioe) {
         if (!ioTrouble) {
-            log.error("Error while writing to target file", ioe);
+            RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.ioError(this, ioe);
             ioTrouble = true;
         }
     }
@@ -522,12 +526,17 @@
             }
 
         } catch (ImageException ie) {
-            log.error("Error while processing image: "
-                    + (info != null ? info.toString() : uri), ie);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
         } catch (FileNotFoundException fe) {
-            log.error(fe.getMessage());
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
         } catch (IOException ioe) {
-            handleIOTrouble(ioe);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 
@@ -1070,8 +1079,9 @@
                             try {
                                 this.pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
                             } catch (PSDictionaryFormatException e) {
-                                log.error("Failed to parse dictionary string: "
-                                        + e.getMessage() + ", content = '" + content + "'");
+                                PSEventProducer eventProducer = PSEventProducer.Provider.get(
+                                        getUserAgent().getEventBroadcaster());
+                                eventProducer.postscriptDictionaryParseError(this, content, e);
                             }
                         }
                     } else if (attachment instanceof PSCommentBefore) {
@@ -1169,8 +1179,9 @@
                         try {
                             pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
                         } catch (PSDictionaryFormatException e) {
-                            log.error("failed to parse dictionary string: "
-                                    + e.getMessage() + ", [" + content + "]");
+                            PSEventProducer eventProducer = PSEventProducer.Provider.get(
+                                    getUserAgent().getEventBroadcaster());
+                            eventProducer.postscriptDictionaryParseError(this, content, e);
                         }
                     }
                 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSSVGHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSSVGHandler.java Mon Apr 14 06:05:52 2008
@@ -23,31 +23,24 @@
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
 
-// DOM
 import org.w3c.dom.Document;
-import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.svg.SVGSVGElement;
 
-// Batik
 import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.gvt.GraphicsNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
 
-// FOP
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
-import org.apache.fop.render.XMLHandler;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-
-// Commons-Logging
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * PostScript XML handler for SVG. Uses Apache Batik for SVG processing.
@@ -57,7 +50,8 @@
  *
  * @version $Id$
  */
-public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
+public class PSSVGHandler extends AbstractGenericSVGHandler
+            implements PSRendererContextConstants {
 
     /** logging instance */
     private static Log log = LogFactory.getLog(PSSVGHandler.class);
@@ -68,16 +62,6 @@
     public PSSVGHandler() {
     }
 
-    /** {@inheritDoc} */
-    public void handleXML(RendererContext context, 
-                Document doc, String ns) throws Exception {
-        PSInfo psi = getPSInfo(context);
-
-        if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
-            renderSVGDocument(context, doc, psi);
-        }
-    }
-
     /**
      * Get the pdf information from the render context.
      *
@@ -234,10 +218,10 @@
      * Render the svg document.
      * @param context the renderer context
      * @param doc the svg document
-     * @param psInfo the pdf information of the current context
      */
     protected void renderSVGDocument(RendererContext context,
-            Document doc, PSInfo psInfo) {
+            Document doc) {
+        PSInfo psInfo = getPSInfo(context);
         int xOffset = psInfo.currentXPosition;
         int yOffset = psInfo.currentYPosition;
         PSGenerator gen = psInfo.psGenerator;
@@ -250,9 +234,7 @@
         }
 
         SVGUserAgent ua
-             = new SVGUserAgent(
-                context.getUserAgent().getSourcePixelUnitToMillimeter(),
-                new AffineTransform());
+             = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
 
         PSGraphics2D graphics = new PSGraphics2D(strokeText, gen);
         graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
@@ -273,8 +255,9 @@
         try {
             root = builder.build(ctx, doc);
         } catch (Exception e) {
-            log.error("SVG graphic could not be built: "
-                                   + e.getMessage(), e);
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
             return;
         }
         // get the 'width' and 'height' attributes of the SVG document
@@ -305,10 +288,10 @@
             // viewBox puts it.
             gen.concatMatrix(sx, 0, 0, sy, xOffset / 1000f, yOffset / 1000f);
 
+            /*
             SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
             AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
-                    psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f);
-            /*
+                    psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f, ctx);
             if (!at.isIdentity()) {
                 double[] vals = new double[6];
                 at.getMatrix(vals);
@@ -322,15 +305,17 @@
             try {
                 root.paint(graphics);
             } catch (Exception e) {
-                log.error("SVG graphic could not be rendered: "
-                                       + e.getMessage(), e);
+                SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                        context.getUserAgent().getEventBroadcaster());
+                eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
             }
 
             gen.restoreGraphicsState();
             gen.commentln("%FOPEndSVG");
         } catch (IOException ioe) {
-            log.error("SVG graphic could not be rendered: "
-                                   + ioe.getMessage(), ioe);
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                    context.getUserAgent().getEventBroadcaster());
+            eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
         }
     }
 
@@ -339,10 +324,5 @@
         return (renderer instanceof PSRenderer);
     }
     
-    /** {@inheritDoc} */
-    public String getNamespace() {
-        return SVGDOMImplementation.SVG_NAMESPACE_URI;
-    }
-
 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/ResourceHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/ResourceHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/ResourceHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/ResourceHandler.java Mon Apr 14 06:05:52 2008
@@ -20,8 +20,8 @@
 package org.apache.fop.render.ps;
 
 import java.awt.geom.Dimension2D;
-import java.awt.image.RenderedImage;
 import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -68,6 +68,7 @@
 import org.apache.xmlgraphics.ps.dsc.tools.DSCTools;
 
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fonts.FontInfo;
 
 /**
@@ -321,7 +322,10 @@
                     throw new UnsupportedOperationException("Unsupported image type: " + img);
                 }
             } catch (ImageException ie) {
-                throw new IOException("Error while generating form for image: " + ie.getMessage());
+                ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                        userAgent.getEventBroadcaster());
+                eventProducer.imageError(resTracker, (info != null ? info.toString() : uri),
+                        ie, null);
             }
         }
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java Mon Apr 14 06:05:52 2008
@@ -22,7 +22,6 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
 
 /**
  * Base postscript commment element class
@@ -46,8 +45,8 @@
     protected void startOfNode() throws FOPException {
         if (parent.getNameId() != Constants.FO_DECLARATIONS
                 && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
-          throw new ValidationException(getName()
-          + " must be a child of fo:declarations or fo:simple-page-master.");            
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                    "rule.childOfSPMorDeclarations");
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java Mon Apr 14 06:05:52 2008
@@ -20,14 +20,14 @@
 package org.apache.fop.render.ps.extensions;
 
 // FOP
+import org.xml.sax.Locator;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 
-import org.xml.sax.Locator;
-
 /**
  * Base class for the PostScript-specific extension elements.
  */
@@ -98,7 +98,7 @@
      * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
      */
     public String getNormalNamespacePrefix() {
-        return "fox";
+        return "ps";
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java Mon Apr 14 06:05:52 2008
@@ -20,13 +20,14 @@
 package org.apache.fop.render.ps.extensions;
 
 // FOP
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
 
 /**
  * Base class for the PostScript-specific extension elements.
@@ -36,15 +37,15 @@
     private PSSetupCode setupCode = new PSSetupCode();
     
     /**
+     * Main constructor.
+     * @param parent the parent node
      * @see org.apache.fop.fo.FONode#FONode(FONode)
      */
     public AbstractPSExtensionObject(FONode parent) {
         super(parent);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void validateChildNode(Locator loc, String nsURI, String localName) 
                 throws ValidationException {
         if (FO_URI.equals(nsURI)) {
@@ -71,7 +72,7 @@
     
     /**{@inheritDoc} */
     public String getNormalNamespacePrefix() {
-        return "fox";
+        return "ps";
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java Mon Apr 14 06:05:52 2008
@@ -27,6 +27,9 @@
  */
 public class PSCommentAfterElement extends AbstractPSCommentElement {
 
+    /** the element name */
+    protected static final String ELEMENT = "ps-comment-after";
+
     /**
      * Main constructor
      * @param parent node

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java Mon Apr 14 06:05:52 2008
@@ -27,6 +27,9 @@
  */
 public class PSCommentBeforeElement extends AbstractPSCommentElement {
 
+    /** the element name */
+    protected static final String ELEMENT = "ps-comment-before";
+
     /**
      * Main constructor
      * @param parent parent node

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java Mon Apr 14 06:05:52 2008
@@ -19,13 +19,15 @@
 
 package org.apache.fop.render.ps.extensions;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * ContentHandler (parser) for restoring PSExtension objects from XML.
@@ -91,25 +93,19 @@
         content.append(ch, start, length);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void endDocument() throws SAXException {
         if (listener != null) {
             listener.notifyObjectBuilt(getObject());
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public Object getObject() {
         return returnedObject;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void setObjectBuiltListener(ObjectBuiltListener listener) {
         this.listener = listener;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java Mon Apr 14 06:05:52 2008
@@ -22,13 +22,13 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
 
 /**
  * Extension element for fox:ps-page-setup-code. 
  */
 public class PSPageSetupCodeElement extends AbstractPSExtensionObject {
 
+    /** The element name */
     protected static final String ELEMENT = "ps-page-setup-code";
     
     /**
@@ -43,7 +43,8 @@
     protected void startOfNode() throws FOPException {
         super.startOfNode();
         if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
-            throw new ValidationException(getName() + " must be a child of fo:simple-page-master.");
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                "rule.childOfSPM");
         }
     }
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java Mon Apr 14 06:05:52 2008
@@ -19,20 +19,21 @@
 
 package org.apache.fop.render.ps.extensions;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
 
 /**
  * Extension element for ps:ps-setpagedevice. 
  */
 public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
 
+    /** The element name */
     protected static final String ELEMENT = "ps-setpagedevice";
 
     /**
@@ -52,8 +53,8 @@
         super.startOfNode();
         if ( !((parent.getNameId() == Constants.FO_DECLARATIONS)
                 || (parent.getNameId() == Constants.FO_SIMPLE_PAGE_MASTER)) ) {
-            throw new ValidationException( getName()
-                    + " must be a child of fo:declarations or fo:simple-page-master.");
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                    "rule.childOfSPMorDeclarations");
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java Mon Apr 14 06:05:52 2008
@@ -22,13 +22,13 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
 
 /**
  * Extension element for fox:ps-setup-code. 
  */
 public class PSSetupCodeElement extends AbstractPSExtensionObject {
 
+    /** The element name */
     protected static final String ELEMENT = "ps-setup-code";
     
     /**
@@ -43,7 +43,8 @@
     protected void startOfNode() throws FOPException {
         super.startOfNode();
         if (parent.getNameId() != Constants.FO_DECLARATIONS) {
-            throw new ValidationException(getName() + " must be a child of fo:declarations.");
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                    "rule.childOfDeclarations");
         }
     }
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java Mon Apr 14 06:05:52 2008
@@ -21,6 +21,7 @@
 
 // Java
 import java.awt.geom.Point2D;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -51,6 +52,7 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FONode;
@@ -88,6 +90,7 @@
 import org.apache.fop.fo.properties.FixedLength;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.render.DefaultFontResolver;
+import org.apache.fop.render.RendererEventProducer;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfBeforeContainer;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfListContainer;
@@ -159,6 +162,16 @@
     }
 
     /**
+     * Central exception handler for I/O exceptions.
+     * @param ioe IOException to handle
+     */
+    protected void handleIOTrouble(IOException ioe) {
+        RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+                getUserAgent().getEventBroadcaster());
+        eventProducer.ioError(this, ioe);
+    }
+
+    /**
      * {@inheritDoc}
      */
     public void startDocument() throws SAXException {
@@ -195,9 +208,9 @@
                 this.pagemaster
                         = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
                 if (this.pagemaster == null) {
-                    log.warn("Only simple-page-masters are supported on page-sequences: " 
-                            + reference);
-                    log.warn("Using default simple-page-master from page-sequence-master...");
+                    RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+                            getUserAgent().getEventBroadcaster());
+                    eventProducer.onlySPMSupported(this, reference, pageSeq.getLocator());
                     PageSequenceMaster master 
                         = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
                     this.pagemaster = master.getNextSimplePageMaster(
@@ -218,7 +231,9 @@
                     PageAttributesConverter.convertPageAttributes(
                             pagemaster));
             } else {
-                log.warn("No simple-page-master could be determined!");
+                RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.noSPMFound(this, pageSeq.getLocator());
             }
 
             builderContext.pushContainer(sect);
@@ -226,9 +241,7 @@
             bHeaderSpecified = false;
             bFooterSpecified = false;
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startPageSequence: " + ioe.getMessage(), ioe);
-            //TODO throw new FOPException(ioe);
+            handleIOTrouble(ioe);
         } catch (FOPException fope) {
             // TODO could we throw Exception in all FOEventHandler events?
             log.error("startPageSequence: " + fope.getMessage(), fope);
@@ -338,8 +351,7 @@
                 log.warn("A " + fl.getLocalName() + " has been skipped: " + fl.getFlowName());
             }
         } catch (IOException ioe) {
-            log.error("startFlow: " + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startFlow: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -396,9 +408,7 @@
             textrun.pushBlockAttributes(rtfAttr);
             textrun.addBookmark(bl.getId());
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startBlock: " + ioe.getMessage());
-            throw new RuntimeException("IOException: " + ioe);
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startBlock: " + e.getMessage());
             throw new RuntimeException("Exception: " + e);
@@ -427,8 +437,7 @@
             textrun.popBlockAttributes();
 
         } catch (IOException ioe) {
-            log.error("startBlock:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startBlock:" + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -457,9 +466,7 @@
             textrun.addParagraphBreak();
             textrun.pushBlockAttributes(rtfAttr);
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startBlock: " + ioe.getMessage());
-            throw new RuntimeException("IOException: " + ioe);
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startBlock: " + e.getMessage());
             throw new RuntimeException("Exception: " + e);
@@ -486,8 +493,7 @@
             textrun.popBlockAttributes();
 
         } catch (IOException ioe) {
-            log.error("startBlock:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startBlock:" + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -530,6 +536,8 @@
             table.setBorderAttributes(borderAttributes);
             
             builderContext.pushContainer(table);
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startTable:" + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -590,7 +598,6 @@
             log.error("startColumn: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
-
     }
 
      /**
@@ -649,8 +656,7 @@
             textrun.pushInlineAttributes(rtfAttr);
             textrun.addBookmark(inl.getId());
         } catch (IOException ioe) {
-            log.error("startInline:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (FOPException fe) {
             log.error("startInline:" + fe.getMessage());
             throw new RuntimeException(fe.getMessage());
@@ -677,8 +683,7 @@
             RtfTextrun textrun = container.getTextrun();
             textrun.popInlineAttributes();
         } catch (IOException ioe) {
-            log.error("startInline:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startInline:" + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -698,6 +703,8 @@
 
             RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
             tbl.setHeaderAttribs(atts);
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startBody: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -715,6 +722,8 @@
         try {
             RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
             tbl.setHeaderAttribs(null);
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("endBody: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -745,6 +754,8 @@
 
             // reset column iteration index to correctly access column widths
             builderContext.getTableContext().selectFirstColumn();
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startRow: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -778,6 +789,8 @@
                 
                 tctx.selectNextColumn();
             }
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("endRow: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -870,6 +883,8 @@
             }
             
             builderContext.pushContainer(cell);
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startCell: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -906,8 +921,7 @@
                 ListAttributesConverter.convertAttributes(lb));
             builderContext.pushContainer(newList);
         } catch (IOException ioe) {
-            log.error("startList: " + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (FOPException fe) {
             log.error("startList: " + fe.getMessage());
             throw new RuntimeException(fe.getMessage());
@@ -961,8 +975,7 @@
             
             builderContext.pushContainer(list.newListItem());
         } catch (IOException ioe) {
-            log.error("startList: " + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startList: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -995,8 +1008,7 @@
             RtfListItemLabel label = item.new RtfListItemLabel(item);
             builderContext.pushContainer(label);
         } catch (IOException ioe) {
-            log.error("startPageNumber:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startPageNumber: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -1077,8 +1089,7 @@
             builderContext.pushContainer(link);
 
         } catch (IOException ioe) {
-            log.error("startLink:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startLink: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -1104,21 +1115,28 @@
             return;
         }
 
+        String uri = eg.getURL();
+        ImageInfo info = null;
         try {
-            String uri = eg.getURL();
 
             //set image data
             FOUserAgent userAgent = eg.getUserAgent();
             ImageManager manager = userAgent.getFactory().getImageManager();
-            ImageInfo info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
-            if (info == null) {
-                log.error("Image could not be found: " + uri);
-                return;
-            }
+            info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
             
             putGraphic(eg, info);
-        } catch (Exception e) {
-            log.error("Error while handling an external-graphic: " + e.getMessage(), e);
+        } catch (ImageException ie) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+        } catch (FileNotFoundException fe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
+        } catch (IOException ioe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
         }
     }
 
@@ -1144,6 +1162,12 @@
             // Set the image size to the size of the svg.
             Point2D csize = new Point2D.Float(-1, -1);
             Point2D intrinsicDimensions = child.getDimension(csize);
+            if (intrinsicDimensions == null) {
+                ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.ifoNoIntrinsicSize(this, child.getLocator());
+                return;
+            }
             size.setSizeInMillipoints(
                     (int)Math.round(intrinsicDimensions.getX() * 1000),
                     (int)Math.round(intrinsicDimensions.getY() * 1000));
@@ -1157,8 +1181,14 @@
             Image converted = manager.convertImage(image, FLAVORS);
             putGraphic(ifo, converted);
             
-        } catch (Exception e) {
-            log.error("Error while handling an instream-foreign-object: " + e.getMessage(), e);
+        } catch (ImageException ie) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, null, ie, null);
+        } catch (IOException ioe) {
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageIOError(this, null, ioe, null);
         }
     }
 
@@ -1183,7 +1213,9 @@
 
             putGraphic(abstractGraphic, image);
         } catch (ImageException ie) {
-            log.error("Error while loading/processing image: " + info.getOriginalURI(), ie);
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageError(this, null, ie, null);
         }
     }
     
@@ -1210,8 +1242,9 @@
         }
 
         if (rawData == null) {
-            log.warn(FONode.decorateWithContextInfo("Image could not be embedded: "
-                    + image, abstractGraphic));
+            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.imageWritingError(this, null);
             return;
         }
 
@@ -1322,9 +1355,7 @@
             builderContext.pushContainer(rtfFootnote);
 
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startFootnote: " + ioe.getMessage());
-            throw new RuntimeException("IOException: " + ioe);
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startFootnote: " + e.getMessage());
             throw new RuntimeException("Exception: " + e);
@@ -1358,9 +1389,7 @@
 
             rtfFootnote.startBody();
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startFootnoteBody: " + ioe.getMessage());
-            throw new RuntimeException("IOException: " + ioe);
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startFootnoteBody: " + e.getMessage());
             throw new RuntimeException("Exception: " + e);
@@ -1383,9 +1412,7 @@
 
             rtfFootnote.endBody();
         } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("endFootnoteBody: " + ioe.getMessage());
-            throw new RuntimeException("IOException: " + ioe);
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("endFootnoteBody: " + e.getMessage());
             throw new RuntimeException("Exception: " + e);
@@ -1421,10 +1448,8 @@
             textrun.pushInlineAttributes(rtfAttr);
             textrun.addString(new String(data, start, length - start));
             textrun.popInlineAttributes();
-         } catch (IOException ioe) {
-            // FIXME could we throw Exception in all FOEventHandler events?
-            log.error("characters: " + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+        } catch (IOException ioe) {
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("characters:" + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -1452,8 +1477,7 @@
             RtfTextrun textrun = container.getTextrun();
             textrun.addPageNumber(rtfAttr);
         } catch (IOException ioe) {
-            log.error("startPageNumber:" + ioe.getMessage());
-            throw new RuntimeException(ioe.getMessage());
+            handleIOTrouble(ioe);
         } catch (Exception e) {
             log.error("startPageNumber: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
@@ -1611,7 +1635,9 @@
                 endCell( (TableCell) foNode);
             }
         } else {
-            log.warn("Ignored deferred event for " + foNode);
+            RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+                    getUserAgent().getEventBroadcaster());
+            eventProducer.ignoredDeferredEvent(this, foNode, bStart, foNode.getLocator());
         }
     }
 
@@ -1655,8 +1681,9 @@
                 }
             } else {
                 //TODO Implement implicit column setup handling!
-                log.warn("No table-columns found on table. RTF output requires that all"
-                        + " table-columns for a table are defined. Output will be incorrect.");
+                RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.explicitTableColumnsRequired(this, table.getLocator());
             }
 
             //recurse table-header

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/xml/XMLRenderer.java Mon Apr 14 06:05:52 2008
@@ -41,6 +41,7 @@
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.AttributesImpl;
 
+import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.util.XMLizable;
 
 import org.apache.fop.apps.FOPException;
@@ -90,7 +91,6 @@
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.XMLHandler;
 import org.apache.fop.util.ColorUtil;
-import org.apache.fop.util.QName;
 
 /**
  * Renderer that renders areas to XML for debugging purposes.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/SVGUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/SVGUserAgent.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/SVGUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/SVGUserAgent.java Mon Apr 14 06:05:52 2008
@@ -19,49 +19,42 @@
  
 package org.apache.fop.svg;
 
-import javax.xml.parsers.SAXParserFactory;
-import org.apache.batik.bridge.UserAgentAdapter;
-
-// Java
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Dimension2D;
-import java.awt.Dimension;
 
-// Commons-Logging
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOUserAgent;
 
 /**
- * The SVG user agent.
- * This is an implementation of the batik svg user agent
- * for handling errors and getting user agent values.
+ * The SVG user agent. This is an implementation of the Batik SVG user agent.
  */
-public class SVGUserAgent extends UserAgentAdapter {
-    private AffineTransform currentTransform = null;
-    private float pixelUnitToMillimeter = 0.0f;
+public class SVGUserAgent extends SimpleSVGUserAgent {
+    
+    private SVGEventProducer eventProducer;
+    private Exception lastException;
 
     /**
-     * logging instance
+     * Creates a new SVGUserAgent.
+     * @param foUserAgent the FO user agent to associate with this SVG user agent
+     * @param at the current transform
      */
-    private Log logger = LogFactory.getLog(SVGUserAgent.class);
+    public SVGUserAgent(FOUserAgent foUserAgent, AffineTransform at) {
+        super(foUserAgent.getSourcePixelUnitToMillimeter(), at);
+        this.eventProducer = SVGEventProducer.Provider.get(foUserAgent.getEventBroadcaster());
+    }
 
     /**
      * Creates a new SVGUserAgent.
-     * @param pixelUnitToMM the pixel to millimeter conversion factor
-     * currently in effect
-     * @param at the current transform
+     * @param foUserAgent the FO user agent to associate with this SVG user agent
      */
-    public SVGUserAgent(float pixelUnitToMM, AffineTransform at) {
-        pixelUnitToMillimeter = pixelUnitToMM;
-        currentTransform = at;
+    public SVGUserAgent(FOUserAgent foUserAgent) {
+        this(foUserAgent, new AffineTransform());
     }
-
+    
     /**
-     * Returns the logger associated with this user agent.
-     * @return Logger the logger
+     * Returns the last exception sent to the {@link #displayError(Exception)} method.
+     * @return the last exception or null if no exception occurred
      */
-    protected final Log getLogger() {
-        return logger;
+    public Exception getLastException() {
+        return this.lastException;
     }
 
     /**
@@ -69,7 +62,7 @@
      * @param message the message to display
      */
     public void displayError(String message) {
-        logger.error(message);
+        this.eventProducer.error(this, message, null);
     }
 
     /**
@@ -77,7 +70,8 @@
      * @param ex the exception to display
      */
     public void displayError(Exception ex) {
-        logger.error("SVG Error" + ex.getMessage(), ex);
+        this.lastException = ex;
+        this.eventProducer.error(this, ex.getLocalizedMessage(), ex);
     }
 
     /**
@@ -86,7 +80,7 @@
      * @param message the message to display
      */
     public void displayMessage(String message) {
-        logger.info(message);
+        this.eventProducer.info(this, message);
     }
 
     /**
@@ -94,78 +88,7 @@
      * @param message the message to display
      */
     public void showAlert(String message) {
-        logger.warn(message);
-    }
-
-    /**
-     * Returns a customized the pixel to mm factor.
-     * @return the pixel unit to millimeter conversion factor
-     */
-    public float getPixelUnitToMillimeter() {
-        return pixelUnitToMillimeter;
+        this.eventProducer.alert(this, message);
     }
 
-    /**
-     * Returns the language settings.
-     * @return the languages supported
-     */
-    public String getLanguages() {
-        return "en"; // userLanguages;
-    }
-
-    /**
-     * Returns the media type for this rendering.
-     * @return the media for fo documents is "print"
-     */
-    public String getMedia() {
-        return "print";
-    }
-
-    /**
-     * Returns the user stylesheet uri.
-     * @return null if no user style sheet was specified.
-     */
-    public String getUserStyleSheetURI() {
-        return null; // userStyleSheetURI;
-    }
-
-    /**
-     * Returns the class name of the XML parser.
-     * @return the XML parser class name
-     */
-    public String getXMLParserClassName() {
-        try {
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            return factory.newSAXParser().getXMLReader().getClass().getName();
-        } catch (Exception e) {
-            return null;
-        }
-    }
-
-    /**
-     * Is the XML parser validating.
-     * @return true if the xml parser is validating
-     */
-    public boolean isXMLParserValidating() {
-        return false;
-    }
-
-    /**
-     * Get the transform of the svg document.
-     * @return the transform
-     */
-    public AffineTransform getTransform() {
-        return currentTransform;
-    }
-
-    /**
-     * Get the default viewport size for an svg document.
-     * This returns a default value of 100x100.
-     * @return the default viewport size
-     */
-    public Dimension2D getViewportSize() {
-        return new Dimension(100, 100);
-    }
-
-}
-
+}
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/QName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/QName.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/QName.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/QName.java Mon Apr 14 06:05:52 2008
@@ -19,23 +19,17 @@
 
 package org.apache.fop.util;
 
-import java.io.Serializable;
-
 /**
  * Represents a qualified name of an XML element or an XML attribute.
  * <p>
  * Note: This class allows to carry a namespace prefix but it is not used in the equals() and 
  * hashCode() methods.
+ * @deprecated Use the XML Graphics Commons variant instead!
  */
-public class QName implements Serializable {
+public class QName extends org.apache.xmlgraphics.util.QName {
 
     private static final long serialVersionUID = -5225376740044770690L;
     
-    private String namespaceURI;
-    private String localName;
-    private String prefix;
-    private int hashCode;
-    
     /**
      * Main constructor.
      * @param namespaceURI the namespace URI
@@ -43,16 +37,7 @@
      * @param localName the local name
      */
     public QName(String namespaceURI, String prefix, String localName) {
-        if (localName == null) {
-            throw new NullPointerException("Parameter localName must not be null");
-        }
-        if (localName.length() == 0) {
-            throw new IllegalArgumentException("Parameter localName must not be empty");
-        }
-        this.namespaceURI = namespaceURI;
-        this.prefix = prefix;
-        this.localName = localName;
-        this.hashCode = toHashString().hashCode();
+        super(namespaceURI, prefix, localName);
     }
     
     /**
@@ -61,78 +46,7 @@
      * @param qName the qualified name
      */
     public QName(String namespaceURI, String qName) {
-        if (qName == null) {
-            throw new NullPointerException("Parameter localName must not be null");
-        }
-        if (qName.length() == 0) {
-            throw new IllegalArgumentException("Parameter localName must not be empty");
-        }
-        this.namespaceURI = namespaceURI;
-        int p = qName.indexOf(':');
-        if (p > 0) {
-            this.prefix = qName.substring(0, p);
-            this.localName = qName.substring(p + 1);
-        } else {
-            this.prefix = null;
-            this.localName = qName;
-        }
-        this.hashCode = toHashString().hashCode();
+        super(namespaceURI, qName);
     }
     
-    /** @return the namespace URI */
-    public String getNamespaceURI() {
-        return this.namespaceURI;
-    }
-    
-    /** @return the namespace prefix */
-    public String getPrefix() {
-        return this.prefix;
-    }
-    
-    /** @return the local name */
-    public String getLocalName() {
-        return this.localName;
-    }
-    
-    /** @return the fully qualified name */
-    public String getQName() {
-        return getPrefix() != null ? getPrefix() + ':' + getLocalName() : getLocalName();
-    }
-
-    /** {@inheritDoc} */
-    public int hashCode() {
-        return this.hashCode;
-    }
-
-    /** {@inheritDoc} */
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        } else if (obj == this) {
-            return true;
-        } else {
-            if (obj instanceof QName) {
-                QName other = (QName)obj;
-                if ((getNamespaceURI() == null && other.getNamespaceURI() == null)
-                        || getNamespaceURI().equals(other.getNamespaceURI())) {
-                    return getLocalName().equals(other.getLocalName());
-                }
-            }
-        }
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    public String toString() {
-        return prefix != null
-                ? (prefix + ":" + localName)
-                : toHashString();
-    }
-
-    private String toHashString() {
-        return (namespaceURI != null 
-                ? ("{" + namespaceURI + "}" + localName) 
-                : localName);
-    }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/UtilityCodeTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/UtilityCodeTestSuite.java?rev=647787&r1=647786&r2=647787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/UtilityCodeTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/UtilityCodeTestSuite.java Mon Apr 14 06:05:52 2008
@@ -23,12 +23,14 @@
 import junit.framework.TestSuite;
 
 import org.apache.fop.pdf.PDFObjectTestCase;
+import org.apache.fop.events.BasicEventTestCase;
 import org.apache.fop.traits.BorderPropsTestCase;
 import org.apache.fop.util.DataURIResolverTestCase;
 import org.apache.fop.util.ElementListUtilsTestCase;
 import org.apache.fop.util.PDFNumberTestCase;
 import org.apache.fop.util.ColorUtilTestCase;
 import org.apache.fop.util.UnitConvTestCase;
+import org.apache.fop.util.XMLResourceBundleTestCase;
 
 /**
  * Test suite for FOP's utility classes.
@@ -50,6 +52,8 @@
         suite.addTest(new TestSuite(BorderPropsTestCase.class));
         suite.addTest(new TestSuite(ElementListUtilsTestCase.class));
         suite.addTest(new TestSuite(DataURIResolverTestCase.class));
+        suite.addTest(new TestSuite(BasicEventTestCase.class));
+        suite.addTest(new TestSuite(XMLResourceBundleTestCase.class));
         //$JUnit-END$
         return suite;
     }



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