]> source.dussan.org Git - poi.git/commitdiff
more support for configurable max record len
authorPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 20:53:54 +0000 (20:53 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 20:53:54 +0000 (20:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894493 13f79535-47bb-0310-9956-ffa450edef68

21 files changed:
poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/DIB.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExMediaAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextBytesAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoRun.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java
poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java

index da67f62fa5b50f7655205740536374f2d8a145d7..0faf461808a28d4395062dc321846f567848bc4b 100644 (file)
@@ -49,11 +49,26 @@ import org.apache.poi.util.IOUtils;
 
 public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
     //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 final Deque<Iterator<?>> iterStack = new ArrayDeque<>();
     private Object current;
 
+    /**
+     * @param length the max record length allowed for HemfEmbeddedIterator
+     */
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    /**
+     * @return the max record length allowed for HemfEmbeddedIterator
+     */
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
+
     public HemfEmbeddedIterator(HemfPicture emf) {
         this(emf.getRecords().iterator());
     }
index c8de83855372b79c65b878099a09fb65aea41810..42f5ab66cdfefcfc3355336335a7851f0a69abca 100644 (file)
@@ -31,7 +31,22 @@ import org.apache.poi.util.IOUtils;
 public abstract class EscherPart extends HPBFPart {
 
     //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 CString
+     */
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    /**
+     * @return the max record length allowed for CString
+     */
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
 
     private EscherRecord[] records;
 
index 4ec6add0e9e5ef43e2040f2b28f54a4f628d9ade..cd571679c27956ae524715d7d14755be58972416 100644 (file)
@@ -35,8 +35,6 @@ import org.apache.poi.util.LocaleUtil;
  */
 public final class QuillContents extends HPBFPart {
     private static final Logger LOG = LogManager.getLogger(QuillContents.class);
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
     private final QCBit[] bits;
@@ -69,7 +67,7 @@ public final class QuillContents extends HPBFPart {
                 int from = (int)LittleEndian.getUInt(data, offset+16);
                 int len = (int)LittleEndian.getUInt(data, offset+20);
 
-                byte[] bitData = IOUtils.safelyClone(data, from, len, MAX_RECORD_LENGTH);
+                byte[] bitData = IOUtils.safelyClone(data, from, len, EscherPart.getMaxRecordLength());
 
                 // Create
                 if(bitType.equals("TEXT")) {
index 8f30cef3ca81ea2a099ace004c10c48666943eed..7fb2513fc3eead17061abb244422b2853325d178 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hslf.blip;
 
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.hslf.record.RecordAtom;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -30,9 +31,6 @@ import org.apache.poi.util.Removal;
  */
 public final class DIB extends Bitmap {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     /**
      * Size of the BITMAPFILEHEADER structure preceding the actual DIB bytes
      */
@@ -118,7 +116,7 @@ public final class DIB extends Bitmap {
         LittleEndian.putInt(header, 10, offset);
 
         //DIB data is the header + dib bytes
-        byte[] dib = IOUtils.safelyAllocate(header.length + (long)data.length, MAX_RECORD_LENGTH);
+        byte[] dib = IOUtils.safelyAllocate(header.length + (long)data.length, RecordAtom.getMaxRecordLength());
         System.arraycopy(header, 0, dib, 0, header.length);
         System.arraycopy(data, 0, dib, header.length, data.length);
 
index e0004baeeedd2c21112f432948ee74e6eae8c1ac..0edd3cd95e52c5762946afc45a990a72b072c2a5 100644 (file)
@@ -36,10 +36,6 @@ import org.apache.poi.util.StringUtil;
 
 public final class CString extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
-    private static int MAX_RECORD_LENGTH = 1_000_000;
-
     private byte[] _header;
 
     /** The bytes that make up the text */
@@ -50,20 +46,6 @@ public final class CString extends RecordAtom {
         return StringUtil.getFromUnicodeLE(_text);
     }
 
-    /**
-     * @param length the max record length allowed for CString
-     */
-    public static void setMaxRecordLength(int length) {
-        MAX_RECORD_LENGTH = length;
-    }
-
-    /**
-     * @return the max record length allowed for CString
-     */
-    public static int getMaxRecordLength() {
-        return MAX_RECORD_LENGTH;
-    }
-
     /** Updates the text in the Atom. */
     public void setText(String text) {
         // Convert to little endian unicode
@@ -103,7 +85,7 @@ public final class CString extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Grab the text
-        _text = IOUtils.safelyClone(source,start+8, len-8, MAX_RECORD_LENGTH);
+        _text = IOUtils.safelyClone(source,start+8, len-8, getMaxRecordLength());
     }
     /**
      * Create an empty CString
index 7a2e413dffafcf9a25ce7f8d2b72e4720ee29371..9d5400416615010ed2db73e8121f37daf1b17000 100644 (file)
@@ -21,6 +21,7 @@
 package org.apache.poi.hslf.record;
 
 import static org.apache.logging.log4j.util.Unbox.box;
+import static org.apache.poi.hslf.record.RecordAtom.getMaxRecordLength;
 import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT;
 
 import java.io.IOException;
@@ -44,11 +45,8 @@ import org.apache.poi.util.StringUtil;
  *  PowerPoint document. Instead, it lives in a separate stream in the
  *  document. As such, it has to be treated specially
  */
-public class CurrentUserAtom
-{
+public class CurrentUserAtom {
     private static final Logger LOG = LogManager.getLogger(CurrentUserAtom.class);
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     /** Standard Atom header */
     private static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
@@ -132,7 +130,7 @@ public class CurrentUserAtom
 
         // Grab the contents
         try (InputStream in = dir.createDocumentInputStream("Current User")) {
-            _contents = IOUtils.toByteArray(in, docProps.getSize(), MAX_RECORD_LENGTH);
+            _contents = IOUtils.toByteArray(in, docProps.getSize(), getMaxRecordLength());
         }
 
         // See how long it is. If it's under 28 bytes long, we can't
@@ -212,7 +210,7 @@ public class CurrentUserAtom
         //  4 = revision
         //  3 * len = ascii + unicode
         int size = 8 + 20 + 4 + (3 * lastEditUser.length());
-        _contents = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
+        _contents = IOUtils.safelyAllocate(size, getMaxRecordLength());
 
         // First we have a 8 byte atom header
         System.arraycopy(atomHeader,0,_contents,0,4);
@@ -231,7 +229,7 @@ public class CurrentUserAtom
 
         // The username gets stored twice, once as US
         //  ascii, and again as unicode laster on
-        byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), MAX_RECORD_LENGTH);
+        byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), getMaxRecordLength());
         StringUtil.putCompressedUnicode(lastEditUser,asciiUN,0);
 
         // Now we're able to do the length of the last edited user
@@ -253,7 +251,7 @@ public class CurrentUserAtom
         LittleEndian.putInt(_contents,28+asciiUN.length,(int)releaseVersion);
 
         // username in unicode
-        byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, MAX_RECORD_LENGTH);
+        byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, getMaxRecordLength());
         StringUtil.putUnicodeLE(lastEditUser,ucUN,0);
         System.arraycopy(ucUN,0,_contents,28+asciiUN.length+4,ucUN.length);
 
index 4388aa0704df49cad2b09a33c962a71e837b9a02..06cd97984fa2d22412d1ccafca468934c8094b44 100644 (file)
@@ -60,11 +60,6 @@ public final class DocumentAtom extends RecordAtom {
     }
 
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
-
-
     private final byte[] _header = new byte[8];
     private static final long _type = RecordTypes.DocumentAtom.typeID;
 
@@ -111,13 +106,16 @@ public final class DocumentAtom extends RecordAtom {
     public int getFirstSlideNum() { return firstSlideNum; }
 
     /**
-     * The Size of the Document's slides, @see DocumentAtom.SlideSize for values
-     * @deprecated to be replaced by enum
+     * The Size of the Document's slides, {@link DocumentAtom.SlideSize} for values.
      */
-    @Deprecated
-    @Removal(version = "5.0.0")
-    public int getSlideSizeType() { return slideSizeType; }
+    public SlideSize getSlideSizeType() { return SlideSize.values()[slideSizeType]; }
 
+    /**
+     * The Size of the Document's slides, {@link DocumentAtom.SlideSize} for values.
+     * @deprecated replaced by {@link #getSlideSizeType()}
+     */
+    @Deprecated
+    @Removal(version = "6.0.0")
     public SlideSize getSlideSizeTypeEnum() {
         return SlideSize.values()[slideSizeType];
     }
@@ -126,7 +124,7 @@ public final class DocumentAtom extends RecordAtom {
         slideSizeType = size.ordinal();
     }
 
-    /** Was the document saved with True Type fonts embeded? */
+    /** Was the document saved with True Type fonts embedded? */
     public boolean getSaveWithFonts() {
         return saveWithFonts != 0;
     }
@@ -190,7 +188,7 @@ public final class DocumentAtom extends RecordAtom {
         showComments = leis.readByte();
 
         // If there's any other bits of data, keep them about
-        reserved = IOUtils.safelyAllocate(maxLen-48L, MAX_RECORD_LENGTH);
+        reserved = IOUtils.safelyAllocate(maxLen-48L, getMaxRecordLength());
         leis.readFully(reserved);
     }
 
index 08ac291bdf77671a9bd46f545678f2813dab0f9e..247b14900d22884366d79a0836031ac2788f1811 100644 (file)
@@ -43,9 +43,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public class ExEmbedAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     /**
      * Embedded document does not follow the color scheme.
      */
@@ -96,7 +93,7 @@ public class ExEmbedAtom extends RecordAtom {
         _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 8 bytes long
         if(_data.length < 8) {
index c65d1a5603d90bbe2ad8fd9ac75e1f33d0cb8c01..46dedd9f9627983cda77d392502df66f51f1320d 100644 (file)
@@ -33,10 +33,7 @@ import org.apache.poi.util.LittleEndian;
 /**
  * An atom record that specifies information about external audio or video data.
  */
-public final class ExMediaAtom extends RecordAtom
-{
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
+public final class ExMediaAtom extends RecordAtom {
 
     /**
      * A bit that specifies whether the audio or video data is repeated continuously during playback.
@@ -91,7 +88,7 @@ public final class ExMediaAtom extends RecordAtom
         _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());
     }
 
     /**
index 2baf3f400c2bbeab4d8aa2816f42b736d8115dc7..3bf3a006a361584770bd0c541a8b50fa94f39c48 100644 (file)
@@ -29,15 +29,10 @@ import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
- * Tne atom that holds the seed info used by a ExObjList
+ * The atom that holds the seed info used by a ExObjList
  */
 
-public class ExObjListAtom extends RecordAtom
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
-    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+public class ExObjListAtom extends RecordAtom{
 
     /**
      * Record header.
@@ -49,20 +44,6 @@ public class ExObjListAtom extends RecordAtom
      */
     private byte[] _data;
 
-    /**
-     * @param length the max record length allowed for MasterTextPropAtom
-     */
-    public static void setMaxRecordLength(int length) {
-        MAX_RECORD_LENGTH = length;
-    }
-
-    /**
-     * @return the max record length allowed for MasterTextPropAtom
-     */
-    public static int getMaxRecordLength() {
-        return MAX_RECORD_LENGTH;
-    }
-
     /**
      * Constructs a brand new link related atom record.
      */
@@ -89,7 +70,7 @@ public class ExObjListAtom extends RecordAtom
         _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) {
index 43c1f151904b714c07191f3fc02487e94a8e3710..f172611896412e77cd960c9e27a00cdac86570e9 100644 (file)
@@ -42,9 +42,6 @@ import org.apache.poi.util.StringUtil;
 
 public final class FontEntityAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     private static final int[] FLAGS_MASKS = {
         0x0001, 0x0100, 0x0200, 0x0400, 0x0800
     };
@@ -75,7 +72,7 @@ public final class FontEntityAtom extends RecordAtom {
         _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());
     }
 
     /**
index 47efe8e8299653577ed4a786b6813e362b350de3..328efb1b294788513488e1f565479ff8a6870876 100644 (file)
@@ -38,9 +38,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     private final List<org.apache.poi.hslf.record.Record> _childRecords = new ArrayList<>();
 
     public HSLFEscherClientDataRecord() {}
@@ -68,7 +65,7 @@ public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
     @Override
     public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
-        byte[] remainingData = IOUtils.safelyClone(data,  offset+8,  bytesRemaining, MAX_RECORD_LENGTH);
+        byte[] remainingData = IOUtils.safelyClone(data,  offset+8,  bytesRemaining, RecordAtom.getMaxRecordLength());
         setRemainingData(remainingData);
         return bytesRemaining + 8;
     }
index 5e4664293d5402151ae8b3d015c61d55028aafe2..606cb042c8cbc603a578409416fa21fe6d99f016 100644 (file)
@@ -32,11 +32,7 @@ import org.apache.poi.util.LittleEndian;
  *  as what slide it is tied to
  */
 
-public final class NotesAtom extends RecordAtom
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
+public final class NotesAtom extends RecordAtom {
 
     private byte[] _header;
     private static long _type = 1009l;
@@ -81,7 +77,7 @@ public final class NotesAtom extends RecordAtom
         followMasterObjects = (flags & 1) == 1;
 
         // There might be 2 more bytes, which are a reserved field
-        reserved = IOUtils.safelyClone(source, start+14, len-14, MAX_RECORD_LENGTH);
+        reserved = IOUtils.safelyClone(source, start+14, len-14, getMaxRecordLength());
     }
 
     /**
index 58b87a6355368fbba95b74264740f49a5358dd40..c4026720e4f1c3468ef597d8da54223981f063d6 100644 (file)
@@ -21,8 +21,26 @@ package org.apache.poi.hslf.record;
  * Abstract class which all atom records will extend.
  */
 
-public abstract class RecordAtom extends Record
-{
+public abstract class RecordAtom extends Record {
+
+    //arbitrarily selected; may need to increase
+    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 CString
+     */
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    /**
+     * @return the max record length allowed for CString
+     */
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
+
     /**
      * We are an atom
      */
index 3760f2d2ceda566025e553f4c63c6cd3b37f23d3..b7dcd38220ce1fc86dc51a90b9c84cdc05c4f977 100644 (file)
@@ -38,9 +38,6 @@ public final class SlideAtom extends RecordAtom {
     public static final int USES_MASTER_SLIDE_ID  =  0x80000000;
     // private static final int MASTER_SLIDE_ID      =  0x00000000;
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     private byte[] _header;
     private static long _type = 1007l;
 
@@ -103,7 +100,7 @@ public final class SlideAtom extends RecordAtom {
 
         // If there's any other bits of data, keep them about
         // 8 bytes header + 20 bytes to flags + 2 bytes flags = 30 bytes
-        reserved = IOUtils.safelyClone(source,start+30, len-30, MAX_RECORD_LENGTH);
+        reserved = IOUtils.safelyClone(source,start+30, len-30, getMaxRecordLength());
     }
 
     /**
index d7e30b353229c93fc89ed76e7d27d1a4856b11b6..62773615e0bc7c942d2761d1267231cc8707a09e 100644 (file)
@@ -52,8 +52,6 @@ import org.apache.poi.util.LittleEndian;
 
 public final class StyleTextPropAtom extends RecordAtom {
     public static final long _type = RecordTypes.StyleTextPropAtom.typeID;
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     private final byte[] _header;
     private byte[] reserved;
@@ -136,7 +134,7 @@ public final class StyleTextPropAtom extends RecordAtom {
 
         // Save the contents of the atom, until we're asked to go and
         //  decode them (via a call to setParentTextSize(int)
-        rawContents = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        rawContents = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
         reserved = new byte[0];
 
         // Set empty lists, ready for when they call setParentTextSize
@@ -401,7 +399,7 @@ public final class StyleTextPropAtom extends RecordAtom {
 
         out.append("  original byte stream \n");
 
-        byte[] buf = IOUtils.safelyAllocate(rawContents.length + (long)reserved.length, MAX_RECORD_LENGTH);
+        byte[] buf = IOUtils.safelyAllocate(rawContents.length + (long)reserved.length, getMaxRecordLength());
         System.arraycopy(rawContents, 0, buf, 0, rawContents.length);
         System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
         out.append( HexDump.dump(buf, 0, 0) );
index 341693db9b96d13cec9f4c2f72ab8d535ad7327d..4ea4e767e9323ab41223af30f57fc028c8677fa9 100644 (file)
@@ -38,8 +38,6 @@ import org.apache.poi.util.StringUtil;
 
 public final class TextBytesAtom extends RecordAtom {
     public static final long _type = RecordTypes.TextBytesAtom.typeID;
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     private byte[] _header;
 
@@ -73,7 +71,7 @@ public final class TextBytesAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Grab the text
-        _text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _text = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
     }
 
     /**
index 4fd297387dffc129030b69c7d72aa0c9d8a62ac4..fdc973935d7d8592851bd1c1f6096cc9aebbdc74 100644 (file)
@@ -36,8 +36,6 @@ import org.apache.poi.util.StringUtil;
 
 public final class TextCharsAtom extends RecordAtom {
     public static final long _type = RecordTypes.TextCharsAtom.typeID;
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     private byte[] _header;
 
@@ -52,7 +50,7 @@ public final class TextCharsAtom extends RecordAtom {
     /** Updates the text in the Atom. */
     public void setText(String text) {
         // Convert to little endian unicode
-        _text = IOUtils.safelyAllocate(text.length() * 2L, MAX_RECORD_LENGTH);
+        _text = IOUtils.safelyAllocate(text.length() * 2L, getMaxRecordLength());
         StringUtil.putUnicodeLE(text,_text,0);
 
         // Update the size (header bytes 5-8)
@@ -72,7 +70,7 @@ public final class TextCharsAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Grab the text
-        _text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _text = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
     }
     /**
      * Create an empty TextCharsAtom
index 9c890a2b56e51d10fe7dd5569a2ccc49d39a5901..c42e5349d4674698ac6de3b35f3a6ac5a5412cca 100644 (file)
@@ -35,9 +35,6 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
 
 public class TextSpecInfoRun implements GenericRecord {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     /**
      * A enum that specifies the spelling status of a run of text.
      */
@@ -176,7 +173,7 @@ public class TextSpecInfoRun implements GenericRecord {
         if (smartTagFld.isSet(mask)) {
             // An unsigned integer specifies the count of items in rgSmartTagIndex.
             int count = source.readInt();
-            smartTagsBytes = IOUtils.safelyAllocate(4 + count * 4L, MAX_RECORD_LENGTH);
+            smartTagsBytes = IOUtils.safelyAllocate(4 + count * 4L, RecordAtom.getMaxRecordLength());
             LittleEndian.putInt(smartTagsBytes, 0, count);
             // An array of SmartTagIndex that specifies the indices.
             // The count of items in the array is specified by count.
index 87175331bed45cd3ff7031a603aeedc60419cff6..995c7b9e3e285990c2a2ca720260b0091317c71b 100644 (file)
@@ -32,9 +32,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public final class TxInteractiveInfoAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
-
     /**
      * Record header.
      */
@@ -69,7 +66,7 @@ public final class TxInteractiveInfoAtom extends RecordAtom {
         _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());
     }
 
     /**
index 34f2480ffe2f78abdcb74387f26f675809c58183..9cdf6f62c40ba90d5d7d39aad643f0c01df11a37 100644 (file)
@@ -66,7 +66,7 @@ public final class TestDocumentAtom {
     void testSlideDetails() {
         DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
         assertEquals(1, da.getFirstSlideNum());
-        assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
+        assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeType());
     }
 
     @Test