@SuppressWarnings("WeakerAccess")
public class HemfText {
- 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 HemfText
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for HemfText
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
public enum EmfGraphicsMode {
GM_COMPATIBLE, GM_ADVANCED
public final class HMEFDumper {
//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 HMEFDumper
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for HMEFDumper
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
public static void main(String[] args) throws Exception {
if(args.length < 1) {
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
- * @param length the max record length allowed for CString
+ * @param length the max record length allowed for EscherPart
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max record length allowed for CString
+ * @return the max record length allowed for EscherPart
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
*/
public final class AnimationInfoAtom extends RecordAtom {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
/**
* whether the animation plays in the reverse direction
*/
_header = Arrays.copyOfRange(source, start, start+8);
// Grab the record data
- _recdata = IOUtils.safelyClone(source,start+8, len-8, MAX_RECORD_LENGTH);
+ _recdata = IOUtils.safelyClone(source,start+8, len-8, getMaxRecordLength());
}
/**
* An atomic record containing information about a comment.
*/
-public final class Comment2000Atom extends RecordAtom
-{
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+public final class Comment2000Atom extends RecordAtom {
/**
* Record header.
_header = Arrays.copyOfRange(source, start, start+8);
// Get the record data.
- _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
}
/**
*/
public final class ExHyperlinkAtom extends RecordAtom {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
/**
* Record header.
*/
_header = Arrays.copyOfRange(source, start, start+8);
// Get the record data.
- _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
// Must be at least 4 bytes long
if(_data.length < 4) {
CHINESE3
}
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
/**
* A bit that specifies whether the date is displayed in the footer.
* @see #getMask()
_header = Arrays.copyOfRange(source, start, start+8);
// Grab the record data
- _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _recdata = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
}
/**
*/
public class InteractiveInfoAtom extends RecordAtom {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
public enum Action {
NONE,
MACRO,
_header = Arrays.copyOfRange(source, start, start+8);
// Get the record data.
- _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
// Must be at least 16 bytes long
if(_data.length < 16) {
* (via CurrentUserAtom and UserEditAtom) pointing to the new slide location
*/
-public final class PersistPtrHolder extends PositionDependentRecordAtom
-{
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+public final class PersistPtrHolder extends PositionDependentRecordAtom {
private final byte[] _header;
private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
// count * 32 bit offsets
// Repeat as many times as you have data
_slideLocations = new HashMap<>();
- _ptrData = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _ptrData = IOUtils.safelyClone(source, start+8, len-8, RecordAtom.getMaxRecordLength());
int pos = 0;
while(pos < _ptrData.length) {
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
- * @param length the max record length allowed for CString
+ * @param length the max record length allowed for RecordAtom
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max record length allowed for CString
+ * @return the max record length allowed for RecordAtom
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
*/
public final class TextRulerAtom extends RecordAtom {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
private static final BitField DEFAULT_TAB_SIZE = getInstance(0x0001);
private static final BitField C_LEVELS = getInstance(0x0002);
private static final BitField TAB_STOPS = getInstance(0x0004);
* @param len the length of the slice in the byte array.
*/
TextRulerAtom(final byte[] source, final int start, final int len) {
- final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, MAX_RECORD_LENGTH));
+ final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, getMaxRecordLength()));
try {
*/
public final class TextSpecInfoAtom extends RecordAtom {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
private static final long _type = RecordTypes.TextSpecInfoAtom.typeID;
/**
_header = Arrays.copyOfRange(source, start, start+8);
// Get the record data.
- _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
}
/**
* Gets the record type.
*/
public final class TxMasterStyleAtom extends RecordAtom {
private static final Logger LOG = LogManager.getLogger(TxMasterStyleAtom.class);
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
/**
* Maximum number of indentation levels allowed in PowerPoint documents
protected TxMasterStyleAtom(byte[] source, int start, int len) {
_header = Arrays.copyOfRange(source, start, start+8);
- _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
//read available styles
try {
/*package*/ static final String PROPERTY_PRESERVE_BIN_TABLES = "org.apache.poi.hwpf.preserveBinTables";
private static final String PROPERTY_PRESERVE_TEXT_TABLE = "org.apache.poi.hwpf.preserveTextTable";
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private static final String STREAM_DATA = "Data";
*/
private Fields _fields;
+ /**
+ * @param length the max record length allowed for HWPFDocument
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for HWPFDocument
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
/**
* This constructor loads a Word document from an InputStream.
*
import java.util.Collections;
import java.util.List;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
* differently for CHP fkps and PAP fkps.
*/
@Internal
-public final class CHPFormattedDiskPage extends FormattedDiskPage
-{
+public final class CHPFormattedDiskPage extends FormattedDiskPage {
private static final int FC_SIZE = 4;
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
private ArrayList<CHPX> _chpxList = new ArrayList<>();
private ArrayList<CHPX> _overFlow;
-
public CHPFormattedDiskPage()
{
}
- /**
- * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
- * read from a Word file).
- *
- * @deprecated Use
- * {@link #CHPFormattedDiskPage(byte[], int, CharIndexTranslator)}
- * instead
- */
- @Deprecated
- public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
- TextPieceTable tpt )
- {
- this( documentStream, offset, tpt );
- }
-
/**
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
* read from a Word file).
int size = LittleEndian.getUByte(_fkp, _offset + chpxOffset);
- return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, MAX_RECORD_LENGTH);
+ return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, HWPFDocument.getMaxRecordLength());
}
protected byte[] toByteArray( CharIndexTranslator translator )
import java.util.LinkedList;
import java.util.List;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.IOUtils;
@Internal
public class ComplexFileTable {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
private static final byte GRPPRL_TYPE = 1;
private static final byte TEXT_PIECE_TABLE_TYPE = 2;
offset++;
int size = LittleEndian.getShort(tableStream, offset);
offset += LittleEndianConsts.SHORT_SIZE;
- byte[] bs = IOUtils.safelyClone(tableStream, offset, size, MAX_RECORD_LENGTH);
+ byte[] bs = IOUtils.safelyClone(tableStream, offset, size, HWPFDocument.getMaxRecordLength());
offset += size;
SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.types.DOPAbstractType;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
@Internal
-public final class DocumentProperties extends DOPAbstractType
-{
-
- //arbitrarily selected; may need to increase
- private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
- private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+public final class DocumentProperties extends DOPAbstractType {
private byte[] _preserved;
- /**
- * @param length the max record length allowed for DocumentProperties
- */
- public static void setMaxRecordLength(int length) {
- MAX_RECORD_LENGTH = length;
- }
-
- /**
- * @return the max record length allowed for DocumentProperties
- */
- public static int getMaxRecordLength() {
- return MAX_RECORD_LENGTH;
- }
-
/**
* @deprecated Use {@link #DocumentProperties(byte[],int,int)} instead
*/
final int supportedSize = DOPAbstractType.getSize();
if ( length != supportedSize )
{
- this._preserved = IOUtils.safelyClone( tableStream, offset + supportedSize, length - supportedSize, MAX_RECORD_LENGTH );
+ this._preserved = IOUtils.safelyClone( tableStream, offset + supportedSize,
+ length - supportedSize, HWPFDocument.getMaxRecordLength());
}
else
{
import java.util.Arrays;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.IOUtils;
@Internal
public final class Ffn {
- //arbitrarily selected; may need to increase
- private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
- private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
-
private int _cbFfnM1;//total length of FFN - 1.
private byte _info;
private static BitField _prq = BitFieldFactory.getInstance(0x0003);// pitch request
// extra facilitator members
private int _xszFfnLength;
- /**
- * @param length the max record length allowed for Ffn
- */
- public static void setMaxRecordLength(int length) {
- MAX_RECORD_LENGTH = length;
- }
-
- /**
- * @return the max record length allowed for Ffn
- */
- public static int getMaxRecordLength() {
- return MAX_RECORD_LENGTH;
- }
-
public Ffn(byte[] buf, int offset) {
int offsetTmp = offset;
// changed protected to public
public byte[] toByteArray() {
int offset = 0;
- byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH);
+ byte[] buf = IOUtils.safelyAllocate(this.getSize(), HWPFDocument.getMaxRecordLength());
buf[offset] = (byte) _cbFfnM1;
offset += LittleEndianConsts.BYTE_SIZE;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.types.FibBaseAbstractType;
import org.apache.poi.hwpf.model.types.FibRgLw97AbstractType;
import org.apache.poi.hwpf.model.types.FibRgW97AbstractType;
@Internal
public final class FileInformationBlock {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
private static final Logger LOG = LogManager.getLogger(FileInformationBlock.class);
private final FibBase _fibBase;
// first short is already read as _nFibNew
final int fibRgCswNewLength = ( _cswNew - 1 ) * LittleEndianConsts.SHORT_SIZE;
- _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH);
+ _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, fibRgCswNewLength, HWPFDocument.getMaxRecordLength());
}
else
{
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordTypes;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.types.PICFAbstractType;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@Internal
-public class PICFAndOfficeArtData
-{
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+public class PICFAndOfficeArtData {
/**
* Can contain either a {@link EscherBlipRecord} or a {@link EscherBSERecord}.
short _cchPicName = LittleEndian.getUByte(dataStream, offset);
offset += 1;
- _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, MAX_RECORD_LENGTH);
+ _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, HWPFDocument.getMaxRecordLength());
offset += _cchPicName;
}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianConsts;
@Internal
-public class SectionTable
-{
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+public class SectionTable {
private static final Logger LOG = LogManager.getLogger(SectionTable.class);
private static final int SED_SIZE = 12;
// The first short at the offset is the size of the grpprl.
int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
fileOffset += LittleEndianConsts.SHORT_SIZE;
- byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize, MAX_RECORD_LENGTH);
+ byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize, HWPFDocument.getMaxRecordLength());
_sections.add(new SEPX(sed, startAt, endAt, buf));
}
}