Browse Source

configurable max record len

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894526 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_0
PJ Fanning 2 years ago
parent
commit
977a870899

BIN
poi-excelant/src/main/java9/module-info.class View File


+ 16
- 1
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SoundData.java View File

@@ -34,7 +34,22 @@ public final class SoundData extends RecordAtom {


//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 SoundData
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}

/**
* @return the max record length allowed for SoundData
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
}

/**
* Record header.

+ 16
- 1
poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java View File

@@ -49,7 +49,22 @@ import org.apache.poi.util.LocaleUtil;

public class HwmfText {
private static final Logger LOG = LogManager.getLogger(HwmfText.class);
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 HwmfText
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}

/**
* @return the max record length allowed for HwmfText
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
}

/**
* The META_SETTEXTCHAREXTRA record defines inter-character spacing for text justification in the

+ 16
- 1
poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java View File

@@ -67,7 +67,22 @@ public abstract class HWPFDocumentCore extends POIDocument {
protected static final String STREAM_TABLE_1 = "1Table";

//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 500_000_000;
private static final int DEFAULT_MAX_RECORD_LENGTH = 500_000_000;
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;

/**
* @param length the max record length allowed for HWPFDocumentCore
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}

/**
* @return the max record length allowed for HWPFDocumentCore
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
}

/**
* Size of the not encrypted part of the FIB

+ 17
- 3
poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java View File

@@ -46,15 +46,29 @@ import org.apache.poi.util.NotImplemented;
import org.apache.poi.util.StringUtil;

/**
* Provides very simple support for old (Word 6 / Word 95)
* files.
* Provides very simple support for old (Word 6 / Word 95) files.
*/
public class HWPFOldDocument extends HWPFDocumentCore {

private static final Logger LOG = LogManager.getLogger(HWPFOldDocument.class);

//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 10_000_000;
private static final int DEFAULT_MAX_RECORD_LENGTH = 10_000_000;
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;

/**
* @param length the max record length allowed for HWPFOldDocument
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}

/**
* @return the max record length allowed for HWPFOldDocument
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
}

private static final Charset DEFAULT_CHARSET = StringUtil.WIN_1252;


+ 1
- 3
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java View File

@@ -26,8 +26,6 @@ import org.apache.poi.util.Internal;

@Internal
public class OldTextPieceTable extends TextPieceTable {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000_000;

public OldTextPieceTable() {
super();
@@ -82,7 +80,7 @@ public class OldTextPieceTable extends TextPieceTable {
int textSizeBytes = textSizeChars * multiple;

// Grab the data that makes up the piece
byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, MAX_RECORD_LENGTH);
byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, getMaxRecordLength());

// And now build the piece
final TextPiece newTextPiece = newTextPiece(nodeStartChars, nodeEndChars, buf, pieces[x]);

+ 17
- 2
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java View File

@@ -36,13 +36,28 @@ import static org.apache.logging.log4j.util.Unbox.box;
/**
* The piece table for matching up character positions to bits of text. This
* mostly works in bytes, but the TextPieces themselves work in characters. This
* does the icky convertion.
* does the icky conversion.
*/
@Internal
public class TextPieceTable implements CharIndexTranslator {
private static final Logger LOG = LogManager.getLogger(TextPieceTable.class);
//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 TextPieceTable
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}

/**
* @return the max record length allowed for TextPieceTable
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
}


// int _multiple;

Loading…
Cancel
Save