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 sp...@apache.org on 2008/02/14 22:57:53 UTC

svn commit: r627882 [15/41] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/intermediate/ examples/embedding/xml/xml/ examples/fo/ examples/...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRenderer.java Thu Feb 14 13:55:44 2008
@@ -21,7 +21,8 @@
 
 // Java
 import java.awt.Color;
-import java.awt.color.ColorSpace;
+import java.awt.Point;
+import java.awt.Rectangle;
 import java.awt.color.ICC_Profile;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
@@ -38,6 +39,16 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.IOUtils;
+
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.xmp.Metadata;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
@@ -49,6 +60,7 @@
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.OffDocumentExtensionAttachment;
 import org.apache.fop.area.OffDocumentItem;
+import org.apache.fop.area.PageSequence;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Trait;
@@ -60,14 +72,12 @@
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
+import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fo.extensions.xmp.XMPMetadata;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.Typeface;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.image.ImageFactory;
-import org.apache.fop.image.XMLImage;
 import org.apache.fop.pdf.PDFAMode;
 import org.apache.fop.pdf.PDFAction;
 import org.apache.fop.pdf.PDFAnnotList;
@@ -86,6 +96,7 @@
 import org.apache.fop.pdf.PDFLink;
 import org.apache.fop.pdf.PDFMetadata;
 import org.apache.fop.pdf.PDFNumber;
+import org.apache.fop.pdf.PDFNumsArray;
 import org.apache.fop.pdf.PDFOutline;
 import org.apache.fop.pdf.PDFOutputIntent;
 import org.apache.fop.pdf.PDFPage;
@@ -102,10 +113,6 @@
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ColorProfileUtil;
-import org.apache.xmlgraphics.xmp.Metadata;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
-import org.w3c.dom.Document;
 
 /**
  * Renderer that renders areas to PDF.
@@ -140,6 +147,11 @@
     public static final String PDF_X_MODE = "pdf-x-mode";
     /** Rendering Options key for the ICC profile for the output intent. */
     public static final String KEY_OUTPUT_PROFILE = "output-profile";
+    /**
+     * Rendering Options key for disabling the sRGB color space (only possible if no PDF/A or
+     * PDF/X profile is active).
+     */
+    public static final String KEY_DISABLE_SRGB_COLORSPACE = "disable-srgb-colorspace";
 
     /** Controls whether comments are written to the PDF stream. */
     protected static final boolean WRITE_COMMENTS = true;
@@ -226,10 +238,10 @@
 
     /** the ICC stream used as output profile by this document for PDF/A and PDF/X functionality. */
     protected PDFICCStream outputProfile;
-    /** the ICC stream for the sRGB color space. */
-    //protected PDFICCStream sRGBProfile;
     /** the default sRGB color space. */
     protected PDFICCBasedColorSpace sRGBColorSpace;
+    /** controls whether the sRGB color space should be installed */
+    protected boolean disableSRGBColorSpace = false;
     
     /** Optional URI to an output profile to be used. */
     protected String outputProfileURI; 
@@ -337,6 +349,10 @@
         if (s != null) {
             this.outputProfileURI = s;
         }
+        setting = agent.getRendererOptions().get(KEY_DISABLE_SRGB_COLORSPACE);
+        if (setting != null) {
+            this.disableSRGBColorSpace = booleanValueOf(setting);
+        }
     }
 
     /**
@@ -357,7 +373,7 @@
         this.pdfDoc.getInfo().setTitle(userAgent.getTitle());
         this.pdfDoc.getInfo().setKeywords(userAgent.getKeywords());
         this.pdfDoc.setFilterMap(filterMap);
-        this.pdfDoc.outputHeader(stream);
+        this.pdfDoc.outputHeader(ostream);
 
         //Setup encryption if necessary
         PDFEncryptionManager.setupPDFEncryption(encryptionParams, this.pdfDoc);
@@ -380,27 +396,21 @@
     }
 
     private void addsRGBColorSpace() throws IOException {
-        if (this.sRGBColorSpace != null) {
-            return;
-        }
-        ICC_Profile profile;
-        PDFICCStream sRGBProfile = pdfDoc.getFactory().makePDFICCStream();
-        InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm");
-        if (in != null) {
-            try {
-                profile = ICC_Profile.getInstance(in);
-            } finally {
-                IOUtils.closeQuietly(in);
+        if (disableSRGBColorSpace) {
+            if (this.pdfAMode != PDFAMode.DISABLED
+                    || this.pdfXMode != PDFXMode.DISABLED
+                    || this.outputProfileURI != null) {
+                throw new IllegalStateException("It is not possible to disable the sRGB color"
+                        + " space if PDF/A or PDF/X functionality is enabled or an"
+                        + " output profile is set!");
             }
         } else {
-            //Fallback: Use the sRGB profile from the JRE (about 140KB)
-            profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
+            if (this.sRGBColorSpace != null) {
+                return;
+            }
+            //Map sRGB as default RGB profile for DeviceRGB
+            this.sRGBColorSpace = PDFICCBasedColorSpace.setupsRGBAsDefaultRGBColorSpace(pdfDoc);
         }
-        sRGBProfile.setColorSpace(profile, null);
-        
-        //Map sRGB as default RGB profile for DeviceRGB
-        this.sRGBColorSpace = pdfDoc.getFactory().makeICCBasedColorSpace(
-                null, "DefaultRGB", sRGBProfile);
     }
     
     private void addDefaultOutputProfile() throws IOException {
@@ -604,7 +614,7 @@
 
     private void renderXMPMetadata(XMPMetadata metadata) {
         Metadata docXMP = metadata.getMetadata();
-        Metadata fopXMP = PDFMetadata.createXMPFromUserAgent(pdfDoc);
+        Metadata fopXMP = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
         //Merge FOP's own metadata into the one from the XSL-FO document
         fopXMP.mergeInto(docXMP);
         XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
@@ -632,16 +642,24 @@
         }
     }
 
-    /** Saves the graphics state of the rendering engine. */
+    /** {@inheritDoc} */
     protected void saveGraphicsState() {
         endTextObject();
+        currentState.push();
         currentStream.add("q\n");
     }
 
-    /** Restores the last graphics state of the rendering engine. */
-    protected void restoreGraphicsState() {
+    private void restoreGraphicsState(boolean popState) {
         endTextObject();
         currentStream.add("Q\n");
+        if (popState) {
+            currentState.pop();
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected void restoreGraphicsState() {
+        restoreGraphicsState(true);
     }
 
     /** Indicates the beginning of a text object. */
@@ -664,13 +682,15 @@
 
     /**
      * Start the next page sequence.
-     * For the pdf renderer there is no concept of page sequences
+     * For the PDF renderer there is no concept of page sequences
      * but it uses the first available page sequence title to set
-     * as the title of the pdf document.
-     *
-     * @param seqTitle the title of the page sequence
-     */
-    public void startPageSequence(LineArea seqTitle) {
+     * as the title of the PDF document, and the language of the
+     * document.
+     * @param pageSequence the page sequence
+     */
+    public void startPageSequence(PageSequence pageSequence) {
+        super.startPageSequence(pageSequence);
+        LineArea seqTitle = pageSequence.getTitle();
         if (seqTitle != null) {
             String str = convertTitleToString(seqTitle);
             PDFInfo info = this.pdfDoc.getInfo();
@@ -678,10 +698,20 @@
                 info.setTitle(str);
             }
         }
+        if (pageSequence.getLanguage() != null) {
+            String lang = pageSequence.getLanguage();
+            String country = pageSequence.getCountry();
+            String langCode = lang + (country != null ? "-" + country : "");
+            if (pdfDoc.getRoot().getLanguage() == null) {
+                //Only set if not set already (first non-null is used)
+                //Note: No checking is performed whether the values are valid!
+                pdfDoc.getRoot().setLanguage(langCode);
+            }
+        }
         if (pdfDoc.getRoot().getMetadata() == null) {
             //If at this time no XMP metadata for the overall document has been set, create it
             //from the PDFInfo object.
-            Metadata xmp = PDFMetadata.createXMPFromUserAgent(pdfDoc);
+            Metadata xmp = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
             PDFMetadata pdfMetadata = pdfDoc.getFactory().makeMetadata(
                     xmp, true);
             pdfDoc.getRoot().setMetadata(pdfMetadata);
@@ -725,11 +755,12 @@
             pageLabels = this.pdfDoc.getFactory().makePageLabels();
             this.pdfDoc.getRoot().setPageLabels(pageLabels);
         }
-        PDFDictionary dict = new PDFDictionary();
+        PDFNumsArray nums = pageLabels.getNums(); 
+        PDFDictionary dict = new PDFDictionary(nums);
         dict.put("P", page.getPageNumberString());
         //TODO If the sequence of generated page numbers were inspected, this could be
         //expressed in a more space-efficient way
-        pageLabels.getNums().put(page.getPageIndex(), dict);
+        nums.put(page.getPageIndex(), dict);
     }
     
     /**
@@ -778,16 +809,13 @@
         this.pdfDoc.output(ostream);
     }
 
-    /**
-     * {@inheritDoc} 
-     */
+    /** {@inheritDoc} */
     protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
+        saveGraphicsState();
         // Set the given CTM in the graphics state
-        currentState.push();
         currentState.concatenate(
                 new AffineTransform(CTMHelper.toPDFArray(ctm)));
 
-        saveGraphicsState();
         if (clippingRect != null) {
             clipRect((float)clippingRect.getX() / 1000f, 
                     (float)clippingRect.getY() / 1000f, 
@@ -798,14 +826,19 @@
         currentStream.add(CTMHelper.toPDFString(ctm) + " cm\n");
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void endVParea() {
         restoreGraphicsState();
-        currentState.pop();
     }
 
+    /** {@inheritDoc} */
+    protected void concatenateTransformationMatrix(AffineTransform at) {
+        if (!at.isIdentity()) {
+            currentState.concatenate(at);
+            currentStream.add(CTMHelper.toPDFString(at, false) + " cm\n");
+        }
+    }
+    
     /**
      * Handle the traits for a region
      * This is used to draw the traits for the given page region.
@@ -1007,15 +1040,7 @@
         }
     }
     
-    /**
-     * Clip a rectangular area.
-     * write a clipping operation given coordinates in the current
-     * transform.
-     * @param x the x coordinate
-     * @param y the y coordinate
-     * @param width the width of the area
-     * @param height the height of the area
-     */
+    /** {@inheritDoc} */
     protected void clipRect(float x, float y, float width, float height) {
         currentStream.add(format(x) + " " + format(y) + " " 
                 + format(width) + " " + format(height) + " re ");
@@ -1096,7 +1121,7 @@
                 comment("------ break out!");
             }
             breakOutList.add(0, data); //Insert because of stack-popping
-            restoreGraphicsState();
+            restoreGraphicsState(false);
         }
         return breakOutList;
     }
@@ -1106,23 +1131,14 @@
      * @param breakOutList the state stack to restore.
      */
     protected void restoreStateStackAfterBreakOut(List breakOutList) {
-        CTM tempctm;
         comment("------ restoring context after break-out...");
         PDFState.Data data;
         Iterator i = breakOutList.iterator();
-        double[] matrix = new double[6];
         while (i.hasNext()) {
             data = (PDFState.Data)i.next();
-            currentState.push();
             saveGraphicsState();
             AffineTransform at = data.getTransform();
-            if (!at.isIdentity()) {
-                currentState.concatenate(at);
-                at.getMatrix(matrix);
-                tempctm = new CTM(matrix[0], matrix[1], matrix[2], matrix[3], 
-                                  matrix[4] * 1000, matrix[5] * 1000);
-                currentStream.add(CTMHelper.toPDFString(tempctm) + " cm\n");
-            }
+            concatenateTransformationMatrix(at);
             //TODO Break-out: Also restore items such as line width and color
             //Left out for now because all this painting stuff is very
             //inconsistent. Some values go over PDFState, some don't.
@@ -1549,7 +1565,7 @@
                 startPending = false;
             }
             if (!useMultiByte) {
-                if (ch > 127) {
+                if (ch < 32 || ch > 127) {
                     pdf.append("\\");
                     pdf.append(Integer.toOctalString((int) ch));
                 } else {
@@ -1655,29 +1671,44 @@
         }
     }
 
-    /**
-     * {@inheritDoc} 
-     */
+    /** {@inheritDoc} */
     public void renderImage(Image image, Rectangle2D pos) {
         endTextObject();
         String url = image.getURL();
-        putImage(url, pos);
+        putImage(url, pos, image.getForeignAttributes());
     }
 
     /** {@inheritDoc} */
     protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) {
         endTextObject();
-        putImage(url, pos);
+        putImage(url, pos, foreignAttributes);
+    }
+    
+    /**
+     * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
+     * @param uri URL of the bitmap
+     * @param pos Position of the bitmap
+     * @deprecated Use {@link @putImage(String, Rectangle2D, Map)} instead.
+     */
+    protected void putImage(String uri, Rectangle2D pos) {
+        putImage(uri, pos, null);
     }
     
     /**
      * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
-     * @param url URL of the bitmap
+     * @param uri URL of the bitmap
      * @param pos Position of the bitmap
+     * @param foreignAttributes foreign attributes associated with the image
      */
-    protected void putImage(String url, Rectangle2D pos) {
-        url = ImageFactory.getURL(url);
-        PDFXObject xobject = pdfDoc.getXObject(url);
+    protected void putImage(String uri, Rectangle2D pos, Map foreignAttributes) {
+        Rectangle posInt = new Rectangle(
+                (int)pos.getX(),
+                (int)pos.getY(),
+                (int)pos.getWidth(),
+                (int)pos.getHeight());
+
+        uri = URISpecification.getURL(uri);
+        PDFXObject xobject = pdfDoc.getXObject(uri);
         if (xobject != null) {
             float w = (float) pos.getWidth() / 1000f;
             float h = (float) pos.getHeight() / 1000f;
@@ -1685,79 +1716,47 @@
                        (float)pos.getY() / 1000f, w, h, xobject);
             return;
         }
+        Point origin = new Point(currentIPPosition, currentBPPosition);
+        int x = origin.x + posInt.x;
+        int y = origin.y + posInt.y;
 
-        ImageFactory fact = userAgent.getFactory().getImageFactory();
-        FopImage fopimage = fact.getImage(url, userAgent);
-        if (fopimage == null) {
-            return;
-        }
-        if (!fopimage.load(FopImage.DIMENSIONS)) {
-            return;
-        }
-        String mime = fopimage.getMimeType();
-        
-        //First check for a dynamically registered handler
-        PDFImageHandler handler = imageHandlerRegistry.getHandler(mime);
-        if (handler != null) {
-            PDFXObject xobj;
-            try {
-                xobj = handler.generateImage(fopimage, url, pdfDoc);
-            } catch (IOException ioe) {
-                log.error("I/O error while handling " + mime + " image", ioe);
-                return;
-            }
-            fact.releaseImage(url, userAgent);
+        ImageManager manager = getUserAgent().getFactory().getImageManager();
+        ImageInfo info = null;
+        try {
+            ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
+            info = manager.getImageInfo(uri, sessionContext);
             
-            float w = (float)pos.getWidth() / 1000f;
-            float h = (float)pos.getHeight() / 1000f;
-            placeImage((float) pos.getX() / 1000,
-                       (float) pos.getY() / 1000, w, h, xobj);
-        } else if ("text/xml".equals(mime)) {
-            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
-                return;
-            }
-            Document doc = ((XMLImage) fopimage).getDocument();
-            String ns = ((XMLImage) fopimage).getNameSpace();
-
-            renderDocument(doc, ns, pos, null);
-        } else if ("image/svg+xml".equals(mime)) {
-            if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
-                return;
-            }
-            Document doc = ((XMLImage) fopimage).getDocument();
-            String ns = ((XMLImage) fopimage).getNameSpace();
-
-            renderDocument(doc, ns, pos, null);
-        } else if ("image/eps".equals(mime)) {
-            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
-            PDFXObject xobj = pdfDoc.addImage(currentContext, pdfimage);
-            fact.releaseImage(url, userAgent);
             
-            float w = (float)pos.getWidth() / 1000f;
-            float h = (float)pos.getHeight() / 1000f;
-            placeImage((float) pos.getX() / 1000,
-                       (float) pos.getY() / 1000, w, h, xobj);
-        } else if ("image/jpeg".equals(mime) || "image/tiff".equals(mime)) {
-            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
-            PDFXObject xobj = pdfDoc.addImage(currentContext, pdfimage);
-            fact.releaseImage(url, userAgent);
-
-            float w = (float)pos.getWidth() / 1000f;
-            float h = (float)pos.getHeight() / 1000f;
-            placeImage((float) pos.getX() / 1000,
-                       (float) pos.getY() / 1000, w, h, xobj);
-        } else {
-            if (!fopimage.load(FopImage.BITMAP)) {
-                return;
-            }
-            FopPDFImage pdfimage = new FopPDFImage(fopimage, url);
-            PDFXObject xobj = pdfDoc.addImage(currentContext, pdfimage);
-            fact.releaseImage(url, userAgent);
-
-            float w = (float) pos.getWidth() / 1000f;
-            float h = (float) pos.getHeight() / 1000f;
-            placeImage((float) pos.getX() / 1000f,
-                       (float) pos.getY() / 1000f, w, h, xobj);
+            
+            Map hints = ImageUtil.getDefaultHints(sessionContext);
+            org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
+                        info, imageHandlerRegistry.getSupportedFlavors(), hints, sessionContext);
+            
+            //First check for a dynamically registered handler
+            PDFImageHandler handler = imageHandlerRegistry.getHandler(img.getClass());
+            if (handler != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Using PDFImageHandler: " + handler.getClass().getName());
+                }
+                try {
+                    RendererContext context = createRendererContext(
+                            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);
+                    return;
+                }
+            } else {
+                throw new UnsupportedOperationException(
+                        "No PDFImageHandler available for image: "
+                            + info + " (" + img.getClass().getName() + ")");
+            }
+        } catch (ImageException ie) {
+            log.error("Error while processing image: "
+                    + (info != null ? info.toString() : uri), ie);
+        } catch (IOException ioe) {
+            log.error("I/O error while processing image: "
+                    + (info != null ? info.toString() : uri), ioe);
         }
 
         // output new data
@@ -1776,7 +1775,7 @@
      * @param h height for image
      * @param xobj the image XObject
      */
-    protected void placeImage(float x, float y, float w, float h, PDFXObject xobj) {
+    public void placeImage(float x, float y, float w, float h, PDFXObject xobj) {
         saveGraphicsState();
         currentStream.add(format(w) + " 0 0 "
                           + format(-h) + " "
@@ -1786,10 +1785,7 @@
         restoreGraphicsState();
     }
 
-    /**
-     * {@inheritDoc}
-     *          int, int, int, int, java.util.Map)
-     */
+    /** {@inheritDoc} */
     protected RendererContext createRendererContext(int x, int y, int width, int height, 
             Map foreignAttributes) {
         RendererContext context = super.createRendererContext(

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.pdf;
 
@@ -24,6 +24,7 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.pdf.PDFAMode;
@@ -80,6 +81,10 @@
             s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null);
             if (s != null) {
                 pdfRenderer.setOutputProfileURI(s);
+            }
+            Configuration child = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+            if (child != null) {
+                pdfRenderer.disableSRGBColorSpace = child.getValueAsBoolean(false);
             }
         }
     }

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

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java Thu Feb 14 13:55:44 2008
@@ -1,55 +1,55 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PDF Renderer.
- */
-public class PDFRendererMaker extends AbstractRendererMaker {
-
-    private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
-    
-    /** {@inheritDoc} */
-    public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new PDFRenderer();
-    }
-
-    /** {@inheritDoc} */
-    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
-        return new PDFRendererConfigurator(userAgent);
-    }
-    
-    /** {@inheritDoc} */
-    public boolean needsOutputStream() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    public String[] getSupportedMimeTypes() {
-        return MIMES;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.render.AbstractRendererMaker;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
+
+/**
+ * RendererMaker for the PDF Renderer.
+ */
+public class PDFRendererMaker extends AbstractRendererMaker {
+
+    private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
+    
+    /** {@inheritDoc} */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
+        return new PDFRenderer();
+    }
+
+    /** {@inheritDoc} */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PDFRendererConfigurator(userAgent);
+    }
+    
+    /** {@inheritDoc} */
+    public boolean needsOutputStream() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    public String[] getSupportedMimeTypes() {
+        return MIMES;
+    }
+
+}

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

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java Thu Feb 14 13:55:44 2008
@@ -19,42 +19,40 @@
 
 package org.apache.fop.render.pdf;
 
+import java.awt.Color;
+import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Map;
-import java.awt.Color;
-import java.awt.geom.AffineTransform;
 
 import org.w3c.dom.Document;
 
-import org.apache.fop.render.AbstractGenericSVGHandler;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererContextConstants;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.util.SVGConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFPage;
+import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFStream;
-import org.apache.fop.pdf.PDFResourceContext;
+import org.apache.fop.render.AbstractGenericSVGHandler;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.svg.PDFAElementBridge;
 import org.apache.fop.svg.PDFBridgeContext;
 import org.apache.fop.svg.PDFGraphics2D;
 import org.apache.fop.svg.SVGUserAgent;
 import org.apache.fop.util.QName;
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
-import org.apache.fop.fonts.FontInfo;
-
-// Commons-Logging
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.avalon.framework.configuration.Configuration;
-
-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.batik.util.SVGConstants;
 
 /**
  * PDF XML handler for SVG (uses Apache Batik).
@@ -154,10 +152,15 @@
         int xOffset = pdfInfo.currentXPosition;
         int yOffset = pdfInfo.currentYPosition;
 
-        final float deviceResolution = context.getUserAgent().getTargetResolution();
+        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.");
         
-        final float uaResolution = context.getUserAgent().getSourceResolution();
+        final float uaResolution = userAgent.getSourceResolution();
         SVGUserAgent ua = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
 
         //Scale for higher resolution on-the-fly images from Batik
@@ -176,6 +179,8 @@
         
         BridgeContext ctx = new PDFBridgeContext(ua, 
                 (strokeText ? null : pdfInfo.fi),
+                userAgent.getFactory().getImageManager(),
+                userAgent.getImageSessionContext(),
                 new AffineTransform());
         
         GraphicsNode root;

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRenderer.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRendererMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRendererMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRendererMaker.java Thu Feb 14 13:55:44 2008
@@ -1,56 +1,56 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.print;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.PrintRendererConfigurator;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the Print Renderer.
- */
-public class PrintRendererMaker extends AbstractRendererMaker {
-
-    private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_PRINT};
-    
-    /**{@inheritDoc} */
-    public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new PrintRenderer();
-    }
-
-    /** {@inheritDoc} */
-    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
-        return new PrintRendererConfigurator(userAgent);
-    }
-
-    /** {@inheritDoc} */
-    public boolean needsOutputStream() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    public String[] getSupportedMimeTypes() {
-        return MIMES;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.print;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.render.AbstractRendererMaker;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
+
+/**
+ * RendererMaker for the Print Renderer.
+ */
+public class PrintRendererMaker extends AbstractRendererMaker {
+
+    private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_PRINT};
+    
+    /**{@inheritDoc} */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
+        return new PrintRenderer();
+    }
+
+    /** {@inheritDoc} */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PrintRendererConfigurator(userAgent);
+    }
+
+    /** {@inheritDoc} */
+    public boolean needsOutputStream() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    public String[] getSupportedMimeTypes() {
+        return MIMES;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/print/PrintRendererMaker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/EPSTranscoder.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/NativeTextHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java Thu Feb 14 13:55:44 2008
@@ -1,312 +1,312 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id: $ */
-
-package org.apache.fop.render.ps;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * This class is used to encapsulate postscript dictionary objects.
- */
-public class PSDictionary extends java.util.HashMap {
-    
-    private static final long serialVersionUID = 815367222496219197L;
-
-    /**
-     * This class is used to parse dictionary strings.
-     */
-    private static class Maker {
-        
-        /**
-         * Simple token holding class
-         */
-        private class Token {
-            /**
-             * start index in string
-             */
-            private int startIndex = -1;
-            
-            /**
-             * end index in string
-             */
-            private int endIndex = -1;
-            
-            /**
-             * token string value
-             */
-            private String value;        
-        }
-        
-        private static final String[][] BRACES = {
-            {"<<", ">>"},
-            {"[", "]"},
-            {"{", "}"}
-        };
-
-        private static final int OPENING = 0;
-        private static final int CLOSING = 1;
-        private static final int DICTIONARY = 0;
-        private static final int ARRAY = 1;
-        private static final int PROCEDURE = 2;
-
-        /**
-         * Returns a Token containing the start, end index and value of the next token
-         * found in a given string
-         * 
-         * @param str
-         *            string to search
-         * @param fromIndex
-         *            search from index
-         * @return Token containing the start, end index and value of the next token
-         */
-        protected Token nextToken(String str, int fromIndex) {
-            Token t = null;
-            for (int i = fromIndex; i < str.length(); i++) {
-                boolean isWhitespace = Character.isWhitespace(str.charAt(i));
-                // start index found
-                if (t == null && !isWhitespace) {
-                    t = new Token();
-                    t.startIndex = i;
-                // end index found
-                } else if (t != null && isWhitespace) {
-                    t.endIndex = i;
-                    break;
-                }
-            }
-            // start index found
-            if (t != null) {
-                // end index not found so take end of string
-                if (t.endIndex == -1) {
-                    t.endIndex = str.length();
-                }
-                t.value = str.substring(t.startIndex, t.endIndex);
-            }
-            return t;
-        }
-
-        /**
-         * Returns the closing brace index from a given string searches from a
-         * given index
-         * 
-         * @param str
-         *            string to search
-         * @param braces
-         *            string array of opening and closing brace
-         * @param fromIndex
-         *            searches from index
-         * @return matching brace index
-         * @throws org.apache.fop.render.ps.PSDictionaryFormatException
-         *            thrown in the event that a parsing error occurred
-         */
-        private int indexOfMatchingBrace(String str, String[] braces,
-                int fromIndex) throws PSDictionaryFormatException {
-            final int len = str.length();
-            if (braces.length != 2) {
-                throw new PSDictionaryFormatException("Wrong number of braces");
-            }
-            for (int openCnt = 0, closeCnt = 0; fromIndex < len; fromIndex++) {
-                if (str.startsWith(braces[OPENING], fromIndex)) {
-                    openCnt++;
-                } else if (str.startsWith(braces[CLOSING], fromIndex)) {
-                    closeCnt++;
-                    if (openCnt > 0 && openCnt == closeCnt) {
-                        return fromIndex; // found
-                    }
-                }
-            }
-            return -1; // not found
-        }
-
-        /**
-         * Strips braces from complex object string
-         * 
-         * @param str
-         *            String to parse
-         * @param braces
-         *            String array containing opening and closing braces
-         * @return String with braces stripped
-         * @throws
-         *      org.apache.fop.render.ps.PSDictionaryFormatException object format exception
-         */
-        private String stripBraces(String str, String[] braces) throws PSDictionaryFormatException {
-            // find first opening brace
-            int firstIndex = str.indexOf(braces[OPENING]);
-            if (firstIndex == -1) {
-                throw new PSDictionaryFormatException(
-                        "Failed to find opening parameter '" + braces[OPENING]
-                                + "");
-            }
-
-            // find last matching brace
-            int lastIndex = indexOfMatchingBrace(str, braces, firstIndex);
-            if (lastIndex == -1) {
-                throw new PSDictionaryFormatException(
-                        "Failed to find matching closing parameter '"
-                                + braces[CLOSING] + "'");
-            }
-
-            // strip brace and trim
-            int braceLen = braces[OPENING].length();
-            str = str.substring(firstIndex + braceLen, lastIndex).trim();
-            return str;
-        }
-
-        /**
-         * Parses a dictionary string and provides a dictionary object
-         * 
-         * @param str a dictionary string
-         * @return A postscript dictionary object
-         * @throws
-         *      PSDictionaryFormatException thrown if a dictionary format exception occurs
-         */
-        public PSDictionary parseDictionary(String str) throws PSDictionaryFormatException {
-            PSDictionary dictionary = new PSDictionary();
-            str = stripBraces(str.trim(), BRACES[DICTIONARY]);
-            // length of dictionary string
-            final int len = str.length();
-
-            Token keyToken;
-            for (int currIndex = 0; (keyToken = nextToken(str, currIndex)) != null
-                    && currIndex <= len;) {
-                if (keyToken.value == null) {
-                    throw new PSDictionaryFormatException("Failed to parse object key");
-                }
-                Token valueToken = nextToken(str, keyToken.endIndex + 1);
-                String[] braces = null;
-                for (int i = 0; i < BRACES.length; i++) {
-                    if (valueToken.value.startsWith(BRACES[i][OPENING])) {
-                        braces = BRACES[i];
-                        break;
-                    }
-                }
-                Object obj = null;
-                if (braces != null) {
-                    // find closing brace
-                    valueToken.endIndex = indexOfMatchingBrace(str, braces,
-                        valueToken.startIndex)
-                        + braces[OPENING].length();
-                    if (valueToken.endIndex < 0) {
-                        throw new PSDictionaryFormatException("Closing value brace '"
-                            + braces[CLOSING] + "' not found for key '"
-                            + keyToken.value + "'");
-                    }
-                    valueToken.value = str.substring(valueToken.startIndex, valueToken.endIndex);
-                }
-                if (braces == null || braces == BRACES[PROCEDURE]) {
-                    obj = valueToken.value;                        
-                } else if (BRACES[ARRAY] == braces) {
-                    List objList = new java.util.ArrayList();
-                    String objString = stripBraces(valueToken.value, braces);
-                    StringTokenizer tokenizer = new StringTokenizer(objString, ",");
-                    while (tokenizer.hasMoreTokens()) {
-                        objList.add(tokenizer.nextToken());
-                    }
-                    obj = objList;                        
-                } else if (BRACES[DICTIONARY] == braces) {
-                    obj = parseDictionary(valueToken.value);
-                }
-                dictionary.put(keyToken.value, obj);
-                currIndex = valueToken.endIndex + 1;
-            }
-            return dictionary;
-        }    
-    }
-    
-    /**
-     * Parses a given a dictionary string and returns an object 
-     * 
-     * @param str dictionary string
-     * @return dictionary object
-     * @throws PSDictionaryFormatException object format exception
-     */
-    public static PSDictionary valueOf(String str) throws PSDictionaryFormatException {
-        return (new Maker()).parseDictionary(str);
-    }
-
-    /**
-     * @param obj object to test equality against
-     * @return whether a given object is equal to this dictionary object
-     * @see java.lang.Object#equals(Object)
-     */
-    public boolean equals(Object obj) {
-        if (!(obj instanceof PSPageDeviceDictionary)) {
-            return false;
-        }
-        PSDictionary dictionaryObj = (PSDictionary) obj;
-        if (dictionaryObj.size() != size()) {
-            return false;
-        }
-        for (Iterator it = keySet().iterator(); it.hasNext();) {
-            String key = (String) it.next();
-            if (!dictionaryObj.containsKey(key)) {
-                return false;
-            }
-            if (!dictionaryObj.get(key).equals(get(key))) {
-                return false;
-            }
-        }
-        return true;
-    }
-    
-    /**
-     * @return a hash code value for this object.
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode() {
-        int hashCode = 7;
-        for (Iterator it = values().iterator(); it.hasNext();) {
-            Object value = it.next();
-            hashCode += value.hashCode();
-        }
-        return hashCode;
-    }
-
-    /**
-     * @return a string representation of this dictionary
-     * @see java.lang.String#toString()
-     */
-    public String toString() {
-        if (isEmpty()) {
-            return "";
-        }
-        StringBuffer sb = new StringBuffer("<<\n");
-        for (Iterator it = super.keySet().iterator(); it.hasNext();) {
-            String key = (String) it.next();
-            sb.append("  " + key + " ");
-            Object obj = super.get(key);
-            if (obj instanceof java.util.ArrayList) {
-                List array = (List)obj;
-                String str = "[";
-                for (int i = 0; i < array.size(); i++) {
-                    Object element = array.get(i);
-                    str += element + " ";
-                }
-                str = str.trim();
-                str += "]";
-                sb.append(str + "\n");                
-            } else {
-                sb.append(obj.toString() + "\n");
-            }
-        }
-        sb.append(">>");
-        return sb.toString();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * This class is used to encapsulate postscript dictionary objects.
+ */
+public class PSDictionary extends java.util.HashMap {
+    
+    private static final long serialVersionUID = 815367222496219197L;
+
+    /**
+     * This class is used to parse dictionary strings.
+     */
+    private static class Maker {
+        
+        /**
+         * Simple token holding class
+         */
+        private class Token {
+            /**
+             * start index in string
+             */
+            private int startIndex = -1;
+            
+            /**
+             * end index in string
+             */
+            private int endIndex = -1;
+            
+            /**
+             * token string value
+             */
+            private String value;        
+        }
+        
+        private static final String[][] BRACES = {
+            {"<<", ">>"},
+            {"[", "]"},
+            {"{", "}"}
+        };
+
+        private static final int OPENING = 0;
+        private static final int CLOSING = 1;
+        private static final int DICTIONARY = 0;
+        private static final int ARRAY = 1;
+        private static final int PROCEDURE = 2;
+
+        /**
+         * Returns a Token containing the start, end index and value of the next token
+         * found in a given string
+         * 
+         * @param str
+         *            string to search
+         * @param fromIndex
+         *            search from index
+         * @return Token containing the start, end index and value of the next token
+         */
+        protected Token nextToken(String str, int fromIndex) {
+            Token t = null;
+            for (int i = fromIndex; i < str.length(); i++) {
+                boolean isWhitespace = Character.isWhitespace(str.charAt(i));
+                // start index found
+                if (t == null && !isWhitespace) {
+                    t = new Token();
+                    t.startIndex = i;
+                // end index found
+                } else if (t != null && isWhitespace) {
+                    t.endIndex = i;
+                    break;
+                }
+            }
+            // start index found
+            if (t != null) {
+                // end index not found so take end of string
+                if (t.endIndex == -1) {
+                    t.endIndex = str.length();
+                }
+                t.value = str.substring(t.startIndex, t.endIndex);
+            }
+            return t;
+        }
+
+        /**
+         * Returns the closing brace index from a given string searches from a
+         * given index
+         * 
+         * @param str
+         *            string to search
+         * @param braces
+         *            string array of opening and closing brace
+         * @param fromIndex
+         *            searches from index
+         * @return matching brace index
+         * @throws org.apache.fop.render.ps.PSDictionaryFormatException
+         *            thrown in the event that a parsing error occurred
+         */
+        private int indexOfMatchingBrace(String str, String[] braces,
+                int fromIndex) throws PSDictionaryFormatException {
+            final int len = str.length();
+            if (braces.length != 2) {
+                throw new PSDictionaryFormatException("Wrong number of braces");
+            }
+            for (int openCnt = 0, closeCnt = 0; fromIndex < len; fromIndex++) {
+                if (str.startsWith(braces[OPENING], fromIndex)) {
+                    openCnt++;
+                } else if (str.startsWith(braces[CLOSING], fromIndex)) {
+                    closeCnt++;
+                    if (openCnt > 0 && openCnt == closeCnt) {
+                        return fromIndex; // found
+                    }
+                }
+            }
+            return -1; // not found
+        }
+
+        /**
+         * Strips braces from complex object string
+         * 
+         * @param str
+         *            String to parse
+         * @param braces
+         *            String array containing opening and closing braces
+         * @return String with braces stripped
+         * @throws
+         *      org.apache.fop.render.ps.PSDictionaryFormatException object format exception
+         */
+        private String stripBraces(String str, String[] braces) throws PSDictionaryFormatException {
+            // find first opening brace
+            int firstIndex = str.indexOf(braces[OPENING]);
+            if (firstIndex == -1) {
+                throw new PSDictionaryFormatException(
+                        "Failed to find opening parameter '" + braces[OPENING]
+                                + "");
+            }
+
+            // find last matching brace
+            int lastIndex = indexOfMatchingBrace(str, braces, firstIndex);
+            if (lastIndex == -1) {
+                throw new PSDictionaryFormatException(
+                        "Failed to find matching closing parameter '"
+                                + braces[CLOSING] + "'");
+            }
+
+            // strip brace and trim
+            int braceLen = braces[OPENING].length();
+            str = str.substring(firstIndex + braceLen, lastIndex).trim();
+            return str;
+        }
+
+        /**
+         * Parses a dictionary string and provides a dictionary object
+         * 
+         * @param str a dictionary string
+         * @return A postscript dictionary object
+         * @throws
+         *      PSDictionaryFormatException thrown if a dictionary format exception occurs
+         */
+        public PSDictionary parseDictionary(String str) throws PSDictionaryFormatException {
+            PSDictionary dictionary = new PSDictionary();
+            str = stripBraces(str.trim(), BRACES[DICTIONARY]);
+            // length of dictionary string
+            final int len = str.length();
+
+            Token keyToken;
+            for (int currIndex = 0; (keyToken = nextToken(str, currIndex)) != null
+                    && currIndex <= len;) {
+                if (keyToken.value == null) {
+                    throw new PSDictionaryFormatException("Failed to parse object key");
+                }
+                Token valueToken = nextToken(str, keyToken.endIndex + 1);
+                String[] braces = null;
+                for (int i = 0; i < BRACES.length; i++) {
+                    if (valueToken.value.startsWith(BRACES[i][OPENING])) {
+                        braces = BRACES[i];
+                        break;
+                    }
+                }
+                Object obj = null;
+                if (braces != null) {
+                    // find closing brace
+                    valueToken.endIndex = indexOfMatchingBrace(str, braces,
+                        valueToken.startIndex)
+                        + braces[OPENING].length();
+                    if (valueToken.endIndex < 0) {
+                        throw new PSDictionaryFormatException("Closing value brace '"
+                            + braces[CLOSING] + "' not found for key '"
+                            + keyToken.value + "'");
+                    }
+                    valueToken.value = str.substring(valueToken.startIndex, valueToken.endIndex);
+                }
+                if (braces == null || braces == BRACES[PROCEDURE]) {
+                    obj = valueToken.value;                        
+                } else if (BRACES[ARRAY] == braces) {
+                    List objList = new java.util.ArrayList();
+                    String objString = stripBraces(valueToken.value, braces);
+                    StringTokenizer tokenizer = new StringTokenizer(objString, ",");
+                    while (tokenizer.hasMoreTokens()) {
+                        objList.add(tokenizer.nextToken());
+                    }
+                    obj = objList;                        
+                } else if (BRACES[DICTIONARY] == braces) {
+                    obj = parseDictionary(valueToken.value);
+                }
+                dictionary.put(keyToken.value, obj);
+                currIndex = valueToken.endIndex + 1;
+            }
+            return dictionary;
+        }    
+    }
+    
+    /**
+     * Parses a given a dictionary string and returns an object 
+     * 
+     * @param str dictionary string
+     * @return dictionary object
+     * @throws PSDictionaryFormatException object format exception
+     */
+    public static PSDictionary valueOf(String str) throws PSDictionaryFormatException {
+        return (new Maker()).parseDictionary(str);
+    }
+
+    /**
+     * @param obj object to test equality against
+     * @return whether a given object is equal to this dictionary object
+     * @see java.lang.Object#equals(Object)
+     */
+    public boolean equals(Object obj) {
+        if (!(obj instanceof PSPageDeviceDictionary)) {
+            return false;
+        }
+        PSDictionary dictionaryObj = (PSDictionary) obj;
+        if (dictionaryObj.size() != size()) {
+            return false;
+        }
+        for (Iterator it = keySet().iterator(); it.hasNext();) {
+            String key = (String) it.next();
+            if (!dictionaryObj.containsKey(key)) {
+                return false;
+            }
+            if (!dictionaryObj.get(key).equals(get(key))) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    /**
+     * @return a hash code value for this object.
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode() {
+        int hashCode = 7;
+        for (Iterator it = values().iterator(); it.hasNext();) {
+            Object value = it.next();
+            hashCode += value.hashCode();
+        }
+        return hashCode;
+    }
+
+    /**
+     * @return a string representation of this dictionary
+     * @see java.lang.String#toString()
+     */
+    public String toString() {
+        if (isEmpty()) {
+            return "";
+        }
+        StringBuffer sb = new StringBuffer("<<\n");
+        for (Iterator it = super.keySet().iterator(); it.hasNext();) {
+            String key = (String) it.next();
+            sb.append("  " + key + " ");
+            Object obj = super.get(key);
+            if (obj instanceof java.util.ArrayList) {
+                List array = (List)obj;
+                String str = "[";
+                for (int i = 0; i < array.size(); i++) {
+                    Object element = array.get(i);
+                    str += element + " ";
+                }
+                str = str.trim();
+                str += "]";
+                sb.append(str + "\n");                
+            } else {
+                sb.append(obj.toString() + "\n");
+            }
+        }
+        sb.append(">>");
+        return sb.toString();
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionary.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java Thu Feb 14 13:55:44 2008
@@ -1,37 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id: $ */
-
-package org.apache.fop.render.ps;
-
-/**
- * Thrown to indicate that a formatting error has occured when
- * trying to parse a postscript dictionary object
- */
-public class PSDictionaryFormatException extends Exception {
-
-    private static final long serialVersionUID = 6492321557297860931L;
-
-    /**
-     * Default constructor
-     * @param string error message
-     */
-    public PSDictionaryFormatException(String string) {
-        super(string);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps;
+
+/**
+ * Thrown to indicate that a formatting error has occured when
+ * trying to parse a postscript dictionary object
+ */
+public class PSDictionaryFormatException extends Exception {
+
+    private static final long serialVersionUID = 6492321557297860931L;
+
+    /**
+     * Default constructor
+     * @param string error message
+     */
+    public PSDictionaryFormatException(String string) {
+        super(string);
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java Thu Feb 14 13:55:44 2008
@@ -31,16 +31,18 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.ps.DSCConstants;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSResource;
+import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
+
 import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.LazyFont;
 import org.apache.fop.fonts.Typeface;
-import org.apache.xmlgraphics.ps.DSCConstants;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSResource;
-import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
 
 /**
  * Utility code for font handling in PostScript.
@@ -108,8 +110,10 @@
             } else if ("WinAnsiEncoding".equals(fm.getEncoding())) {
                 redefineFontEncoding(gen, fm.getFontName(), fm.getEncoding());
             } else {
+                /* Don't complain anymore, just use the font's default encoding.
                 gen.commentln("%WARNING: Only WinAnsiEncoding is supported. Font '" 
                     + fm.getFontName() + "' asks for: " + fm.getEncoding());
+                */
             }
         }
         gen.commentln("%FOPEndFontReencode");

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java Thu Feb 14 13:55:44 2008
@@ -1,93 +1,105 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
- 
-package org.apache.fop.render.ps;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.Graphics2DImagePainter;
-import org.apache.fop.render.RendererContext;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-
-/**
- * Graphics2DAdapter implementation for PostScript.
- */
-public class PSGraphics2DAdapter implements Graphics2DAdapter {
-
-    private PSRenderer renderer;
-
-    /**
-     * Main constructor
-     * @param renderer the Renderer instance to which this instance belongs
-     */
-    public PSGraphics2DAdapter(PSRenderer renderer) {
-        this.renderer = renderer;
-    }
-    
-    /** {@inheritDoc} */
-    public void paintImage(Graphics2DImagePainter painter, 
-            RendererContext context,
-            int x, int y, int width, int height) throws IOException {
-        PSGenerator gen = renderer.gen;
-        
-        float fwidth = width / 1000f;
-        float fheight = height / 1000f;
-        float fx = x / 1000f;
-        float fy = y / 1000f;
-        
-        // get the 'width' and 'height' attributes of the SVG document
-        Dimension dim = painter.getImageSize();
-        float imw = (float)dim.getWidth() / 1000f;
-        float imh = (float)dim.getHeight() / 1000f;
-
-        float sx = fwidth / (float)imw;
-        float sy = fheight / (float)imh;
-
-        gen.commentln("%FOPBeginGraphics2D");
-        gen.saveGraphicsState();
-        // Clip to the image area.
-        gen.writeln("newpath");
-        gen.defineRect(fx, fy, fwidth, fheight);
-        gen.writeln("clip");
-        
-        // transform so that the coordinates (0,0) is from the top left
-        // and positive is down and to the right. (0,0) is where the
-        // viewBox puts it.
-        gen.concatMatrix(sx, 0, 0, sy, fx, fy);
-
-        final boolean textAsShapes = false;
-        PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
-        graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-        AffineTransform transform = new AffineTransform();
-        // scale to viewbox
-        transform.translate(fx, fy);
-        gen.getCurrentState().concatMatrix(transform);
-        Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
-        painter.paint(graphics, area);
-
-        gen.restoreGraphicsState();
-        gen.commentln("%FOPEndGraphics2D");
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+ 
+package org.apache.fop.render.ps;
+
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.render.Graphics2DAdapter;
+import org.apache.fop.render.RendererContext;
+
+/**
+ * Graphics2DAdapter implementation for PostScript.
+ */
+public class PSGraphics2DAdapter implements Graphics2DAdapter {
+
+    private PSGenerator gen;
+    private boolean clip = true;
+
+    /**
+     * Main constructor
+     * @param renderer the Renderer instance to which this instance belongs
+     */
+    public PSGraphics2DAdapter(PSRenderer renderer) {
+        this(renderer.gen, true);
+    }
+    
+    /**
+     * Constructor for use without a PSRenderer instance.
+     * @param gen the PostScript generator
+     * @param clip true if the image should be clipped
+     */
+    public PSGraphics2DAdapter(PSGenerator gen, boolean clip) {
+        this.gen = gen;
+        this.clip = clip;
+    }
+    
+    /** {@inheritDoc} */
+    public void paintImage(Graphics2DImagePainter painter, 
+            RendererContext context,
+            int x, int y, int width, int height) throws IOException {
+        float fwidth = width / 1000f;
+        float fheight = height / 1000f;
+        float fx = x / 1000f;
+        float fy = y / 1000f;
+        
+        // get the 'width' and 'height' attributes of the SVG document
+        Dimension dim = painter.getImageSize();
+        float imw = (float)dim.getWidth() / 1000f;
+        float imh = (float)dim.getHeight() / 1000f;
+
+        float sx = fwidth / (float)imw;
+        float sy = fheight / (float)imh;
+
+        gen.commentln("%FOPBeginGraphics2D");
+        gen.saveGraphicsState();
+        if (clip) {
+            // Clip to the image area.
+            gen.writeln("newpath");
+            gen.defineRect(fx, fy, fwidth, fheight);
+            gen.writeln("clip");
+        }
+        
+        // transform so that the coordinates (0,0) is from the top left
+        // and positive is down and to the right. (0,0) is where the
+        // viewBox puts it.
+        gen.concatMatrix(sx, 0, 0, sy, fx, fy);
+
+        final boolean textAsShapes = false;
+        PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
+        graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
+        AffineTransform transform = new AffineTransform();
+        // scale to viewbox
+        transform.translate(fx, fy);
+        gen.getCurrentState().concatMatrix(transform);
+        Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
+        painter.paint(graphics, area);
+
+        gen.restoreGraphicsState();
+        gen.commentln("%FOPEndGraphics2D");
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageFormResource.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageUtils.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageUtils.java Thu Feb 14 13:55:44 2008
@@ -19,20 +19,15 @@
  
 package org.apache.fop.render.ps;
 
-import java.awt.Dimension;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
 import org.apache.fop.image.EPSImage;
 import org.apache.fop.image.FopImage;
-import org.apache.fop.image.JpegImage;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSResource;
 
 /**
- * Utility code for rendering images in PostScript. 
+ * Utility code for rendering images in PostScript.
  */
 public class PSImageUtils extends org.apache.xmlgraphics.ps.PSImageUtils {
 
@@ -40,93 +35,6 @@
     protected static Log log = LogFactory.getLog(PSImageUtils.class);
 
     /**
-     * Renders a bitmap image to PostScript.
-     * @param img image to render
-     * @param x x position
-     * @param y y position
-     * @param w width
-     * @param h height
-     * @param gen PS generator
-     * @throws IOException In case of an I/O problem while rendering the image
-     */
-    public static void renderBitmapImage(FopImage img, 
-                float x, float y, float w, float h, PSGenerator gen)
-                    throws IOException {
-        boolean isJPEG = (img instanceof JpegImage && (gen.getPSLevel() >= 3));
-        byte[] imgmap = convertImageToRawBitmapArray(img, isJPEG);
-        if (imgmap == null) {
-            gen.commentln("%Image data is not available: " + img);
-            return; //Image cannot be converted 
-        }
-        
-        String imgDescription = img.getMimeType() + " " + img.getOriginalURI();
-        Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
-        Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
-        writeImage(imgmap, imgDim, imgDescription, targetRect, isJPEG, 
-                img.getColorSpace(), gen);
-    }
-
-    /**
-     * Renders a bitmap image (as form) to PostScript.
-     * @param img image to render
-     * @param form the form resource
-     * @param x x position
-     * @param y y position
-     * @param w width
-     * @param h height
-     * @param gen PS generator
-     * @throws IOException In case of an I/O problem while rendering the image
-     */
-    public static void renderForm(FopImage img, PSResource form, 
-                float x, float y, float w, float h, PSGenerator gen)
-                    throws IOException {
-        Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
-        paintForm(form, targetRect, gen);
-    }
-    
-    /**
-     * Generates a form resource for a FopImage in PostScript.
-     * @param img image to render
-     * @param form the form resource
-     * @param gen PS generator
-     * @throws IOException In case of an I/O problem while rendering the image
-     */
-    public static void generateFormResourceForImage(FopImage img, PSResource form,
-                PSGenerator gen) throws IOException {
-        boolean isJPEG = (img instanceof JpegImage && (gen.getPSLevel() >= 3));
-        byte[] imgmap = convertImageToRawBitmapArray(img, isJPEG);
-        if (imgmap == null) {
-            gen.commentln("%Image data is not available: " + img);
-            return; //Image cannot be converted 
-        }
-        
-        String imgDescription = img.getMimeType() + " " + img.getOriginalURI();
-        Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
-        writeReusableImage(imgmap, imgDim, form.getName(), imgDescription, isJPEG, 
-                img.getColorSpace(), gen);
-    }
-
-    private static byte[] convertImageToRawBitmapArray(FopImage img, boolean allowUndecodedJPEG)
-                throws IOException {
-        if (img instanceof JpegImage && allowUndecodedJPEG) {
-            if (!img.load(FopImage.ORIGINAL_DATA)) {
-                return null;
-            }
-        } else {
-            if (!img.load(FopImage.BITMAP)) {
-                return null;
-            }
-        }
-        byte[] imgmap;
-        if (img.getBitmapsSize() > 0) {
-            imgmap = img.getBitmaps();
-        } else {
-            imgmap = img.getRessourceBytes();
-        }
-        return imgmap;
-    }
-
-    /**
      * Renders an EPS image to PostScript.
      * @param img EPS image to render
      * @param x x position
@@ -134,6 +42,8 @@
      * @param w width
      * @param h height
      * @param gen PS generator
+     * @deprecated Use {@link #renderEPS(java.io.InputStream, String, java.awt.geom.Rectangle2D,
+     *          java.awt.geom.Rectangle2D, PSGenerator)} instead
      */
     public static void renderEPS(EPSImage img, 
             float x, float y, float w, float h,

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSImageUtils.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id



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