From: Adrian Cumiskey Date: Mon, 21 Jul 2008 13:42:40 +0000 (+0000) Subject: * Fixed problem with SVG object type not being determined. X-Git-Tag: fop-1_0~376^2~120 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=72035be677ea5ecbf5520e20d045dd92594a47e0;p=xmlgraphics-fop.git * Fixed problem with SVG object type not being determined. * 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 --- diff --git a/src/java/org/apache/fop/apps/MimeConstants.java b/src/java/org/apache/fop/apps/MimeConstants.java index cdd30c0e1..87048fa4d 100644 --- a/src/java/org/apache/fop/apps/MimeConstants.java +++ b/src/java/org/apache/fop/apps/MimeConstants.java @@ -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"; - } diff --git a/src/java/org/apache/fop/render/afp/DataObjectCache.java b/src/java/org/apache/fop/render/afp/DataObjectCache.java index a3314a4a2..c77d3d0e2 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectCache.java +++ b/src/java/org/apache/fop/render/afp/DataObjectCache.java @@ -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; diff --git a/src/java/org/apache/fop/render/afp/DataObjectInfo.java b/src/java/org/apache/fop/render/afp/DataObjectInfo.java index 021e5fef6..dc4d09c7f 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/DataObjectInfo.java @@ -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(); + } diff --git a/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java b/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java index 108d7bfb6..30214bf4a 100644 --- a/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java @@ -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; + } } diff --git a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java index 8a3d55150..6e0f6f58d 100644 --- a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java @@ -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 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 c55653214..b458e962d 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -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()) { 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 0a5fb5bbe..e3904b831 100644 --- a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java +++ b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java @@ -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."); } } 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 201696bd0..3c2eecaf1 100644 --- a/src/java/org/apache/fop/render/afp/modca/Registry.java +++ b/src/java/org/apache/fop/render/afp/modca/Registry.java @@ -45,7 +45,7 @@ public final class Registry { private static final byte COMPID_TIFF = 14; /** mime type entry mapping */ - private java.util.Map/**/ mimeEntryMap + private java.util.Map/**/ mimeObjectTypeMap = Collections.synchronizedMap( new java.util.HashMap/**/()); @@ -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; } /**