]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
* Fixed problem with SVG object type not being determined.
authorAdrian Cumiskey <acumiskey@apache.org>
Mon, 21 Jul 2008 13:42:40 +0000 (13:42 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Mon, 21 Jul 2008 13:42:40 +0000 (13:42 +0000)
* MimeConstants now extends the one in commons.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@678410 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/apps/MimeConstants.java
src/java/org/apache/fop/render/afp/DataObjectCache.java
src/java/org/apache/fop/render/afp/DataObjectInfo.java
src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java
src/java/org/apache/fop/render/afp/ImageObjectInfo.java
src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java
src/java/org/apache/fop/render/afp/modca/Registry.java

index cdd30c0e1e1b4ff54008c3bcacb5df4002272da4..87048fa4dacc1a9c696d05abb13e8dffa228930f 100644 (file)
@@ -22,51 +22,8 @@ package org.apache.fop.apps;
 /**
  * Frequently used MIME types for various file formats used when working with Apache FOP.
  */
-public interface MimeConstants {
+public interface MimeConstants extends org.apache.xmlgraphics.util.MimeConstants {
 
-    /** Portable Document Format */
-    String MIME_PDF             = "application/pdf";
-    
-    /** PostScript */
-    String MIME_POSTSCRIPT      = "application/postscript";
-    /** Encapsulated PostScript (same MIME type as PostScript) */
-    String MIME_EPS             = MIME_POSTSCRIPT;
-    
-    /** HP's PCL */
-    String MIME_PCL             = "application/x-pcl";
-    /** HP's PCL (alternative MIME type) */
-    String MIME_PCL_ALT         = "application/vnd.hp-PCL";
-    
-    /** IBM's AFP */
-    String MIME_AFP             = "application/x-afp";
-    /** IBM's AFP (alternative MIME type) */
-    String MIME_AFP_ALT         = "application/vnd.ibm.modcap";
-    
-    /** Plain text */
-    String MIME_PLAIN_TEXT      = "text/plain";
-    
-    /** Rich text format */
-    String MIME_RTF             = "application/rtf";
-    /** Rich text format (alternative 1) */
-    String MIME_RTF_ALT1        = "text/richtext";
-    /** Rich text format (alternative 2) */
-    String MIME_RTF_ALT2        = "text/rtf";
-    
-    /** FrameMaker's MIF */
-    String MIME_MIF             = "application/mif";
-    
-    /** Scalable Vector Graphics */
-    String MIME_SVG             = "image/svg+xml";
-    
-    /** GIF images */
-    String MIME_GIF             = "image/gif";
-    /** PNG images */
-    String MIME_PNG             = "image/png";
-    /** JPEG images */
-    String MIME_JPEG            = "image/jpeg";
-    /** TIFF images */
-    String MIME_TIFF            = "image/tiff";
-       
     /** Apache FOP's AWT preview (non-standard MIME type) */
     String MIME_FOP_AWT_PREVIEW = "application/X-fop-awt-preview";
     /** Apache FOP's Direct Printing (non-standard MIME type) */
@@ -74,7 +31,4 @@ public interface MimeConstants {
     /** Apache FOP's area tree XML */
     String MIME_FOP_AREA_TREE   = "application/X-fop-areatree";
 
-    /** Proposed but non-registered MIME type for XSL-FO */
-    String MIME_XSL_FO          = "text/xsl";
-    
 }
index a3314a4a2bd373517e022ff9163cb80bcf21b8ba..c77d3d0e2375ce5ec8e274e5e199c130d383106e 100644 (file)
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
-import java.util.Collections;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
index 021e5fef6175e2fda19d262c11d4f251d3d66fa2..dc4d09c7f1f82ef43672657f63db664278106585 100644 (file)
@@ -32,7 +32,7 @@ import org.apache.xmlgraphics.util.QName;
 /**
  * A list of parameters associated with an AFP data objects
  */
-public class DataObjectInfo {
+public abstract class DataObjectInfo {
     private static final Log log = LogFactory.getLog("org.apache.fop.afp");
 
     private static final String RESOURCE_NAME = "afp:resource-name";
@@ -175,7 +175,8 @@ public class DataObjectInfo {
 
     /** {@inheritDoc} */
     public String toString() {
-        return (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
+        return "mimeType=" + getMimeType()
+            + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
             + (objectType != null ? ", objectType=" + objectType : "")
             + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
     }
@@ -197,4 +198,12 @@ public class DataObjectInfo {
     public void setUri(String uri) {
         getResourceInfo().setUri(uri);
     }
+
+    /**
+     * Returns the mime type of this data object
+     * 
+     * @return the mime type of this data object
+     */
+    public abstract String getMimeType();
+
 }
index 108d7bfb6e92fc22c64a992a614f12cd51458e55..30214bf4aeea7607956264c7cbc29483d66df59b 100644 (file)
@@ -19,6 +19,8 @@
 
 package org.apache.fop.render.afp;
 
+import org.apache.xmlgraphics.util.MimeConstants;
+
 /**
  *  A graphics object info which contains necessary painting objects
  */
@@ -43,4 +45,14 @@ public class GraphicsObjectInfo extends DataObjectInfo {
     public void setPainter(GraphicsObjectPainter graphicsPainter) {
         this.painter = graphicsPainter;
     }
+    
+    /** {@inheritDoc} */
+    public String toString() {
+        return "GraphicsObjectInfo{" + super.toString() + "}";
+    }
+
+    /** {@inheritDoc} */
+    public String getMimeType() {
+        return MimeConstants.MIME_SVG;
+    }
 }
index 8a3d551502cd538646aa045fc320e5372c691f09..6e0f6f58d2028fb78e678df160f8c29e3a6c51f6 100644 (file)
@@ -165,11 +165,7 @@ public class ImageObjectInfo extends DataObjectInfo {
         this.dataHeight = imageDataHeight;
     }
 
-    /**
-     * Returns the mime type of this image
-     * 
-     * @return the mime type of this image
-     */
+    /** {@inheritDoc} */
     public String getMimeType() {
         return mimeType;
     }
@@ -194,12 +190,12 @@ public class ImageObjectInfo extends DataObjectInfo {
     
     /** {@inheritDoc} */
     public String toString() {
-        return super.toString() 
-            + ", mimeType=" + mimeType
+        return "ImageObjectInfo{" + super.toString() 
             + ", dataWidth=" + dataWidth
             + ", dataHeight=" + dataHeight
             + ", color=" + color
-            + ", bitPerPixel=" + bitsPerPixel;
+            + ", bitPerPixel=" + bitsPerPixel
+            + "}";
     }
 
 }
\ No newline at end of file
index c556532146c2273080315e96119666ae8d08f44d..b458e962da805f27157c348975bac1fd0ad6c48d 100644 (file)
@@ -428,6 +428,8 @@ public class AFPDataStream extends AbstractResourceGroupContainer {
         Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
         if (objectType != null) {
             dataObjectInfo.setObjectType(objectType);
+        } else {
+            log.info("Unknown object type for '" + dataObjectInfo + "'");
         }
         
         DataObjectCache.Record record = cache.store(dataObjectInfo);
@@ -457,7 +459,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer {
                     log.warn("Data object located at '" + uri + "'"
                             + " of type '" + objectType.getMimeType() + "'"
                             + " cannot be referenced with an include"
-                            + " so it will be embedded directly");
+                            + " so it will be embedded directly in the page");
                 }                
             } else {
                 if (resourceLevel.isExternal()) {
index 0a5fb5bbe850bb760e5382df0a05efea9caf2be7..e3904b8317d0da8e3114c53076913010915ffdfa 100644 (file)
@@ -368,10 +368,6 @@ public class DataObjectFactory {
                     resourceObj.setDataObject(dataObj);
                     dataObj = resourceObj;
                 }
-            } else {
-                String uri = dataObjectInfo.getUri();
-                log.warn("Data object '" + uri + "' not supported at "
-                        + resourceLevel.toString() + " level, will be embedded in page.");
             }
         }
         
index 201696bd09acfc708657aafceecab6e7d49d9e4a..3c2eecaf1130b786e2917599be13accb097a74ce 100644 (file)
@@ -45,7 +45,7 @@ public final class Registry {
     private static final byte COMPID_TIFF = 14;
 
     /** mime type entry mapping */
-    private java.util.Map/*<String, Registry.ObjectType>*/ mimeEntryMap
+    private java.util.Map/*<String, Registry.ObjectType>*/ mimeObjectTypeMap
         = Collections.synchronizedMap(
                 new java.util.HashMap/*<String, Registry.ObjectType>*/());
 
@@ -69,7 +69,7 @@ public final class Registry {
     }
     
     private void init() {
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_EPS,
                 new ObjectType(
                         COMPID_EPS,
@@ -79,7 +79,7 @@ public final class Registry {
                         MimeConstants.MIME_EPS
                 )
         );
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_TIFF,
                 new ObjectType(
                         COMPID_TIFF,
@@ -89,7 +89,7 @@ public final class Registry {
                         MimeConstants.MIME_TIFF
                 )
         );
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_GIF,
                 new ObjectType(
                         COMPID_GIF,
@@ -99,7 +99,7 @@ public final class Registry {
                         MimeConstants.MIME_GIF
                 )
         );
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_JPEG,
                 new ObjectType(
                         COMPID_JFIF,
@@ -109,7 +109,7 @@ public final class Registry {
                         MimeConstants.MIME_JPEG
                 )
         );
-        mimeEntryMap.put(MimeConstants.MIME_PDF,
+        mimeObjectTypeMap.put(MimeConstants.MIME_PDF,
                 new ObjectType(
                         COMPID_PDF_SINGLE_PAGE,
                         new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x19},
@@ -118,7 +118,7 @@ public final class Registry {
                         MimeConstants.MIME_PDF
                 )
         );         
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_PCL,
                 new ObjectType(
                         COMPID_PCL_PAGE_OBJECT,
@@ -130,14 +130,14 @@ public final class Registry {
         );
         
         // Entries without component and object ids
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_SVG,
                 new ObjectType(
                         "Scaleable Vector Graphics",
                         MimeConstants.MIME_SVG
                 )
         );
-        mimeEntryMap.put(
+        mimeObjectTypeMap.put(
                 MimeConstants.MIME_PNG,
                 new ObjectType(
                         "Portable Network Graphics",
@@ -146,22 +146,6 @@ public final class Registry {
         );
     }
 
-    /**
-     * Returns the Registry ObjectType for a given mimetype
-     * 
-     * @param mimeType the object mime type
-     * @return the Registry ObjectType for a given data object info
-     */
-    public Registry.ObjectType getObjectType(String mimeType) {
-        ObjectType entry = null;
-        if (mimeType != null) {
-            entry = (Registry.ObjectType)mimeEntryMap.get(mimeType);
-        } else {
-            log.info("mimetype '" + mimeType + "' not found");
-        }
-        return entry;
-    }
-
     /**
      * Returns the Registry ObjectType for a given data object info
      * 
@@ -169,13 +153,9 @@ public final class Registry {
      * @return the Registry ObjectType for a given data object info
      */
     public Registry.ObjectType getObjectType(DataObjectInfo dataObjectInfo) {
-        ObjectType entry = null;
-        if (dataObjectInfo instanceof ImageObjectInfo) {
-            ImageObjectInfo imageInfo = (ImageObjectInfo)dataObjectInfo;
-            String mimeType = imageInfo.getMimeType();
-            return getObjectType(mimeType);
-        }
-        return entry;
+        String mimeType = dataObjectInfo.getMimeType();
+        ObjectType objectType = (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
+        return objectType;
     }
 
     /**