From: Adrian Cumiskey Date: Mon, 21 Jul 2008 15:35:26 +0000 (+0000) Subject: Removed arbitrary image formats from MO:DCA registry. X-Git-Tag: fop-1_0~376^2~117 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d42d76c06b2b2561ef204a447dec0c2d0228a762;p=xmlgraphics-fop.git Removed arbitrary image formats from MO:DCA registry. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@678450 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index bb65ca11f..944303d7b 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -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]); diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 48307fea4..dc61fdccb 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -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); } } diff --git a/src/java/org/apache/fop/render/afp/DataObjectCache.java b/src/java/org/apache/fop/render/afp/DataObjectCache.java index c77d3d0e2..85b9f1893 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectCache.java +++ b/src/java/org/apache/fop/render/afp/DataObjectCache.java @@ -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); diff --git a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java index b458e962d..f25dd1bfb 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -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 diff --git a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java index e3904b831..a5d156331 100644 --- a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java +++ b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java @@ -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(); diff --git a/src/java/org/apache/fop/render/afp/modca/Registry.java b/src/java/org/apache/fop/render/afp/modca/Registry.java index 3c2eecaf1..ae32654de 100644 --- a/src/java/org/apache/fop/render/afp/modca/Registry.java +++ b/src/java/org/apache/fop/render/afp/modca/Registry.java @@ -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; }