You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2011/04/21 16:59:09 UTC

svn commit: r1095739 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java src/java/org/apache/fop/afp/goca/GraphicsData.java src/java/org/apache/fop/afp/modca/GraphicsObject.java status.xml

Author: jeremias
Date: Thu Apr 21 14:59:09 2011
New Revision: 1095739

URL: http://svn.apache.org/viewvc?rev=1095739&view=rev
Log:
AFP GOCA: Work-around for InfoPrint's AFP implementation (AFP Viewer 3.5.4.1, AFP Workbench 2.5.4.1) which seems to lose the character set state over Graphics Data (GAD) boundaries. Setting the SegFlag on the SFI header did not help. Instead, the character set is re-set before each Character String order.
As part of the fix, some additional flags were implemented, but now not used. They might be useful in the future.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsData.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/modca/GraphicsObject.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java?rev=1095739&r1=1095738&r2=1095739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java Thu Apr 21 14:59:09 2011
@@ -34,6 +34,7 @@ public final class GraphicsChainedSegmen
 
     private byte[] predecessorNameBytes;
     private boolean appended;
+    private boolean prologPresent;
 
     /**
      * Main constructor
@@ -42,7 +43,7 @@ public final class GraphicsChainedSegmen
      *            the name of this graphics segment
      */
     public GraphicsChainedSegment(String name) {
-        this(name, null, false);
+        this(name, null, false, false);
     }
 
     /**
@@ -53,8 +54,10 @@ public final class GraphicsChainedSegmen
      * @param predecessorNameBytes
      *            the name of the predecessor in this chain
      * @param appended true if this segment is appended to the previous one
+     * @param prologPresent true if this segment starts with a prolog
      */
-    public GraphicsChainedSegment(String name, byte[] predecessorNameBytes, boolean appended) {
+    public GraphicsChainedSegment(String name, byte[] predecessorNameBytes,
+            boolean appended, boolean prologPresent) {
         super(name);
         if (predecessorNameBytes != null) {
             this.predecessorNameBytes = new byte[predecessorNameBytes.length];
@@ -62,6 +65,7 @@ public final class GraphicsChainedSegmen
                     this.predecessorNameBytes, 0, predecessorNameBytes.length);
         }
         this.appended = appended;
+        this.prologPresent = prologPresent;
     }
 
     /** {@inheritDoc} */
@@ -71,8 +75,8 @@ public final class GraphicsChainedSegmen
     }
 
     private static final byte APPEND_NEW_SEGMENT = 0;
-//    private static final byte PROLOG = 4;
     private static final byte APPEND_TO_EXISING = 6;
+    private static final byte PROLOG = 0x10;
 
     private static final int NAME_LENGTH = 4;
 
@@ -98,7 +102,12 @@ public final class GraphicsChainedSegmen
         System.arraycopy(nameBytes, 0, data, 2, NAME_LENGTH);
 
         data[6] = 0x00; // FLAG1 (ignored)
-        data[7] = this.appended ? APPEND_TO_EXISING : APPEND_NEW_SEGMENT; //FLAG2
+
+        //FLAG2
+        data[7] |= this.appended ? APPEND_TO_EXISING : APPEND_NEW_SEGMENT;
+        if (this.prologPresent) {
+            data[7] |= PROLOG;
+        }
 
         int dataLength = super.getDataLength();
         byte[] len = BinaryUtils.convert(dataLength, 2);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsData.java?rev=1095739&r1=1095738&r2=1095739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsData.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/GraphicsData.java Thu Apr 21 14:59:09 2011
@@ -32,11 +32,14 @@ import org.apache.fop.afp.util.StringUti
 public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
 
     /** the maximum graphics data length */
-    public static final int MAX_DATA_LEN = 8192;
+    public static final int MAX_DATA_LEN = GraphicsChainedSegment.MAX_DATA_LEN + 16;
+    //+16 to avoid unnecessary, practically empty GraphicsData instances.
 
     /** the graphics segment */
     private GraphicsChainedSegment currentSegment = null;
 
+    private boolean segmentedData;
+
     /**
      * Main constructor
      */
@@ -50,6 +53,15 @@ public final class GraphicsData extends 
     }
 
     /**
+     * Sets the indicator that this instance is a part of a series of segmented data chunks.
+     * This indirectly sets the SegFlag on the SFI header.
+     * @param segmented true if this data object is not the last of the series
+     */
+    public void setSegmentedData(boolean segmented) {
+        this.segmentedData = segmented;
+    }
+
+    /**
      * Returns a new segment name
      *
      * @return a new segment name
@@ -66,22 +78,23 @@ public final class GraphicsData extends 
      * @return a newly created graphics segment
      */
     public GraphicsChainedSegment newSegment() {
-        return newSegment(false);
+        return newSegment(false, false);
     }
 
     /**
      * Creates a new graphics segment.
      * @param appended true if this segment is appended to the previous one
+     * @param prologPresent true if started with a prolog
      * @return a newly created graphics segment
      */
-    public GraphicsChainedSegment newSegment(boolean appended) {
+    public GraphicsChainedSegment newSegment(boolean appended, boolean prologPresent) {
         String segmentName = createSegmentName();
         if (currentSegment == null) {
             currentSegment = new GraphicsChainedSegment(segmentName);
         } else {
             currentSegment.setComplete(true);
             currentSegment = new GraphicsChainedSegment(segmentName,
-                    currentSegment.getNameBytes(), appended);
+                    currentSegment.getNameBytes(), appended, prologPresent);
         }
         super.addObject(currentSegment);
         return currentSegment;
@@ -93,7 +106,7 @@ public final class GraphicsData extends 
         if (currentSegment == null
                 || (currentSegment.getDataLength() + object.getDataLength())
                 >= GraphicsChainedSegment.MAX_DATA_LEN) {
-            newSegment(true);
+            newSegment(true, false);
         }
         currentSegment.addObject(object);
     }
@@ -117,6 +130,9 @@ public final class GraphicsData extends 
         byte[] len = BinaryUtils.convert(dataLength, 2);
         data[1] = len[0]; // Length byte 1
         data[2] = len[1]; // Length byte 2
+        if (this.segmentedData) {
+            data[6] |= 32; //Data is segmented
+        }
         os.write(data);
 
         writeObjects(objects, os);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/modca/GraphicsObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/modca/GraphicsObject.java?rev=1095739&r1=1095738&r2=1095739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/modca/GraphicsObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/modca/GraphicsObject.java Thu Apr 21 14:59:09 2011
@@ -39,6 +39,7 @@ import org.apache.fop.afp.goca.GraphicsB
 import org.apache.fop.afp.goca.GraphicsChainedSegment;
 import org.apache.fop.afp.goca.GraphicsCharacterString;
 import org.apache.fop.afp.goca.GraphicsData;
+import org.apache.fop.afp.goca.GraphicsEndProlog;
 import org.apache.fop.afp.goca.GraphicsFillet;
 import org.apache.fop.afp.goca.GraphicsFullArc;
 import org.apache.fop.afp.goca.GraphicsImage;
@@ -62,8 +63,8 @@ public class GraphicsObject extends Abst
     private GraphicsData currentData = null;
 
     /** list of objects contained within this container */
-    protected List/*<GraphicsData>*/ objects
-        = new java.util.ArrayList/*<GraphicsData>*/();
+    protected List<GraphicsData> objects
+        = new java.util.ArrayList<GraphicsData>();
 
     /** the graphics state */
     private final GraphicsState graphicsState = new GraphicsState();
@@ -325,6 +326,10 @@ public class GraphicsObject extends Abst
      * @param y the y coordinate
      */
     public void addString(String str, int x, int y) {
+        //Work-around for InfoPrint's AFP which loses character set state over Graphics Data
+        //boundaries.
+        addObject(new GraphicsSetCharacterSet(graphicsState.characterSet));
+
         addObject(new GraphicsCharacterString(str, x, y));
     }
 
@@ -342,6 +347,13 @@ public class GraphicsObject extends Abst
         addObject(new GraphicsAreaEnd());
     }
 
+    /**
+     * Ends the prolog.
+     */
+    public void endProlog() {
+        addObject(new GraphicsEndProlog());
+    }
+
     /** {@inheritDoc} */
     @Override
     public String toString() {
@@ -359,9 +371,9 @@ public class GraphicsObject extends Abst
     /** {@inheritDoc} */
     @Override
     public void setComplete(boolean complete) {
-        Iterator it = objects.iterator();
+        Iterator<GraphicsData> it = objects.iterator();
         while (it.hasNext()) {
-            Completable completedObject = (Completable)it.next();
+            Completable completedObject = it.next();
             completedObject.setComplete(true);
         }
         super.setComplete(complete);

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1095739&r1=1095738&r2=1095739&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Apr 21 14:59:09 2011
@@ -60,6 +60,10 @@
     -->
     <release version="FOP Trunk" date="TBD">
       <action context="Renderers" dev="JM" type="fix">
+        AFP GOCA: Work-around for InfoPrint's AFP implementation which seems to lose
+        the character set state over Graphics Data (GAD) boundaries.
+      </action>
+      <action context="Renderers" dev="JM" type="fix">
         Bugfix for AFP GOCA segments: they were not properly marked as appended which could
         lead to graphics state changes in some implementations.
       </action>



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