You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/10/22 20:53:55 UTC

svn commit: r1894493 - in /poi/trunk/poi-scratchpad/src: main/java/org/apache/poi/hemf/usermodel/ main/java/org/apache/poi/hpbf/model/ main/java/org/apache/poi/hslf/blip/ main/java/org/apache/poi/hslf/record/ test/java/org/apache/poi/hslf/record/

Author: fanningpj
Date: Fri Oct 22 20:53:54 2021
New Revision: 1894493

URL: http://svn.apache.org/viewvc?rev=1894493&view=rev
Log:
more support for configurable max record len

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

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java Fri Oct 22 20:53:54 2021
@@ -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());
     }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java Fri Oct 22 20:53:54 2021
@@ -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;
 

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java Fri Oct 22 20:53:54 2021
@@ -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
                 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")) {

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/DIB.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/DIB.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/DIB.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/blip/DIB.java Fri Oct 22 20:53:54 2021
@@ -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);
 

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java Fri Oct 22 20:53:54 2021
@@ -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 Recor
         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 Recor
         _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

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java Fri Oct 22 20:53:54 2021
@@ -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);
 

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java Fri Oct 22 20:53:54 2021
@@ -60,11 +60,6 @@ public final class DocumentAtom extends
     }
 
 
-    //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
     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
         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
         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);
     }
 

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java Fri Oct 22 20:53:54 2021
@@ -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 RecordA
         _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) {

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExMediaAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExMediaAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExMediaAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExMediaAtom.java Fri Oct 22 20:53:54 2021
@@ -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 R
         _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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java Fri Oct 22 20:53:54 2021
@@ -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.
@@ -50,20 +45,6 @@ public class ExObjListAtom extends Recor
     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.
      */
     protected ExObjListAtom() {
@@ -89,7 +70,7 @@ public class ExObjListAtom extends Recor
         _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) {

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java Fri Oct 22 20:53:54 2021
@@ -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 extend
         _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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java Fri Oct 22 20:53:54 2021
@@ -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
     @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;
     }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java Fri Oct 22 20:53:54 2021
@@ -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 Rec
         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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java Fri Oct 22 20:53:54 2021
@@ -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
      */

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java Fri Oct 22 20:53:54 2021
@@ -38,9 +38,6 @@ public final class SlideAtom extends Rec
     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 Rec
 
         // 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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextPropAtom.java Fri Oct 22 20:53:54 2021
@@ -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 ext
 
         // 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 ext
 
         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) );

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextBytesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextBytesAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextBytesAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextBytesAtom.java Fri Oct 22 20:53:54 2021
@@ -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
         _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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java Fri Oct 22 20:53:54 2021
@@ -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
     /** 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
         _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

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoRun.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoRun.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoRun.java Fri Oct 22 20:53:54 2021
@@ -35,9 +35,6 @@ import org.apache.poi.util.LittleEndianB
 
 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
         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.

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java Fri Oct 22 20:53:54 2021
@@ -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
         _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());
     }
 
     /**

Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java?rev=1894493&r1=1894492&r2=1894493&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java Fri Oct 22 20:53:54 2021
@@ -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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org