Lines 28-33
Link Here
|
28 |
import org.apache.poi.ddf.EscherRecordFactory; |
28 |
import org.apache.poi.ddf.EscherRecordFactory; |
29 |
import org.apache.poi.ddf.NullEscherSerializationListener; |
29 |
import org.apache.poi.ddf.NullEscherSerializationListener; |
30 |
import org.apache.poi.util.LittleEndian; |
30 |
import org.apache.poi.util.LittleEndian; |
|
|
31 |
import org.apache.poi.hssf.util.LazilyConcatenatedByteArray; |
31 |
|
32 |
|
32 |
/** |
33 |
/** |
33 |
* The escher container record is used to hold escher records. It is abstract and |
34 |
* The escher container record is used to hold escher records. It is abstract and |
Lines 47-53
Link Here
|
47 |
} |
48 |
} |
48 |
|
49 |
|
49 |
private List escherRecords; |
50 |
private List escherRecords; |
50 |
private byte[] rawData; |
51 |
private LazilyConcatenatedByteArray rawDataContainer = new LazilyConcatenatedByteArray(); |
51 |
|
52 |
|
52 |
|
53 |
|
53 |
public AbstractEscherHolderRecord() |
54 |
public AbstractEscherHolderRecord() |
Lines 60-66
Link Here
|
60 |
escherRecords = new ArrayList(); |
61 |
escherRecords = new ArrayList(); |
61 |
if (! DESERIALISE ) |
62 |
if (! DESERIALISE ) |
62 |
{ |
63 |
{ |
63 |
rawData = in.readRemainder(); |
64 |
rawDataContainer.concatenate(in.readRemainder()); |
64 |
} |
65 |
} |
65 |
else |
66 |
else |
66 |
{ |
67 |
{ |
Lines 70-75
Link Here
|
70 |
} |
71 |
} |
71 |
|
72 |
|
72 |
protected void convertRawBytesToEscherRecords() { |
73 |
protected void convertRawBytesToEscherRecords() { |
|
|
74 |
byte[] rawData = getRawData(); |
73 |
convertToEscherRecords(0, rawData.length, rawData); |
75 |
convertToEscherRecords(0, rawData.length, rawData); |
74 |
} |
76 |
} |
75 |
private void convertToEscherRecords( int offset, int size, byte[] data ) |
77 |
private void convertToEscherRecords( int offset, int size, byte[] data ) |
Lines 109-114
Link Here
|
109 |
{ |
111 |
{ |
110 |
LittleEndian.putShort( data, 0 + offset, getSid() ); |
112 |
LittleEndian.putShort( data, 0 + offset, getSid() ); |
111 |
LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) ); |
113 |
LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) ); |
|
|
114 |
byte[] rawData = getRawData(); |
112 |
if ( escherRecords.size() == 0 && rawData != null ) |
115 |
if ( escherRecords.size() == 0 && rawData != null ) |
113 |
{ |
116 |
{ |
114 |
LittleEndian.putShort(data, 0 + offset, getSid()); |
117 |
LittleEndian.putShort(data, 0 + offset, getSid()); |
Lines 129-135
Link Here
|
129 |
} |
132 |
} |
130 |
|
133 |
|
131 |
public int getRecordSize() { |
134 |
public int getRecordSize() { |
|
|
135 |
byte[] rawData = getRawData(); |
132 |
if (escherRecords.size() == 0 && rawData != null) { |
136 |
if (escherRecords.size() == 0 && rawData != null) { |
|
|
137 |
// XXX: It should be possible to derive this without concatenating the array, too. |
133 |
return rawData.length; |
138 |
return rawData.length; |
134 |
} |
139 |
} |
135 |
int size = 0; |
140 |
int size = 0; |
Lines 229-258
Link Here
|
229 |
*/ |
234 |
*/ |
230 |
public void join( AbstractEscherHolderRecord record ) |
235 |
public void join( AbstractEscherHolderRecord record ) |
231 |
{ |
236 |
{ |
232 |
int length = this.rawData.length + record.getRawData().length; |
237 |
rawDataContainer.concatenate(record.getRawData()); |
233 |
byte[] data = new byte[length]; |
|
|
234 |
System.arraycopy( rawData, 0, data, 0, rawData.length ); |
235 |
System.arraycopy( record.getRawData(), 0, data, rawData.length, record.getRawData().length ); |
236 |
rawData = data; |
237 |
} |
238 |
} |
238 |
|
239 |
|
239 |
public void processContinueRecord( byte[] record ) |
240 |
public void processContinueRecord( byte[] record ) |
240 |
{ |
241 |
{ |
241 |
int length = this.rawData.length + record.length; |
242 |
rawDataContainer.concatenate(record); |
242 |
byte[] data = new byte[length]; |
|
|
243 |
System.arraycopy( rawData, 0, data, 0, rawData.length ); |
244 |
System.arraycopy( record, 0, data, rawData.length, record.length ); |
245 |
rawData = data; |
246 |
} |
243 |
} |
247 |
|
244 |
|
248 |
public byte[] getRawData() |
245 |
public byte[] getRawData() |
249 |
{ |
246 |
{ |
250 |
return rawData; |
247 |
return rawDataContainer.toArray(); |
251 |
} |
248 |
} |
252 |
|
249 |
|
253 |
public void setRawData( byte[] rawData ) |
250 |
public void setRawData( byte[] rawData ) |
254 |
{ |
251 |
{ |
255 |
this.rawData = rawData; |
252 |
rawDataContainer.clear(); |
|
|
253 |
rawDataContainer.concatenate(rawData); |
256 |
} |
254 |
} |
257 |
|
255 |
|
258 |
/** |
256 |
/** |
Lines 260-265
Link Here
|
260 |
*/ |
258 |
*/ |
261 |
public void decode() |
259 |
public void decode() |
262 |
{ |
260 |
{ |
|
|
261 |
byte[] rawData = getRawData(); |
263 |
convertToEscherRecords(0, rawData.length, rawData ); |
262 |
convertToEscherRecords(0, rawData.length, rawData ); |
264 |
} |
263 |
} |
265 |
} |
264 |
} |