Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java?rev=677689&r1=677688&r2=677689&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java (original) +++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java Thu Jul 17 12:13:56 2008 @@ -24,7 +24,9 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; +import java.util.Set; +import org.apache.fop.render.afp.DataObjectCache; import org.apache.fop.render.afp.DataObjectInfo; import org.apache.fop.render.afp.ResourceInfo; import org.apache.fop.render.afp.ResourceLevel; @@ -35,15 +37,11 @@ */ public final class ResourceGroup extends AbstractNamedAFPObject { - /** - * Default name for the resource group - */ + /** Default name for the resource group */ private static final String DEFAULT_NAME = "RG000001"; - /** - * Mapping of resource uri to data resource object (image/graphic) - */ - private Map/*<String,Writeable>*/ resourceMap = null; + /** Set of resource uri */ + private Set/*<String>*/ resourceSet = new java.util.HashSet/*<String>*/(); /** * Default constructor @@ -55,67 +53,62 @@ /** * Constructor for the ResourceGroup, this takes a * name parameter which must be 8 characters long. + * * @param name the resource group name */ public ResourceGroup(String name) { super(name); } - - private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC"; - - private ObjectContainer createObjectContainer() { - String name = OBJECT_CONTAINER_NAME_PREFIX - + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 6); - return new ObjectContainer(name); - } - - private DataObjectFactory dataObjectFactory = new DataObjectFactory(); - - /** - * Creates a data object in this resource group - * @param dataObjectInfo the data object info - * @return an include object reference - */ - public IncludeObject createObject(DataObjectInfo dataObjectInfo) { - DataObjectAccessor dataObjectAccessor - = (DataObjectAccessor)getResourceMap().get(dataObjectInfo.getUri()); - ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - ResourceLevel resourceLevel = resourceInfo.getLevel(); - AbstractDataObject dataObj; - if (dataObjectAccessor == null) { - dataObj = dataObjectFactory.create(dataObjectInfo); - ObjectContainer objectContainer = null; - String resourceName = resourceInfo.getName(); - if (resourceName != null) { - objectContainer = new ObjectContainer(resourceName); - } else { - objectContainer = createObjectContainer(); - resourceName = objectContainer.getName(); - } - objectContainer.setDataObject(dataObj); - objectContainer.setDataObjectInfo(dataObjectInfo); - - // When located at print-file level or externally, - // wrap the object container in a resource object - if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { - ResourceObject resourceObject = new ResourceObject(resourceName); - resourceObject.setDataObject(objectContainer); - resourceObject.setDataObjectInfo(dataObjectInfo); - dataObjectAccessor = resourceObject; - } else { // Access data object through container - dataObjectAccessor = objectContainer; - } - - // Add to resource map - getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor); - } - String name = dataObjectAccessor.getName(); - IncludeObject includeObj = new IncludeObject(name, dataObjectAccessor); - return includeObj; - } + +// /** +// * Creates a data object in this resource group +// * +// * @param dataObjectInfo the data object info +// * @return an include object reference +// */ +// public IncludeObject createObject(DataObjectInfo dataObjectInfo) { +// String uri = dataObjectInfo.getUri(); +// resourceSet.get(); +// DataObjectAccessor dataObjectAccessor +// = (DataObjectAccessor)getResourceMap().getData(dataObjectInfo.getUri()); +// ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); +// ResourceLevel resourceLevel = resourceInfo.getLevel(); +// AbstractDataObject dataObj; +// if (dataObjectAccessor == null) { +// dataObj = dataObjectFactory.createObject(dataObjectInfo); +// ObjectContainer objectContainer = null; +// String resourceName = resourceInfo.getName(); +// if (resourceName != null) { +// objectContainer = new ObjectContainer(resourceName); +// } else { +// objectContainer = createObjectContainer(); +// resourceName = objectContainer.getName(); +// } +// objectContainer.setDataObject(dataObj); +// objectContainer.setDataObjectInfo(dataObjectInfo); +// +// // When located at print-file level or externally, +// // wrap the object container in a resource object +// if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { +// ResourceObject resourceObject = new ResourceObject(resourceName); +// resourceObject.setDataObject(objectContainer); +// resourceObject.setDataObjectInfo(dataObjectInfo); +// dataObjectAccessor = resourceObject; +// } else { // Access data object through container +// dataObjectAccessor = objectContainer; +// } +// +// // Add to resource map +// getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor); +// } +// String name = dataObjectAccessor.getName(); +// IncludeObject includeObj = dataObjectFactory.createInclude(dataObjectInfo); +// return includeObj; +// } /** * Checks if a named object is of a valid type to be added to a resource group + * * @param namedObj a named object * @return true if the named object is of a valid type to be added to a resource group */ @@ -131,26 +124,23 @@ // || namedObj instanceof BarcodeObject ); } + /** - * Adds a named object to this resource group - * @param namedObj a named AFP object + * Add this object cache resource info to this resource group + * + * @param resourceInfo the resource info */ - protected void addObject(AbstractNamedAFPObject namedObj) { - if (isValidObjectType(namedObj)) { - getResourceMap().put(namedObj.getName(), namedObj); - } else { - throw new IllegalArgumentException("invalid object type " + namedObj); - } + public void addObject(ResourceInfo resourceInfo) { + resourceSet.add(resourceInfo); } /** + * Returns the number of resources contained in this resource group + * * @return the number of resources contained in this resource group */ public int getResourceCount() { - if (resourceMap != null) { - return resourceMap.size(); - } - return 0; + return resourceSet.size(); } /** @@ -161,78 +151,42 @@ * @return true if the resource exists within this resource group */ public boolean resourceExists(String uri) { - return getResourceMap().containsKey(uri); + return resourceSet.contains(uri); } - /** - * Returns the list of resources - * @return the list of resources - */ - public Map/*<String, DataObjectAccessor>*/ getResourceMap() { - if (resourceMap == null) { - resourceMap = new java.util.HashMap/*<String, Writeable>*/(); - } - return resourceMap; - } - - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void writeContent(OutputStream os) throws IOException { - if (resourceMap != null) { - Collection includes = resourceMap.values(); - Iterator it = includes.iterator(); + Iterator it = resourceSet.iterator(); + if (it.hasNext()) { + DataObjectCache cache = DataObjectCache.getInstance(); while (it.hasNext()) { - Writable dataObject = (Writable)it.next(); - dataObject.write(os); + ResourceInfo resourceInfo = (ResourceInfo)it.next(); + byte[] data = cache.get(resourceInfo); + if (data != null) { + os.write(data); + } else { + log.error("data was null"); + } } } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xC6; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.RESOURCE_GROUP); os.write(data); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xC6; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.RESOURCE_GROUP); os.write(data); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public String toString() { - return this.name + " " + getResourceMap(); + return this.name + " " + resourceSet/*getResourceMap()*/; } }
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java?rev=677689&r1=677688&r2=677689&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java (original) +++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java Thu Jul 17 12:13:56 2008 @@ -22,9 +22,6 @@ import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.render.afp.DataObjectInfo; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; import org.apache.fop.render.afp.modca.triplets.Triplet; import org.apache.fop.render.afp.tools.BinaryUtils; @@ -32,18 +29,10 @@ * This resource structured field begins an envelope that is used to carry * resource objects in print-file-level (external) resource groups. */ -public class ResourceObject extends AbstractPreparedAFPObject implements DataObjectAccessor { +public class ResourceObject extends AbstractPreparedAFPObject { - /** - * the object container of this resource object - */ private AbstractNamedAFPObject namedObject; - - /** - * the data object info - */ - private DataObjectInfo dataObjectInfo; - + /** * Default constructor * @@ -55,102 +44,71 @@ /** * Sets the data object referenced by this resource object + * * @param obj the named data object */ public void setDataObject(AbstractNamedAFPObject obj) { - this.namedObject = obj; - - String fqn = obj.getFullyQualifiedName(); - if (fqn != null) { - super.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - fqn); - } - - byte type; - if (obj instanceof ObjectContainer) { - type = ResourceObjectTypeTriplet.OBJECT_CONTAINER; - } else if (obj instanceof ImageObject) { - type = ResourceObjectTypeTriplet.IMAGE_OBJECT; - } else if (obj instanceof GraphicsObject) { - type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT; - } else if (obj instanceof Document) { - type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT; - } else if (obj instanceof PageSegment) { - type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT; - } else if (obj instanceof Overlay) { - type = ResourceObjectTypeTriplet.OVERLAY_OBJECT; - } else { - throw new UnsupportedOperationException( - "Unsupported resource object type " + obj); - } - getTriplets().add(new ResourceObjectTypeTriplet(type)); - } - - /** - * [EMAIL PROTECTED] - */ - public AbstractNamedAFPObject getDataObject() { - return namedObject; - } - - /** - * [EMAIL PROTECTED] - */ - public DataObjectInfo getDataObjectInfo() { - return this.dataObjectInfo; - } - - /** - * [EMAIL PROTECTED] - */ - public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { - this.dataObjectInfo = dataObjectInfo; + this.namedObject = obj; +// +// String fqn = obj.getFullyQualifiedName(); +// if (fqn != null) { +// super.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// fqn); +// } +// +// byte type; +// if (obj instanceof ObjectContainer) { +// type = ResourceObjectTypeTriplet.OBJECT_CONTAINER; +// } else if (obj instanceof ImageObject) { +// type = ResourceObjectTypeTriplet.IMAGE_OBJECT; +// } else if (obj instanceof GraphicsObject) { +// type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT; +// } else if (obj instanceof Document) { +// type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT; +// } else if (obj instanceof PageSegment) { +// type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT; +// } else if (obj instanceof Overlay) { +// type = ResourceObjectTypeTriplet.OVERLAY_OBJECT; +// } else { +// throw new UnsupportedOperationException( +// "Unsupported resource object type " + obj); +// } +// getTriplets().add(new ResourceObjectTypeTriplet(type)); + } + +// /** [EMAIL PROTECTED] */ +// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { +// this.dataObjectInfo = dataObjectInfo; +// +// if (namedObject instanceof ObjectContainer) { +// Registry.ObjectType objectType = dataObjectInfo.getObjectType(); +// super.setObjectClassification( +// ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, +// objectType); +// } +// } - if (namedObject instanceof ObjectContainer) { - Registry.ObjectType objectType = dataObjectInfo.getObjectType(); - super.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, - objectType); - } - } - - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ protected void writeStart(OutputStream os) throws IOException { super.writeStart(os); - + + byte[] data = new byte[19]; + copySF(data, Type.BEGIN, Category.NAME_RESOURCE); + // Set the total record length byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA8, // Structured field id byte 2 - (byte)0xCE, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - 0x00, // Reserved - 0x00, // Reserved - }; + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + + // Set reserved bits + data[17] = 0x00; // Reserved + data[18] = 0x00; // Reserved os.write(data); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); // write triplets if (namedObject != null) { @@ -158,60 +116,48 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA9, // Structured field id byte 2 - (byte)0xCE, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.NAME_RESOURCE); os.write(data); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public String toString() { return this.getName(); } + /** + * Sets Resource Object Type triplet + * + * @param type the resource object type + */ + public void setType(byte type) { + getTriplets().add(new ResourceObjectTypeTriplet(type)); + } + + /** + * Resource object types + */ + protected static final byte GRAPHICS_OBJECT = 0x03; +// private static final byte BARCODE_OBJECT = 0x05; + protected static final byte IMAGE_OBJECT = 0x06; +// private static final byte FONT_CHARACTER_SET_OBJECT = 0x40; +// private static final byte CODE_PAGE_OBJECT = 0x41; +// private static final byte CODED_FONT_OBJECT = 0x42; + protected static final byte OBJECT_CONTAINER = (byte) 0x92; + protected static final byte DOCUMENT_OBJECT = (byte) 0xA8; + protected static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB; + protected static final byte OVERLAY_OBJECT = (byte) 0xFC; +// private static final byte PAGEDEF_OBJECT = (byte) 0xFD; +// private static final byte FORMDEF_OBJECT = (byte) 0xFE; + private class ResourceObjectTypeTriplet extends Triplet { private static final byte RESOURCE_OBJECT = 0x21; /** - * Resource object types - */ - private static final byte GRAPHICS_OBJECT = 0x03; -// private static final byte BARCODE_OBJECT = 0x05; - private static final byte IMAGE_OBJECT = 0x06; -// private static final byte FONT_CHARACTER_SET_OBJECT = 0x40; -// private static final byte CODE_PAGE_OBJECT = 0x41; -// private static final byte CODED_FONT_OBJECT = 0x42; - private static final byte OBJECT_CONTAINER = (byte) 0x92; - private static final byte DOCUMENT_OBJECT = (byte) 0xA8; - private static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB; - private static final byte OVERLAY_OBJECT = (byte) 0xFC; -// private static final byte PAGEDEF_OBJECT = (byte) 0xFD; -// private static final byte FORMDEF_OBJECT = (byte) 0xFE; - - /** * Main constructor * * @param type Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Writable.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Writable.java?rev=677689&r1=677688&r2=677689&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Writable.java (original) +++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Writable.java Thu Jul 17 12:13:56 2008 @@ -26,9 +26,11 @@ * Implementing object is able to write to an AFPDataStream */ public interface Writable { + /** * DataStream objects must implement the write() * method to write its data to the given OutputStream + * * @param outputStream The outputsteam stream * @throws java.io.IOException an I/O exception of some sort has occurred. */ Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=677689&r1=677688&r2=677689&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original) +++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Thu Jul 17 12:13:56 2008 @@ -42,6 +42,7 @@ /** * Default constructor + * * @param userAgent user agent */ public PDFRendererConfigurator(FOUserAgent userAgent) { @@ -52,6 +53,7 @@ * Configure the PDF renderer. * Get the configuration to be used for pdf stream filters, * fonts etc. + * * @param renderer pdf renderer * @throws FOPException fop exception */ @@ -79,7 +81,8 @@ if (s != null) { pdfRenderer.setXMode(PDFXMode.valueOf(s)); } - Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false); + Configuration encryptionParamsConfig + = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false); if (encryptionParamsConfig != null) { PDFEncryptionParams encryptionParams = new PDFEncryptionParams(); Configuration ownerPasswordConfig = encryptionParamsConfig.getChild( @@ -124,15 +127,18 @@ if (s != null) { pdfRenderer.setOutputProfileURI(s); } - Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); + Configuration disableColorSpaceConfig = cfg.getChild( + PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); if (disableColorSpaceConfig != null) { - pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false); + pdfRenderer.disableSRGBColorSpace + = disableColorSpaceConfig.getValueAsBoolean(false); } } } /** * Builds a filter map from an Avalon Configuration object. + * * @param cfg the Configuration object * @return Map the newly built filter map * @throws ConfigurationException if a filter list is defined twice Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java?rev=677689&r1=677688&r2=677689&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java (original) +++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java Thu Jul 17 12:13:56 2008 @@ -91,6 +91,7 @@ pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); if (foreign != null && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
