]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix for AFP GOCA segments: they were not properly marked as appended which could...
authorJeremias Maerki <jeremias@apache.org>
Wed, 20 Apr 2011 14:07:36 +0000 (14:07 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 20 Apr 2011 14:07:36 +0000 (14:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1095418 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
src/java/org/apache/fop/afp/goca/GraphicsData.java
status.xml

index 8d94bf9fc64307c80aa0997d6c0ee6b0f233073c..9e70168742eb387c8fb79cfd4fc45360048c51ec 100644 (file)
@@ -33,6 +33,7 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
     protected static final int MAX_DATA_LEN = 8192;
 
     private byte[] predecessorNameBytes;
+    private boolean appended;
 
     /**
      * Main constructor
@@ -41,7 +42,7 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
      *            the name of this graphics segment
      */
     public GraphicsChainedSegment(String name) {
-        super(name);
+        this(name, null, false);
     }
 
     /**
@@ -51,24 +52,32 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
      *            the name of this graphics segment
      * @param predecessorNameBytes
      *            the name of the predecessor in this chain
+     * @param appended true if this segment is appended to the previous one
      */
-    public GraphicsChainedSegment(String name, byte[] predecessorNameBytes) {
+    public GraphicsChainedSegment(String name, byte[] predecessorNameBytes, boolean appended) {
         super(name);
-        this.predecessorNameBytes = predecessorNameBytes;
+        if (predecessorNameBytes != null) {
+            this.predecessorNameBytes = new byte[predecessorNameBytes.length];
+            System.arraycopy(predecessorNameBytes, 0,
+                    this.predecessorNameBytes, 0, predecessorNameBytes.length);
+        }
+        this.appended = appended;
     }
 
     /** {@inheritDoc} */
+    @Override
     public int getDataLength() {
         return 14 + super.getDataLength();
     }
 
     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 APPEND_TO_EXISING = 6;
 
     private static final int NAME_LENGTH = 4;
 
     /** {@inheritDoc} */
+    @Override
     protected int getNameLength() {
         return NAME_LENGTH;
     }
@@ -78,6 +87,7 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
     }
 
     /** {@inheritDoc} */
+    @Override
     public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[14];
         data[0] = getOrderCode(); // BEGIN_SEGMENT
@@ -88,7 +98,7 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
         System.arraycopy(nameBytes, 0, data, 2, NAME_LENGTH);
 
         data[6] = 0x00; // FLAG1 (ignored)
-        data[7] = APPEND_NEW_SEGMENT;
+        data[7] = this.appended ? APPEND_TO_EXISING : APPEND_NEW_SEGMENT; //FLAG2
 
         int dataLength = super.getDataLength();
         byte[] len = BinaryUtils.convert(dataLength, 2);
@@ -105,7 +115,8 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
-        return "GraphicsChainedSegment(name=" + super.getName() + ")";
+        return "GraphicsChainedSegment(name=" + super.getName() + ", len: " + getDataLength() + ")";
     }
 }
\ No newline at end of file
index 1ba757e4b14e1d435ee1a0dd97b563a8d50f911d..752d09b48d67a7dfba022e64d544e23d3aadd60b 100644 (file)
@@ -44,6 +44,7 @@ public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
     }
 
     /** {@inheritDoc} */
+    @Override
     public int getDataLength() {
         return 8 + super.getDataLength();
     }
@@ -60,28 +61,39 @@ public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
     }
 
     /**
-     * Creates a new graphics segment
+     * Creates a new graphics segment.
      *
      * @return a newly created graphics segment
      */
     public GraphicsChainedSegment newSegment() {
+        return newSegment(false);
+    }
+
+    /**
+     * Creates a new graphics segment.
+     * @param appended true if this segment is appended to the previous one
+     * @return a newly created graphics segment
+     */
+    public GraphicsChainedSegment newSegment(boolean appended) {
         String segmentName = createSegmentName();
         if (currentSegment == null) {
             currentSegment = new GraphicsChainedSegment(segmentName);
         } else {
             currentSegment.setComplete(true);
-            currentSegment = new GraphicsChainedSegment(segmentName, currentSegment.getNameBytes());
+            currentSegment = new GraphicsChainedSegment(segmentName,
+                    currentSegment.getNameBytes(), appended);
         }
         super.addObject(currentSegment);
         return currentSegment;
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addObject(StructuredData object) {
         if (currentSegment == null
                 || (currentSegment.getDataLength() + object.getDataLength())
                 >= GraphicsChainedSegment.MAX_DATA_LEN) {
-            newSegment();
+            newSegment(true);
         }
         currentSegment.addObject(object);
     }
@@ -97,6 +109,7 @@ public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
     }
 
     /** {@inheritDoc} */
+    @Override
     public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[9];
         copySF(data, SF_CLASS, Type.DATA, Category.GRAPHICS);
@@ -110,8 +123,9 @@ public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
-        return "GraphicsData";
+        return "GraphicsData(len: " + getDataLength() + ")";
     }
 
     /**
index 23dedd01852fca48adb17f5def3e1fb7d6382f07..808fc5d66cbaae3be5e110e2926e9f421a872f40 100644 (file)
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <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>
       <action context="Renderers" dev="CB" type="fix" fixes-bug="51010" due-to="Max Aster">
         Bugzilla 51010: Bookmarks create useless lines in RTF 
       </action>