*/
public class EscherComplexProperty extends EscherProperty {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private byte[] complexData;
+ /**
+ * @param length the max record length allowed for EscherComplexProperty
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for EscherComplexProperty
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
/**
* Create a complex property using the property id and a byte array containing the complex
* data value size.
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
+
/**
* <p>Class to manipulate data in the Clipboard Variant ({@link
* Variant#VT_CF VT_CF}) format.</p>
public static final int CF_BITMAP = 2;
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
* <p>A <code>byte[]</code> to hold a thumbnail image in ({@link
*/
private byte[] _thumbnailData;
+ /**
+ * @param length the max record length allowed for SubRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+ /**
+ * @return the max record length allowed for SubRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
/**
* <p>Default Constructor. If you use it then one you'll have to add
public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
public static final short sid = 0xEB;
- static final int MAX_RECORD_SIZE = 8228;
- private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4;
+ private static final int DEFAULT_MAX_RECORD_SIZE = 8228;
+ private static int MAX_RECORD_SIZE = DEFAULT_MAX_RECORD_SIZE;
+
+ /**
+ * @param size the max record size allowed for DrawingGroupRecord
+ */
+ public static void setMaxRecordSize(int size) {
+ MAX_RECORD_SIZE = size;
+ }
+
+ /**
+ * @return the max record size allowed for DrawingGroupRecord
+ */
+ public static int getMaxRecordSize() {
+ return MAX_RECORD_SIZE;
+ }
+
+ private static int getMaxDataSize() {
+ return MAX_RECORD_SIZE - 4;
+ }
public DrawingGroupRecord() {}
static int grossSizeFromDataSize(int dataSize)
{
- return dataSize + ( (dataSize - 1) / MAX_DATA_SIZE + 1 ) * 4;
+ return dataSize + ( (dataSize - 1) / getMaxDataSize() + 1 ) * 4;
}
private int writeData( int offset, byte[] data, byte[] rawData )
int writtenRawData = 0;
while (writtenRawData < rawData.length)
{
- int segmentLength = Math.min( rawData.length - writtenRawData, MAX_DATA_SIZE);
- if (writtenRawData / MAX_DATA_SIZE >= 2)
+ final int maxDataSize = getMaxDataSize();
+ int segmentLength = Math.min( rawData.length - writtenRawData, maxDataSize);
+ if (writtenRawData / maxDataSize >= 2)
writeContinueHeader( data, offset, segmentLength );
else
writeHeader( data, offset, segmentLength );
// not a real sid - dummy value
public static final short sid = 9876;
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+ /**
+ * @param length the max record length allowed for EscherAggregate
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for EscherAggregate
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
/** @deprecated not used */
@Deprecated
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+ /**
+ * @param length the max record length allowed for SubRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for SubRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
protected SubRecord() {}
import org.junit.jupiter.api.Test;
final class TestDrawingGroupRecord {
- private static final int MAX_RECORD_SIZE = 8228;
+ private static final int MAX_RECORD_SIZE = DrawingGroupRecord.getMaxRecordSize();
private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4;
@Test