xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acumis...@apache.org
Subject svn commit: r648675 [1/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp: ./ goca/ modca/ modca/triplets/
Date Wed, 16 Apr 2008 12:03:29 GMT
Author: acumiskey
Date: Wed Apr 16 05:03:15 2008
New Revision: 648675

URL: http://svn.apache.org/viewvc?rev=648675&view=rev
Log:
Further reworking and refinements.  Not a working model yet.

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java
      - copied, changed from r647228, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java
Removed:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImageData.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2D.java Wed Apr 16 05:03:15 2008
@@ -486,13 +486,13 @@
         this.customTextHandler = handler;
     }
 
-    /**
-     * Sets the SVG document URI
-     * @param documentURI the SVG document URI
-     */
-    public void setDocumentURI(String documentURI) {
-        this.documentURI = documentURI;
-    }
+//    /**
+//     * Sets the SVG document URI
+//     * @param documentURI the SVG document URI
+//     */
+//    public void setDocumentURI(String documentURI) {
+//        this.documentURI = documentURI;
+//    }
 
     /**
      * @return the GOCA graphics object

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java Wed Apr 16 05:03:15 2008
@@ -22,8 +22,13 @@
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.render.AbstractGraphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 
@@ -48,16 +53,23 @@
         Boolean grayObj = (Boolean)context.getProperty(AFPRendererContextConstants.AFP_GRAYSCALE);
         boolean gray = (grayObj != null ? grayObj.booleanValue() : false);
         
+        FOUserAgent userAgent = context.getUserAgent();
+        
         //Paint to a BufferedImage
-        int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
+        int resolution = (int)Math.round(userAgent.getTargetResolution());
         BufferedImage bi = paintToBufferedImage(painter, wrappedContext, resolution, gray, false);
         
+        ImageManager manager = userAgent.getFactory().getImageManager();
+        ImageSessionContext sessionContext = userAgent.getImageSessionContext();
         
         //TODO: AC - fix
-//        String uri = null;
-//        java.util.Map foreignAttributes = null;
-//        ImageInfo imageInfo = new ImageInfo();
-//        afp.drawBufferedImage(uri, bi, resolution, x, y, width, height, foreignAttributes);
+        String uri = null;
+        
+        try {
+            ImageInfo info = manager.getImageInfo(uri, sessionContext);
+            java.util.Map foreignAttributes = null;
+            afp.drawBufferedImage(info, bi, resolution, x, y, width, height, foreignAttributes);
+        } catch (ImageException e) {
+        }
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java Wed Apr 16 05:03:15 2008
@@ -344,7 +344,7 @@
     public void startRenderer(OutputStream outputStream) throws IOException {
         currentPageFonts = new java.util.HashMap();
         currentColor = new Color(255, 255, 255);
-        afpDataStream = new AFPDataStream();
+        this.afpDataStream = new AFPDataStream();
         afpDataStream.setPortraitRotation(portraitRotation);
         afpDataStream.setLandscapeRotation(landscapeRotation);
         afpDataStream.setOutputStream(outputStream);
@@ -354,7 +354,8 @@
      * {@inheritDoc}
      */
     public void stopRenderer() throws IOException {
-        afpDataStream.write();
+        getAFPDataStream().write();
+        afpDataStream = null;
     }
 
     /**
@@ -391,7 +392,7 @@
         // renderPageGroupExtensions(page);
 
         final int pageRotation = 0;
-        this.afpDataStream.startPage(pageWidth, pageHeight, pageRotation,
+        getAFPDataStream().startPage(pageWidth, pageHeight, pageRotation,
                 getResolution(), getResolution());
 
         renderPageObjectExtensions(page);
@@ -399,7 +400,7 @@
         if (this.pages == null) {
             this.pages = new java.util.HashMap();
         }
-        this.pages.put(page, afpDataStream.savePage());
+        this.pages.put(page, getAFPDataStream().savePage());
 
     }
 
@@ -620,13 +621,13 @@
 
         if (pages != null && pages.containsKey(pageViewport)) {
 
-            this.afpDataStream.restorePage((PageObject) pages.remove(pageViewport));
+            getAFPDataStream().restorePage((PageObject) pages.remove(pageViewport));
 
         } else {
             // renderPageGroupExtensions(page);
 
             final int pageRotation = 0;
-            this.afpDataStream.startPage(pageWidth, pageHeight, pageRotation,
+            getAFPDataStream().startPage(pageWidth, pageHeight, pageRotation,
                     getResolution(), getResolution());
 
             renderPageObjectExtensions(pageViewport);
@@ -641,14 +642,14 @@
         while (i.hasNext()) {
             AFPFontAttributes afpFontAttributes = (AFPFontAttributes) i.next();
 
-            afpDataStream.createFont(
+            getAFPDataStream().createFont(
                 (byte)afpFontAttributes.getFontReference(),
                 afpFontAttributes.getFont(),
                 afpFontAttributes.getPointSize());
 
         }
 
-        afpDataStream.endPage();
+        getAFPDataStream().endPage();
         
         popViewPortPos();
     }
@@ -702,7 +703,7 @@
             currentColor.getGreen(),
             currentColor.getBlue());
          */
-        afpDataStream.createLine(
+        getAFPDataStream().createLine(
             pts2units(x),
             pts2units(y),
             pts2units(x + width),
@@ -722,6 +723,7 @@
             log.error("Negative extent received. Border won't be painted.");
             return;
         }
+        
         switch (style) {
             case Constants.EN_DOUBLE:
                 if (horz) {
@@ -947,7 +949,7 @@
 
         String name = (String)getPageSegments().get(uri);
         if (name != null) {
-            afpDataStream.createIncludePageSegment(name, mpts2units(x), mpts2units(y));
+            getAFPDataStream().createIncludePageSegment(name, mpts2units(x), mpts2units(y));
         } else {
             ImageManager manager = getUserAgent().getFactory().getImageManager();
             ImageInfo info = null;
@@ -1007,7 +1009,7 @@
                     imageObjectInfo.setCompression(ccitt.getCompression());
                     imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
                     
-                    afpDataStream.createObject(imageObjectInfo);
+                    getAFPDataStream().createObject(imageObjectInfo);
 
                             
 //                    ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw, afph,
@@ -1251,7 +1253,8 @@
         imageObjectInfo.setBitsPerPixel(bitsPerPixel);
         imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes);
 
-        AbstractNamedAFPObject obj = afpDataStream.createObject(imageObjectInfo);
+        //AbstractNamedAFPObject obj = 
+        getAFPDataStream().createObject(imageObjectInfo);
 //            ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw,
 //                    afph, afpres, afpres);
 //            io.setImageParameters(imageResolution, imageResolution,
@@ -1379,7 +1382,7 @@
         }
 
         try {
-            afpDataStream.createText(
+            getAFPDataStream().createText(
                 afpFontAttributes.getFontReference(),
                 mpts2units(rx),
                 mpts2units(bl),
@@ -1596,7 +1599,7 @@
                     if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
                         String overlay = aps.getName();
                         if (overlay != null) {
-                            afpDataStream.createIncludePageOverlay(overlay);
+                            getAFPDataStream().createIncludePageOverlay(overlay);
                         }
                     } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT
                             .equals(element)) {
@@ -1607,11 +1610,11 @@
                             .equals(element)) {
                         String name = aps.getName();
                         String value = aps.getValue();
-                        afpDataStream.createTagLogicalElement(name, value);
+                        getAFPDataStream().createTagLogicalElement(name, value);
                     } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
                         String content = aps.getContent();
                         if (content != null) {
-                            afpDataStream.createNoOperation(content);
+                            getAFPDataStream().createNoOperation(content);
                         }
                     }
 //                    else if (AFPElementMapping.RESOURCE.equals(element)) {
@@ -1814,14 +1817,14 @@
 
     private void pushViewPortPos(ViewPortPos vpp) {
         viewPortPositions.add(vpp);
-        afpDataStream.setOffsets(vpp.x, vpp.y, vpp.rot);
+        getAFPDataStream().setOffsets(vpp.x, vpp.y, vpp.rot);
     }
 
     private void popViewPortPos() {
         viewPortPositions.remove(viewPortPositions.size() - 1);
         if (viewPortPositions.size() > 0) {
             ViewPortPos vpp = (ViewPortPos)viewPortPositions.get(viewPortPositions.size() - 1);
-            afpDataStream.setOffsets(vpp.x, vpp.y, vpp.rot);
+            getAFPDataStream().setOffsets(vpp.x, vpp.y, vpp.rot);
         }
     }
 
@@ -1913,7 +1916,7 @@
     
     /** {@inheritDoc} */
     public void startPageSequence(LineArea seqTitle) {
-        afpDataStream.endPageGroup();
-        afpDataStream.startPageGroup();
+        getAFPDataStream().endPageGroup();
+        getAFPDataStream().startPageGroup();
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java Wed Apr 16 05:03:15 2008
@@ -30,15 +30,12 @@
 import org.apache.batik.dom.AbstractDocument;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
 import org.apache.batik.gvt.GraphicsNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.render.afp.modca.AFPDataStream;
 import org.apache.fop.render.afp.modca.GraphicsObject;
-import org.apache.fop.render.afp.modca.IncludeObject;
 import org.apache.fop.svg.SVGUserAgent;
 import org.w3c.dom.Document;
 
@@ -60,10 +57,10 @@
     }
 
     /**
-     * Get the afp information from the render context.
+     * Get the AFP information from the render context.
      *
      * @param context the renderer context
-     * @return the afp information retrieved from the context
+     * @return the AFP information retrieved from the context
      */
     public static AFPInfo getAFPInfo(RendererContext context) {
         AFPInfo afpi = new AFPInfo();
@@ -103,9 +100,6 @@
         graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
         graphics.setAFPInfo(afpInfo);
         
-        String uri = ((AbstractDocument)doc).getDocumentURI();
-        graphics.setDocumentURI(uri);
-        
         GVTBuilder builder = new GVTBuilder();
 
         boolean strokeText = false;
@@ -160,7 +154,9 @@
         
         // set the data object parameters
         DataObjectInfo info = new DataObjectInfo();
-        info.setUri(uri);
+        
+        String docUri = ((AbstractDocument)doc).getDocumentURI();
+        info.setUri(docUri);
         info.setX(x);
         info.setY(y);
         info.setWidth(width);
@@ -170,14 +166,11 @@
         Map/*<QName, String>*/ foreignAttributes
             = (Map/*<QName, String>*/)context.getProperty(
                 RendererContextConstants.FOREIGN_ATTRIBUTES);
-        if (foreignAttributes != null) {
-            info.setResourceInfoFromForeignAttributes(foreignAttributes);
-        }
+        info.setResourceInfoFromForeignAttributes(foreignAttributes);
 
-        //TODO: AC - fix
-//        IncludeObject includeObj = afpInfo.getAFPDataStream().createObject(info);
-//        GraphicsObject graphicsObj = (GraphicsObject)includeObj.getReferencedObject();
-//        graphics.setGraphicsObject(graphicsObj);
+        AFPDataStream afpDataStream = afpInfo.getAFPDataStream();
+        GraphicsObject graphicsObj = (GraphicsObject)afpDataStream.createObject(info);
+        graphics.setGraphicsObject(graphicsObj);
         
         try {
             root.paint(graphics);
@@ -203,5 +196,4 @@
         context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
                 Boolean.FALSE);
     }
-    
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java Wed Apr 16 05:03:15 2008
@@ -25,14 +25,20 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.render.afp.extensions.AFPElementMapping;
-import org.apache.fop.render.afp.modca.ObjectTypeRegistry;
-import org.apache.fop.render.afp.modca.ObjectTypeRegistry.ObjectType;
-import org.apache.fop.util.QName;
+import org.apache.fop.render.afp.modca.Registry;
+import org.apache.fop.render.afp.modca.Registry.ObjectType;
+import org.apache.xmlgraphics.util.QName;
 
 /**
  * A list of parameters associated with an AFP data objects
  */
 public class DataObjectInfo {
+    private static final Log log = LogFactory.getLog("org.apache.fop.afp");
+
+    private static final String RESOURCE_NAME = "afp:resource-name";
+    private static final String RESOURCE_LEVEL = "afp:resource-level";
+    private static final String RESOURCE_GROUP_FILE = "afp:resource-group-file";
+
     private static final ResourceInfo DEFAULT_RESOURCE_INFO = new ResourceInfo();
     
     private String uri;
@@ -42,16 +48,19 @@
     private int height;
     private int widthRes;
     private int heightRes;
+    private int rotation = 0;
     
-    // object type entry
-    private ObjectType objectTypeEntry;
+    /** object type entry */
+    private ObjectType objectType;
+    
+    /** resource info */
     private ResourceInfo resourceInfo = DEFAULT_RESOURCE_INFO;
     
     /**
      * Sets the data object uri
      * @param uri the data object uri
      */
-    protected void setUri(String uri) {
+    public void setUri(String uri) {
         this.uri = uri;
     }
 
@@ -159,18 +168,33 @@
     }
     
     /**
-     * Sets the object type entry
-     * @param entry the object type entry
+     * @return the rotation of this data object
+     */
+    public int getRotation() {
+        return rotation;
+    }
+
+    /**
+     * Sets the data object rotation
+     * @param rotation the data object rotation
+     */
+    protected void setRotation(int rotation) {
+        this.rotation = rotation;
+    }
+
+    /**
+     * Sets the object type
+     * @param objectType the object type
      */    
-    public void setObjectType(ObjectTypeRegistry.ObjectType entry) {
-        this.objectTypeEntry = entry;
+    public void setObjectType(Registry.ObjectType objectType) {
+        this.objectType = objectType;
     }
 
     /**
      * @return the object type entry
      */
-    protected ObjectType getObjectTypeEntry() {
-        return objectTypeEntry;
+    protected ObjectType getObjectType() {
+        return objectType;
     }
 
     /**
@@ -188,17 +212,12 @@
         this.resourceInfo = resourceInfo;
     }
 
-    
-    private static final String RESOURCE_NAME = "afp:resource-name";
-    private static final String RESOURCE_LEVEL = "afp:resource-level";
-    private static final String RESOURCE_GROUP_FILE = "afp:resource-group-file";
-
     /**
      * Sets the resource group settings using the given foreign attributes
      * @param foreignAttributes a mapping of element attributes names to values
      */
     public void setResourceInfoFromForeignAttributes(Map/*<QName, String>*/ foreignAttributes) {
-        if (foreignAttributes != null) {
+        if (foreignAttributes != null && !foreignAttributes.isEmpty()) {
             this.resourceInfo = new ResourceInfo();
             QName resourceNameKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_NAME);
             String resourceName = (String)foreignAttributes.get(resourceNameKey);
@@ -214,15 +233,19 @@
                                 RESOURCE_GROUP_FILE);
                         String resourceExternalDest
                             = (String)foreignAttributes.get(resourceGroupFileKey);
+                        if (resourceExternalDest == null) {
+                            String msg = RESOURCE_GROUP_FILE + " not specified";
+                            log.warn(msg);
+                            throw new UnsupportedOperationException(msg);
+                        }
                         File resourceExternalGroupFile = new File(resourceExternalDest);
                         if (resourceExternalGroupFile.canWrite()) {
                             resourceInfo.setExternalResourceGroupFile(resourceExternalGroupFile);
                         }
                     }
                 } else {
-                    Log log = LogFactory.getLog("org.apache.fop.afp");
-                    log.warn("invalid resource level '" + level
-                            + "', using default document level");
+                    String msg = RESOURCE_LEVEL + " is null or not valid";
+                    log.warn(msg);
                 }
             }
         }
@@ -239,7 +262,8 @@
             + ", height=" + height
             + ", widthRes=" + widthRes
             + ", heightRes=" + heightRes
+            + ", rotation=" + rotation
             + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "")
-            + (objectTypeEntry != null ? ", objectTypeEntry=" + objectTypeEntry : "");
+            + (objectType != null ? ", objectTypeEntry=" + objectType : "");
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ResourceInfo.java Wed Apr 16 05:03:15 2008
@@ -99,7 +99,7 @@
      * @return true if the resource level was successfully set
      */
     public boolean setLevel(String lvl) {
-        if (isValid(lvl)) {
+        if (lvl != null && isValid(lvl)) {
             this.level = lvl;
             return true;
         }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java Wed Apr 16 05:03:15 2008
@@ -22,10 +22,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer;
+
 /**
  * A GOCA graphics area (container for filled shapes/objects)
  */
-public final class GraphicsArea extends AbstractGraphicsContainer {
+public final class GraphicsArea extends AbstractPreparedObjectContainer {
 
     /** draw boundary lines around this area */
     private boolean drawBoundary = false;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java Wed Apr 16 05:03:15 2008
@@ -22,13 +22,14 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer;
 import org.apache.fop.render.afp.modca.PreparedAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
  * A GOCA graphics segment
  */
-public final class GraphicsChainedSegment extends AbstractGraphicsContainer {
+public final class GraphicsChainedSegment extends AbstractPreparedObjectContainer {
 
     /**
      * The maximum segment data length
@@ -91,10 +92,8 @@
     }
 
     private static final byte APPEND_NEW_SEGMENT = 0;
-
-    private static final byte PROLOG = 4;
-
-    private static final byte APPEND_TO_EXISING = 48;
+//    private static final byte PROLOG = 4;
+//    private static final byte APPEND_TO_EXISING = 48;
 
     /**
      * {@inheritDoc}
@@ -148,7 +147,7 @@
      */
     protected void beginArea() {
         this.currentArea = new GraphicsArea();
-        super.addDrawingOrder(currentArea);
+        super.addObject(currentArea);
     }
 
     /**
@@ -161,11 +160,11 @@
     /**
      * {@inheritDoc}
      */
-    protected PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) {
+    public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) {
         if (currentArea != null) {
-            currentArea.addDrawingOrder(drawingOrder);
+            currentArea.addObject(drawingOrder);
         } else {
-            super.addDrawingOrder(drawingOrder);
+            super.addObject(drawingOrder);
         }
         return drawingOrder;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsData.java Wed Apr 16 05:03:15 2008
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer;
 import org.apache.fop.render.afp.modca.PreparedAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 import org.apache.fop.render.afp.tools.StringUtils;
@@ -29,7 +30,7 @@
 /**
  * A GOCA graphics data
  */
-public final class GraphicsData extends AbstractGraphicsContainer {   
+public final class GraphicsData extends AbstractPreparedObjectContainer {   
     
     /**
      * The maximum graphics data length
@@ -115,20 +116,20 @@
         } else {
             this.currentSegment = new GraphicsChainedSegment(name, currentSegment);            
         }
-        super.addDrawingOrder(currentSegment);
+        super.addObject(currentSegment);
         return currentSegment;
     }
 
     /**
      * {@inheritDoc}
      */
-    public PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) {
+    public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) {
         if (currentSegment == null 
             || (currentSegment.getDataLength() + drawingOrder.getDataLength())
             >= GraphicsChainedSegment.MAX_DATA_LEN) {
             newSegment();
         }
-        currentSegment.addDrawingOrder(drawingOrder);
+        currentSegment.addObject(drawingOrder);
         return drawingOrder;
     }
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImageData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImageData.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImageData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsImageData.java Wed Apr 16 05:03:15 2008
@@ -41,10 +41,13 @@
         if (startIndex + MAX_DATA_LEN >= imageData.length) {
             dataLen = imageData.length - startIndex - 1;
         }
-        super.data = new byte[dataLen + 2];
+
+        byte[] data = new byte[dataLen + 2];
         data[0] = (byte) 0x92; // GIMD
         data[1] = BinaryUtils.convert(dataLen, 1)[0]; // LENGTH
         System.arraycopy(imageData, startIndex, data, 2, dataLen);
+
+        super.setData(data);
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java Wed Apr 16 05:03:15 2008
@@ -431,6 +431,9 @@
                 col, vsci, ica, data);
     }
 
+    /** Maintain a reference count of instream objects */
+    private int instreamObjectCount = 0;
+
     /**
      * Creates a data object in the datastream.  The data object resides according
      * to its type, info and MO:DCA-L (resource) support.
@@ -441,20 +444,35 @@
      *            a data object
      */
     public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) {
-        ObjectTypeRegistry registry = ObjectTypeRegistry.getInstance();
-        ObjectTypeRegistry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
+        String uri = dataObjectInfo.getUri();
+        
+        // if this is an instream data object adjust uri to ensure that it is unique
+        if (uri.endsWith("/")) {
+            uri += "#" + (++instreamObjectCount);
+            dataObjectInfo.setUri(uri);
+        }
+        
+        Registry.ObjectType objectType = Registry.getInstance().getObjectType(dataObjectInfo);
+        // recognised object type
         if (objectType != null) {
             dataObjectInfo.setObjectType(objectType);
-        }        
-        AbstractNamedAFPObject dataObj;
-        // can this data object use the include object (IOB) mechanism?
-        if (objectType.canBeIncluded()) {
-            ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
-            ResourceGroup resourceGroup = getResourceGroup(resourceInfo);
-            dataObj = resourceGroup.createObject(dataObjectInfo);
-        } else {
-            dataObj = getCurrentPage().createObject(dataObjectInfo);
-        }
+
+            // can this data object use the include object (IOB) referencing mechanism?
+            if (objectType.canBeIncluded()) {
+                ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+                ResourceGroup resourceGroup = getResourceGroup(resourceInfo);
+                IncludeObject includeObject = resourceGroup.createObject(dataObjectInfo);
+                
+                // add include to current page
+                getCurrentPage().addObject(includeObject);
+                return includeObject.getDataObject();
+            } else {
+                log.warn(uri + "cannot be included so will embed directly");
+            }
+        }
+        // unrecognised/unsupported object type so create/embed data object directly in current page
+        AbstractNamedAFPObject dataObj = getCurrentPage().createObject(dataObjectInfo);
+        getCurrentPage().addObject(dataObj);
         return dataObj;
     }
     
@@ -822,28 +840,27 @@
             // write any external resources
             Iterator it = getExternalResourceGroups().keySet().iterator();
             while (it.hasNext()) {
-                String externalDest = (String)it.next();
+                File resourceGroupFile = (File)it.next();
                 ResourceGroup resourceGroup
-                    = (ResourceGroup)getExternalResourceGroups().get(externalDest);
+                    = (ResourceGroup)getExternalResourceGroups().get(resourceGroupFile);
                 OutputStream os = null;
                 try {
-                    log.debug("Writing external AFP resource file " + externalDest);
-                    os = new java.io.FileOutputStream(externalDest);
+                    log.debug("Writing external AFP resource file "
+                            + resourceGroupFile.getAbsolutePath());
+                            
+                    os = new java.io.FileOutputStream(resourceGroupFile);
                     resourceGroup.writeDataStream(os);
-                } catch (FileNotFoundException e) {
-                    log.error("Failed to open external AFP resource file "
-                            + externalDest);
                 } catch (IOException e) {
                     log.error(
                             "An error occurred when attempting to write external AFP resource file "
-                            + externalDest);
+                            + resourceGroupFile.getAbsolutePath());
                 } finally {
                     if (os != null) {
                         try {
                             os.close();
                         } catch (IOException e) {
                             log.error("Failed to close outputstream for external AFP resource file "
-                                    + externalDest);
+                                    + resourceGroupFile.getAbsolutePath());
                         }
                     }
                 }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java?rev=648675&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStreamWriter.java Wed Apr 16 05:03:15 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Implementing object is able to write to an AFPDataStream
+ */
+public interface AFPDataStreamWriter {
+    /**
+     * DataStream objects must implement the writeDataStream()
+     * method to write its data to the given OutputStream
+     * @param os The outputsteam stream
+     * @throws java.io.IOException an I/O exception of some sort has occurred.
+     */
+    void writeDataStream(OutputStream os) throws IOException;
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java Wed Apr 16 05:03:15 2008
@@ -33,20 +33,12 @@
  * AFP format.
  *
  */
-public abstract class AbstractAFPObject {
+public abstract class AbstractAFPObject implements AFPDataStreamWriter {
 
     /**
      * Static logging instance
      */
     protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
-
-    /**
-     * DataStream objects must implement the writeDataStream()
-     * method to write its data to the given OutputStream
-     * @param os The outputsteam stream
-     * @throws java.io.IOException an I/O exception of some sort has occurred.
-     */
-    public abstract void writeDataStream(OutputStream os) throws IOException;
 
     /**
      * Help method to write a set of AFPObjects to the AFP datastream.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java Wed Apr 16 05:03:15 2008
@@ -22,13 +22,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.goca.AbstractGraphicsContainer;
 
 /**
  * Abstract base class used by the ImageObject and GraphicsObject which both
  * have define an ObjectEnvironmentGroup
  */
-public abstract class AbstractDataObject extends AbstractGraphicsContainer {
+public abstract class AbstractDataObject extends AbstractPreparedObjectContainer {
 
     /**
      * The object environment group

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java Wed Apr 16 05:03:15 2008
@@ -410,22 +410,6 @@
         writeObjects(objects, os);
     }
     
-//  /**
-//  * {@inheritDoc}
-//  */
-// public IncludeObject createImageObject(ImageObjectParameters params) {
-//     endPresentationObject();
-//     return super.createImageObject(params);
-// }
-//
-// /**
-//  * {@inheritDoc}
-//  */
-// public IncludeObject createGraphicsObject(DataObjectParameters params) {
-//     endPresentationObject();
-//     return super.createGraphicsObject(params);
-// }
-
     /**
      * {@inheritDoc}
      */
@@ -437,12 +421,4 @@
         endPresentationObject();
         super.addObject(obj);
     }
-    
-//    /**
-//     * {@inheritDoc}
-//     */
-//    protected void addObject(AbstractStructuredAFPObject obj) {
-//        endPresentationObject();
-//        super.addObject(obj);
-//    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java Wed Apr 16 05:03:15 2008
@@ -80,4 +80,12 @@
     protected int getLength() {
         return getStartDataLength() + getTripletDataLength() + getDataLength();
     }
+    
+    /**
+     * Sets the data
+     * @param data the data
+     */
+    protected void setData(byte[] data) {
+        this.data = data;
+    }
 }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java?rev=648675&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java Wed Apr 16 05:03:15 2008
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A base container of prepared structured AFP objects
+ */
+public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject
+implements PreparedAFPObject {
+    
+    /**
+     * list of objects contained within this container  
+     */
+    protected List/*<PreparedAFPObject>*/ objects = null;
+
+    /**
+     * Default constructor
+     */
+    protected AbstractPreparedObjectContainer() {
+    }
+
+    /**
+     * Named constructor
+     * @param name the name of the container
+     */
+    protected AbstractPreparedObjectContainer(String name) {
+        super(name);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeContent(OutputStream os) throws IOException {
+        if (objects != null) {
+            super.writeObjects(objects, os);
+        }
+    }
+
+    private List/*<PreparedAFPObject>*/ getObjects() {
+        if (objects == null) {
+            this.objects = new java.util.ArrayList/*<PreparedAFPObject>*/();
+        }
+        return this.objects;
+    }
+    
+    /**
+     * Adds a given prepared object to this container
+     * @param preparedObject the prepared object
+     * @return the drawingOrder if it was added, null otherwise
+     */
+    public PreparedAFPObject addObject(PreparedAFPObject preparedObject) {
+        log.debug(this + " adding " + preparedObject);
+        getObjects().add(preparedObject);
+        return preparedObject;
+    }
+    
+    /**
+     * @return the current data length of this container including
+     * all enclosed objects (and their containers)
+     */
+    public int getDataLength() {
+        int dataLen = 0;
+        if (objects != null) {
+            Iterator it = objects.iterator();
+            while (it.hasNext()) {
+                Object obj = it.next();
+                if (obj instanceof PreparedAFPObject) {
+                    dataLen += ((PreparedAFPObject)obj).getDataLength();
+                }
+            }
+        }
+        return dataLen;
+    } 
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java Wed Apr 16 05:03:15 2008
@@ -91,6 +91,9 @@
         }
     }
     
+    /**
+     * @return the resource environment group
+     */
     private ResourceEnvironmentGroup getResourceEnvironmentGroup() {
         if (resourceEnvironmentGroup == null) {
             this.resourceEnvironmentGroup = new ResourceEnvironmentGroup();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java Wed Apr 16 05:03:15 2008
@@ -194,9 +194,6 @@
                             "Invalid compression scheme: " + compression);
             }
         }
-        imageObj.setFullyQualifiedName(
-                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-                FullyQualifiedNameTriplet.FORMAT_URL, info.getUri());
         imageObj.setImageParameters(info.getWidthRes(), info.getHeightRes(), 
                 info.getDataWidth(), info.getDataHeight());
         if (info.isColor()) {
@@ -213,9 +210,10 @@
     /**
      * Helper method to create a graphic in the current container and to return
      * the object.
+     * @param info the data object info
      * @return a newly created graphics object
      */
-    protected GraphicsObject createGraphic() {
+    protected GraphicsObject createGraphic(DataObjectInfo info) {
         String name = GRAPHIC_NAME_PREFIX
             + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
         GraphicsObject graphicsObj = new GraphicsObject(name);
@@ -244,8 +242,13 @@
         if (info instanceof ImageObjectInfo) {
             dataObject = createImage((ImageObjectInfo)info);
         } else {
-            dataObject = createGraphic();
+            dataObject = createGraphic(info);
         }
+
+         dataObject.setFullyQualifiedName(
+                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
+                FullyQualifiedNameTriplet.FORMAT_URL, info.getUri());
+
         return dataObject;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java Wed Apr 16 05:03:15 2008
@@ -63,6 +63,7 @@
             try {
                 getTripletData();
             } catch (IOException e) {
+                log.error("failed to get triplet data");
             }
         }
         if (tripletData != null) {
@@ -228,7 +229,7 @@
      *        object/component type of the object
      * @param strucFlgs information on the structure of the object and its container
      */
-    public void setObjectClassification(byte objectClass, ObjectTypeRegistry.ObjectType objectType,
+    public void setObjectClassification(byte objectClass, Registry.ObjectType objectType,
             StrucFlgs strucFlgs) {
         addTriplet(new ObjectClassificationTriplet(objectClass, objectType, strucFlgs));
     }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java?rev=648675&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java Wed Apr 16 05:03:15 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.afp.modca;
+
+/**
+ * A common interface of ResourceObject and ContainerObject
+ */
+public interface DataObjectAccessor extends AFPDataStreamWriter {
+
+    /**
+     * @return the actual data object referenced in this envelope 
+     */
+    AbstractNamedAFPObject getDataObject();
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java Wed Apr 16 05:03:15 2008
@@ -127,13 +127,13 @@
     /**
      * {@inheritDoc}
      */
-    protected PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) {
+    public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) {
         if (graphicsData == null
                 || (graphicsData.getDataLength() + drawingOrder.getDataLength())
                 >= GraphicsData.MAX_DATA_LEN) {
             newData();
         }
-        graphicsData.addDrawingOrder(drawingOrder);
+        graphicsData.addObject(drawingOrder);
         return drawingOrder;
     }
     
@@ -154,7 +154,7 @@
      */
     private GraphicsData newData() {
         this.graphicsData = new GraphicsData();            
-        super.addDrawingOrder(graphicsData);
+        super.addObject(graphicsData);
         return graphicsData;
     }
     
@@ -163,7 +163,7 @@
      * @param col the active color to use
      */
     public void setColor(Color col) {
-        addDrawingOrder(new GraphicsSetProcessColor(col));
+        addObject(new GraphicsSetProcessColor(col));
     }
 
     /**
@@ -171,7 +171,7 @@
      * @param coords the x and y coordinates of the current position
      */
     public void setCurrentPosition(int[] coords) {
-        addDrawingOrder(new GraphicsSetCurrentPosition(coords));
+        addObject(new GraphicsSetCurrentPosition(coords));
     }
 
     /**
@@ -180,7 +180,7 @@
      */
     public void setLineWidth(int multiplier) {
         GraphicsSetLineWidth lw = new GraphicsSetLineWidth(multiplier);
-        addDrawingOrder(lw);
+        addObject(lw);
     }
 
     /**
@@ -189,7 +189,7 @@
      */
     public void setLineType(byte type) {
         GraphicsSetLineType lt = new GraphicsSetLineType(type);
-        addDrawingOrder(lt);
+        addObject(lt);
     }    
 
     /**
@@ -201,7 +201,7 @@
                 fill ? GraphicsSetPatternSymbol.SOLID_FILL
                      : GraphicsSetPatternSymbol.NO_FILL
         );
-        addDrawingOrder(pat);
+        addObject(pat);
     }
     
     /**
@@ -209,7 +209,7 @@
      * @param fontReference the character set (font) reference
      */
     public void setCharacterSet(int fontReference) {
-        addDrawingOrder(new GraphicsSetCharacterSet(fontReference));
+        addObject(new GraphicsSetCharacterSet(fontReference));
     }
 
     /**
@@ -217,7 +217,7 @@
      * @param coords the x/y coordinates (can be a series)
      */
     public void addLine(int[] coords) {
-        addDrawingOrder(new GraphicsLine(coords));
+        addObject(new GraphicsLine(coords));
     }
 
     /**
@@ -225,7 +225,7 @@
      * @param coords the x/y coordinates
      */
     public void addBox(int[] coords) {
-        addDrawingOrder(new GraphicsBox(coords));
+        addObject(new GraphicsBox(coords));
     }
 
     /**
@@ -233,7 +233,7 @@
      * @param coords the x/y coordinates
      */
     public void addFillet(int[] coords) {
-        addDrawingOrder(new GraphicsFillet(coords));
+        addObject(new GraphicsFillet(coords));
     }
 
     /**
@@ -244,7 +244,7 @@
      * @param ymaj the maximum value of the y coordinate
      */
     public void setArcParams(int xmaj, int ymin, int xmin, int ymaj) {
-        addDrawingOrder(new GraphicsSetArcParameters(xmaj, ymin, xmin, ymaj));
+        addObject(new GraphicsSetArcParameters(xmaj, ymin, xmin, ymaj));
     }
 
     /**
@@ -255,7 +255,7 @@
      * @param mhr the fractional portion of the multiplier
      */
     public void addFullArc(int x, int y, int mh, int mhr) {
-        addDrawingOrder(new GraphicsFullArc(x, y, mh, mhr));
+        addObject(new GraphicsFullArc(x, y, mh, mhr));
     }
 
     /**
@@ -264,16 +264,16 @@
      * @param y the y coordinate
      * @param width the image width
      * @param height the image height
-     * @param rawData the image data
+     * @param imgData the image data
      */
-    public void addImage(int x, int y, int width, int height, byte[] rawData) {
-        addDrawingOrder(new GraphicsImageBegin(x, y, width, height));
+    public void addImage(int x, int y, int width, int height, byte[] imgData) {
+        addObject(new GraphicsImageBegin(x, y, width, height));
         for (int startIndex = 0;
-            startIndex <= rawData.length;
+            startIndex <= imgData.length;
             startIndex += GraphicsImageData.MAX_DATA_LEN) {
-            addDrawingOrder(new GraphicsImageData(rawData, startIndex));
+            addObject(new GraphicsImageData(imgData, startIndex));
         }
-        addDrawingOrder(new GraphicsImageEnd());
+        addObject(new GraphicsImageEnd());
     }
 
     /**
@@ -283,7 +283,7 @@
      * @param y the y coordinate
      */
     public void addString(String str, int x, int y) {
-        addDrawingOrder(new GraphicsString(str, x, y));
+        addObject(new GraphicsString(str, x, y));
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java Wed Apr 16 05:03:15 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
 
@@ -40,7 +39,7 @@
  * data objects in the page segment.
  * </p>
  */
-public class IncludeObject extends AbstractNamedAFPObject {
+public class IncludeObject extends AbstractNamedAFPObject implements DataObjectAccessor {
 
     /**
      * the include object is of type page segment
@@ -96,45 +95,69 @@
      * The Y-axis origin defined in the object
      */
     private int yContentOffset = -1;
-    
-//    /**
-//     * The object referenced by this include object
-//     */
-//    private Resource resourceObj = null;
-    
+        
     /**
-     * the level at which this resource object resides
+     * the resource info
      */
-    private ResourceInfo level = null;
+    private ResourceInfo resourceInfo = null;
 
     /**
      * the referenced data object
      */
-    private AbstractNamedAFPObject dataObj = null;
+    private DataObjectAccessor dataObjectAccessor = null;
     
     /**
      * Constructor for the include object with the specified name, the name must
      * be a fixed length of eight characters and is the name of the referenced
      * object.
      *
-     * @param resourceObj the resource object wrapper
+     * @param name the name of this include object
+     * @param dataObjectAccessor the data object accessor
+     * @param resourceInfo the resource information
+     */
+    public IncludeObject(String name, DataObjectAccessor dataObjectAccessor,
+            ResourceInfo resourceInfo) {
+        super(name);
+        
+        setDataObjectAccessor(dataObjectAccessor);
+        setResourceInfo(resourceInfo);
+    }
+
+    /**
+     * Sets the data object accessor and the object type
+     * @param dataObjectAccessor the data object accessor
      */
-    public IncludeObject(AbstractNamedAFPObject dataObj) {
-        super(dataObj.getName());
-        this.dataObj = dataObj;
-//      AbstractStructuredAFPObject referencedObject = resourceObj.getReferencedObject();
-        if (dataObj instanceof ImageObject) {
+    private void setDataObjectAccessor(DataObjectAccessor dataObjectAccessor) {
+        this.dataObjectAccessor = dataObjectAccessor;
+        
+        AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject();
+        
+        if (dataObject instanceof ImageObject) {
             this.objectType = TYPE_IMAGE;
-        } else if (dataObj instanceof GraphicsObject) {
+        } else if (dataObject instanceof GraphicsObject) {
             this.objectType = TYPE_GRAPHIC;
-        } else if (dataObj instanceof PageSegment) {
+        } else if (dataObject instanceof PageSegment) {
             this.objectType = TYPE_PAGE_SEGMENT;
         } else {
             this.objectType = TYPE_OTHER;
         }
+    }
 
+    /**
+     * @return the data object accessor
+     */
+    private DataObjectAccessor getDataObjectAccessor() {
+        return this.dataObjectAccessor;
+    }
+    
+    /**
+     * Sets the resource level for this resource object
+     * @param resourceInfo the resource information
+     */
+    private void setResourceInfo(ResourceInfo resourceInfo) {
+        this.resourceInfo = resourceInfo;
+        
         // set data object reference triplet
-        ResourceInfo resourceInfo = getResourceInfo();
         if (resourceInfo != null && resourceInfo.isExternal()) {
             String dest = resourceInfo.getExternalResourceGroupDest();
             super.setFullyQualifiedName(
@@ -143,38 +166,22 @@
         } else {
             super.setFullyQualifiedName(
                     FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, dataObj.getName());            
+                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, getDataObject().getName());
         }        
     }
-
-    /**
-     * Sets the resource level for this resource object
-     * @param level the resource level
-     */
-    public void setResourceInfo(ResourceInfo level) {
-        this.level = level;
-    }
     
     /**
      * @return the resource info of this resource object
      */
     public ResourceInfo getResourceInfo() {
-        return this.level;
+        return this.resourceInfo;
     }
 
-//    /**
-//     * @return the resource container object referenced by this include object
-//     */
-//    public Resource getResource() {
-//        return this.resourceObj;
-//    }
-
     /**
      * @return the actual resource data object referenced by this include object
      */
-    public AbstractStructuredAFPObject getReferencedObject() {
-        return this.dataObj;
-        //getResource().getReferencedObject();
+    public AbstractNamedAFPObject getDataObject() {
+        return getDataObjectAccessor().getDataObject();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java Wed Apr 16 05:03:15 2008
@@ -41,12 +41,12 @@
 
     /**
      * Main constructor
-     * @param obj a map data resource for a given structured AFP object
+     * @param includeObj a map data resource for a given structured AFP object
      */
     public MapDataResource(IncludeObject includeObj) {
-        AbstractStructuredAFPObject refObj = includeObj.getReferencedObject();
+        AbstractStructuredAFPObject dataObject = includeObj.getDataObject();
 //        ResourceObject resObj = includeObj.getResource();
-        String fqName = refObj.getFullyQualifiedName();
+        String fqName = dataObject.getFullyQualifiedName();
         ResourceInfo resourceInfo = includeObj.getResourceInfo();
         if (fqName != null) {
             if (resourceInfo.isExternal()) {
@@ -75,7 +75,7 @@
             dataInContainer, containerHasOEG, dataInOCD
         );
 
-        //TODO: AC - fix
+        //  
 //        super.setObjectClassification(
 //                ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
 //                objectType, strucFlgs);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java Wed Apr 16 05:03:15 2008
@@ -31,40 +31,56 @@
 /**
  * Object containers are MO:DCA objects that envelop and carry object data.
  */
-public class ObjectContainer extends AbstractNamedAFPObject {
+public class ObjectContainer extends AbstractPreparedAFPObject implements DataObjectAccessor {
+                
+    /**
+     * the data object
+     */
+    private AbstractDataObject dataObj = null;
     
     /**
-     * the object container data
+     * the object data
      */
-    private ObjectContainerData objectContainerData;
-
+    private byte[] objectData = null;
+    
     /**
      * Main constructor
      * @param name the name of this object container
-     * @param dataObj the data object to reside within this object container
-     * @param info the data object info about the data object
+     * @param dataObjectInfo the data object info
      */
-    public ObjectContainer(String name, AbstractDataObject dataObj, DataObjectInfo info) {
+    public ObjectContainer(String name, DataObjectInfo dataObjectInfo) {
         super(name);
-        
         final boolean dataInContainer = true;
         final boolean containerHasOEG = false;
         final boolean dataInOCD = true;
         StrucFlgs strucFlgs = new StrucFlgs(
             dataInContainer, containerHasOEG, dataInOCD
         );
-        ObjectTypeRegistry registry = ObjectTypeRegistry.getInstance();
-        ObjectTypeRegistry.ObjectType entry = registry.getObjectType(info);
-        super.setObjectClassification(
-            ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
-            entry, strucFlgs
-        );
-        
-        // write data object to object container data
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // TODO: AC - fix
-//        dataObj.writeDataStream(bos);
-        this.objectContainerData = new ObjectContainerData(bos.toByteArray());
+        Registry registry = Registry.getInstance();
+        Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
+        if (objectType != null) {
+            super.setObjectClassification(
+                    ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
+                    objectType, strucFlgs
+            );
+        } else {
+            log.warn("no object type for " + dataObjectInfo.getUri());
+        }
+    }
+    
+    /**
+     * Sets the data object for this object container
+     * @param dataObj the data object to reside within this object container
+     */
+    public void setDataObject(AbstractDataObject dataObj) {
+        this.dataObj = dataObj;        
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public AbstractNamedAFPObject getDataObject() {
+        return this.dataObj;
     }
     
     /**
@@ -73,8 +89,13 @@
     protected void writeStart(OutputStream os) throws IOException {
         super.writeStart(os);
         
+        // create object data from data object
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        dataObj.writeDataStream(bos);
+        this.objectData = bos.toByteArray();
+
         // Set the total record length
-        byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2);
+        byte[] len = BinaryUtils.convert(18 + getTripletDataLength() + objectData.length, 2);
         byte[] data = new byte[] {
             0x5A, // Structured field identifier
             len[0], // Length byte 1
@@ -92,23 +113,24 @@
             nameBytes[4],
             nameBytes[5],
             nameBytes[6],
-            nameBytes[7],
-            0x00, // Reserved
-            0x00, // Reserved
+            nameBytes[7]
         };
         os.write(data);
     }
-
+    
     /**
      * {@inheritDoc}
      */
     protected void writeContent(OutputStream os) throws IOException {
-        super.writeContent(os); // write triplets
-        if (objectContainerData != null) {
+        super.writeContent(os);
+        
+        // write out object data in chunks of object container data
+        for (int i = 0; i <= objectData.length; i += ObjectContainerData.MAX_DATA_LEN) {
+            ObjectContainerData objectContainerData = new ObjectContainerData(objectData, i);
             objectContainerData.writeDataStream(os);
         }
     }
-
+    
     /**
      * {@inheritDoc}
      */
@@ -135,37 +157,50 @@
         os.write(data);
     }
     
-    private class ObjectContainerData extends AbstractStructuredAFPObject {
-        /** the object data */
-        private byte[] objData = null;
+    /**
+     * An Object Container Data holds a chunk of the data object
+     */
+    private class ObjectContainerData extends AbstractPreparedAFPObject {
+        
+        /**
+         * The maximum object container data length
+         */ 
+        private static final int MAX_DATA_LEN = 32759;
         
         /**
          * Main constructor
          * @param objData the object data
          */
-        public ObjectContainerData(byte[] objData) {
-            this.objData = objData;
+        public ObjectContainerData(byte[] objData, int startIndex) {
+            int dataLen = MAX_DATA_LEN;
+            if (startIndex + MAX_DATA_LEN >= objData.length) {
+                dataLen = objData.length - startIndex - 1;
+            }
+            byte[] len = BinaryUtils.convert(8 + dataLen, 2);
+            byte[] data = new byte[9 + dataLen];
+            data[0] = 0x5A; // Structured field identifier 
+            data[1] = len[0]; // Length byte 1
+            data[2] = len[1]; // Length byte 2
+            data[3] = (byte)0xD3; // Structured field id byte 1
+            data[4] = (byte)0xEE; // Structured field id byte 2
+            data[5] = (byte)0x92; // Structured field id byte 3
+            data[6] = 0x00; // Flags
+            data[7] = 0x00; // Reserved
+            data[8] = 0x00; // Reserved
+            
+            // copy object data chunk
+            System.arraycopy(data, startIndex, data, 9, dataLen);
+            
+            super.setData(data);
         }
         
         /**
          * {@inheritDoc}
          */
-        public void writeDataStream(OutputStream os) throws IOException {
-            // Set the total record length
-            byte[] len = BinaryUtils.convert(8 + objData.length, 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)0xEE, // Structured field id byte 2
-                (byte)0x92, // Structured field id byte 3
-                0x00, // Flags
-                0x00, // Reserved
-                0x00, // Reserved
-            };
-
-            os.write(data);
+        public String toString() {
+            return "ObjectContainerData("
+                + (data != null ? "" + (data.length - 2) : "null")
+                + ")";
         }
     }
 }

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java (from r647228, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java&r1=647228&r2=648675&rev=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java Wed Apr 16 05:03:15 2008
@@ -19,18 +19,17 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.io.UnsupportedEncodingException;
 import java.util.Collections;
 
-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 object type registry
+ * MOD:CA Registry of object types 
  */
-public final class ObjectTypeRegistry {
+public final class Registry {
+
     /** IOB supported object types */    
     private static final byte COMPID_GIF = 22;
     private static final byte COMPID_JFIF = 23; // jpeg file interchange format 
@@ -42,26 +41,26 @@
     private static final byte COMPID_TIFF = 14;
 
     /** mime type entry mapping */
-    private java.util.Map/*<String, ObjectTypeRegistry.Entry>*/ mimeEntryMap
+    private java.util.Map/*<String, Registry.ObjectType>*/ mimeEntryMap
         = Collections.synchronizedMap(
-                Collections.unmodifiableMap(
-                        new java.util.HashMap/*<String, ObjectTypeRegistry.Entry>*/()));
+                new java.util.HashMap/*<String, Registry.ObjectType>*/());
 
-    private static ObjectTypeRegistry instance = null;
+    /** singleton instance */
+    private static Registry instance = null;
 
     /**
-     * @return a single instance of Registry
+     * @return a single instance of an ObjectTypeRegistry
      */
-    public static ObjectTypeRegistry getInstance() {
-        synchronized (instance) {
+    public static Registry getInstance() {
+        synchronized (Registry.class) {
             if (instance == null) {
-                instance = new ObjectTypeRegistry();
-            }            
+                instance = new Registry();
+            }
         }
         return instance;
     }
     
-    private ObjectTypeRegistry() {
+    private Registry() {
         init();
     }
     
@@ -122,18 +121,17 @@
     }
 
     /**
-     * Returns the registry Entry for a given data object info
+     * Returns the Registry ObjectType for a given data object info
      * 
-     * @param info
-     *            the data object info
-     * @return the registry Entry for a given data object info
+     * @param dataObjectInfo the data object info
+     * @return the Registry ObjectType for a given data object info
      */
-    public ObjectType getObjectType(DataObjectInfo info) {
+    public Registry.ObjectType getObjectType(DataObjectInfo dataObjectInfo) {
         ObjectType entry = null;
-        if (info instanceof ImageObjectInfo) {
-            ImageObjectInfo imageInfo = (ImageObjectInfo)info;
+        if (dataObjectInfo instanceof ImageObjectInfo) {
+            ImageObjectInfo imageInfo = (ImageObjectInfo)dataObjectInfo;
             String mimeType = imageInfo.getMimeType();
-            entry = (ObjectType)mimeEntryMap.get(mimeType);
+            entry = (Registry.ObjectType)mimeEntryMap.get(mimeType);
         }
         return entry;
     }
@@ -144,30 +142,21 @@
     public class ObjectType {
         private byte componentId; 
         private byte[] oid;
-        private byte[] name;
+        private String name;
         private boolean canBeIncluded;
         
         /**
          * Main constructor
          * @param componentId the component id of this object type
          * @param oid the object id of this object type
-         * @param objectTypeName the object type name
+         * @param name the object type name
          * @param canBeIncluded true if this object can be included with an IOB structured field
          */
-        public ObjectType(byte componentId, byte[] oid, String objectTypeName,
+        public ObjectType(byte componentId, byte[] oid, String name,
                 boolean canBeIncluded) {
             this.componentId = componentId;
             this.oid = oid;
-            try {
-                this.name = objectTypeName.getBytes(AFPConstants.EBCIDIC_ENCODING);
-            } catch (UnsupportedEncodingException e) {
-                // should never happen!
-                LogFactory.getLog("org.apache.fop.render.afp.modca.Registry.Entry").error(
-                        "character encoding error occurred on componentId "
-                        + componentId
-                        + " : "
-                        + e.getMessage());
-            }
+            this.name = name;
             this.canBeIncluded = canBeIncluded;
         }
                 
@@ -183,7 +172,7 @@
         /**
          * @return the object type name for the given componentId 
          */
-        public byte[] getName() {
+        public String getName() {
             return this.name;
         }
 
@@ -199,6 +188,13 @@
          */
         public boolean canBeIncluded() {
             return this.canBeIncluded;
+        }
+        
+        /**
+         * {@inheritDoc}
+         */
+        public String toString() {
+            return this.getName();
         }
     }
 }

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=648675&r1=648674&r2=648675&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 Wed Apr 16 05:03:15 2008
@@ -30,7 +30,6 @@
 import org.apache.fop.render.afp.ResourceInfo;
 import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
 import org.apache.fop.render.afp.tools.StringUtils;
-import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
 
 /**
  * A Resource Group contains a set of overlays.
@@ -45,7 +44,7 @@
     /**
      * Mapping of resource uri to data resource object (image/graphic) 
      */
-    private Map/*<String,IncludeObject>*/ resourceMap = null;
+    private Map/*<String, DataObjectAccessor>*/ resourceMap = null;
 
     /**
      * This resource groups container
@@ -64,6 +63,7 @@
      * Constructor for the ResourceGroup, this takes a
      * name parameter which must be 8 characters long.
      * @param name the resource group name
+     * @param container the parent resource group container
      */
     public ResourceGroup(String name, AbstractResourceGroupContainer container) {
         super(name);
@@ -71,8 +71,7 @@
     }
 
     private static final String RESOURCE_NAME_PREFIX = "RES";
-    private static final String INCLUDE_NAME_PREFIX = "INC";
-    
+
     /**
      * Helper method to create a new resource object in the current container and to return
      * the object.
@@ -84,68 +83,50 @@
         ResourceObject resource = new ResourceObject(name);
         return resource;
     }
-    
-//    /**
-//     * Helper method to create a new resource object in the current container and to return
-//     * the object.
-//     * @return a newly created resource object
-//     */
-//    private IncludeObject createIncludeObject() {
-//        String name = INCLUDE_NAME_PREFIX
-//        + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
-//        IncludeObject includeObj = new IncludeObject(name);
-//        return includeObj;
-//    }
+
+    private AbstractResourceGroupContainer getContainer() {
+        return this.container;
+    }
 
     /**
      * Creates a data object in this resource group
-     * @param info the data object info
+     * @param dataObjectInfo the data object info
      * @return an include object reference
      */
-    public IncludeObject createObject(DataObjectInfo info) {
-        IncludeObject includeObj = (IncludeObject)getResourceMap().get(info.getUri());
-        if (includeObj == null) {
-            AbstractDataObject dataObj;
-            if (info instanceof ImageObjectInfo) {
-                dataObj = container.createImage((ImageObjectInfo)info);
+    public IncludeObject createObject(DataObjectInfo dataObjectInfo) {
+        DataObjectAccessor dataObjectAccessor
+            = (DataObjectAccessor)getResourceMap().get(dataObjectInfo.getUri());
+        ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+        AbstractDataObject dataObj;
+        if (dataObjectAccessor == null) {
+            if (dataObjectInfo instanceof ImageObjectInfo) {
+                dataObj = getContainer().createImage((ImageObjectInfo)dataObjectInfo);
             } else {
-                dataObj = container.createGraphic();
+                dataObj = getContainer().createGraphic(dataObjectInfo);
             }
 
-            ResourceInfo resourceInfo = info.getResourceInfo();
-            String resourceName = resourceInfo.getName();
-            if (resourceInfo.isExternal()) {
-                ObjectContainer objectContainer = new ObjectContainer(resourceName, dataObj, info);
-            } else {
-                
-            }
-            
-            // Wrap the data object in a page segment
-            PageSegment pageSegment = container.createPageSegment();
-            pageSegment.addObject(dataObj);
+            dataObj.setViewport(dataObjectInfo.getX(), dataObjectInfo.getY(),
+                    dataObjectInfo.getWidth(), dataObjectInfo.getHeight(),
+                    dataObjectInfo.getWidthRes(), dataObjectInfo.getHeightRes(),
+                    dataObjectInfo.getRotation());
 
+            String resourceName = resourceInfo.getName();
+            ObjectContainer objectContainer = new ObjectContainer(resourceName, dataObjectInfo);
+            objectContainer.setDataObject(dataObj);
             
-            // TODO: AC - rotation?
-            int rotation = 0;
-            dataObj.setViewport(info.getX(), info.getY(),
-                    info.getWidth(), info.getHeight(),
-                    info.getWidthRes(), info.getHeightRes(), rotation);
-            
-            includeObj.setResourceInfo(resourceInfo);
-
-            // If resource is to be stored externally,
-            // wrap the page segment in a resource object 
+            // When externally located, Wrap data object in a resource object
             if (resourceInfo.isExternal()) {
-                ResourceObject resource = createResourceObject();
-                resource.setReferencedObject(pageSegment);
-                includeObj = new IncludeObject(resource);
-            } else {
-                includeObj = new IncludeObject(pageSegment);
+                ResourceObject resourceObj = createResourceObject();
+                resourceObj.setObjectContainer(objectContainer);
+                dataObjectAccessor = resourceObj;
+            } else { // no wrappers just container
+                dataObjectAccessor = objectContainer;
             }
-            // Add include object to resource map
-            getResourceMap().put(info.getUri(), includeObj);                
+            getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor);            
         }
-        //includeObj.setObjectAreaSize(params.getX(), params.getY());
+        AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject();
+        String name = dataObject.getName();
+        IncludeObject includeObj = new IncludeObject(name, dataObjectAccessor, resourceInfo);
         return includeObj;
     }
     
@@ -174,9 +155,9 @@
      * Returns the list of resources
      * @return the list of resources
      */
-    public Map/*<String,AbstractAFPObject>*/ getResourceMap() {
+    public Map/*<String, DataObjectAccessor>*/ getResourceMap() {
         if (resourceMap == null) {
-            resourceMap = new java.util.HashMap/*<String,AbstractAFPObject>*/();
+            resourceMap = new java.util.HashMap/*<String, DataObjectAccessor>*/();
         }
         return resourceMap;
     }
@@ -189,9 +170,8 @@
             Collection includes = resourceMap.values();
             Iterator it = includes.iterator();
             while (it.hasNext()) {
-                IncludeObject includeObj = (IncludeObject)it.next();
-                AbstractStructuredAFPObject obj = includeObj.getReferencedObject();
-                obj.writeDataStream(os);
+                DataObjectAccessor dataObjectAccessor = (DataObjectAccessor)it.next();
+                dataObjectAccessor.writeDataStream(os);
             }
         }
     }
@@ -240,6 +220,6 @@
      * {@inheritDoc}
      */
     public String toString() {
-        return this.name + " " + this.resourceMap;
+        return this.name + " " + getResourceMap();
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message