private byte[] predecessorNameBytes;
private boolean appended;
+ private boolean prologPresent;
/**
* Main constructor
* the name of this graphics segment
*/
public GraphicsChainedSegment(String name) {
- this(name, null, false);
+ this(name, null, false, false);
}
/**
* @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];
this.predecessorNameBytes, 0, predecessorNameBytes.length);
}
this.appended = appended;
+ this.prologPresent = prologPresent;
}
/** {@inheritDoc} */
}
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;
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);
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
*/
return 8 + super.getDataLength();
}
+ /**
+ * 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 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;
if (currentSegment == null
|| (currentSegment.getDataLength() + object.getDataLength())
>= GraphicsChainedSegment.MAX_DATA_LEN) {
- newSegment(true);
+ newSegment(true, false);
}
currentSegment.addObject(object);
}
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);
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;
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();
* @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));
}
addObject(new GraphicsAreaEnd());
}
+ /**
+ * Ends the prolog.
+ */
+ public void endProlog() {
+ addObject(new GraphicsEndProlog());
+ }
+
/** {@inheritDoc} */
@Override
public String toString() {
/** {@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);
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">
+ 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.