xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r1095418 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java src/java/org/apache/fop/afp/goca/GraphicsData.java status.xml
Date Wed, 20 Apr 2011 14:07:37 GMT
Author: jeremias
Date: Wed Apr 20 14:07:36 2011
New Revision: 1095418

URL: http://svn.apache.org/viewvc?rev=1095418&view=rev
Log:
Bugfix for AFP GOCA segments: they were not properly marked as appended which could lead to
graphics state changes in some implementations.

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/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=1095418&r1=1095417&r2=1095418&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 Wed
Apr 20 14:07:36 2011
@@ -33,6 +33,7 @@ public final class GraphicsChainedSegmen
     protected static final int MAX_DATA_LEN = 8192;
 
     private byte[] predecessorNameBytes;
+    private boolean appended;
 
     /**
      * Main constructor
@@ -41,7 +42,7 @@ public final class GraphicsChainedSegmen
      *            the name of this graphics segment
      */
     public GraphicsChainedSegment(String name) {
-        super(name);
+        this(name, null, false);
     }
 
     /**
@@ -51,24 +52,32 @@ public final class GraphicsChainedSegmen
      *            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 GraphicsChainedSegmen
     }
 
     /** {@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 GraphicsChainedSegmen
         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 GraphicsChainedSegmen
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
-        return "GraphicsChainedSegment(name=" + super.getName() + ")";
+        return "GraphicsChainedSegment(name=" + super.getName() + ", len: " + getDataLength()
+ ")";
     }
 }
\ No newline at end of file

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=1095418&r1=1095417&r2=1095418&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 Wed Apr 20 14:07:36
2011
@@ -44,6 +44,7 @@ public final class GraphicsData extends 
     }
 
     /** {@inheritDoc} */
+    @Override
     public int getDataLength() {
         return 8 + super.getDataLength();
     }
@@ -60,28 +61,39 @@ public final class GraphicsData extends 
     }
 
     /**
-     * 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 
     }
 
     /** {@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 
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
-        return "GraphicsData";
+        return "GraphicsData(len: " + getDataLength() + ")";
     }
 
     /**

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1095418&r1=1095417&r2=1095418&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Apr 20 14:07:36 2011
@@ -59,6 +59,10 @@
       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>	



---------------------------------------------------------------------
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