]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Removed arbitrary image formats from MO:DCA registry.
authorAdrian Cumiskey <acumiskey@apache.org>
Mon, 21 Jul 2008 15:35:26 +0000 (15:35 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Mon, 21 Jul 2008 15:35:26 +0000 (15:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@678450 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/afp/AFPRenderer.java
src/java/org/apache/fop/render/afp/AFPSVGHandler.java
src/java/org/apache/fop/render/afp/DataObjectCache.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 bb65ca11fe7524a573da9b8180be99e23033fefd..944303d7b8377b1a8d83a0f2870c560114736eb6 100644 (file)
@@ -635,12 +635,16 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
                             (float)posInt.getHeight()
                     };
                     int[] coords = mpts2units(srcPts);
-                    String mimeType = info.getMimeType();
+                    
                     // create image object parameters
                     ImageObjectInfo imageObjectInfo = new ImageObjectInfo();
                     imageObjectInfo.setBuffered(false);
                     imageObjectInfo.setUri(uri);
-                    imageObjectInfo.setMimeType(mimeType);
+                    
+                    String mimeType = info.getMimeType();
+                    if (mimeType != null) {
+                        imageObjectInfo.setMimeType(mimeType);
+                    }
 
                     ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo();
                     objectAreaInfo.setX(coords[X]);
index 48307fea48ca32a18e1ee80a0589a5e0f1061a2a..dc61fdccb4bb886d312b145fca5e2caddbfb5c4f 100644 (file)
@@ -221,7 +221,6 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
     /** {@inheritDoc} */
     protected void updateRendererContext(RendererContext context) {
         //Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
-        context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
-                Boolean.FALSE);
+        context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean.FALSE);
     }
 }
index c77d3d0e2375ce5ec8e274e5e199c130d383106e..85b9f1893a061a843b1725d419a699a5359964b0 100644 (file)
@@ -155,9 +155,9 @@ public final class DataObjectCache {
      * @return a cache record
      */
     public Record store(DataObjectInfo dataObjectInfo) {
-        Registry.ObjectType objectType = dataObjectInfo.getObjectType();
         Record record = null;
-        if (!objectType.canBeIncluded()) {
+        Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+        if (objectType == null || !objectType.canBeIncluded()) {
             AbstractNamedAFPObject dataObj = factory.createObject(dataObjectInfo);
             if (dataObj == null) {
                 log.error("Failed to create object: " + dataObjectInfo);
index b458e962da805f27157c348975bac1fd0ad6c48d..f25dd1bfb00f65441d6f6f835b3e172b7e6bf386 100644 (file)
@@ -263,7 +263,6 @@ public class AFPDataStream extends AbstractResourceGroupContainer {
         String overlayName = "OVL"
                 + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5);
 
-        DataObjectCache cache = DataObjectCache.getInstance();
         DataObjectFactory factory = cache.getFactory();
         this.currentOverlay = factory.createOverlay(
                 overlayName, width, height, widthRes, heightRes, overlayRotation);
@@ -446,9 +445,9 @@ public class AFPDataStream extends AbstractResourceGroupContainer {
                 if (objectType.canBeIncluded()) {
                     
                     // Create and return include
-                    DataObjectFactory factory = cache.getFactory();                         
-                    IncludeObject includeObj = factory.createInclude(
-                            record.getObjectName(), dataObjectInfo);
+                    DataObjectFactory factory = cache.getFactory();
+                    String objectName = record.getObjectName();
+                    IncludeObject includeObj = factory.createInclude(objectName, dataObjectInfo);
                     getCurrentPage().addObject(includeObj);
                     
                     // Record the resource cache key (uri) in the ResourceGroup
index e3904b8317d0da8e3114c53076913010915ffdfa..a5d15633180e3a19cab7342f255ec068f1e90551 100644 (file)
@@ -197,31 +197,20 @@ public class DataObjectFactory {
         if (includeObj == null) {
             includeObj = new IncludeObject(name);
         
-            Registry.ObjectType objectType = dataObjectInfo.getObjectType();
-            if (objectType.isImage()) {
+            if (dataObjectInfo instanceof ImageObjectInfo) {
                 includeObj.setDataObjectType(IncludeObject.TYPE_IMAGE);
-            } else if (objectType.isGraphic()) {
+            } else if (dataObjectInfo instanceof GraphicsObjectInfo) {
                 includeObj.setDataObjectType(IncludeObject.TYPE_GRAPHIC);
-    //        } else if (dataObject instanceof PageSegment) {
-    //            includeObj.setDataObjectType(IncludeObject.TYPE_PAGE_SEGMENT);
             } else {
                 includeObj.setDataObjectType(IncludeObject.TYPE_OTHER);
-                // Strip any object container
-    //            AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject();
-    //            if (dataObject instanceof ObjectContainer) {
-    //                ObjectContainer objectContainer = (ObjectContainer)dataObject;
-    //                dataObject = objectContainer.getDataObject();
-    //            }
             }
             
-//            includeObj.setFullyQualifiedName(
-//                    FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME,
-//                    FullyQualifiedNameTriplet.FORMAT_CHARSTR,
-//                    dataObjectInfo.getUri());
-    
-            includeObj.setObjectClassification(
-                 ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
-                 objectType);
+            Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+            if (objectType != null) {
+                includeObj.setObjectClassification(
+                   ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
+                   objectType);
+            }
             
             ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
             
index 3c2eecaf1130b786e2917599be13accb097a74ce..ae32654def02eabece7f7f08e12931b900bd430b 100644 (file)
@@ -24,16 +24,12 @@ import java.util.Collections;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.render.afp.DataObjectInfo;
-import org.apache.fop.render.afp.ImageObjectInfo;
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
  * MOD:CA Registry of object types 
  */
 public final class Registry {
-    /** logging instance */
-    private static final Log log = LogFactory.getLog("org.apache.fop.afp");
-
     /** IOB supported object types */    
     private static final byte COMPID_GIF = 22;
     private static final byte COMPID_JFIF = 23; // jpeg file interchange format 
@@ -127,35 +123,23 @@ public final class Registry {
                         true,
                         MimeConstants.MIME_PCL
                 )
-        );
-        
-        // Entries without component and object ids
-        mimeObjectTypeMap.put(
-                MimeConstants.MIME_SVG,
-                new ObjectType(
-                        "Scaleable Vector Graphics",
-                        MimeConstants.MIME_SVG
-                )
-        );
-        mimeObjectTypeMap.put(
-                MimeConstants.MIME_PNG,
-                new ObjectType(
-                        "Portable Network Graphics",
-                        MimeConstants.MIME_PNG
-                )
-        );
+        );        
     }
 
     /**
      * Returns the Registry ObjectType for a given data object info
+     * or null if not registered
      * 
      * @param dataObjectInfo the data object info
      * @return the Registry ObjectType for a given data object info
+     * or null if not registered
      */
     public Registry.ObjectType getObjectType(DataObjectInfo dataObjectInfo) {
         String mimeType = dataObjectInfo.getMimeType();
-        ObjectType objectType = (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
-        return objectType;
+        if (mimeType != null) {
+            return (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
+        }
+        return null; 
     }
 
     /**
@@ -168,29 +152,6 @@ public final class Registry {
         private boolean canBeIncluded;
         private String mimeType;
 
-        /**
-         * Constructor
-         * 
-         * @param name the object type name
-         * @param canBeIncluded true if this object can be included with an IOB structured field
-         * @param mimeType the mime type associated with this object type
-         */
-        private ObjectType(String name, boolean canBeIncluded, String mimeType) {
-            this.name = name;
-            this.canBeIncluded = canBeIncluded;
-            this.mimeType = mimeType;
-        }
-
-        /**
-         * Constructor
-         * 
-         * @param name the object type name
-         * @param mimeType the mime type associated with this object type
-         */
-        private ObjectType(String name, String mimeType) {
-            this(name, false, mimeType);
-        }
-
         /**
          * Main constructor
          * 
@@ -202,7 +163,9 @@ public final class Registry {
          */
         public ObjectType(byte componentId, byte[] oid, String name,
                 boolean canBeIncluded, String mimeType) {
-            this(name, canBeIncluded, mimeType);
+            this.name = name;
+            this.canBeIncluded = canBeIncluded;
+            this.mimeType = mimeType;
             this.componentId = componentId;
             this.oid = oid;
         }
@@ -261,7 +224,6 @@ public final class Registry {
         public boolean isImage() {
             return mimeType == MimeConstants.MIME_TIFF
             || mimeType == MimeConstants.MIME_GIF
-            || mimeType == MimeConstants.MIME_PNG
             || mimeType == MimeConstants.MIME_JPEG;
         }