protected static final int MAX_DATA_LEN = 8192;
private byte[] predecessorNameBytes;
+ private boolean appended;
/**
* Main constructor
* the name of this graphics segment
*/
public GraphicsChainedSegment(String name) {
- super(name);
+ this(name, null, false);
}
/**
* 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;
}
}
/** {@inheritDoc} */
+ @Override
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[14];
data[0] = getOrderCode(); // BEGIN_SEGMENT
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);
}
/** {@inheritDoc} */
+ @Override
public String toString() {
- return "GraphicsChainedSegment(name=" + super.getName() + ")";
+ return "GraphicsChainedSegment(name=" + super.getName() + ", len: " + getDataLength() + ")";
}
}
\ No newline at end of file
}
/** {@inheritDoc} */
+ @Override
public int getDataLength() {
return 8 + super.getDataLength();
}
}
/**
- * 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);
}
}
/** {@inheritDoc} */
+ @Override
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[9];
copySF(data, SF_CLASS, Type.DATA, Category.GRAPHICS);
}
/** {@inheritDoc} */
+ @Override
public String toString() {
- return "GraphicsData";
+ return "GraphicsData(len: " + getDataLength() + ")";
}
/**
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>