xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r816718 [8/11] - in /xmlgraphics/fop/branches/Temp_Accessibility: ./ examples/fo/advanced/ hyph/ lib/ src/codegen/unicode/java/org/apache/fop/hyphenation/ src/codegen/unicode/java/org/apache/fop/text/linebreak/ src/codegen/unicode/java/org/...
Date Fri, 18 Sep 2009 17:10:52 GMT
Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGState.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGState.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGState.java Fri Sep 18 17:10:42 2009
@@ -175,10 +175,8 @@
      * endobj
      */
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (obj == this) {
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoTo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoTo.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoTo.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoTo.java Fri Sep 18 17:10:42 2009
@@ -143,13 +143,8 @@
      * endobj
      */
 
-    /**
-     * Check if this equals another object.
-     *
-     * @param obj the object to compare
-     * @return true if this equals other object
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (this == obj) {
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoToRemote.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoToRemote.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoToRemote.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFGoToRemote.java Fri Sep 18 17:10:42 2009
@@ -127,13 +127,8 @@
      * endobj
      */
 
-    /**
-     * Check if this equals another object.
-     *
-     * @param obj the object to compare
-     * @return true if this equals other object
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (this == obj) {
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLaunch.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLaunch.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLaunch.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLaunch.java Fri Sep 18 17:10:42 2009
@@ -42,13 +42,8 @@
         return sb.toString();
     }
 
-    /**
-     * Check if this equals another object.
-     *
-     * @param obj the object to compare
-     * @return true if this equals other object
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (this == obj) {
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLink.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLink.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLink.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFLink.java Fri Sep 18 17:10:42 2009
@@ -118,13 +118,8 @@
      * endobj
      */
 
-    /**
-     * Check if this equals another object.
-     *
-     * @param obj the object to compare
-     * @return true if this equals other object
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (this == obj) {
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFObject.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFObject.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFObject.java Fri Sep 18 17:10:42 2009
@@ -393,4 +393,20 @@
         return formatDateTime(time, TimeZone.getDefault());
     }
 
+    /**
+     * Check if the other PDFObject has the same content as the current object.
+     * <p>
+     * Note: This function has a contract which is less binding than
+     * {@link #equals(Object)}. Whereas equals would require all values to be
+     * identical, this method is not required to check everything. In the case
+     * of PDFObjects, this means that the overriding function does not have to
+     * check for {@link #getObjectID()}.
+     * 
+     * @param o
+     *            object to compare to.
+     * @return true if the other object has the same content.
+     */
+    protected boolean contentEquals(PDFObject o) {
+        return this.equals(o);
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPage.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPage.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPage.java Fri Sep 18 17:10:42 2009
@@ -38,42 +38,42 @@
      * Create a /Page object
      *
      * @param resources the /Resources object
-     * @param contents the content stream
-     * @param pageWidth the page's width in points
-     * @param pageHeight the page's height in points
      * @param pageIndex the page's zero-based index (or -1 if the page number is auto-determined)
-     */
-    public PDFPage(PDFResources resources, PDFStream contents,
-                   int pageWidth, int pageHeight, int pageIndex) {
-
-        /* generic creation of object */
-        super(resources);
+     * @param mediaBox the MediaBox
+     * @param cropBox the CropBox. If null, mediaBox is used.
+     * @param bleedBox the BleedBox. If null, cropBox is used.
+     * @param trimBox the TrimBox. If null, bleedBox is used.
+     */
+    public PDFPage(PDFResources resources, int pageIndex,
+                   Rectangle2D mediaBox, Rectangle2D cropBox,
+                   Rectangle2D bleedBox, Rectangle2D trimBox) {
+      /* generic creation of object */
+      super(resources);
+
+      put("Type", new PDFName("Page"));
+      /* set fields using parameters */
+      setSimplePageSize(mediaBox, cropBox, bleedBox, trimBox);
+      this.pageIndex = pageIndex;
+    }
+
+    private void setSimplePageSize(Rectangle2D mediaBox, Rectangle2D cropBox,
+                                   Rectangle2D bleedBox, Rectangle2D trimBox) {
+        setMediaBox(mediaBox);
 
-        put("Type", new PDFName("Page"));
-        /* set fields using parameters */
-        setContents(contents);
-        setSimplePageSize(pageWidth, pageHeight);
-        this.pageIndex = pageIndex;
-    }
+        if (cropBox == null) {
+            cropBox = mediaBox;
+        }
+        setCropBox(cropBox);
 
-    /**
-     * Create a /Page object
-     *
-     * @param resources the /Resources object
-     * @param pageWidth the page's width in points
-     * @param pageHeight the page's height in points
-     * @param pageIndex the page's zero-based index (or -1 if the page number is auto-determined)
-     */
-    public PDFPage(PDFResources resources,
-                   int pageWidth, int pageHeight, int pageIndex) {
-        this(resources, null, pageWidth, pageHeight, pageIndex);
-    }
+        if (bleedBox == null) {
+            bleedBox = cropBox;
+        }
+        setBleedBox(bleedBox); //Recommended by PDF/X
 
-    private void setSimplePageSize(int width, int height) {
-        Rectangle2D box = new Rectangle2D.Double(0, 0, width, height);
-        setMediaBox(box);
-        setBleedBox(box); //Recommended by PDF/X
-        setTrimBox(box); //Needed for PDF/X
+        if (trimBox == null) {
+            trimBox = bleedBox;
+        }
+        setTrimBox(trimBox); //Needed for PDF/X
     }
 
     private PDFArray toPDFArray(Rectangle2D box) {
@@ -90,11 +90,11 @@
     }
 
     /**
-     * Sets the "TrimBox" entry
-     * @param box the trim rectangle
+     * Sets the "CropBox" entry
+     * @param box the bleed rectangle
      */
-    public void setTrimBox(Rectangle2D box) {
-        put("TrimBox", toPDFArray(box));
+    public void setCropBox(Rectangle2D box) {
+        put("CropBox", toPDFArray(box));
     }
 
     /**
@@ -106,6 +106,14 @@
     }
 
     /**
+     * Sets the "TrimBox" entry
+     * @param box the trim rectangle
+     */
+    public void setTrimBox(Rectangle2D box) {
+        put("TrimBox", toPDFArray(box));
+    }
+
+    /**
      * set this page contents
      *
      * @param contents the contents of the page

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPattern.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPattern.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFPattern.java Fri Sep 18 17:10:42 2009
@@ -336,13 +336,8 @@
      */
     public byte[] toPDF() { return null; }
 
-    /**
-     * Check if this pattern is equal to another.
-     *
-     * @param obj the object to compare against
-     * @return true if the patterns are equal
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (obj == null) {
             return false;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFShading.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFShading.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFShading.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/pdf/PDFShading.java Fri Sep 18 17:10:42 2009
@@ -529,14 +529,8 @@
         return (p.toString());
     }
 
-    /**
-     * Check if this shading is equal to another shading.
-     * This is used to check if a shading already exists.
-     *
-     * @param obj the object to compare against
-     * @return true if the shadings are equal
-     */
-    public boolean equals(Object obj) {
+    /** {@inheritDoc} */
+    protected boolean contentEquals(PDFObject obj) {
         if (obj == null) {
             return false;
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/AbstractConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/AbstractConfigurator.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/AbstractConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/AbstractConfigurator.java Fri Sep 18 17:10:42 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render;
 

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

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

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPCustomizable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPCustomizable.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPCustomizable.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPCustomizable.java Fri Sep 18 17:10:42 2009
@@ -51,6 +51,12 @@
     void setNativeImagesSupported(boolean nativeImages);
 
     /**
+     * Sets the shading mode for painting filled rectangles.
+     * @param shadingMode the shading mode
+     */
+    void setShadingMode(AFPShadingMode shadingMode);
+
+    /**
      * Sets the output/device resolution
      *
      * @param resolution

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Fri Sep 18 17:10:42 2009
@@ -25,19 +25,26 @@
 import java.io.IOException;
 import java.util.Map;
 
+import org.apache.fop.afp.AFPDitheredRectanglePainter;
 import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPRectanglePainter;
 import org.apache.fop.afp.AFPResourceLevelDefaults;
 import org.apache.fop.afp.AFPResourceManager;
 import org.apache.fop.afp.AFPUnitConverter;
+import org.apache.fop.afp.AbstractAFPPainter;
 import org.apache.fop.afp.DataStream;
 import org.apache.fop.afp.fonts.AFPFontCollection;
 import org.apache.fop.afp.fonts.AFPPageFonts;
+import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
+import org.apache.fop.afp.util.ResourceAccessor;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.fonts.FontCollection;
 import org.apache.fop.fonts.FontEventAdapter;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontManager;
 import org.apache.fop.render.afp.extensions.AFPElementMapping;
+import org.apache.fop.render.afp.extensions.AFPIncludeFormMap;
 import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
 import org.apache.fop.render.afp.extensions.AFPPageSetup;
 import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
@@ -70,12 +77,18 @@
     private Map/*<String,String>*/pageSegmentMap
         = new java.util.HashMap/*<String,String>*/();
 
+    /** Medium Map referenced on previous page **/
+    private String lastMediumMap;
+
     private static final int LOC_ELSEWHERE = 0;
     private static final int LOC_FOLLOWING_PAGE_SEQUENCE = 1;
     private static final int LOC_IN_PAGE_HEADER = 2;
 
     private int location = LOC_ELSEWHERE;
 
+    /** the shading mode for filled rectangles */
+    private AFPShadingMode shadingMode = AFPShadingMode.COLOR;
+
     /**
      * Default constructor.
      */
@@ -125,6 +138,16 @@
         return this.resourceManager;
     }
 
+    AbstractAFPPainter createRectanglePainter() {
+        if (AFPShadingMode.DITHERED.equals(this.shadingMode)) {
+            return new AFPDitheredRectanglePainter(
+                    getPaintingState(), getDataStream(), getResourceManager());
+        } else {
+            return new AFPRectanglePainter(
+                    getPaintingState(), getDataStream());
+        }
+    }
+
     /** {@inheritDoc} */
     public void startDocument() throws IFException {
         super.startDocument();
@@ -259,7 +282,8 @@
             } else {
                 if (this.location != LOC_IN_PAGE_HEADER) {
                     throw new IFException(
-                        "AFP page setup extension encountered outside the page header: " + aps, null);
+                        "AFP page setup extension encountered outside the page header: " + aps,
+                        null);
                 }
                 if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
                     String overlay = aps.getName();
@@ -278,15 +302,31 @@
                 }
             }
         } else if (extension instanceof AFPInvokeMediumMap) {
-            if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE) {
+            if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE
+                    && this.location != LOC_IN_PAGE_HEADER) {
+
                 throw new IFException(
-                    "AFP IMM extension must be between page-sequence and the first page: "
-                        + extension, null);
+                    "AFP IMM extension must be between page-sequence"
+                    + " and the first page or child of page-header: "
+                    + extension, null);
             }
             AFPInvokeMediumMap imm = (AFPInvokeMediumMap)extension;
             String mediumMap = imm.getName();
-            if (mediumMap != null) {
+            if (mediumMap != null && !mediumMap.equals(lastMediumMap)) {
                 dataStream.createInvokeMediumMap(mediumMap);
+                lastMediumMap = mediumMap;
+            }
+        } else if (extension instanceof AFPIncludeFormMap) {
+            AFPIncludeFormMap formMap = (AFPIncludeFormMap)extension;
+            ResourceAccessor accessor = new DefaultFOPResourceAccessor(
+                    getUserAgent(), null, null);
+            try {
+                getResourceManager().createIncludedResource(formMap.getName(),
+                        formMap.getSrc(), accessor,
+                        ResourceObject.TYPE_FORMDEF);
+            } catch (IOException ioe) {
+                throw new IFException(
+                        "I/O error while embedding form map resource: " + formMap.getName(), ioe);
             }
         }
     }
@@ -309,6 +349,11 @@
     }
 
     /** {@inheritDoc} */
+    public void setShadingMode(AFPShadingMode shadingMode) {
+        this.shadingMode = shadingMode;
+    }
+
+    /** {@inheritDoc} */
     public void setResolution(int resolution) {
         paintingState.setResolution(resolution);
     }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPDocumentHandlerMaker.java Fri Sep 18 17:10:42 2009
@@ -30,8 +30,10 @@
  */
 public class AFPDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker {
 
-    private static final String[] MIMES = new String[]
-                              {MimeConstants.MIME_AFP};
+    private static final String[] MIMES = new String[] {
+            MimeConstants.MIME_AFP,
+            MimeConstants.MIME_AFP_ALT
+    };
 
     /** {@inheritDoc} */
     public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) {

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPPainter.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPPainter.java Fri Sep 18 17:10:42 2009
@@ -35,8 +35,8 @@
 
 import org.apache.fop.afp.AFPBorderPainter;
 import org.apache.fop.afp.AFPPaintingState;
-import org.apache.fop.afp.AFPRectanglePainter;
 import org.apache.fop.afp.AFPUnitConverter;
+import org.apache.fop.afp.AbstractAFPPainter;
 import org.apache.fop.afp.BorderPaintingInfo;
 import org.apache.fop.afp.DataStream;
 import org.apache.fop.afp.RectanglePaintingInfo;
@@ -46,10 +46,8 @@
 import org.apache.fop.afp.fonts.CharacterSet;
 import org.apache.fop.afp.modca.AbstractPageObject;
 import org.apache.fop.afp.modca.PresentationTextObject;
-import org.apache.fop.afp.modca.ResourceObject;
 import org.apache.fop.afp.ptoca.PtocaBuilder;
 import org.apache.fop.afp.ptoca.PtocaProducer;
-import org.apache.fop.afp.util.ResourceAccessor;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
@@ -79,7 +77,7 @@
     /** the border painter */
     private AFPBorderPainterAdapter borderPainter;
     /** the rectangle painter */
-    private AFPRectanglePainter rectanglePainter;
+    private AbstractAFPPainter rectanglePainter;
 
     /** unit converter */
     private final AFPUnitConverter unitConv;
@@ -94,7 +92,7 @@
         this.state = IFState.create();
         this.borderPainter = new AFPBorderPainterAdapter(
                 new AFPBorderPainter(getPaintingState(), getDataStream()));
-        this.rectanglePainter = new AFPRectanglePainter(getPaintingState(), getDataStream());
+        this.rectanglePainter = documentHandler.createRectanglePainter();
         this.unitConv = getPaintingState().getUnitConverter();
     }
 
@@ -222,7 +220,11 @@
             }
             RectanglePaintingInfo rectanglePaintInfo = new RectanglePaintingInfo(
                     toPoint(rect.x), toPoint(rect.y), toPoint(rect.width), toPoint(rect.height));
-            rectanglePainter.paint(rectanglePaintInfo);
+            try {
+                rectanglePainter.paint(rectanglePaintInfo);
+            } catch (IOException ioe) {
+                throw new IFException("IO error while painting rectangle", ioe);
+            }
         }
     }
 
@@ -341,17 +343,7 @@
 
         if (afpFont.isEmbeddable()) {
             try {
-                //Embed fonts (char sets and code pages)
-                //TODO This should be moved to a place where it has less performance impact
-                if (charSet.getResourceAccessor() != null) {
-                    ResourceAccessor accessor = charSet.getResourceAccessor();
-                    documentHandler.getResourceManager().createIncludedResource(
-                            charSet.getName(), accessor,
-                            ResourceObject.TYPE_FONT_CHARACTER_SET);
-                    documentHandler.getResourceManager().createIncludedResource(
-                            charSet.getCodePage(), accessor,
-                            ResourceObject.TYPE_CODE_PAGE);
-                }
+                documentHandler.getResourceManager().embedFont(afpFont, charSet);
             } catch (IOException ioe) {
                 throw new IFException("Error while embedding font resources", ioe);
             }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRenderer.java Fri Sep 18 17:10:42 2009
@@ -43,6 +43,7 @@
 
 import org.apache.fop.afp.AFPBorderPainter;
 import org.apache.fop.afp.AFPDataObjectInfo;
+import org.apache.fop.afp.AFPDitheredRectanglePainter;
 import org.apache.fop.afp.AFPEventProducer;
 import org.apache.fop.afp.AFPPaintingState;
 import org.apache.fop.afp.AFPRectanglePainter;
@@ -50,6 +51,7 @@
 import org.apache.fop.afp.AFPResourceManager;
 import org.apache.fop.afp.AFPTextDataInfo;
 import org.apache.fop.afp.AFPUnitConverter;
+import org.apache.fop.afp.AbstractAFPPainter;
 import org.apache.fop.afp.BorderPaintingInfo;
 import org.apache.fop.afp.DataStream;
 import org.apache.fop.afp.RectanglePaintingInfo;
@@ -59,10 +61,14 @@
 import org.apache.fop.afp.fonts.AFPPageFonts;
 import org.apache.fop.afp.fonts.CharacterSet;
 import org.apache.fop.afp.modca.PageObject;
+import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
+import org.apache.fop.afp.util.ResourceAccessor;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.CTM;
+import org.apache.fop.area.OffDocumentExtensionAttachment;
 import org.apache.fop.area.OffDocumentItem;
 import org.apache.fop.area.PageSequence;
 import org.apache.fop.area.PageViewport;
@@ -73,6 +79,7 @@
 import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontCollection;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontManager;
@@ -80,6 +87,8 @@
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.afp.extensions.AFPElementMapping;
+import org.apache.fop.render.afp.extensions.AFPExtensionAttachment;
+import org.apache.fop.render.afp.extensions.AFPIncludeFormMap;
 import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
 import org.apache.fop.render.afp.extensions.AFPPageSetup;
 
@@ -167,7 +176,13 @@
     /** the image handler registry */
     private final AFPImageHandlerRegistry imageHandlerRegistry;
 
-    private AFPRectanglePainter rectanglePainter;
+    private AbstractAFPPainter rectanglePainter;
+
+    /** the shading mode for filled rectangles */
+    private AFPShadingMode shadingMode = AFPShadingMode.COLOR;
+
+    /** medium map referenced used on previous page **/
+    private String lastMediumMap;
 
     /**
      * Constructor for AFPRenderer.
@@ -201,11 +216,21 @@
 
         this.dataStream = resourceManager.createDataStream(paintingState, outputStream);
         this.borderPainter = new AFPBorderPainter(paintingState, dataStream);
-        this.rectanglePainter = new AFPRectanglePainter(paintingState, dataStream);
+        this.rectanglePainter = createRectanglePainter();
 
         dataStream.startDocument();
     }
 
+    AbstractAFPPainter createRectanglePainter() {
+        if (AFPShadingMode.DITHERED.equals(this.shadingMode)) {
+            return new AFPDitheredRectanglePainter(
+                    this.paintingState, this.dataStream, this.resourceManager);
+        } else {
+            return new AFPRectanglePainter(
+                    this.paintingState, this.dataStream);
+        }
+    }
+
     /** {@inheritDoc} */
     public void stopRenderer() throws IOException {
         dataStream.endDocument();
@@ -263,8 +288,30 @@
 
     /** {@inheritDoc} */
     public void processOffDocumentItem(OffDocumentItem odi) {
-        // TODO
-        log.debug("NYI processOffDocumentItem(" + odi + ")");
+        if (odi instanceof OffDocumentExtensionAttachment) {
+            ExtensionAttachment attachment = ((OffDocumentExtensionAttachment)odi).getAttachment();
+            if (attachment != null) {
+                if (AFPExtensionAttachment.CATEGORY.equals(attachment.getCategory())) {
+                    if (attachment instanceof AFPIncludeFormMap) {
+                        handleIncludeFormMap((AFPIncludeFormMap)attachment);
+                    }
+                }
+            }
+        }
+    }
+
+    private void handleIncludeFormMap(AFPIncludeFormMap formMap) {
+        ResourceAccessor accessor = new DefaultFOPResourceAccessor(
+                getUserAgent(), null, null);
+        try {
+            this.resourceManager.createIncludedResource(formMap.getName(),
+                    formMap.getSrc(), accessor,
+                    ResourceObject.TYPE_FORMDEF);
+        } catch (IOException ioe) {
+            AFPEventProducer eventProducer
+                = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
+            eventProducer.resourceEmbeddingError(this, formMap.getName(), ioe);
+        }
     }
 
     /** {@inheritDoc} */
@@ -336,6 +383,9 @@
 
             int resolution = paintingState.getResolution();
 
+            // IMM should occur before BPG
+            renderInvokeMediumMap(pageViewport);
+
             dataStream.startPage(pageWidth, pageHeight, pageRotation,
                     resolution, resolution);
 
@@ -362,7 +412,12 @@
     /** {@inheritDoc} */
     public void fillRect(float x, float y, float width, float height) {
         RectanglePaintingInfo rectanglePaintInfo = new RectanglePaintingInfo(x, y, width, height);
-        rectanglePainter.paint(rectanglePaintInfo);
+        try {
+            rectanglePainter.paint(rectanglePaintInfo);
+        } catch (IOException ioe) {
+            //TODO not ideal, but the AFPRenderer is legacy
+            throw new RuntimeException("I/O error while painting a filled rectangle", ioe);
+        }
     }
 
     /** {@inheritDoc} */
@@ -543,6 +598,18 @@
         AFPFont font = (AFPFont)fontMetricMap.get(internalFontName);
         AFPPageFonts pageFonts = paintingState.getPageFonts();
         AFPFontAttributes fontAttributes = pageFonts.registerFont(internalFontName, font, fontSize);
+        Font fnt = getFontFromArea(text);
+
+        if (font.isEmbeddable()) {
+            CharacterSet charSet = font.getCharacterSet(fontSize);
+            try {
+                this.resourceManager.embedFont(font, charSet);
+            } catch (IOException ioe) {
+                AFPEventProducer eventProducer
+                    = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
+                eventProducer.resourceEmbeddingError(this, charSet.getName(), ioe);
+            }
+        }
 
         // create text data info
         AFPTextDataInfo textDataInfo = new AFPTextDataInfo();
@@ -583,7 +650,7 @@
         textDataInfo.setString(textString);
 
         try {
-            dataStream.createText(textDataInfo);
+            dataStream.createText(textDataInfo, textLetterSpaceAdjust, textWordSpaceAdjust, fnt, charSet);
         } catch (UnsupportedEncodingException e) {
             AFPEventProducer eventProducer
                 = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
@@ -643,6 +710,35 @@
     }
 
     /**
+     * checks for IMM Extension and renders if found and different
+     * from previous page
+     *
+     * @param pageViewport the page object
+     */
+    private void renderInvokeMediumMap(PageViewport pageViewport) {
+         if (pageViewport.getExtensionAttachments() != null
+                && pageViewport.getExtensionAttachments().size() > 0) {
+             Iterator it = pageViewport.getExtensionAttachments().iterator();
+             while (it.hasNext()) {
+                 ExtensionAttachment attachment = (ExtensionAttachment) it.next();
+                 if (AFPExtensionAttachment.CATEGORY.equals(attachment.getCategory())) {
+                     AFPExtensionAttachment aea = (AFPExtensionAttachment)attachment;
+                     if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(aea.getElementName())) {
+                         AFPInvokeMediumMap imm = (AFPInvokeMediumMap)attachment;
+                         String mediumMap = imm.getName();
+                         if (mediumMap != null) {
+                             if (!mediumMap.equals(lastMediumMap)) {
+                                dataStream.createInvokeMediumMap(mediumMap);
+                                 lastMediumMap = mediumMap;
+                             }
+                         }
+                     }
+                 }
+             }
+         }
+    }
+
+    /**
      * Method to render the page extension.
      * <p>
      *
@@ -659,27 +755,29 @@
             while (it.hasNext()) {
                 ExtensionAttachment attachment = (ExtensionAttachment) it.next();
                 if (AFPPageSetup.CATEGORY.equals(attachment.getCategory())) {
-                    AFPPageSetup aps = (AFPPageSetup) attachment;
-                    String element = aps.getElementName();
-                    if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
-                        String overlay = aps.getName();
-                        if (overlay != null) {
-                            dataStream.createIncludePageOverlay(overlay);
-                        }
-                    } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT
-                            .equals(element)) {
-                        String name = aps.getName();
-                        String source = aps.getValue();
-                        pageSegmentMap.put(source, name);
-                    } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT
-                            .equals(element)) {
-                        String name = aps.getName();
-                        String value = aps.getValue();
-                        dataStream.createTagLogicalElement(name, value);
-                    } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
-                        String content = aps.getContent();
-                        if (content != null) {
-                            dataStream.createNoOperation(content);
+                    if (attachment instanceof AFPPageSetup) {
+                        AFPPageSetup aps = (AFPPageSetup) attachment;
+                        String element = aps.getElementName();
+                        if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
+                            String overlay = aps.getName();
+                            if (overlay != null) {
+                                dataStream.createIncludePageOverlay(overlay);
+                            }
+                        } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT
+                                .equals(element)) {
+                            String name = aps.getName();
+                            String source = aps.getValue();
+                            pageSegmentMap.put(source, name);
+                        } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT
+                                .equals(element)) {
+                            String name = aps.getName();
+                            String value = aps.getValue();
+                            dataStream.createTagLogicalElement(name, value);
+                        } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
+                            String content = aps.getContent();
+                            if (content != null) {
+                                dataStream.createNoOperation(content);
+                            }
                         }
                     }
                 }
@@ -728,6 +826,11 @@
     }
 
     /** {@inheritDoc} */
+    public void setShadingMode(AFPShadingMode shadingMode) {
+        this.shadingMode = shadingMode;
+    }
+
+    /** {@inheritDoc} */
     public void setResolution(int resolution) {
         paintingState.setResolution(resolution);
     }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Fri Sep 18 17:10:42 2009
@@ -20,6 +20,7 @@
 package org.apache.fop.render.afp;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.List;
@@ -67,8 +68,12 @@
     }
 
     private AFPFontInfo buildFont(Configuration fontCfg, String fontPath)
-        throws ConfigurationException {
+            throws ConfigurationException {
+
+        FontManager fontManager = this.userAgent.getFactory().getFontManager();
+        FontTriplet.Matcher referencedFontsMatcher = fontManager.getReferencedFontsMatcher();
 
+        boolean embeddable = true;
         Configuration[] triple = fontCfg.getChildren("font-triplet");
         List/*<FontTriplet>*/ tripletList = new java.util.ArrayList/*<FontTriplet>*/();
         if (triple.length == 0) {
@@ -80,6 +85,9 @@
             FontTriplet triplet = new FontTriplet(triple[j].getAttribute("name"),
                     triple[j].getAttribute("style"),
                     weight);
+            if (referencedFontsMatcher != null && referencedFontsMatcher.matches(triplet)) {
+                embeddable = false;
+            }
             tripletList.add(triplet);
         }
 
@@ -109,7 +117,7 @@
         }
         ResourceAccessor accessor = new DefaultFOPResourceAccessor(
                 this.userAgent,
-                this.userAgent.getFactory().getFontManager().getFontBaseURL(),
+                fontManager.getFontBaseURL(),
                 baseURI);
 
         String type = afpFontCfg.getAttribute("type");
@@ -134,11 +142,12 @@
 
             // Create a new font object
             RasterFont font = new RasterFont(name);
+            font.setEmbeddable(embeddable);
 
             Configuration[] rasters = afpFontCfg.getChildren("afp-raster-font");
             if (rasters.length == 0) {
-                log.error(
-                        "Mandatory font configuration elements '<afp-raster-font...' are missing");
+                log.error("Mandatory font configuration elements '<afp-raster-font...'"
+                        + " are missing at " + afpFontCfg.getLocation());
                 return null;
             }
             for (int j = 0; j < rasters.length; j++) {
@@ -150,7 +159,8 @@
                     "Mandatory afp-raster-font configuration attribute 'characterset=' is missing");
                     return null;
                 }
-                int size = rasterCfg.getAttributeAsInteger("size");
+                float size = rasterCfg.getAttributeAsFloat("size");
+                int sizeMpt = (int)(size * 1000);
                 String base14 = rasterCfg.getAttribute("base14-font", null);
 
                 if (base14 != null) {
@@ -159,7 +169,7 @@
                             + base14);
                         try {
                             Typeface tf = (Typeface)clazz.newInstance();
-                            font.addCharacterSet(size, new FopCharacterSet(
+                            font.addCharacterSet(sizeMpt, new FopCharacterSet(
                                 codepage, encoding, characterset, tf));
                         } catch (Exception ie) {
                             String msg = "The base 14 font class " + clazz.getName()
@@ -172,7 +182,7 @@
                         log.error(msg);
                     }
                 } else {
-                    font.addCharacterSet(size, new CharacterSet(
+                    font.addCharacterSet(sizeMpt, new CharacterSet(
                         codepage, encoding, characterset, accessor));
                 }
             }
@@ -210,6 +220,7 @@
             }
             // Create a new font object
             OutlineFont font = new OutlineFont(name, characterSet);
+            font.setEmbeddable(embeddable);
             return new AFPFontInfo(font, tripletList);
         } else {
             log.error("No or incorrect type attribute");
@@ -299,6 +310,12 @@
         boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false);
         customizable.setNativeImagesSupported(nativeImageSupport);
 
+        // shading (filled rectangles)
+        Configuration shadingCfg = cfg.getChild("shading");
+        AFPShadingMode shadingMode = AFPShadingMode.valueOf(
+                shadingCfg.getValue(AFPShadingMode.COLOR.getName()));
+        customizable.setShadingMode(shadingMode);
+
         // renderer resolution
         Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
         if (rendererResolutionCfg != null) {
@@ -312,16 +329,21 @@
             String resourceGroupDest = null;
             try {
                 resourceGroupDest = resourceGroupFileCfg.getValue();
+                if (resourceGroupDest != null) {
+                    File resourceGroupFile = new File(resourceGroupDest);
+                    resourceGroupFile.createNewFile();
+                    if (resourceGroupFile.canWrite()) {
+                        customizable.setDefaultResourceGroupFilePath(resourceGroupDest);
+                    } else {
+                        log.warn("Unable to write to default external resource group file '"
+                                    + resourceGroupDest + "'");
+                    }
+                }
             } catch (ConfigurationException e) {
                 LogUtil.handleException(log, e,
                         userAgent.getFactory().validateUserConfigStrictly());
-            }
-            File resourceGroupFile = new File(resourceGroupDest);
-            if (resourceGroupFile.canWrite()) {
-                customizable.setDefaultResourceGroupFilePath(resourceGroupDest);
-            } else {
-                log.warn("Unable to write to default external resource group file '"
-                            + resourceGroupDest + "'");
+            } catch (IOException ioe) {
+                throw new FOPException("Could not create default external resource group file", ioe);
             }
         }
 

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java Fri Sep 18 17:10:42 2009
@@ -42,6 +42,9 @@
     /** include page segment element */
     public static final String INCLUDE_PAGE_SEGMENT = "include-page-segment";
 
+    /** include form map element */
+    public static final String INCLUDE_FORM_MAP = "include-form-map";
+
     /** NOP */
     public static final String NO_OPERATION = "no-operation";
 
@@ -81,6 +84,9 @@
                 INCLUDE_PAGE_OVERLAY,
                 new AFPIncludePageOverlayMaker());
             foObjs.put(
+                INCLUDE_FORM_MAP,
+                new AFPIncludeFormMapMaker());
+            foObjs.put(
                 NO_OPERATION,
                 new AFPNoOperationMaker());
             foObjs.put(
@@ -101,6 +107,12 @@
         }
     }
 
+    static class AFPIncludeFormMapMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPIncludeFormMapElement(parent, INCLUDE_FORM_MAP);
+        }
+    }
+
     static class AFPTagLogicalElementMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
             return new AFPPageSetupElement(parent, TAG_LOGICAL_ELEMENT);

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java Fri Sep 18 17:10:42 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp.extensions;
 

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Fri Sep 18 17:10:42 2009
@@ -19,6 +19,9 @@
 
 package org.apache.fop.render.afp.extensions;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
@@ -48,13 +51,14 @@
     public void startElement(String uri, String localName, String qName, Attributes attributes)
                 throws SAXException {
         boolean handled = false;
-        if (AFPPageSetup.CATEGORY.equals(uri)) {
+        if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
             lastAttributes = attributes;
             handled = true;
             if (localName.equals(AFPElementMapping.NO_OPERATION)
                     || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
+                    || localName.equals(AFPElementMapping.INCLUDE_FORM_MAP)
                     || localName.equals(AFPElementMapping.INVOKE_MEDIUM_MAP)) {
                 //handled in endElement
             } else {
@@ -62,7 +66,7 @@
             }
         }
         if (!handled) {
-            if (AFPPageSetup.CATEGORY.equals(uri)) {
+            if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
                 throw new SAXException("Unhandled element " + localName
                         + " in namespace: " + uri);
             } else {
@@ -74,26 +78,38 @@
 
     /** {@inheritDoc} */
     public void endElement(String uri, String localName, String qName) throws SAXException {
-        if (AFPPageSetup.CATEGORY.equals(uri)) {
-            AFPPageSetup pageSetupExtn = null;
-            if (localName.equals(AFPElementMapping.INVOKE_MEDIUM_MAP)) {
-                this.returnedObject = new AFPInvokeMediumMap();
-            }
-            else {
-                pageSetupExtn = new AFPPageSetup(localName);
-                this.returnedObject = pageSetupExtn; 
-            }
-            String name = lastAttributes.getValue("name");
-            if (name != null) {
-                returnedObject.setName(name);
-            }
-            String value = lastAttributes.getValue("value");
-            if (value != null && pageSetupExtn != null) {
-                pageSetupExtn.setValue(value);
-            }
-            if (content.length() > 0 && pageSetupExtn != null) {
-                pageSetupExtn.setContent(content.toString());
-                content.setLength(0); //Reset text buffer (see characters())
+        if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
+            if (AFPElementMapping.INCLUDE_FORM_MAP.equals(localName)) {
+                AFPIncludeFormMap formMap = new AFPIncludeFormMap();
+                String name = lastAttributes.getValue("name");
+                formMap.setName(name);
+                String src = lastAttributes.getValue("src");
+                try {
+                    formMap.setSrc(new URI(src));
+                } catch (URISyntaxException e) {
+                    throw new SAXException("Invalid URI: " + src, e);
+                }
+                this.returnedObject = formMap;
+            } else {
+                AFPPageSetup pageSetupExtn = null;
+                if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(localName)) {
+                    this.returnedObject = new AFPInvokeMediumMap();
+                } else {
+                    pageSetupExtn = new AFPPageSetup(localName);
+                    this.returnedObject = pageSetupExtn;
+                }
+                String name = lastAttributes.getValue("name");
+                if (name != null) {
+                    returnedObject.setName(name);
+                }
+                String value = lastAttributes.getValue("value");
+                if (value != null && pageSetupExtn != null) {
+                    pageSetupExtn.setValue(value);
+                }
+                if (content.length() > 0 && pageSetupExtn != null) {
+                    pageSetupExtn.setContent(content.toString());
+                    content.setLength(0); //Reset text buffer (see characters())
+                }
             }
         }
     }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java Fri Sep 18 17:10:42 2009
@@ -26,8 +26,8 @@
 
 /**
  * This class represents an AFP-specific extension element to embed Invoke Medium Map (IMM)
- * fields at the beginning of a page group. The element is optional and expected as a direct child
- * of an fo:page-sequence.
+ * fields at the beginning of a page group or just prior to a Page. The element is optional
+ * and expected as a direct child of an fo:page-sequence or fo:simple-page-master
  */
 public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject {
 
@@ -42,7 +42,9 @@
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE) {
+        if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE
+                && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
+            
             invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
                 "rule.childOfPageSequence");
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Fri Sep 18 17:10:42 2009
@@ -36,6 +36,9 @@
  */
 public class AFPPageSetupElement extends AbstractAFPExtensionObject {
 
+    private static final String ATT_VALUE = "value";
+    private static final String ATT_SRC = "src";
+
     /**
      * Constructs an AFP object (called by Maker).
      *
@@ -86,18 +89,18 @@
         super.processNode(elementName, locator, attlist, propertyList);
         AFPPageSetup pageSetup = getPageSetupAttachment();
         if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) {
-            String attr = attlist.getValue("src");
+            String attr = attlist.getValue(ATT_SRC);
             if (attr != null && attr.length() > 0) {
                 pageSetup.setValue(attr);
             } else {
-                throw new FOPException(elementName + " must have a src attribute.");
+                missingPropertyError(ATT_SRC);
             }
         } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) {
-            String attr = attlist.getValue("value");
+            String attr = attlist.getValue(ATT_VALUE);
             if (attr != null && attr.length() > 0) {
                 pageSetup.setValue(attr);
             } else {
-                throw new FOPException(elementName + " must have a value attribute.");
+                missingPropertyError(ATT_VALUE);
             }
         }
     }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/awt/AWTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/awt/AWTRenderer.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/awt/AWTRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/awt/AWTRenderer.java Fri Sep 18 17:10:42 2009
@@ -30,6 +30,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.geom.Rectangle2D;
+import java.awt.geom.Point2D;
 import java.awt.print.PageFormat;
 import java.awt.print.Pageable;
 import java.awt.print.Paper;
@@ -46,6 +47,7 @@
 import org.apache.fop.render.awt.viewer.Renderable;
 import org.apache.fop.render.awt.viewer.StatusListener;
 import org.apache.fop.render.java2d.Java2DRenderer;
+import org.apache.fop.render.extensions.prepress.PageScale;
 
 /**
  * The AWTRender outputs the pages generated by the layout engine to a Swing
@@ -149,11 +151,23 @@
         Rectangle2D bounds = getPageViewport(pageNum).getViewArea();
         pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
         pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
-        double scale = scaleFactor
+        double scaleX = scaleFactor
                 * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
                 / userAgent.getTargetPixelUnitToMillimeter();
-        int bitmapWidth = (int) ((pageWidth * scale) + 0.5);
-        int bitmapHeight = (int) ((pageHeight * scale) + 0.5);
+        double scaleY = scaleFactor
+                * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+                / userAgent.getTargetPixelUnitToMillimeter();
+        if (getPageViewport(pageNum).getForeignAttributes() != null) {
+            String scale = (String) getPageViewport(pageNum).getForeignAttributes().get(
+                    PageScale.EXT_PAGE_SCALE);
+            Point2D scales = PageScale.getScale(scale);
+            if (scales != null) {
+                scaleX *= scales.getX();
+                scaleY *= scales.getY();
+            }
+        }
+        int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
+        int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
         return new Dimension(bitmapWidth, bitmapHeight);
     }
 

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-Id
+Revision Id

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java:699793-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java:699793-816269

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFContentHandler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFContentHandler.java:680381-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFContentHandler.java:680381-816269

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFPainter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFPainter.java:680381-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFPainter.java:680381-816269

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java Fri Sep 18 17:10:42 2009
@@ -563,10 +563,8 @@
         }
         try {
             pageIndices.put(page.getKey(), new Integer(page.getPageIndex()));
-            Rectangle2D viewArea = page.getViewArea();
-            Dimension dim = new Dimension(
-                    (int)Math.ceil(viewArea.getWidth()),
-                    (int)Math.ceil(viewArea.getHeight()));
+            Rectangle viewArea = page.getViewArea();
+            Dimension dim = new Dimension(viewArea.width, viewArea.height);
 
             establishForeignAttributes(page.getForeignAttributes());
             documentHandler.startPage(page.getPageIndex(), page.getPageNumberString(),

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java:680381-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java:680381-816269

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java:685127-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java:685127-816269

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java Fri Sep 18 17:10:42 2009
@@ -106,9 +106,17 @@
                 } else {
                     String id = attributes.getValue("id");
                     int pageIndex = XMLUtil.getAttributeAsInt(attributes, "page-index");
-                    int x = XMLUtil.getAttributeAsInt(attributes, "x");
-                    int y = XMLUtil.getAttributeAsInt(attributes, "y");
-                    action = new GoToXYAction(id, pageIndex, new Point(x, y));
+                    final Point location;
+                    if (pageIndex < 0) {
+                        location = null;
+                    } else {
+                        final int x = XMLUtil
+                                .getAttributeAsInt(attributes, "x");
+                        final int y = XMLUtil
+                                .getAttributeAsInt(attributes, "y");
+                        location = new Point(x, y);
+                    }
+                    action = new GoToXYAction(id, pageIndex, location);
                 }
                 objectStack.push(action);
             } else if (GOTO_URI.getLocalName().equals(localName)) {

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java Fri Sep 18 17:10:42 2009
@@ -71,18 +71,34 @@
 
     /**
      * Returns the page index of the target page.
+     * <p>
+     * This function will always return a valid value for safety. Use
+     * {@link #isComplete()} to check if the link is actually complete.
+     * 
      * @return the page index (0-based)
      */
     public int getPageIndex() {
-        return this.pageIndex;
+        if (this.pageIndex >= 0) {
+            return this.pageIndex;
+        } else {
+            return 0;
+        }
     }
 
     /**
      * Returns the absolute coordinates of the target location on the page.
+     * <p>
+     * This function will always return a valid value for safety. Use
+     * {@link #isComplete()} to check if the link is actually complete.
+     * 
      * @return the target location (coordinates in millipoints)
      */
     public Point getTargetLocation() {
-        return this.targetLocation;
+        if (this.targetLocation == null) {
+            return new Point(0, 0);
+        } else {
+            return this.targetLocation;
+        }
     }
 
     /**
@@ -93,9 +109,13 @@
         this.targetLocation = location;
     }
 
+    private boolean isCompleteExceptTargetLocation() {
+        return (getPageIndex() >= 0);
+    }
+    
     /** {@inheritDoc} */
     public boolean isComplete() {
-        return (getPageIndex() >= 0) && (getTargetLocation() != null);
+        return this.isCompleteExceptTargetLocation() && (this.targetLocation != null);
     }
 
     /** {@inheritDoc} */
@@ -107,10 +127,10 @@
             return false;
         }
         GoToXYAction otherAction = (GoToXYAction)other;
-        if (getPageIndex() != otherAction.getPageIndex()) {
+        if (this.pageIndex != otherAction.pageIndex) {
             return false;
         }
-        if (getTargetLocation() == null || otherAction.getTargetLocation() == null) {
+        if (this.targetLocation == null || otherAction.targetLocation == null) {
             return false;
         }
         if (!getTargetLocation().equals(otherAction.getTargetLocation())) {
@@ -121,16 +141,16 @@
 
     /** {@inheritDoc} */
     public void toSAX(ContentHandler handler) throws SAXException {
-        if (getTargetLocation() == null) {
-            setTargetLocation(new Point(0, 0));
-        }
         AttributesImpl atts = new AttributesImpl();
-        if (isComplete()) {
+        if (this.isCompleteExceptTargetLocation()) {
+            final Point reportedTargetLocation = this.getTargetLocation();
             atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID());
             atts.addAttribute(null, "page-index", "page-index",
                     XMLUtil.CDATA, Integer.toString(pageIndex));
-            atts.addAttribute(null, "x", "x", XMLUtil.CDATA, Integer.toString(targetLocation.x));
-            atts.addAttribute(null, "y", "y", XMLUtil.CDATA, Integer.toString(targetLocation.y));
+            atts.addAttribute(null, "x", "x", XMLUtil.CDATA, 
+                    Integer.toString(reportedTargetLocation.x));
+            atts.addAttribute(null, "y", "y", XMLUtil.CDATA, 
+                    Integer.toString(reportedTargetLocation.y));
         } else {
             atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID());
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Fri Sep 18 17:10:42 2009
@@ -24,6 +24,7 @@
 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
@@ -75,6 +76,8 @@
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.extensions.prepress.PageBoundaries;
+import org.apache.fop.render.extensions.prepress.PageScale;
 import org.apache.fop.render.pdf.CTMHelper;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ColorUtil;
@@ -290,7 +293,10 @@
 
         this.currentPageViewport = pageViewport;
         try {
-            Rectangle2D bounds = pageViewport.getViewArea();
+            PageBoundaries boundaries = new PageBoundaries(
+                    pageViewport.getViewArea().getSize(), pageViewport.getForeignAttributes());
+            Rectangle bounds = boundaries.getCropBox();
+            Rectangle bleedBox = boundaries.getBleedBox();
             this.pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
             this.pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
 
@@ -299,11 +305,25 @@
                             + " (pageWidth " + pageWidth + ", pageHeight "
                             + pageHeight + ")");
 
-            double scale = scaleFactor
+            // set scale factor
+            double scaleX = scaleFactor;
+            double scaleY = scaleFactor;
+            String scale = (String) currentPageViewport.getForeignAttributes().get(
+                    PageScale.EXT_PAGE_SCALE);
+            Point2D scales = PageScale.getScale(scale);
+            if (scales != null) {
+                scaleX *= scales.getX();
+                scaleY *= scales.getY();
+            }
+
+            scaleX = scaleX
+                * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+                / userAgent.getTargetPixelUnitToMillimeter();
+            scaleY = scaleY
                 * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
                 / userAgent.getTargetPixelUnitToMillimeter();
-            int bitmapWidth = (int) ((pageWidth * scale) + 0.5);
-            int bitmapHeight = (int) ((pageHeight * scale) + 0.5);
+            int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
+            int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
 
 
             BufferedImage currentPageImage = getBufferedImage(bitmapWidth, bitmapHeight);
@@ -326,20 +346,27 @@
 
             // transform page based on scale factor supplied
             AffineTransform at = graphics.getTransform();
-            at.scale(scale, scale);
+            at.scale(scaleX, scaleY);
+            at.translate(bounds.getMinX() / -1000f, bounds.getMinY() / -1000f);
             graphics.setTransform(at);
 
             // draw page frame
             if (!transparentPageBackground) {
                 graphics.setColor(Color.white);
-                graphics.fillRect(0, 0, pageWidth, pageHeight);
+                graphics.fillRect(
+                        (int)Math.round(bleedBox.getMinX() / 1000f),
+                        (int)Math.round(bleedBox.getMinY() / 1000f),
+                        (int)Math.round(bleedBox.getWidth() / 1000f),
+                        (int)Math.round(bleedBox.getHeight() / 1000f));
             }
+            /* why did we have this???
             graphics.setColor(Color.black);
             graphics.drawRect(-1, -1, pageWidth + 2, pageHeight + 2);
             graphics.drawLine(pageWidth + 2, 0, pageWidth + 2, pageHeight + 2);
             graphics.drawLine(pageWidth + 3, 1, pageWidth + 3, pageHeight + 3);
             graphics.drawLine(0, pageHeight + 2, pageWidth + 2, pageHeight + 2);
             graphics.drawLine(1, pageHeight + 3, pageWidth + 3, pageHeight + 3);
+            */
 
             state = new Java2DGraphicsState(graphics, this.fontInfo, at);
             try {

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java Fri Sep 18 17:10:42 2009
@@ -186,6 +186,13 @@
                 gen.selectPaperSource(Integer.parseInt(paperSource.toString()));
             }
 
+            //Output bin
+            Object outputBin = getContext().getForeignAttribute(
+                    PCLElementMapping.PCL_OUTPUT_BIN);
+            if (outputBin != null) {
+                gen.selectOutputBin(Integer.parseInt(outputBin.toString()));
+            }
+
             // Is Page duplex?
             Object pageDuplex = getContext().getForeignAttribute(
                     PCLElementMapping.PCL_DUPLEX_MODE);

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java:699793-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java:699793-816269

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java Fri Sep 18 17:10:42 2009
@@ -30,7 +30,10 @@
  */
 public class PCLDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker {
 
-    private static final String[] MIMES = new String[] {MimeConstants.MIME_PCL};
+    private static final String[] MIMES = new String[] {
+            MimeConstants.MIME_PCL,
+            MimeConstants.MIME_PCL_ALT
+    };
 
     /** {@inheritDoc} */
     public IFDocumentHandler makeIFDocumentHandler(FOUserAgent ua) {

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java:699793-763662
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLDocumentHandlerMaker.java:699793-816269

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Fri Sep 18 17:10:42 2009
@@ -1 +1 @@
-Id
+Revision Id

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLGenerator.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLGenerator.java Fri Sep 18 17:10:42 2009
@@ -48,6 +48,7 @@
 import org.apache.xmlgraphics.util.UnitConv;
 
 import org.apache.fop.util.bitmap.BitmapImageUtil;
+import org.apache.fop.util.bitmap.DitherUtil;
 import org.apache.fop.util.bitmap.MonochromeBitmapConverter;
 
 /**
@@ -65,11 +66,6 @@
     /** A list of all supported resolutions in PCL (values in dpi) */
     public static final int[] PCL_RESOLUTIONS = new int[] {75, 100, 150, 200, 300, 600};
 
-    /** Selects a 4x4 Bayer dither matrix (17 grayscales) */
-    public static final int DITHER_MATRIX_4X4 = 4;
-    /** Selects a 8x8 Bayer dither matrix (65 grayscales) */
-    public static final int DITHER_MATRIX_8X8 = 8;
-
     private final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
     private final DecimalFormat df2 = new DecimalFormat("0.##", symbols);
     private final DecimalFormat df4 = new DecimalFormat("0.####", symbols);
@@ -244,6 +240,18 @@
     }
 
     /**
+     * Selects the output bin. The parameter is usually printer-specific. Usually, "1" is the
+     * default output bin (upper bin) and "2" is the lower (rear) output bin. Some printers
+     * may support additional output bins. Consult the technical reference for your printer
+     * for all available values.
+     * @param selector the integer representing the output bin
+     * @throws IOException In case of an I/O error
+     */
+    public void selectOutputBin(int selector) throws IOException {
+        writeCommand("&l" + selector + "G");
+    }
+
+    /**
      * Selects the duplexing mode for the page.
      * The parameter is usually printer-specific.
      * "0" means Simplex,
@@ -390,7 +398,7 @@
             writeCommand("*c" + lineshade + "G");
             writeCommand("*c2P"); //Shaded fill
         } else {
-            defineGrayscalePattern(col, 32, DITHER_MATRIX_4X4);
+            defineGrayscalePattern(col, 32, DitherUtil.DITHER_MATRIX_4X4);
 
             writeCommand("*c" + formatDouble4(w / 100.0) + "h"
                               + formatDouble4(h / 100.0) + "V");
@@ -401,34 +409,6 @@
         setPatternTransparencyMode(true);
     }
 
-    //Bayer dither matrices (4x4 and 8x8 are derived from the 2x2 matrix)
-    private static final int[] BAYER_D2 = new int[] {0, 2, 3, 1};
-    private static final int[] BAYER_D4;
-    private static final int[] BAYER_D8;
-
-    static {
-        BAYER_D4 = deriveBayerMatrix(BAYER_D2);
-        BAYER_D8 = deriveBayerMatrix(BAYER_D4);
-    }
-
-    private static void setValueInMatrix(int[] dn, int half, int part, int idx, int value) {
-        int xoff = (part & 1) * half;
-        int yoff = (part & 2) * half * half;
-        int matrixIndex = yoff + ((idx / half) * half * 2) + (idx % half) + xoff;
-        dn[matrixIndex] = value;
-    }
-
-    private static int[] deriveBayerMatrix(int[] d) {
-        int[] dn = new int[d.length * 4];
-        int half = (int)Math.sqrt(d.length);
-        for (int part = 0; part < 4; part++) {
-            for (int i = 0, c = d.length; i < c; i++) {
-                setValueInMatrix(dn, half, part, i, d[i] * 4 + BAYER_D2[part]);
-            }
-        }
-        return dn;
-    }
-
     /**
      * Generates a user-defined pattern for a dithering pattern matching the grayscale value
      * of the color given.
@@ -453,35 +433,12 @@
 
         byte[] pattern;
         if (ditherMatrixSize == 8) {
-            int gray65 = gray255 * 65 / 255;
-
-            pattern = new byte[BAYER_D8.length / 8];
-
-            for (int i = 0, c = BAYER_D8.length; i < c; i++) {
-                boolean dot = !(BAYER_D8[i] < gray65 - 1);
-                if (dot) {
-                    int byteIdx = i / 8;
-                    pattern[byteIdx] |= 1 << (i % 8);
-                }
-            }
+            pattern = DitherUtil.getBayerDither(DitherUtil.DITHER_MATRIX_8X8, gray255, false);
         } else {
-            int gray17 = gray255 * 17 / 255;
-
             //Since a 4x4 pattern did not work, the 4x4 pattern is applied 4 times to an
             //8x8 pattern. Maybe this could be changed to use an 8x8 bayer dither pattern
             //instead of the 4x4 one.
-            pattern = new byte[BAYER_D4.length / 8 * 4];
-
-            for (int i = 0, c = BAYER_D4.length; i < c; i++) {
-                boolean dot = !(BAYER_D4[i] < gray17 - 1);
-                if (dot) {
-                    int byteIdx = i / 4;
-                    pattern[byteIdx] |= 1 << (i % 4);
-                    pattern[byteIdx] |= 1 << ((i % 4) + 4);
-                    pattern[byteIdx + 4] |= 1 << (i % 4);
-                    pattern[byteIdx + 4] |= 1 << ((i % 4) + 4);
-                }
-            }
+            pattern = DitherUtil.getBayerDither(DitherUtil.DITHER_MATRIX_4X4, gray255, true);
         }
         data.write(pattern);
         if ((baout.size() % 2) > 0) {
@@ -564,7 +521,7 @@
             if (usePCLShades) {
                 selectCurrentPattern(convertToPCLShade(col), 2);
             } else {
-                defineGrayscalePattern(col, 32, DITHER_MATRIX_4X4);
+                defineGrayscalePattern(col, 32, DitherUtil.DITHER_MATRIX_4X4);
                 selectCurrentPattern(32, 4);
             }
         }

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java Fri Sep 18 17:10:42 2009
@@ -177,6 +177,9 @@
         pageDefinitions.add(new PCLPageDefinition("Ledger", 6,
                 createPhysicalPageSizeInch(11, 17),
                 createLogicalPageRect(75, 0, 3150, 5100), false));
+        pageDefinitions.add(new PCLPageDefinition("A5", 25,
+                createPhysicalPageSizeMm(148, 210),
+                createLogicalPageRect(71, 0, 1745, 2480), false));
         pageDefinitions.add(new PCLPageDefinition("A4", 26,
                 createPhysicalPageSizeMm(210, 297),
                 createLogicalPageRect(71, 0, 2338, 3507), false));
@@ -198,6 +201,9 @@
         pageDefinitions.add(new PCLPageDefinition("LedgerL", 6,
                 createPhysicalPageSizeInch(17, 11),
                 createLogicalPageRect(60, 0, 4980, 3300), true));
+        pageDefinitions.add(new PCLPageDefinition("A5L", 25,
+                createPhysicalPageSizeMm(210, 148),
+                createLogicalPageRect(59, 0, 2362, 1747), true));
         pageDefinitions.add(new PCLPageDefinition("A4L", 26,
                 createPhysicalPageSizeMm(297, 210),
                 createLogicalPageRect(59, 0, 3389, 2480), true));

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/PCLRenderer.java Fri Sep 18 17:10:42 2009
@@ -289,6 +289,12 @@
             gen.selectPaperSource(Integer.parseInt(paperSource));
         }
 
+        //Output bin
+        String outputBin = page.getForeignAttributeValue(PCLElementMapping.PCL_OUTPUT_BIN);
+        if (outputBin != null) {
+            gen.selectOutputBin(Integer.parseInt(outputBin));
+        }
+
         // Is Page duplex?
         String pageDuplex = page.getForeignAttributeValue(PCLElementMapping.PCL_DUPLEX_MODE);
         if (pageDuplex != null) {

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java Fri Sep 18 17:10:42 2009
@@ -40,6 +40,10 @@
     public static final QName PCL_PAPER_SOURCE
         = new QName(PCLElementMapping.NAMESPACE, null, "paper-source");
 
+    /** The extension attribute for the PCL output bin */
+    public static final QName PCL_OUTPUT_BIN
+        = new QName(PCLElementMapping.NAMESPACE, null, "output-bin");
+
     /** The extension attribute for the PCL duplex mode */
     public static final QName PCL_DUPLEX_MODE
         = new QName(PCLElementMapping.NAMESPACE, null, "duplex-mode");

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java Fri Sep 18 17:10:42 2009
@@ -129,12 +129,12 @@
             if (cs == null && desc.startsWith("sRGB")) {
                 //It's the default sRGB profile which we mapped to DefaultRGB in PDFRenderer
                 cs = doc.getResources().getColorSpace("DefaultRGB");
-                if (cs == null) {
-                    //sRGB hasn't been set up for the PDF document
-                    //so install but don't set to DefaultRGB
-                    cs = PDFICCBasedColorSpace.setupsRGBColorSpace(doc);
-                }
             }
+            if (cs == null) {
+                // sRGB hasn't been set up for the PDF document
+                // so install but don't set to DefaultRGB
+                cs = PDFICCBasedColorSpace.setupsRGBColorSpace(doc);
+            }            
             pdfICCStream = cs.getICCStream();
         }
         return pdfICCStream;

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java?rev=816718&r1=816717&r2=816718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java Fri Sep 18 17:10:42 2009
@@ -19,6 +19,8 @@
 
 package org.apache.fop.render.pdf;
 import java.awt.color.ColorSpace;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ICC_Profile;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.image.RenderedImage;
@@ -97,9 +99,19 @@
     }
 
     /** {@inheritDoc} */
+    protected ICC_Profile getEffectiveICCProfile() {
+        ColorSpace cs = getImageColorSpace();
+        if (cs instanceof ICC_ColorSpace) {
+            ICC_ColorSpace iccSpace = (ICC_ColorSpace)cs;
+            return iccSpace.getProfile();
+        } else {
+            return null;
+        }
+    }
+
+    /** {@inheritDoc} */
     public void setup(PDFDocument doc) {
         RenderedImage ri = getImage().getRenderedImage();
-        ColorModel cm = getEffectiveColorModel();
 
         super.setup(doc);
 



---------------------------------------------------------------------
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